/** * @param ureq * @param wControl * @param cancelbutton */ public ReadyToDeleteController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl); Translator fallbackTrans = Util.createPackageTranslator(UserSearchController.class, ureq.getLocale()); setTranslator( Util.createPackageTranslator( ReadyToDeleteController.class, ureq.getLocale(), fallbackTrans)); // use the PropertyHandlerTranslator as tableCtr translator propertyHandlerTranslator = UserManager.getInstance().getPropertyHandlerTranslator(getTranslator()); myContent = createVelocityContainer("panel"); readyToDeletePanel = new Panel("readyToDeletePanel"); readyToDeletePanel.addListener(this); myContent.put("panel", readyToDeletePanel); Roles roles = ureq.getUserSession().getRoles(); isAdministrativeUser = CoreSpringFactory.getImpl(BaseSecurityModule.class).isUserAllowedAdminProps(roles); // (roles.isAuthor() || roles.isGroupManager() || roles.isUserManager() || roles.isOLATAdmin()); initializeTableController(ureq); initializeContent(); putInitialPanel(myContent); }
@Override @SuppressWarnings("unused") protected boolean validateFormLogic(UserRequest ureq) { boolean retVal = true; // datefields are valid // check complex rules involving checks over multiple elements Date fromDateVal = fromDate.getDate(); Date toDateVal = toDate.getDate(); if (!fromDate.hasError() && !toDate.hasError()) { // check valid dates // if both are set, check from < to if (fromDateVal != null && toDateVal != null) { /* * bugfix http://bugs.olat.org/jira/browse/OLAT-813 valid dates and not * empty, in easy mode we assume that Start and End date should * implement the meaning of * ----false---|S|-----|now|-TRUE---------|E|---false--->t ............. * Thus we check for Startdate < Enddate, error otherwise */ if (fromDateVal.after(toDateVal)) { fromDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), fromDate.getTranslator())); fromDate.setErrorKey("form.easy.error.bdateafteredate", null); retVal = false; } } else { if (fromDateVal == null && !fromDate.isEmpty()) { // not a correct begin date fromDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), fromDate.getTranslator())); fromDate.setErrorKey("form.easy.error.bdate", null); retVal = false; } if (toDateVal == null && !toDate.isEmpty()) { toDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), toDate.getTranslator())); toDate.setErrorKey("form.easy.error.edate", null); retVal = false; } } } return retVal; }
/** * @see org.olat.login.auth.AuthenticationController#init(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl) */ public OLATAuthenticationController(UserRequest ureq, WindowControl winControl) { // use fallback translator to registration module super( ureq, winControl, Util.createPackageTranslator(RegistrationManager.class, ureq.getLocale())); loginComp = createVelocityContainer("olat_log", "olatlogin"); if (userModule.isAnyPasswordChangeAllowed()) { pwLink = LinkFactory.createLink("_olat_login_change_pwd", "menu.pw", loginComp, this); pwLink.setElementCssClass("o_login_pwd"); } if (registrationModule.isSelfRegistrationEnabled() && registrationModule.isSelfRegistrationLoginEnabled()) { registerLink = LinkFactory.createLink("_olat_login_register", "menu.register", loginComp, this); registerLink.setElementCssClass("o_login_register"); registerLink.setTitle("menu.register.alt"); } // prepare login form loginForm = new OLATAuthentcationForm(ureq, winControl, "olat_login", getTranslator()); listenTo(loginForm); loginComp.put("loginForm", loginForm.getInitialComponent()); // Check if form is triggered by external loginworkflow that has been failed if (ureq.getParameterSet().contains(PARAM_LOGINERROR)) { showError(translate("login.error", WebappHelper.getMailConfig("mailReplyTo"))); } putInitialPanel(loginComp); }
/** * Description:<br> * TODO: Felix Jost Class Description for Trans * * <p>Initial Date: 24.01.2007 <br> * * @author Felix Jost, http://www.goodsolutions.ch */ public class GuiStackSimpleImpl implements GuiStack { private static final String VELOCITY_ROOT = Util.getPackageVelocityRoot(GuiStackSimpleImpl.class); private Panel contentPanel; /** */ public GuiStackSimpleImpl(Component initialComponent) { contentPanel = new Panel("simpleguistack"); contentPanel.setContent(initialComponent); } /* * (non-Javadoc) * @see org.olat.core.gui.control.GuiStack#pushModalDialog(java.lang.String, org.olat.core.gui.components.Component) */ @Override public void pushModalDialog(Component content) { // wrap the component into a modal foreground dialog with alpha-blended-background VelocityContainer inset = new VelocityContainer("simpleinset", VELOCITY_ROOT + "/simpleinset.html", null, null); inset.put("cont", content); contentPanel.pushContent(inset); } /* * (non-Javadoc) * @see org.olat.core.gui.control.GuiStack#pushContent(org.olat.core.gui.components.Component) */ @Override public void pushContent(Component newContent) { contentPanel.pushContent(newContent); } /* * (non-Javadoc) * @see org.olat.core.gui.control.GuiStack#popContent() */ @Override public void popContent() { contentPanel.popContent(); } /* * (non-Javadoc) * @see org.olat.core.gui.control.GuiStack#getPanel() */ @Override public Panel getPanel() { return contentPanel; } /* * (non-Javadoc) * @see org.olat.core.gui.control.GuiStack#getModalPanel() */ @Override public Panel getModalPanel() { return null; } }
/** @see org.olat.course.nodes.CourseNode#isConfigValid() */ @Override public StatusDescription isConfigValid() { /* * first check the one click cache */ if (oneClickStatusCache != null) { return oneClickStatusCache[0]; } final boolean isValid = MSEditFormController.isConfigValid(getModuleConfiguration()); StatusDescription sd = StatusDescription.NOERROR; if (!isValid) { // FIXME: refine statusdescriptions by moving the statusdescription // generation to the MSEditForm final String shortKey = "error.missingconfig.short"; final String longKey = "error.missingconfig.long"; final String[] params = new String[] {this.getShortTitle()}; final String translPackage = Util.getPackageName(MSEditFormController.class); sd = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translPackage); sd.setDescriptionForUnit(getIdent()); // set which pane is affected by error sd.setActivateableViewIdentifier(MSCourseNodeEditController.PANE_TAB_CONFIGURATION); } return sd; }
public OverviewAuthoringController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl); setTranslator( Util.createPackageTranslator(RepositoryManager.class, getLocale(), getTranslator())); isGuestonly = ureq.getUserSession().getRoles().isGuestOnly(); mainPanel = new MainPanel("authoringMainPanel"); mainPanel.setDomReplaceable(false); mainVC = createVelocityContainer("overview"); mainPanel.setContent(mainVC); segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this); segmentView.setReselect(true); if (!isGuestonly) { favoriteLink = LinkFactory.createLink("search.mark", mainVC, this); segmentView.addSegment(favoriteLink, false); } myEntriesLink = LinkFactory.createLink("search.my", mainVC, this); segmentView.addSegment(myEntriesLink, false); searchLink = LinkFactory.createLink("search.generic", mainVC, this); segmentView.addSegment(searchLink, false); putInitialPanel(mainPanel); }
private void sendFeedback(List<BulkAssessmentFeedback> feedbacks) { if (task == null) { log.error("Haven't a task to know creator and modifiers of the task", null); return; } Identity creator = task.getCreator(); String language = creator.getUser().getPreferences().getLanguage(); Locale locale = I18nManager.getInstance().getLocaleOrDefault(language); Translator translator = Util.createPackageTranslator( BulkAssessmentOverviewController.class, locale, Util.createPackageTranslator(AssessmentManager.class, locale)); MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class); TaskExecutorManager taskManager = CoreSpringFactory.getImpl(TaskExecutorManager.class); String feedbackStr = renderFeedback(feedbacks, translator); MailBundle mail = new MailBundle(); mail.setToId(creator); mail.setFrom(WebappHelper.getMailConfig("mailReplyTo")); List<Identity> modifiers = taskManager.getModifiers(task); if (modifiers.size() > 0) { ContactList cc = new ContactList("CC"); cc.addAllIdentites(modifiers); mail.setContactList(cc); } String businessPath = ""; ICourse course = CourseFactory.loadCourse(courseRes); CourseNode node = course.getRunStructure().getNode(courseNodeIdent); String courseTitle = course.getCourseTitle(); String nodeTitle = node.getShortTitle(); String numOfAssessedIds = Integer.toString(datas == null ? 0 : datas.getRowsSize()); String date = Formatter.getInstance(locale).formatDateAndTime(new Date()); mail.setContext(new MailContextImpl(courseRes, courseNodeIdent, businessPath)); String subject = translator.translate("confirmation.mail.subject", new String[] {courseTitle, nodeTitle}); String body = translator.translate( "confirmation.mail.body", new String[] {courseTitle, nodeTitle, feedbackStr, numOfAssessedIds, date}); mail.setContent(subject, body); mailManager.sendMessage(mail); }
public QTI12MetadataController(UserRequest ureq, WindowControl wControl, Item item) { super(ureq, wControl, "qti_metadatas"); setTranslator( Util.createPackageTranslator( ItemNodeTabbedFormController.class, getLocale(), getTranslator())); this.item = item; initForm(ureq); }
public FreeAccessConfigurationController( UserRequest ureq, WindowControl wControl, OfferAccess link, boolean edit) { super(ureq, wControl, edit); this.link = link; setTranslator( Util.createPackageTranslator( AccessConfigurationController.class, getLocale(), getTranslator())); initForm(ureq); }
/** * @see * org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public StatusDescription[] isConfigValid(CourseEditorEnv cev) { // only here we know which translator to take for translating condition // error messages String translatorStr = Util.getPackageName(ConditionEditController.class); List<StatusDescription> statusDescs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions()); return StatusDescriptionHelper.sort(statusDescs); }
/** * @see * org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public StatusDescription[] isConfigValid(final CourseEditorEnv cev) { oneClickStatusCache = null; // only here we know which translator to take for translating condition error messages final String translatorStr = Util.getPackageName(WikiEditController.class); final List sds = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions()); oneClickStatusCache = StatusDescriptionHelper.sort(sds); return oneClickStatusCache; }
public EducationalMetadataController( UserRequest ureq, WindowControl wControl, QuestionItem item, boolean edit) { super(ureq, wControl, "view"); setTranslator( Util.createPackageTranslator(QuestionsController.class, getLocale(), getTranslator())); this.edit = edit; initForm(ureq); setItem(item); }
// constructor to be used like a normal FormBasicController public GroupSearchController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl, LAYOUT_VERTICAL); businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); Translator pT = Util.createPackageTranslator( BusinessGroupFormController.class, ureq.getLocale(), getTranslator()); flc.setTranslator(pT); initForm(ureq); }
public CcStep01Form( UserRequest ureq, WindowControl wControl, Form rootForm, StepsRunContext runContext, String customLayoutPageName) { super(ureq, wControl, rootForm, runContext, LAYOUT_VERTICAL, customLayoutPageName); translator = Util.createPackageTranslator(CourseCreationHelper.class, ureq.getLocale()); super.setTranslator(translator); initForm(ureq); }
public ConfirmCloseController( UserRequest ureq, WindowControl wControl, List<RepositoryEntry> rows) { super( ureq, wControl, "confirm_close", Util.createPackageTranslator(RepositoryService.class, ureq.getLocale())); numOfMembers = repositoryService.countMembers(rows, getIdentity()); this.rows = rows; initForm(ureq); }
/** * Constructor for a test run controller * * @param userCourseEnv * @param moduleConfiguration * @param secCallback * @param ureq * @param wControl * @param testCourseNode */ public IQRunController( UserCourseEnvironment userCourseEnv, ModuleConfiguration moduleConfiguration, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl, IQTESTCourseNode testCourseNode, RepositoryEntry testEntry) { super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale())); this.modConfig = moduleConfiguration; this.secCallback = secCallback; this.userCourseEnv = userCourseEnv; this.courseNode = testCourseNode; this.type = AssessmentInstance.QMD_ENTRY_TYPE_ASSESS; this.singleUserEventCenter = ureq.getUserSession().getSingleUserEventCenter(); this.referenceTestEntry = testEntry; this.userSession = ureq.getUserSession(); addLoggingResourceable(LoggingResourceable.wrap(courseNode)); myContent = createVelocityContainer("testrun"); mainPanel = putInitialPanel(myContent); if (!modConfig .get(IQEditController.CONFIG_KEY_TYPE) .equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { throw new OLATRuntimeException( "IQRunController launched with Test constructor but module configuration not configured as test", null); } init(ureq); exposeUserTestDataToVC(ureq); StringBuilder qtiChangelog = createChangelogMsg(ureq); // decide about changelog in VC if (qtiChangelog.length() > 0) { // there is some message myContent.contextPut("changeLog", qtiChangelog); } // if show results on test home page configured - show log Boolean showResultOnHomePage = testCourseNode .getModuleConfiguration() .getBooleanEntry(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE); myContent.contextPut("showChangelog", showResultOnHomePage); }
/** * @see * org.olat.repository.handlers.RepositoryHandler#readyToDelete(org.olat.core.id.OLATResourceable, * org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl) */ @Override public boolean readyToDelete( final OLATResourceable res, final UserRequest ureq, final WindowControl wControl) { final ReferenceManager refM = ReferenceManager.getInstance(); final String referencesSummary = refM.getReferencesToSummary(res, ureq.getLocale()); if (referencesSummary != null) { final Translator translator = Util.createPackageTranslator(RepositoryManager.class, ureq.getLocale()); wControl.setError( translator.translate( "details.delete.error.references", new String[] {referencesSummary})); return false; } return true; }
@Override public String createTitleInfo(Subscriber subscriber, Locale locale) { try { Long resId = subscriber.getPublisher().getResId(); String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId); Translator trans = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale); String title = trans.translate("notifications.title", new String[] {displayName}); return title; } catch (Exception e) { log.error( "Error while creating assessment notifications for subscriber: " + subscriber.getKey(), e); checkPublisher(subscriber.getPublisher()); return "-"; } }
// cluster_ok only in VM public static synchronized LocalizedXSLTransformer getInstance(final Locale locale) { LocalizedXSLTransformer instance = instanceHash.get(I18nManager.getInstance().getLocaleKey(locale)); if (instance == null) { final Translator trans = Util.createPackageTranslator(QTIResultDetailsController.class, locale); final LocalizedXSLTransformer newInstance = new LocalizedXSLTransformer(trans); instance = instanceHash.putIfAbsent( I18nManager.getInstance().getLocaleKey(locale), newInstance); // see javadoc of ConcurrentHashMap if (instance == null) { // newInstance was put into the map instance = newInstance; } } return instance; }
public JSRedirectWindowController(UserRequest ureq) { Translator trans = Util.createPackageTranslator(JSRedirectWindowController.class, ureq.getLocale()); VelocityContainer msg = new VelocityContainer("jsredirect", VELOCITY_ROOT + "/js_redirect.html", trans, this); String callbackUrl = Settings.getServerContextPathURI() + OAuthConstants.CALLBACK_PATH; msg.contextPut("callbackUrl", callbackUrl); Windows ws = Windows.getWindows(ureq); WindowBackOffice wbo = ws.getWindowManager() .createWindowBackOffice("jsredirectwindow", this, new WindowSettings()); Window w = wbo.getWindow(); msg.contextPut("theme", w.getGuiTheme()); w.setContentPane(msg); setWindow(w); }
/** * Constructor for a survey run controller * * @param userCourseEnv * @param moduleConfiguration * @param secCallback * @param ureq * @param wControl * @param surveyCourseNode */ public IQRunController( UserCourseEnvironment userCourseEnv, ModuleConfiguration moduleConfiguration, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl, IQSURVCourseNode surveyCourseNode) { super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale())); this.modConfig = moduleConfiguration; this.secCallback = secCallback; this.userCourseEnv = userCourseEnv; this.courseNode = surveyCourseNode; this.referenceTestEntry = surveyCourseNode.getReferencedRepositoryEntry(); this.type = AssessmentInstance.QMD_ENTRY_TYPE_SURVEY; this.singleUserEventCenter = ureq.getUserSession().getSingleUserEventCenter(); iqManager = CoreSpringFactory.getImpl(IQManager.class); addLoggingResourceable(LoggingResourceable.wrap(courseNode)); myContent = createVelocityContainer("surveyrun"); mainPanel = putInitialPanel(myContent); if (!modConfig .get(IQEditController.CONFIG_KEY_TYPE) .equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) { throw new OLATRuntimeException( "IQRunController launched with Survey constructor but module configuration not configured as survey", null); } init(ureq); exposeUserQuestionnaireDataToVC(); StringBuilder qtiChangelog = createChangelogMsg(ureq); // decide about changelog in VC if (qtiChangelog.length() > 0) { // there is some message myContent.contextPut("changeLog", qtiChangelog); } // per default change log is not open myContent.contextPut("showChangelog", Boolean.FALSE); }
@Override protected Component createInitialComponent(final UserRequest ureq) { setVelocityRoot(Util.getPackageVelocityRoot(getClass())); weeklyStatisticVc_ = this.createVelocityContainer("weeklystatisticparent"); weeklyStatisticFormVc_ = this.createVelocityContainer("weeklystatisticform"); form_ = new DateChooserForm(ureq, getWindowControl(), 8 * 7); listenTo(form_); weeklyStatisticFormVc_.put("statisticForm", form_.getInitialComponent()); weeklyStatisticFormVc_.contextPut("statsSince", getStatsSinceStr(ureq)); weeklyStatisticVc_.put("weeklystatisticform", weeklyStatisticFormVc_); final Component parentInitialComponent = super.createInitialComponent(ureq); weeklyStatisticVc_.put("statistic", parentInitialComponent); return weeklyStatisticVc_; }
/** * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, * org.olat.core.gui.components.Component, org.olat.core.gui.control.Event) */ public void event(UserRequest ureq, Component source, Event event) { if (source == showFileButton) { ICourse course = CourseFactory.loadCourse(ores); String personalFolderDir = CourseFactory.getPersonalDirectory(ureq.getIdentity()).getPath(); String targetDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle()) .getPath(); String relPath = ""; if (targetDir.startsWith(personalFolderDir)) { // that should always be the case relPath = targetDir.substring(personalFolderDir.length()).replace("\\", "/"); targetDir = targetDir.substring(0, personalFolderDir.length()); } VFSContainer targetFolder = new LocalFolderImpl(new File(targetDir)); FolderRunController bcrun = new FolderRunController(targetFolder, true, ureq, getWindowControl()); Component folderComponent = bcrun.getInitialComponent(); if (relPath.length() != 0) { if (!relPath.endsWith("/")) { relPath = relPath + "/"; } bcrun.activatePath(ureq, relPath); } String personalFolder = Util.createPackageTranslator(HomeMainController.class, ureq.getLocale(), null) .translate("menu.bc"); removeAsListenerAndDispose(cmc); cmc = new CloseableModalController( getWindowControl(), translate("close"), folderComponent, true, personalFolder); listenTo(cmc); cmc.activate(); } }
/** @see org.olat.course.nodes.CourseNode#isConfigValid() */ @Override public StatusDescription isConfigValid() { /* * first check the one click cache */ if (oneClickStatusCache != null) { return oneClickStatusCache[0]; } StatusDescription sd = StatusDescription.NOERROR; final boolean isValid = WikiEditController.isModuleConfigValid(getModuleConfiguration()); if (!isValid) { final String shortKey = "error.noreference.short"; final String longKey = "error.noreference.long"; final String[] params = new String[] {this.getShortTitle()}; final String translPackage = Util.getPackageName(WikiEditController.class); sd = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translPackage); sd.setDescriptionForUnit(getIdent()); // set which pane is affected by error sd.setActivateableViewIdentifier(WikiEditController.PANE_TAB_WIKICONFIG); } return sd; }
/** * @see * org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer, * org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest) */ @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { // Create the business group name input text element if (bulkMode) { businessGroupName = uifactory.addTextElement( "create.form.title.bgnames", "create.form.title.bgnames", 10 * BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout); businessGroupName.setExampleKey("create.form.message.example.group", null); } else { businessGroupName = uifactory.addTextElement( "create.form.title.bgname", "create.form.title.bgname", BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout); businessGroupName.setNotLongerThanCheck( BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong"); businessGroupName.setRegexMatchCheck( BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName"); } businessGroupName.setElementCssClass("o_sel_group_edit_title"); businessGroupName.setMandatory(true); businessGroupName.setEnabled( !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title)); formLayout.setElementCssClass("o_sel_group_edit_group_form"); // Create the business group description input rich text element businessGroupDescription = uifactory.addRichTextElementForStringDataMinimalistic( "create.form.title.description", "create.form.title.description", "", 10, -1, formLayout, getWindowControl()); businessGroupDescription.setEnabled( !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description)); if (businessGroup != null && !bulkMode) { // link to group direct jump in business path BusinessControlFactory bcf = BusinessControlFactory.getInstance(); List<ContextEntry> entries = bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]"); String url = bcf.getAsURIString(entries, true); StaticTextElement urlEl = uifactory.addStaticTextElement("create.form.businesspath", url, formLayout); urlEl.setElementCssClass("o_sel_group_url"); // link to group visiting card bcf = BusinessControlFactory.getInstance(); entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]"); url = bcf.getAsURIString(entries, true); StaticTextElement cardEl = uifactory.addStaticTextElement("create.form.groupcard", url, formLayout); cardEl.setElementCssClass("o_sel_group_card_url"); } uifactory.addSpacerElement("myspacer", formLayout, true); // Minimum members input businessGroupMinimumMembers = uifactory.addTextElement( "create.form.title.min", "create.form.title.min", 5, "", formLayout); businessGroupMinimumMembers.setDisplaySize(6); businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members"); // Maximum members input businessGroupMaximumMembers = uifactory.addTextElement( "create.form.title.max", "create.form.title.max", 5, "", formLayout); businessGroupMaximumMembers.setDisplaySize(6); businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members"); // Checkboxes enableWaitingList = uifactory.addCheckboxesHorizontal( "create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues); enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list"); enableAutoCloseRanks = uifactory.addCheckboxesHorizontal( "create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues); enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks"); // Enable only if specification of min and max members is possible businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled businessGroupMaximumMembers.setVisible(true); enableWaitingList.setVisible(true); enableAutoCloseRanks.setVisible(true); boolean managedSettings = BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings); businessGroupMinimumMembers.setEnabled(!managedSettings); businessGroupMaximumMembers.setEnabled(!managedSettings); enableWaitingList.setEnabled(!managedSettings); enableAutoCloseRanks.setEnabled(!managedSettings); if ((businessGroup != null) && (!bulkMode)) { businessGroupName.setValue(businessGroup.getName()); businessGroupDescription.setValue(businessGroup.getDescription()); Integer minimumMembers = businessGroup.getMinParticipants(); Integer maximumMembers = businessGroup.getMaxParticipants(); businessGroupMinimumMembers.setValue( minimumMembers == null || minimumMembers.intValue() <= 0 ? "" : minimumMembers.toString()); businessGroupMaximumMembers.setValue( maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString()); if (businessGroup.getWaitingListEnabled() != null) { enableWaitingList.select( "create.form.enableWaitinglist", businessGroup.getWaitingListEnabled()); } if (businessGroup.getAutoCloseRanksEnabled() != null) { enableAutoCloseRanks.select( "create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled()); } } if (!embbeded) { // Create submit and cancel buttons final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator()); formLayout.add(buttonLayout); FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout); submit.setEnabled( !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details)); uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl()); } if ((businessGroup != null) && (!bulkMode)) { // managed group information boolean managed = StringHelper.containsNonWhitespace(businessGroup.getExternalId()) || businessGroup.getManagedFlags().length > 0; if (managed) { uifactory.addSpacerElement("managedspacer", formLayout, false); String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId(); StaticTextElement externalIdEl = uifactory.addStaticTextElement("create.form.externalid", extId, formLayout); externalIdEl.setElementCssClass("o_sel_group_external_id"); FormLayoutContainer flagsFlc = FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator()); flagsFlc.setLabel("create.form.managedflags", null); formLayout.add(flagsFlc); String flags = businessGroup.getManagedFlagsString() == null ? "" : businessGroup.getManagedFlagsString().trim(); String flagsFormatted = null; if (flags.length() > 0) { // use translator from REST admin package to import managed flags context help strings Translator managedTrans = Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale()); StringBuffer flagList = new StringBuffer(); flagList.append("<p class=\"o_important\">"); flagList.append(translate("create.form.managedflags.intro")); flagList.append("</div>"); flagList.append("<ul>"); for (String flag : flags.split(",")) { flagList.append("<li>"); flagList.append(managedTrans.translate("managed.flags.group." + flag)); flagList.append("</li>"); } flagsFormatted = flagList.toString(); } else { flagsFormatted = flags; } StaticTextElement flagsEl = uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc); flagsEl.showLabel(false); flagsEl.setElementCssClass("o_sel_group_managed_flags"); } } }
public String getLinkText(Locale locale) { Translator fallback = Util.createPackageTranslator(CourseNodeConfiguration.class, locale); Translator translator = Util.createPackageTranslator(this.getClass(), locale, fallback); return translator.translate("title_vc"); }
/** * @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( final Subscriber subscriber, Locale locale, Date compareDate) { SubscriptionInfo si = null; Publisher p = subscriber.getPublisher(); if (!NotificationsUpgradeHelper.checkCourse(p)) { // course don't exist anymore NotificationsManager.getInstance().deactivate(p); return NotificationsManager.getInstance().getNoSubscriptionInfo(); } try { Date latestNews = p.getLatestNewsDate(); Identity identity = subscriber.getIdentity(); // do not try to create a subscription info if state is deleted - results in // exceptions, course // can't be loaded when already deleted if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) { Long courseId = new Long(p.getData()); final ICourse course = loadCourseFromId(courseId); if (course != null) { // course admins or users with the course right to have full access to // the assessment tool will have full access to user tests CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager(); final boolean hasFullAccess = (cgm.isIdentityCourseAdministrator(identity) ? true : cgm.hasRight(identity, CourseRights.RIGHT_ASSESSMENT)); final List<Identity> coachedUsers = new ArrayList<Identity>(); if (!hasFullAccess) { // initialize list of users, only when user has not full access List<BusinessGroup> coachedGroups = cgm.getOwnedBusinessGroups(identity); BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); List<Identity> coachedIdentites = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name()); coachedUsers.addAll(coachedIdentites); } List<AssessableCourseNode> testNodes = getCourseTestNodes(course); Translator translator = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale); for (AssessableCourseNode test : testNodes) { final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager(); List<Property> scoreProperties = cpm.listCourseNodeProperties(test, null, null, AssessmentManager.SCORE); List<Property> attemptProperties = cpm.listCourseNodeProperties(test, null, null, AssessmentManager.ATTEMPTS); for (Property attemptProperty : attemptProperties) { Date modDate = attemptProperty.getLastModified(); Identity assessedIdentity = attemptProperty.getIdentity(); if (modDate.after(compareDate) && (hasFullAccess || PersistenceHelper.listContainsObjectByKey( coachedUsers, assessedIdentity))) { String score = null; for (Property scoreProperty : scoreProperties) { if (scoreProperty.getIdentity().equalsByPersistableKey(assessedIdentity)) { score = scoreProperty.getFloatValue().toString(); break; } } if (test instanceof ScormCourseNode) { ScormCourseNode scormTest = (ScormCourseNode) test; // check if completed or passed String status = ScormAssessmentManager.getInstance() .getLastLessonStatus( assessedIdentity.getName(), course.getCourseEnvironment(), scormTest); if (!"passed".equals(status) && !"completed".equals(status)) { continue; } } String desc; String type = translator.translate("notifications.entry." + test.getType()); if (score == null) { desc = translator.translate( "notifications.entry.attempt", new String[] { test.getShortTitle(), NotificationHelper.getFormatedName(assessedIdentity), type }); } else { desc = translator.translate( "notifications.entry", new String[] { test.getShortTitle(), NotificationHelper.getFormatedName(assessedIdentity), score, type }); } String urlToSend = null; String businessPath = null; if (p.getBusinessPath() != null) { businessPath = p.getBusinessPath() + "[assessmentTool:0][Identity:" + assessedIdentity.getKey() + "][CourseNode:" + test.getIdent() + "]"; urlToSend = BusinessControlFactory.getInstance() .getURLFromBusinessPathString(businessPath); } SubscriptionListItem subListItem = new SubscriptionListItem( desc, urlToSend, businessPath, modDate, CSS_CLASS_USER_ICON); if (si == null) { String title = translator.translate( "notifications.header", new String[] {course.getCourseTitle()}); String css = CourseNodeFactory.getInstance() .getCourseNodeConfigurationEvenForDisabledBB(test.getType()) .getIconCSSClass(); si = new SubscriptionInfo( subscriber.getKey(), p.getType(), new TitleItem(title, css), null); } si.addSubscriptionListItem(subListItem); } } } } } if (si == null) { si = NotificationsManager.getInstance().getNoSubscriptionInfo(); } return si; } catch (Exception e) { log.error("Error while creating assessment notifications", e); checkPublisher(p); return NotificationsManager.getInstance().getNoSubscriptionInfo(); } }
/** * Initial Date: Jun 16, 2004 * * @author gnaegi * @author BPS (<a href="http://www.bps-system.de/">BPS Bildungsportal Sachsen GmbH</a>) */ public class MSCourseNode extends AbstractAccessableCourseNode implements AssessableCourseNode { private static final String PACKAGE_MS = Util.getPackageName(MSCourseNodeRunController.class); private static final String PACKAGE = Util.getPackageName(MSCourseNode.class); private static final String TYPE = "ms"; /** configuration: score can be set */ public static final String CONFIG_KEY_HAS_SCORE_FIELD = "hasScoreField"; /** configuration: score min value */ public static final String CONFIG_KEY_SCORE_MIN = "scoreMin"; /** configuration: score max value */ public static final String CONFIG_KEY_SCORE_MAX = "scoreMax"; /** configuration: passed can be set */ public static final String CONFIG_KEY_HAS_PASSED_FIELD = "hasPassedField"; /** configuration: passed set to when score higher than cut value */ public static final String CONFIG_KEY_PASSED_CUT_VALUE = "passedCutValue"; /** configuration: comment can be set */ public static final String CONFIG_KEY_HAS_COMMENT_FIELD = "hasCommentField"; /** configuration: infotext for user */ public static final String CONFIG_KEY_INFOTEXT_USER = "******"; /** configuration: infotext for coach */ public static final String CONFIG_KEY_INFOTEXT_COACH = "nfoTextCoach"; /** Constructor for a course building block of type manual score */ public MSCourseNode() { super(TYPE); MSCourseNode.initDefaultConfig(getModuleConfiguration()); } /** * Adds to the given module configuration the default configuration for the manual scoring * * @param moduleConfiguration */ public static void initDefaultConfig(final ModuleConfiguration moduleConfiguration) { moduleConfiguration.set(CONFIG_KEY_HAS_SCORE_FIELD, Boolean.FALSE); moduleConfiguration.set(CONFIG_KEY_SCORE_MIN, new Float(0)); moduleConfiguration.set(CONFIG_KEY_SCORE_MAX, new Float(0)); moduleConfiguration.set(CONFIG_KEY_HAS_PASSED_FIELD, Boolean.TRUE); // no preset for passed cut value -> manual setting of passed moduleConfiguration.set(CONFIG_KEY_HAS_COMMENT_FIELD, Boolean.TRUE); moduleConfiguration.set(CONFIG_KEY_INFOTEXT_USER, ""); moduleConfiguration.set(CONFIG_KEY_INFOTEXT_COACH, ""); } /** * @see org.olat.course.nodes.CourseNode#createEditController(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl, org.olat.course.ICourse) */ @Override public TabbableController createEditController( final UserRequest ureq, final WindowControl wControl, final ICourse course, final UserCourseEnvironment euce) { final MSCourseNodeEditController childTabCntrllr = new MSCourseNodeEditController(ureq, wControl, this, course, euce); final CourseNode chosenNode = course .getEditorTreeModel() .getCourseNode(euce.getCourseEditorEnv().getCurrentCourseNodeId()); return new NodeEditController( ureq, wControl, course.getEditorTreeModel(), course, chosenNode, course.getCourseEnvironment().getCourseGroupManager(), euce, childTabCntrllr); } /** * @see * org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(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 NodeRunConstructionResult createNodeRunConstructionResult( final UserRequest ureq, final WindowControl wControl, final UserCourseEnvironment userCourseEnv, final NodeEvaluation ne, final String nodecmd) { Controller controller; // Do not allow guests to have manual scoring final Roles roles = ureq.getUserSession().getRoles(); if (roles.isGuestOnly()) { final Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale()); final String title = trans.translate("guestnoaccess.title"); final String message = trans.translate("guestnoaccess.message"); controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message); } else { controller = new MSCourseNodeRunController(ureq, wControl, userCourseEnv, this, true); } final Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_ms_icon"); return new NodeRunConstructionResult(wrappedCtrl); } /** @see org.olat.course.nodes.CourseNode#getReferencedRepositoryEntry() */ @Override public RepositoryEntry getReferencedRepositoryEntry() { return null; } /** @see org.olat.course.nodes.CourseNode#needsReferenceToARepositoryEntry() */ @Override public boolean needsReferenceToARepositoryEntry() { return false; } /** @see org.olat.course.nodes.CourseNode#isConfigValid() */ @Override public StatusDescription isConfigValid() { /* * first check the one click cache */ if (oneClickStatusCache != null) { return oneClickStatusCache[0]; } final boolean isValid = MSEditFormController.isConfigValid(getModuleConfiguration()); StatusDescription sd = StatusDescription.NOERROR; if (!isValid) { // FIXME: refine statusdescriptions by moving the statusdescription // generation to the MSEditForm final String shortKey = "error.missingconfig.short"; final String longKey = "error.missingconfig.long"; final String[] params = new String[] {this.getShortTitle()}; final String translPackage = Util.getPackageName(MSEditFormController.class); sd = new StatusDescription(ValidationStatus.ERROR, shortKey, longKey, params, translPackage); sd.setDescriptionForUnit(getIdent()); // set which pane is affected by error sd.setActivateableViewIdentifier(MSCourseNodeEditController.PANE_TAB_CONFIGURATION); } return sd; } /** * @see * org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public StatusDescription[] isConfigValid(final CourseEditorEnv cev) { oneClickStatusCache = null; // only here we know which translator to take for translating condition // error messages final String translatorStr = Util.getPackageName(MSEditFormController.class); final List sds = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions()); oneClickStatusCache = StatusDescriptionHelper.sort(sds); return oneClickStatusCache; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserScoreEvaluation(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public ScoreEvaluation getUserScoreEvaluation(final UserCourseEnvironment userCourseEnvironment) { // read score from properties final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); Boolean passed = null; Float score = null; // only db lookup if configured, else return null if (hasPassedConfigured()) { passed = am.getNodePassed(this, mySelf); } if (hasScoreConfigured()) { score = am.getNodeScore(this, mySelf); } final ScoreEvaluation se = new ScoreEvaluation(score, passed); return se; } /** * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest, * org.olat.course.ICourse) */ @Override public String informOnDelete(final Locale locale, final ICourse course) { final CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course); final List list = cpm.listCourseNodeProperties(this, null, null, null); if (list.size() == 0) { return null; // no properties created yet } final Translator trans = new PackageTranslator(PACKAGE_MS, locale); return trans.translate("warn.nodedelete"); } /** @see org.olat.course.nodes.CourseNode#cleanupOnDelete(org.olat.course.ICourse) */ @Override public void cleanupOnDelete(final ICourse course) { final CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager(); // Delete all properties: score, passed, log, comment, coach_comment pm.deleteNodeProperties(this, null); } /** @see org.olat.course.nodes.AssessableCourseNode#hasCommentConfigured() */ @Override public boolean hasCommentConfigured() { final ModuleConfiguration config = getModuleConfiguration(); final Boolean comment = (Boolean) config.get(CONFIG_KEY_HAS_COMMENT_FIELD); if (comment == null) { return false; } return comment.booleanValue(); } /** @see org.olat.course.nodes.AssessableCourseNode#hasPassedConfigured() */ @Override public boolean hasPassedConfigured() { final ModuleConfiguration config = getModuleConfiguration(); final Boolean passed = (Boolean) config.get(CONFIG_KEY_HAS_PASSED_FIELD); if (passed == null) { return false; } return passed.booleanValue(); } /** @see org.olat.course.nodes.AssessableCourseNode#hasScoreConfigured() */ @Override public boolean hasScoreConfigured() { final ModuleConfiguration config = getModuleConfiguration(); final Boolean score = (Boolean) config.get(CONFIG_KEY_HAS_SCORE_FIELD); if (score == null) { return false; } return score.booleanValue(); } /** @see org.olat.course.nodes.AssessableCourseNode#hasStatusConfigured() */ @Override public boolean hasStatusConfigured() { return false; } /** @see org.olat.course.nodes.AssessableCourseNode#getMaxScoreConfiguration() */ @Override public Float getMaxScoreConfiguration() { if (!hasScoreConfigured()) { throw new OLATRuntimeException( MSCourseNode.class, "getMaxScore not defined when hasScore set to false", null); } final ModuleConfiguration config = getModuleConfiguration(); final Float max = (Float) config.get(CONFIG_KEY_SCORE_MAX); return max; } /** @see org.olat.course.nodes.AssessableCourseNode#getMinScoreConfiguration() */ @Override public Float getMinScoreConfiguration() { if (!hasScoreConfigured()) { throw new OLATRuntimeException( MSCourseNode.class, "getMinScore not defined when hasScore set to false", null); } final ModuleConfiguration config = getModuleConfiguration(); final Float min = (Float) config.get(CONFIG_KEY_SCORE_MIN); return min; } /** @see org.olat.course.nodes.AssessableCourseNode#getCutValueConfiguration() */ @Override public Float getCutValueConfiguration() { if (!hasPassedConfigured()) { throw new OLATRuntimeException( MSCourseNode.class, "getCutValue not defined when hasPassed set to false", null); } final ModuleConfiguration config = getModuleConfiguration(); final Float cut = (Float) config.get(CONFIG_KEY_PASSED_CUT_VALUE); return cut; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserCoachComment(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getUserCoachComment(final UserCourseEnvironment userCourseEnvironment) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final String coachCommentValue = am.getNodeCoachComment(this, userCourseEnvironment.getIdentityEnvironment().getIdentity()); return coachCommentValue; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserUserComment(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getUserUserComment(final UserCourseEnvironment userCourseEnvironment) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final String userCommentValue = am.getNodeComment(this, userCourseEnvironment.getIdentityEnvironment().getIdentity()); return userCommentValue; } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserLog(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getUserLog(final UserCourseEnvironment userCourseEnvironment) { final UserNodeAuditManager am = userCourseEnvironment.getCourseEnvironment().getAuditManager(); final String logValue = am.getUserNodeLog(this, userCourseEnvironment.getIdentityEnvironment().getIdentity()); return logValue; } /** @see org.olat.course.nodes.AssessableCourseNode#isEditableConfigured() */ @Override public boolean isEditableConfigured() { // manual scoring fields can be edited manually return true; } /** * @see org.olat.course.nodes.AssessableCourseNode#updateUserCoachComment(java.lang.String, * org.olat.course.run.userview.UserCourseEnvironment) */ @Override public void updateUserCoachComment( final String coachComment, final UserCourseEnvironment userCourseEnvironment) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); if (coachComment != null) { am.saveNodeCoachComment(this, mySelf, coachComment); } } /** * @see * org.olat.course.nodes.AssessableCourseNode#updateUserScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation, * org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity) */ @Override public void updateUserScoreEvaluation( final ScoreEvaluation scoreEvaluation, final UserCourseEnvironment userCourseEnvironment, final Identity coachingIdentity, final boolean incrementAttempts) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); am.saveScoreEvaluation( this, coachingIdentity, mySelf, new ScoreEvaluation(scoreEvaluation.getScore(), scoreEvaluation.getPassed()), userCourseEnvironment, incrementAttempts); } /** * @see org.olat.course.nodes.AssessableCourseNode#updateUserUserComment(java.lang.String, * org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity) */ @Override public void updateUserUserComment( final String userComment, final UserCourseEnvironment userCourseEnvironment, final Identity coachingIdentity) { final AssessmentManager am = userCourseEnvironment.getCourseEnvironment().getAssessmentManager(); final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity(); if (userComment != null) { am.saveNodeComment(this, coachingIdentity, mySelf, userComment); } } /** * @see * org.olat.course.nodes.AssessableCourseNode#getUserAttempts(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public Integer getUserAttempts(final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException(MSCourseNode.class, "No attempts available in MS nodes", null); } /** @see org.olat.course.nodes.AssessableCourseNode#hasAttemptsConfigured() */ @Override public boolean hasAttemptsConfigured() { return false; } /** * @see org.olat.course.nodes.AssessableCourseNode#updateUserAttempts(java.lang.Integer, * org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity) */ @Override public void updateUserAttempts( final Integer userAttempts, final UserCourseEnvironment userCourseEnvironment, final Identity coachingIdentity) { throw new OLATRuntimeException( MSCourseNode.class, "Attempts variable can't be updated in MS nodes", null); } /** * @see * org.olat.course.nodes.AssessableCourseNode#incrementUserAttempts(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public void incrementUserAttempts(final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException( MSCourseNode.class, "Attempts variable can't be updated in MS nodes", null); } /** * @see * org.olat.course.nodes.AssessableCourseNode#getDetailsEditController(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl, * org.olat.course.run.userview.UserCourseEnvironment) */ @Override public Controller getDetailsEditController( final UserRequest ureq, final WindowControl wControl, final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException( MSCourseNode.class, "Details controler not available in MS nodes", null); } /** * @see * org.olat.course.nodes.AssessableCourseNode#getDetailsListView(org.olat.course.run.userview.UserCourseEnvironment) */ @Override public String getDetailsListView(final UserCourseEnvironment userCourseEnvironment) { throw new OLATRuntimeException(MSCourseNode.class, "Details not available in MS nodes", null); } /** @see org.olat.course.nodes.AssessableCourseNode#getDetailsListViewHeaderKey() */ @Override public String getDetailsListViewHeaderKey() { throw new OLATRuntimeException(MSCourseNode.class, "Details not available in MS nodes", null); } /** @see org.olat.course.nodes.AssessableCourseNode#hasDetails() */ @Override public boolean hasDetails() { return false; } }
/** * Test methods i18nManager inline translation tool and * InlineTranslationInterceptHandlerController */ @Test public void testInlineTranslationReplaceLocalizationMarkupWithHTML() { // enable inline translation markup i18nMgr.setMarkLocalizedStringsEnabled(null, true); Translator inlineTrans = Util.createPackageTranslator( InlineTranslationInterceptHandlerController.class, i18nMgr.getLocaleOrNull("de")); URLBuilder inlineTranslationURLBuilder = new jUnitURLBuilder(); String testBundle = "org.olat.core.util.i18n.junittestdata"; String testKey = "no.need.to.translate.this"; String rawtext1 = "Lorem impsum<b>nice stuff</b>"; String rawtext2 = "Holderadio <ul>lsdfsdf<y asdf blblb"; String combinedKey = testBundle + ":" + testKey; // test method that adds identifyers around the translation items String plainVanillaWrapped = i18nMgr.getLocalizedString( testBundle, testKey, null, i18nMgr.getLocaleOrNull("de"), false, false); String plainVanillaPlain = "just a test"; Pattern plainVanillaWrappedPattern = Pattern.compile( I18nManager.IDENT_PREFIX + combinedKey + ":([0-9]*?)" + I18nManager.IDENT_START_POSTFIX + plainVanillaPlain + I18nManager.IDENT_PREFIX + combinedKey + ":\\1" + I18nManager.IDENT_END_POSTFIX); Matcher m = plainVanillaWrappedPattern.matcher(plainVanillaWrapped); assertTrue(m.find()); // test find-replace translator identifyers with HTML markup StringOutput inlineTransLink = new StringOutput(); String[] args = (combinedKey + ":1000000001").split(":"); InlineTranslationInterceptHandlerController.buildInlineTranslationLink( args, inlineTransLink, inlineTrans, inlineTranslationURLBuilder); // Plain vanilla text String convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( plainVanillaWrapped, inlineTranslationURLBuilder, inlineTrans); assertEquals( "<span class=\"b_translation_i18nitem\">" + inlineTransLink.toString() + plainVanillaPlain + "</span>", convertedToHTMLMarkup); // Simple link String linkOPEN = "<a href=\"http://www.olat.org/bla/blu:bli#bla\" title='funny title' class=\"b_css b_anothercss\">"; String linkCLOSE = "</a>"; String inlineSpanOPEN = "<span class=\"b_translation_i18nitem\">"; String inlineSpanCLOSE = "</span>"; String translatedWithinLink = linkOPEN + plainVanillaWrapped + linkCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinLink, inlineTranslationURLBuilder, inlineTrans); String convertedWithinLinkExpected = inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + plainVanillaPlain + linkCLOSE + inlineSpanCLOSE + rawtext1; assertEquals(convertedWithinLinkExpected, convertedToHTMLMarkup); // Simple link with span String linkSpanOPEN = "<span class=\"bluber\">"; String linkSpanCLOSE = "</span>"; String translatedWithinLinkAndSpan = rawtext2 + linkOPEN + linkSpanOPEN + plainVanillaWrapped + linkSpanCLOSE + linkCLOSE; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinLinkAndSpan, inlineTranslationURLBuilder, inlineTrans); String convertedWithinLinkAndSpanExpected = rawtext2 + inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + linkSpanOPEN + plainVanillaPlain + linkSpanCLOSE + linkCLOSE + inlineSpanCLOSE; assertEquals(convertedWithinLinkAndSpanExpected, convertedToHTMLMarkup); // Muliple links String translatedWithinMultipleLinks = translatedWithinLink + translatedWithinLinkAndSpan + translatedWithinLinkAndSpan; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinMultipleLinks, inlineTranslationURLBuilder, inlineTrans); String convertedWithinMultipleLinksExpected = convertedWithinLinkExpected + convertedWithinLinkAndSpanExpected + convertedWithinLinkAndSpanExpected; assertEquals(convertedWithinMultipleLinksExpected, convertedToHTMLMarkup); // Input elements String inputOPEN = "<input type='submit' class=\"bluber\" value=\""; String inputCLOSE = "\" />"; String translatedWithinInput = inputOPEN + plainVanillaWrapped + inputCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinInput, inlineTranslationURLBuilder, inlineTrans); String convertedWithinInputExpected = inlineSpanOPEN + inlineTransLink.toString() + inputOPEN + plainVanillaPlain + inputCLOSE + inlineSpanCLOSE + rawtext1; assertEquals(convertedWithinInputExpected, convertedToHTMLMarkup); // checkbox elements String checkboxOPEN = "<input type='submit' class=\"bluber\" type=\"checkbox\" value=\""; String checkboxCLOSE = "\" />"; String translatedWithinCheckbox = checkboxOPEN + plainVanillaWrapped + checkboxCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinCheckbox, inlineTranslationURLBuilder, inlineTrans); String convertedWithinCheckboxExpected = checkboxOPEN + plainVanillaPlain + checkboxCLOSE + rawtext1; assertEquals(convertedWithinCheckboxExpected, convertedToHTMLMarkup); // Input and links mixed String translatedWithinMultipleLinksAndInput = translatedWithinLink + rawtext1 + translatedWithinInput + translatedWithinLinkAndSpan + rawtext2 + translatedWithinInput + translatedWithinLinkAndSpan; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinMultipleLinksAndInput, inlineTranslationURLBuilder, inlineTrans); String convertedWithinMultipleLinksAndInputExpected = convertedWithinLinkExpected + rawtext1 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected + rawtext2 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected; assertEquals(convertedWithinMultipleLinksAndInputExpected, convertedToHTMLMarkup); // Within element attribute String attributeOPEN = "<a href='sdfsdf' title=\""; String attributeCLOSE = "\" class=\"b_bluber\">hello world</a>"; String translatedWithinAttribute = attributeOPEN + plainVanillaWrapped + attributeCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinAttribute, inlineTranslationURLBuilder, inlineTrans); String convertedWithinAttributeExpected = attributeOPEN + plainVanillaPlain + attributeCLOSE + rawtext1; assertEquals(convertedWithinAttributeExpected, convertedToHTMLMarkup); // Ultimate test String translatedUltimate = translatedWithinMultipleLinksAndInput + rawtext1 + translatedWithinAttribute + translatedWithinMultipleLinksAndInput + rawtext2 + translatedWithinInput + translatedWithinLinkAndSpan; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedUltimate, inlineTranslationURLBuilder, inlineTrans); String convertedUltimateExpected = convertedWithinMultipleLinksAndInputExpected + rawtext1 + convertedWithinAttributeExpected + convertedWithinMultipleLinksAndInputExpected + rawtext2 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected; assertEquals(convertedUltimateExpected, convertedToHTMLMarkup); // don't do inline translation markup i18nMgr.setMarkLocalizedStringsEnabled(null, false); }
/** * @param name component name of form * @param quota the quota used to initialize the form or null if empty form is used */ public BGConfigQuotaController(UserRequest ureq, WindowControl wControl, Quota quota) { super(ureq, wControl); setTranslator(Util.createPackageTranslator(QuotaForm.class, getLocale(), getTranslator())); this.quota = quota; initForm(ureq); }