/** * Returns the <code>SubscriptionContext</code> to use for assessment notification about specified * <code>ICourse</code>.<br> * <br> * <b>PRE CONDITIONS</b> * * <ul> * <li><code>course != null</code> * </ul> * * If <code>ident == null</code>, the subscription context is (created and) returned without * authorization control * * @param ident the identity, if null, no subscription check will be made * @param course * @return the subscription context to use or <code>null</code> if the identity associated to the * request is not allowed to be notified * @see #canSubscribeForAssessmentNotification(Identity, ICourse) */ protected SubscriptionContext getAssessmentSubscriptionContext(Identity ident, ICourse course) { SubscriptionContext sctx = null; if (ident == null || canSubscribeForAssessmentNotification(ident, course)) { // Creates a new SubscriptionContext only if not found into cache Long courseId = course.getResourceableId(); synchronized ( subsContexts) { // o_clusterOK by:ld - no problem to have independent subsContexts caches // for each cluster node sctx = subsContexts.get(courseId); if (sctx == null) { // a subscription context showing to the root node (the course's root // node is started when clicking such a notification) CourseNode cn = course.getRunStructure().getRootNode(); CourseEnvironment ce = course.getCourseEnvironment(); // FIXME:fg:b little problem is that the assessment tool and the course are not "the same" // anymore, that is you can open the same course twice in the // dynamic tabs by a) klicking e.g. via repo, and b via notifications link to the // assementtool sctx = new SubscriptionContext( CourseModule.ORES_COURSE_ASSESSMENT, ce.getCourseResourceableId(), cn.getIdent()); subsContexts.put(courseId, sctx); } } } return sctx; }
@Override public boolean isIdentityInCourseGroup(Long groupKey) { if (coachedGroups != null && participatingGroups != null) { return PersistenceHelper.listContainsObjectByKey(participatingGroups, groupKey) || PersistenceHelper.listContainsObjectByKey(coachedGroups, groupKey); } CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); return cgm.isIdentityInGroup(identityEnvironment.getIdentity(), groupKey); }
/** {@inheritDoc} */ @Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if (source instanceof TextElement) { int i = lTargetInputList.indexOf(source); if (i >= 0) { String linkValue = ((TextElement) source).getValue(); if (!linkValue.contains("://")) { linkValue = "http://".concat(linkValue.trim()); } boolean selected = lHtmlTargetInputList.get(i).isSelected(0); if (selected && linkValue.startsWith(Settings.getServerContextPathURI())) { lHtmlTargetInputList.get(i).select(BLANK_KEY, false); } } } else if (source.getComponent() instanceof Link) { if (lAddButtonList.contains(source)) { // add a new form link final LLModel link = (LLModel) ((FormLink) source).getUserObject(); final LLModel newLink = new LLModel(); linkList.add(linkList.indexOf(link) + 1, newLink); addNewFormLink(linkList.indexOf(link) + 1, newLink); } else if (lDelButtonList.contains(source)) { // special case: only one line existent if (linkList.size() == 1) { // clear this line lTargetInputList.get(0).setValue(""); lTargetInputList.get(0).setEnabled(true); lDescriptionInputList.get(0).setValue(""); lCommentInputList.get(0).setValue(""); } else { final LLModel link = (LLModel) ((FormLink) source).getUserObject(); removeFormLink(link); } } else if (lCustomMediaButtonList.contains(source)) { currentLink = (LLModel) ((FormLink) source).getUserObject(); removeAsListenerAndDispose(mediaDialogBox); removeAsListenerAndDispose(mediaChooserController); VFSContainer courseContainer = courseEnv.getCourseFolderContainer(); mediaChooserController = new MediaChooserController( ureq, getWindowControl(), courseContainer, null, null, "", null); listenTo(mediaChooserController); mediaDialogBox = new CloseableModalController( getWindowControl(), translate("choose"), mediaChooserController.getInitialComponent()); mediaDialogBox.activate(); listenTo(mediaDialogBox); } } super.formInnerEvent(ureq, source, event); fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT); }
@Override public boolean isParticipantOfAnyCourse() { if (participantAnyCourse != null) { return participantAnyCourse.booleanValue(); } CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); boolean participantLazy = cgm.isIdentityAnyCourseParticipant(identityEnvironment.getIdentity()); participantAnyCourse = new Boolean(participantLazy); return participantLazy; }
@Override public boolean isCoach() { if (coach != null) { return coach.booleanValue(); } // lazy loading CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); boolean coachLazy = cgm.isIdentityCourseCoach(identityEnvironment.getIdentity()); coach = new Boolean(coachLazy); return coachLazy; }
@Override public boolean isCoachOfAnyCourse() { if (coachAnyCourse != null) { return coachAnyCourse.booleanValue(); } CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); boolean coachLazy = cgm.isIdentityAnyCourseCoach(identityEnvironment.getIdentity()); coachAnyCourse = new Boolean(coachLazy); return coachLazy; }
@Override public boolean isParticipant() { if (participant != null) { return participant.booleanValue(); } // lazy loading CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); boolean partLazy = cgm.isIdentityCourseParticipant(identityEnvironment.getIdentity()); participant = new Boolean(partLazy); return partLazy; }
@Override public boolean isAdmin() { if (admin != null) { return admin.booleanValue(); } // lazy loading CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); boolean admiLazy = cgm.isIdentityCourseAdministrator(identityEnvironment.getIdentity()); admin = new Boolean(admiLazy); return admiLazy; }
public UserCourseEnvironmentImpl( IdentityEnvironment identityEnvironment, CourseEnvironment courseEnvironment) { this(identityEnvironment, courseEnvironment, null, null, null, null, null, null, null, null); if (courseEnvironment != null) { courseReadOnly = courseEnvironment .getCourseGroupManager() .getCourseEntry() .getRepositoryEntryStatus() .isClosed(); } }
@Override public boolean isAdminOfAnyCourse() { if (adminAnyCourse != null) { return adminAnyCourse.booleanValue(); } CourseGroupManager cgm = courseEnvironment.getCourseGroupManager(); boolean adminLazy = identityEnvironment.getRoles().isOLATAdmin() || identityEnvironment.getRoles().isInstitutionalResourceManager() || cgm.isIdentityAnyCourseAdministrator(identityEnvironment.getIdentity()); adminAnyCourse = new Boolean(adminLazy); return adminLazy; }
private void doEditComment(UserRequest ureq, AssessmentRow row) { removeAsListenerAndDispose(commentCalloutCtrl); OLATResourceable courseOres = courseEnv.getCourseGroupManager().getCourseResource(); editCommentCtrl = new EditCommentController(ureq, getWindowControl(), courseOres, gtaNode, row); listenTo(editCommentCtrl); commentCalloutCtrl = new CloseableCalloutWindowController( ureq, getWindowControl(), editCommentCtrl.getInitialComponent(), row.getCommentEditLink().getFormDispatchId(), "", true, ""); listenTo(commentCalloutCtrl); commentCalloutCtrl.activate(); }
private void applyChanges(boolean setAsDone) { List<AssessmentRow> rows = model.getObjects(); ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId()); if (applyToAllEl.isAtLeastSelected(1)) { Float score = null; if (withScore) { String scoreValue = groupScoreEl.getValue(); if (StringHelper.containsNonWhitespace(scoreValue)) { score = Float.parseFloat(scoreValue); } } Boolean passed = null; if (withPassed) { if (cutValue == null) { passed = groupPassedEl.isSelected(0); } else if (score != null) { passed = (score.floatValue() >= cutValue.floatValue()) ? Boolean.TRUE : Boolean.FALSE; } } for (AssessmentRow row : rows) { UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course); ScoreEvaluation newScoreEval; if (setAsDone) { newScoreEval = new ScoreEvaluation(score, passed, AssessmentEntryStatus.done, true, null); } else { newScoreEval = new ScoreEvaluation(score, passed); } gtaNode.updateUserScoreEvaluation(newScoreEval, userCourseEnv, getIdentity(), false); } if (withComment) { String comment = groupCommentEl.getValue(); if (StringHelper.containsNonWhitespace(comment)) { for (AssessmentRow row : rows) { UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course); gtaNode.updateUserUserComment(comment, userCourseEnv, getIdentity()); } } } } else { for (AssessmentRow row : rows) { UserCourseEnvironment userCourseEnv = row.getUserCourseEnvironment(course); Float score = null; if (withScore) { String value = row.getScoreEl().getValue(); if (StringHelper.containsNonWhitespace(value)) { score = Float.parseFloat(value); } } Boolean passed = null; if (withPassed) { if (cutValue == null) { passed = row.getPassedEl().isSelected(0); } else if (score != null) { passed = (score.floatValue() >= cutValue.floatValue()) ? Boolean.TRUE : Boolean.FALSE; } } ScoreEvaluation newScoreEval; if (setAsDone) { newScoreEval = new ScoreEvaluation(score, passed, AssessmentEntryStatus.done, true, null); } else { newScoreEval = new ScoreEvaluation(score, passed); } gtaNode.updateUserScoreEvaluation(newScoreEval, userCourseEnv, getIdentity(), false); if (withComment) { String comment = row.getComment(); if (StringHelper.containsNonWhitespace(comment)) { gtaNode.updateUserUserComment(comment, userCourseEnv, getIdentity()); } } } } }
/** @return True if all results are the same */ private ModelInfos loadModel() { // load participants, load datas ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId()); List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name()); Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>(); List<AssessmentEntry> entries = course .getCourseEnvironment() .getAssessmentManager() .getAssessmentEntries(assessedGroup, gtaNode); for (AssessmentEntry entry : entries) { identityToEntryMap.put(entry.getIdentity(), entry); } int count = 0; boolean same = true; StringBuilder duplicateWarning = new StringBuilder(); Float scoreRef = null; Boolean passedRef = null; String commentRef = null; List<AssessmentRow> rows = new ArrayList<>(identities.size()); for (Identity identity : identities) { AssessmentEntry entry = identityToEntryMap.get(identity); ScoreEvaluation scoreEval = null; if (withScore || withPassed) { scoreEval = gtaNode.getUserScoreEvaluation(entry); if (scoreEval == null) { scoreEval = ScoreEvaluation.EMPTY_EVALUATION; } } String comment = null; if (withComment && entry != null) { comment = entry.getComment(); } boolean duplicate = duplicateMemberKeys.contains(identity.getKey()); if (duplicate) { if (duplicateWarning.length() > 0) duplicateWarning.append(", "); duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity))); } AssessmentRow row = new AssessmentRow(identity, duplicate); rows.add(row); if (withScore) { Float score = scoreEval.getScore(); String pointVal = AssessmentHelper.getRoundedScore(score); TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc); pointEl.setDisplaySize(5); row.setScoreEl(pointEl); if (count == 0) { scoreRef = score; } else if (!same(scoreRef, score)) { same = false; } } if (withPassed && cutValue == null) { Boolean passed = scoreEval.getPassed(); MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues); if (passed != null && passed.booleanValue()) { passedEl.select(onKeys[0], passed.booleanValue()); } row.setPassedEl(passedEl); if (count == 0) { passedRef = passed; } else if (!same(passedRef, passed)) { same = false; } } if (withComment) { FormLink commentLink = uifactory.addFormLink( "comment-" + CodeHelper.getRAMUniqueID(), "comment", "comment", null, flc, Link.LINK); if (StringHelper.containsNonWhitespace(comment)) { commentLink.setIconLeftCSS("o_icon o_icon_comments"); } else { commentLink.setIconLeftCSS("o_icon o_icon_comments_none"); } commentLink.setUserObject(row); row.setComment(comment); row.setCommentEditLink(commentLink); if (count == 0) { commentRef = comment; } else if (!same(commentRef, comment)) { same = false; } } count++; } model.setObjects(rows); table.reset(); return new ModelInfos(same, scoreRef, passedRef, commentRef, duplicateWarning.toString()); }
@Override protected void formOK(UserRequest ureq) { boolean projectChanged = false; if (!project.getTitle().equals(projectTitle.getValue())) { // title has been changed => change project-group name too String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue()); String newProjectGroupDescription = translate("project.member.groupdescription", projectTitle.getValue()); OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource(); ProjectBrokerManagerFactory.getProjectGroupManager() .changeProjectGroupName( getIdentity(), project.getProjectGroup(), newProjectGroupName, newProjectGroupDescription, courseResource); ProjectBrokerManagerFactory.getProjectGroupManager() .sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity()); projectChanged = true; } if (!project.getTitle().equals(projectTitle.getValue())) { project.setTitle(projectTitle.getValue()); projectChanged = true; } if (!project.getDescription().equals(projectDescription.getValue())) { project.setDescription(projectDescription.getValue()); projectChanged = true; } if (projectState.isSelected(0)) { if (!project.getState().equals(stateKeys[0])) { project.setState(stateKeys[0]); projectChanged = true; } } else { if (!project.getState().equals(stateKeys[1])) { project.setState(stateKeys[1]); projectChanged = true; } } if (project.getMaxMembers() != maxMembers.getIntValue()) { project.setMaxMembers(maxMembers.getIntValue()); projectChanged = true; } if (attachmentFileName.getUploadFileName() != null && !attachmentFileName.getUploadFileName().equals("")) { project.setAttachedFileName(attachmentFileName.getUploadFileName()); uploadFiles(attachmentFileName); } // store customfields int index = 0; for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) { Object element = iterator.next(); String value = ""; if (element instanceof TextElement) { TextElement textElement = (TextElement) element; value = textElement.getValue(); } else if (element instanceof SingleSelection) { SingleSelection selectionElement = (SingleSelection) element; if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) { value = selectionElement.getSelectedKey(); } else { value = ""; } } if (!project.getCustomFieldValue(index).equals(value)) { project.setCustomFieldValue(index, value); projectChanged = true; } index++; } // store events for (Project.EventType eventType : eventStartElementList.keySet()) { Date startDate = eventStartElementList.get(eventType).getDate(); Date endDate = eventEndElementList.get(eventType).getDate(); if (!project.getProjectEvent(eventType).getStartDate().equals(startDate) || !project.getProjectEvent(eventType).getEndDate().equals(endDate)) { project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate)); projectChanged = true; } } if (projectChanged) { ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project); ProjectBrokerManagerFactory.getProjectBrokerEmailer() .sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator()); fireEvent(ureq, Event.DONE_EVENT); } }
/** * @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) */ @Override public void event(UserRequest ureq, Component source, Event event) { if (source == onCommand) { // toggle on Preferences prefs = ureq.getUserSession().getGuiPreferences(); prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.TRUE); prefs.save(); // update gui mainVC.remove(onCommand); offCommand = LinkFactory.createLink("command.glossary.off", mainVC, this); offCommand.setTitle("command.glossary.off.alt"); offCommand.setCustomEnabledLinkCSS("b_toolbox_toggle"); // notify textmarker controller glossMarkupItmCtr.setTextMarkingEnabled(true); fireEvent(ureq, new Event("glossaryOn")); } else if (source == offCommand) { // toggle off Preferences prefs = ureq.getUserSession().getGuiPreferences(); prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.FALSE); prefs.save(); // update gui mainVC.remove(offCommand); onCommand = LinkFactory.createLink("command.glossary.on", mainVC, this); onCommand.setTitle("command.glossary.on.alt"); onCommand.setCustomEnabledLinkCSS("b_toolbox_toggle"); // notify textmarker controller glossMarkupItmCtr.setTextMarkingEnabled(false); fireEvent(ureq, new Event("glossaryOff")); } else if (source == mainVC && event.getCommand().equals("command.glossary")) { // start glossary in window final CourseConfig cc = courseEnvir.getCourseConfig(); // do not cache cc, not save // if glossary had been opened from LR as Tab before, warn user: DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs(); RepositoryEntry repoEntry = RepositoryManager.getInstance() .lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false); DTab dt = dts.getDTab(repoEntry.getOlatResource()); if (dt != null) { List<ContextEntry> entries = BusinessControlFactory.getInstance() .createCEListFromResourceType(allowGlossaryEditing ? "true" : "false"); dts.activate(ureq, dt, entries); } else { ControllerCreator ctrlCreator = new ControllerCreator() { public Controller createController(UserRequest lureq, WindowControl lwControl) { GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController( lwControl, lureq, cc, allowGlossaryEditing); listenTo(glossaryController); if (glossaryController == null) { // happens in the unlikely event of a user who is in a course and // now // tries to access the glossary String text = translate("error.noglossary"); return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text); } else { // use a one-column main layout LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController( lureq, lwControl, null, null, glossaryController.getInitialComponent(), null); // dispose glossary on layout dispose layoutCtr.addDisposableChildController(glossaryController); return layoutCtr; } } }; ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator); // open in new browser window openInNewBrowserWindow(ureq, layoutCtrlr); return; // immediate return after opening new browser window! } } }
@Override protected void formOK(UserRequest ureq) { boolean projectChanged = false; if (!project.getTitle().equals(projectTitle.getValue())) { // title has been changed => change project-group name too String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue()); String newProjectGroupDescription = translate("project.member.groupdescription", projectTitle.getValue()); OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource(); ProjectBrokerManagerFactory.getProjectGroupManager() .changeProjectGroupName( getIdentity(), project.getProjectGroup(), newProjectGroupName, newProjectGroupDescription, courseResource); ProjectBrokerManagerFactory.getProjectGroupManager() .sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity()); projectChanged = true; } if (!project.getTitle().equals(projectTitle.getValue())) { project.setTitle(projectTitle.getValue()); projectChanged = true; } if (!project.getDescription().equals(projectDescription.getValue())) { project.setDescription(projectDescription.getValue()); projectChanged = true; } if (project.getMaxMembers() != maxMembers.getIntValue()) { project.setMaxMembers(maxMembers.getIntValue()); ProjectBrokerManagerFactory.getProjectGroupManager() .setProjectGroupMaxMembers( getIdentity(), project.getProjectGroup(), maxMembers.getIntValue()); projectChanged = true; } if (attachmentFileName.getUploadFileName() != null && !attachmentFileName.getUploadFileName().equals("")) { // First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment // name uploadFiles(attachmentFileName); project.setAttachedFileName(attachmentFileName.getUploadFileName()); projectChanged = true; } else if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) { // Attachment file has been removed project.setAttachedFileName(""); projectChanged = true; } // store customfields int index = 0; for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) { Object element = iterator.next(); String value = ""; if (element instanceof TextElement) { TextElement textElement = (TextElement) element; value = textElement.getValue(); } else if (element instanceof SingleSelection) { SingleSelection selectionElement = (SingleSelection) element; if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) { value = selectionElement.getValue(selectionElement.getSelected()); } else { value = ""; } } getLogger() .debug( "customfield index=" + index + " value=" + value + " project.getCustomFieldValue(index)=" + project.getCustomFieldValue(index)); if (!project.getCustomFieldValue(index).equals(value)) { project.setCustomFieldValue(index, value); projectChanged = true; } index++; } // store events for (Project.EventType eventType : eventStartElementList.keySet()) { Date startDate = eventStartElementList.get(eventType).getDate(); Date endDate = eventEndElementList.get(eventType).getDate(); // First handle startdate if (hasBeenChanged(project.getProjectEvent(eventType).getStartDate(), startDate) || hasBeenChanged(project.getProjectEvent(eventType).getEndDate(), endDate)) { project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate)); projectChanged = true; } } if (mailNotification.isSelected(0) != project.isMailNotificationEnabled()) { project.setMailNotificationEnabled(mailNotification.isSelected(0)); projectChanged = true; } if (projectChanged) { if (ProjectBrokerManagerFactory.getProjectBrokerManager().existsProject(project.getKey())) { ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project); ProjectBrokerManagerFactory.getProjectBrokerEmailer() .sendProjectChangedEmailToParticipants( ureq.getIdentity(), project, this.getTranslator()); } else { this.showInfo("info.project.nolonger.exist", project.getTitle()); } } fireEvent(ureq, Event.DONE_EVENT); }
public RepositoryEntry getCourseRepositoryEntry() { if (courseRepoEntry == null) { courseRepoEntry = courseEnvironment.getCourseGroupManager().getCourseEntry(); } return courseRepoEntry; }