use of org.olat.core.util.Formatter in project openolat by klemens.
the class QTI21AssessmentRunController method exposeVisiblityPeriod.
private void exposeVisiblityPeriod() {
boolean showResultsActive = config.getBooleanSafe(IQEditController.CONFIG_KEY_DATE_DEPENDENT_RESULTS);
Date startDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_START_DATE);
Date endDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_END_DATE);
if (showResultsActive && startDate != null) {
Formatter formatter = Formatter.getInstance(getLocale());
String visibilityStartDate = formatter.formatDate(startDate);
String visibilityEndDate = "-";
if (endDate != null) {
visibilityEndDate = formatter.formatDate(endDate);
}
String visibilityPeriod = translate("showResults.visibility", new String[] { visibilityStartDate, visibilityEndDate });
mainVC.contextPut("visibilityPeriod", visibilityPeriod);
} else {
mainVC.contextPut("visibilityPeriod", translate("showResults.visibility.future"));
}
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class QTI21AssessmentRunController method blockedBasedOnDate.
private boolean blockedBasedOnDate() {
mainVC.contextRemove("startTestDate");
mainVC.contextRemove("endTestDate");
boolean dependOnDate = config.getBooleanSafe(IQEditController.CONFIG_KEY_DATE_DEPENDENT_TEST, false);
if (dependOnDate) {
Date startTestDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_START_TEST_DATE);
if (startTestDate != null) {
Formatter formatter = Formatter.getInstance(getLocale());
mainVC.contextPut("startTestDate", formatter.formatDateAndTime(startTestDate));
Date endTestDate = config.getDateValue(IQEditController.CONFIG_KEY_RESULTS_END_TEST_DATE);
if (endTestDate != null) {
mainVC.contextPut("endTestDate", formatter.formatDateAndTime(endTestDate));
}
Date now = new Date();
if (startTestDate != null && startTestDate.after(now)) {
return true;
}
if (endTestDate != null && endTestDate.before(now)) {
return true;
}
}
}
return false;
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class IQRunController method createChangelogMsg.
/**
* @param ureq
* @return
*/
private StringBuilder createChangelogMsg(UserRequest ureq) {
/*
* TODO:pb:is ImsRepositoryResolver the right place for getting the change log?
*/
// re could be null, but if we are here it should not be null!
Roles userRoles = ureq.getUserSession().getRoles();
boolean showAll = userRoles.isAuthor() || userRoles.isOLATAdmin();
// get changelog
Formatter formatter = Formatter.getInstance(ureq.getLocale());
ImsRepositoryResolver resolver = new ImsRepositoryResolver(referenceTestEntry);
QTIChangeLogMessage[] qtiChangeLog = resolver.getDocumentChangeLog();
StringBuilder qtiChangelog = new StringBuilder();
if (qtiChangeLog.length > 0) {
// there are resource changes
Arrays.sort(qtiChangeLog);
for (int i = qtiChangeLog.length - 1; i >= 0; i--) {
// show latest change first
if (!showAll && qtiChangeLog[i].isPublic()) {
// logged in person is a normal user, hence public messages only
Date msgDate = new Date(qtiChangeLog[i].getTimestmp());
qtiChangelog.append("\nChange date: ").append(formatter.formatDateAndTime(msgDate)).append("\n");
String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage());
qtiChangelog.append(msg);
qtiChangelog.append("\n********************************\n");
} else if (showAll) {
// logged in person is an author, olat admin, owner, show all messages
Date msgDate = new Date(qtiChangeLog[i].getTimestmp());
qtiChangelog.append("\nChange date: ").append(formatter.formatDateAndTime(msgDate)).append("\n");
String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage());
qtiChangelog.append(msg);
qtiChangelog.append("\n********************************\n");
}
// else non public messages are not shown to normal user
}
}
return qtiChangelog;
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class ConfirmExtraTimeController method currentAssessmentModeMessage.
private void currentAssessmentModeMessage(FormLayoutContainer layoutCont) {
Formatter formatter = Formatter.getInstance(getLocale());
List<String> modes = new ArrayList<>();
for (AssessmentMode assessmentMode : assessmentModes) {
String title = assessmentMode.getName();
String begin = formatter.formatDateAndTime(assessmentMode.getBegin());
String end = formatter.formatDateAndTime(assessmentMode.getEnd());
modes.add(translate("warning.assessment.mode.date", new String[] { title, begin, end }));
}
layoutCont.contextPut("assessmemtModeMessages", modes);
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class MailListController method reloadModel.
private void reloadModel() {
List<DBMailLight> mails;
if (outbox) {
if (StringHelper.containsNonWhitespace(metaId)) {
mails = mailManager.getEmailsByMetaId(metaId);
} else {
mails = mailManager.getOutbox(getIdentity(), 0, -1, true);
}
// strip meta emails
Set<String> metaIds = new HashSet<>();
for (Iterator<DBMailLight> it = mails.iterator(); it.hasNext(); ) {
DBMailLight mail = it.next();
if (StringHelper.containsNonWhitespace(mail.getMetaId())) {
if (metaIds.contains(mail.getMetaId())) {
it.remove();
} else {
metaIds.add(mail.getMetaId());
}
}
}
} else {
mails = mailManager.getInbox(getIdentity(), null, Boolean.TRUE, null, 0, -1);
}
// extract contexts
Map<String, String> bpToContexts = new HashMap<>();
for (DBMailLight mail : mails) {
String businessPath = mail.getContext().getBusinessPath();
if (StringHelper.containsNonWhitespace(businessPath) && !bpToContexts.containsKey(businessPath)) {
String contextName = contextResolver.getName(businessPath, getLocale());
if (StringHelper.containsNonWhitespace(contextName)) {
bpToContexts.put(businessPath, contextName);
}
}
}
if (!bpToContexts.isEmpty()) {
List<ShortName> filters = new ArrayList<>();
Map<String, MailContextShortName> uniqueNames = new HashMap<>();
ShortName allContextFilter = new MailContextShortName("-");
filters.add(allContextFilter);
for (Map.Entry<String, String> entry : bpToContexts.entrySet()) {
String businessPath = entry.getKey();
String contextName = entry.getValue();
if (!uniqueNames.containsKey(contextName)) {
MailContextShortName cxt = new MailContextShortName(contextName, new HashSet<String>());
filters.add(cxt);
uniqueNames.put(contextName, cxt);
}
uniqueNames.get(contextName).getBusinessPaths().add(businessPath);
}
tableCtr.setFilters(filters, allContextFilter);
}
Formatter formatter = Formatter.getInstance(getLocale());
MailDataModel dataModel = new MailDataModel(mails, bpToContexts, getIdentity(), getTranslator(), formatter, outbox);
tableCtr.setTableDataModel(dataModel);
}
Aggregations