use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller controller;
// Do not allow guests to start tests
Roles roles = ureq.getUserSession().getRoles();
Translator trans = Util.createPackageTranslator(IQTESTCourseNode.class, ureq.getLocale());
if (roles.isGuestOnly()) {
if (isGuestAllowedForQTI21(getReferencedRepositoryEntry())) {
controller = new QTI21AssessmentRunController(ureq, wControl, userCourseEnv, this);
} else {
String title = trans.translate("guestnoaccess.title");
String message = trans.translate("guestnoaccess.message");
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
}
} else {
ModuleConfiguration config = getModuleConfiguration();
boolean onyx = IQEditController.CONFIG_VALUE_QTI2.equals(config.get(IQEditController.CONFIG_KEY_TYPE_QTI));
if (onyx) {
Translator transe = Util.createPackageTranslator(IQEditController.class, ureq.getLocale());
controller = MessageUIFactory.createInfoMessage(ureq, wControl, "", transe.translate("error.onyx"));
} else {
RepositoryEntry testEntry = getReferencedRepositoryEntry();
OLATResource ores = testEntry.getOlatResource();
if (ImsQTI21Resource.TYPE_NAME.equals(ores.getResourceableTypeName())) {
// QTI 2.1
controller = new QTI21AssessmentRunController(ureq, wControl, userCourseEnv, this);
} else {
// QTI 1.2
TestFileResource fr = new TestFileResource();
fr.overrideResourceableId(ores.getResourceableId());
if (!CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(fr, null)) {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
IQSecurityCallback sec = new CourseIQSecurityCallback(this, am, ureq.getIdentity());
controller = new IQRunController(userCourseEnv, getModuleConfiguration(), sec, ureq, wControl, this, testEntry);
} else {
String title = trans.translate("editor.lock.title");
String message = trans.translate("editor.lock.message");
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
}
}
}
}
Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_iqtest_icon");
return new NodeRunConstructionResult(ctrl);
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method createPreviewController.
/**
* @see org.olat.course.nodes.CourseNode#createPreviewController(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public Controller createPreviewController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) {
Controller controller;
ModuleConfiguration config = getModuleConfiguration();
boolean onyx = IQEditController.CONFIG_VALUE_QTI2.equals(config.get(IQEditController.CONFIG_KEY_TYPE_QTI));
if (onyx) {
Translator trans = Util.createPackageTranslator(IQEditController.class, ureq.getLocale());
controller = MessageUIFactory.createInfoMessage(ureq, wControl, "", trans.translate("error.onyx"));
} else {
controller = new IQPreviewController(ureq, wControl, userCourseEnv, this);
}
return controller;
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class PassedRuleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/passed.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("attempts.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
formLayout.add(ruleCont);
ruleCont.getFormItemComponent().contextPut("id", id);
ICourse course = CourseFactory.loadCourse(entry);
String currentStatus = null;
String currentCourseNode = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentStatus = r.getRightOperand();
currentCourseNode = r.getLeftOperand();
}
List<CourseNode> attemptableNodes = new ArrayList<>();
searchPassedNodes(course.getRunStructure().getRootNode(), attemptableNodes);
String[] nodeKeys = new String[attemptableNodes.size()];
String[] nodeValues = new String[attemptableNodes.size()];
for (int i = 0; i < attemptableNodes.size(); i++) {
CourseNode attemptableNode = attemptableNodes.get(i);
nodeKeys[i] = attemptableNode.getIdent();
nodeValues[i] = attemptableNode.getShortTitle() + " ( " + attemptableNode.getIdent() + " )";
}
courseNodeEl = uifactory.addDropdownSingleselect("coursenodes.".concat(id), null, ruleCont, nodeKeys, nodeValues, null);
courseNodeEl.setDomReplacementWrapperRequired(false);
boolean nodeSelected = false;
if (currentCourseNode != null) {
for (String nodeKey : nodeKeys) {
if (currentCourseNode.equals(nodeKey)) {
courseNodeEl.select(nodeKey, true);
nodeSelected = true;
}
}
}
if (!nodeSelected && nodeKeys.length > 0) {
courseNodeEl.select(nodeKeys[0], true);
}
if (StringHelper.containsNonWhitespace(currentCourseNode) && !nodeSelected) {
courseNodeEl.setErrorKey("error.course.node.found", null);
}
Translator trans = formLayout.getTranslator();
String[] statusValues = new String[] { trans.translate("passed"), trans.translate("failed") };
statusEl = uifactory.addDropdownSingleselect("status.".concat(id), null, ruleCont, statusKeys, statusValues, null);
statusEl.setDomReplacementWrapperRequired(false);
boolean statusSelected = false;
if (currentStatus != null) {
for (String statusKey : statusKeys) {
if (currentStatus.equals(statusKey)) {
statusEl.select(statusKey, true);
statusSelected = true;
}
}
}
if (!statusSelected) {
statusEl.select(statusKeys[1], true);
}
return ruleCont;
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class AbstractTaskNotificationHandler method createTitleInfo.
public String createTitleInfo(Subscriber subscriber, Locale locale) {
try {
Translator translator = Util.createPackageTranslator(AbstractTaskNotificationHandler.class, locale);
Long resId = subscriber.getPublisher().getResId();
String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId);
return translator.translate(getNotificationHeaderKey(), new String[] { displayName });
} catch (Exception e) {
getLogger().error("Error while creating task notifications for subscriber: " + subscriber.getKey(), e);
checkPublisher(subscriber.getPublisher());
return "-";
}
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class AbstractTaskNotificationHandler method createSubscriptionInfo.
/**
* @see org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber,
* java.util.Locale, java.util.Date)
*/
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
SubscriptionInfo si;
// there could be news for me, investigate deeper
try {
if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) {
String folderRoot = p.getData();
if (isLogDebugEnabled()) {
logDebug("folderRoot=", folderRoot);
}
final List<FileInfo> fInfos = FolderManager.getFileInfos(folderRoot, compareDate);
final Translator translator = Util.createPackageTranslator(AbstractTaskNotificationHandler.class, locale);
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance("CourseModule", p.getResId()), false);
if (re == null) {
if (!checkPublisher(p)) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} else if (re.getRepositoryEntryStatus().isClosed()) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
String displayName = re.getDisplayname();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(translator.translate(getNotificationHeaderKey(), new String[] { displayName }), getCssClassIcon()), null);
SubscriptionListItem subListItem;
for (Iterator<FileInfo> it_infos = fInfos.iterator(); it_infos.hasNext(); ) {
FileInfo fi = it_infos.next();
MetaInfo metaInfo = fi.getMetaInfo();
String filePath = fi.getRelPath();
if (isLogDebugEnabled())
logDebug("filePath=", filePath);
String fullUserName = getUserNameFromFilePath(metaInfo, filePath);
Date modDate = fi.getLastModified();
String desc = translator.translate(getNotificationEntryKey(), new String[] { filePath, fullUserName });
String businessPath = p.getBusinessPath();
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
String iconCssClass = null;
if (metaInfo != null) {
iconCssClass = metaInfo.getIconCssClass();
}
subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, iconCssClass);
si.addSubscriptionListItem(subListItem);
}
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
} catch (Exception e) {
getLogger().error("Cannot create task notifications for subscriber: " + subscriber.getKey(), e);
checkPublisher(p);
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
}
Aggregations