private void popupTagsCallout(final UserRequest ureq) { final String title = translate("filter.tag"); removeAsListenerAndDispose(moreTagsCtlr); moreTagsCtlr = new EPArtefactTagSelectionController(ureq, getWindowControl(), selectedTagsList); listenTo(moreTagsCtlr); removeAsListenerAndDispose(moreTagsCalloutCtrl); moreTagsCalloutCtrl = new CloseableCalloutWindowController( ureq, getWindowControl(), moreTagsCtlr.getInitialComponent(), (FormLink) tagEditBtn, title, true, null); listenTo(moreTagsCalloutCtrl); moreTagsCalloutCtrl.activate(); }
@Override protected void event(final UserRequest ureq, final Component source, final Event event) { if (source == startButton && startButton.isEnabled()) { final long callingResId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue(); final String callingResDetail = courseNode.getIdent(); removeAsListenerAndDispose(displayController); final Controller returnController = IQManager.getInstance() .createIQDisplayController( modConfig, secCallback, ureq, getWindowControl(), callingResId, callingResDetail); /* * either returnController is a MessageController or it is a IQDisplayController this should not serve as pattern to be copy&pasted. FIXME:2008-11-21:pb * INTRODUCED because of read/write QTI Lock solution for scalability II, 6.1.x Release */ if (returnController instanceof IQDisplayController) { displayController = (IQDisplayController) returnController; listenTo(displayController); if (displayController.isReady()) { // in case displayController was unable to initialize, a message was set by // displayController // this is the case if no more attempts or security check was unsuccessfull final LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController( ureq, getWindowControl(), null, null, displayController.getInitialComponent(), null); listenTo(layoutCtr); // autodispose // need to wrap a course restart controller again, because IQDisplay // runs on top of GUIStack final ICourse course = CourseFactory.loadCourse(callingResId); final RepositoryEntry courseRepositoryEntry = RepositoryServiceImpl.getInstance().lookupRepositoryEntry(course, true); final Panel empty = new Panel("empty"); // empty panel set as "menu" and "tool" final Controller courseCloser = CourseFactory.createDisposedCourseRestartController( ureq, getWindowControl(), courseRepositoryEntry.getResourceableId()); final Controller disposedRestartController = new LayoutMain3ColsController( ureq, getWindowControl(), empty, empty, courseCloser.getInitialComponent(), "disposed course whily in iqRun" + callingResId); layoutCtr.setDisposedMessageController(disposedRestartController); getWindowControl().pushToMainArea(layoutCtr.getInitialComponent()); if (modConfig .get(IQEditController.CONFIG_KEY_TYPE) .equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { assessmentStopped = false; singleUserEventCenter.registerFor(this, getIdentity(), assessmentInstanceOres); singleUserEventCenter.fireEventToListenersOf( new AssessmentEvent(AssessmentEvent.TYPE.STARTED, ureq.getUserSession()), assessmentEventOres); } } // endif isReady } else { // -> qti file was locked -> show info message // user must click again on course node to activate mainPanel.pushContent(returnController.getInitialComponent()); } } else if (source == showResultsButton) { final AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager(); Long assessmentID = am.getAssessmentID(courseNode, ureq.getIdentity()); if (assessmentID == null) { // fallback solution: if the assessmentID is not available via AssessmentManager than try to // get it via IQManager final long callingResId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue(); final String callingResDetail = courseNode.getIdent(); assessmentID = IQManager.getInstance() .getLastAssessmentID(ureq.getIdentity(), callingResId, callingResDetail); } if (assessmentID != null && !assessmentID.equals("")) { final Document doc = IQManager.getInstance() .getResultsReportingFromFile(ureq.getIdentity(), type, assessmentID); // StringBuilder resultsHTML = // LocalizedXSLTransformer.getInstance(ureq.getLocale()).renderResults(doc); final String summaryConfig = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY); final int summaryType = AssessmentInstance.getSummaryType(summaryConfig); final String resultsHTML = IQManager.getInstance().transformResultsReporting(doc, ureq.getLocale(), summaryType); myContent.contextPut("displayreporting", resultsHTML); myContent.contextPut("resreporting", resultsHTML); myContent.contextPut("showResults", Boolean.TRUE); } } else if (source == hideResultsButton) { myContent.contextPut("showResults", Boolean.FALSE); } }
/** * @param ureq * @param cpRoot * @param showMenu * @param activateFirstPage */ CPDisplayController( final UserRequest ureq, final WindowControl wControl, final VFSContainer rootContainer, final boolean showMenu, final boolean activateFirstPage, final String initialUri, final OLATResourceable ores) { super(ureq, wControl); this.rootContainer = rootContainer; // wrapper velocity container for page content this.myContent = createVelocityContainer("cpDisplay"); // the cp component, added to the velocity if (!ureq.getUserSession().getRoles().isGuestOnly()) { final SearchServiceUIFactory searchServiceUIFactory = (SearchServiceUIFactory) CoreSpringFactory.getBean(SearchServiceUIFactory.class); searchCtrl = searchServiceUIFactory.createInputController(ureq, wControl, DisplayOption.BUTTON, null); myContent.put("search_input", searchCtrl.getInitialComponent()); } // TODO:gs:a // may add an additional config for disabling, enabling IFrame style or not in CP mode // but always disable IFrame display when in screenreader mode (no matter whether style gets // ugly) if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) { cpComponent = new HtmlStaticPageComponent("", rootContainer); cpComponent.addListener(this); myContent.put("cpContent", cpComponent); } else { cpContentCtr = new IFrameDisplayController(ureq, getWindowControl(), rootContainer, null, ores); cpContentCtr.setAllowDownload(true); listenTo(cpContentCtr); myContent.put("cpContent", cpContentCtr.getInitialComponent()); } // even if we do not show the menu, we need to build parse the manifest and // find the first node to display at startup final VFSItem mani = rootContainer.resolve("imsmanifest.xml"); if (mani == null || !(mani instanceof VFSLeaf)) { throw new OLATRuntimeException( "error.manifest.missing", null, this.getClass().getPackage().getName(), "CP " + rootContainer + " has no imsmanifest", null); } // initialize tree model in any case ctm = new CPManifestTreeModel((VFSLeaf) mani); if (showMenu) { // the menu is only initialized when needed. cpTree = new MenuTree("cpDisplayTree"); cpTree.setTreeModel(ctm); cpTree.addListener(this); } LoggingResourceable nodeInfo = null; if (activateFirstPage) { // set content to first accessible child or root node if no children // available TreeNode node = ctm.getRootNode(); if (node == null) { throw new OLATRuntimeException( CPDisplayController.class, "root node of content packaging was null, file:" + rootContainer, null); } while (node != null && !node.isAccessible()) { if (node.getChildCount() > 0) { node = (TreeNode) node.getChildAt(0); } else { node = null; } } if (node != null) { // node.isAccessible final String nodeUri = (String) node.getUserObject(); if (cpContentCtr != null) { cpContentCtr.setCurrentURI(nodeUri); } if (cpComponent != null) { cpComponent.setCurrentURI(nodeUri); } if (showMenu) { cpTree.setSelectedNodeId(node.getIdent()); } // activate the selected node in the menu (skips the root node that is // empty anyway and saves one user click) selNodeId = node.getIdent(); nodeInfo = LoggingResourceable.wrapCpNode(nodeUri); } } else if (initialUri != null) { // set page if (cpContentCtr != null) { cpContentCtr.setCurrentURI(initialUri); } if (cpComponent != null) { cpComponent.setCurrentURI(initialUri); } // update menu final TreeNode newNode = ctm.lookupTreeNodeByHref(initialUri); if (newNode != null) { // user clicked on a link which is listed in the // toc if (cpTree != null) { cpTree.setSelectedNodeId(newNode.getIdent()); } else { selNodeId = newNode.getIdent(); } } nodeInfo = LoggingResourceable.wrapCpNode(initialUri); } // Note: the ores has a typename of ICourse - see // CPCourseNode.createNodeRunConstructorResult // which has the following line: // OresHelper.createOLATResourceableInstance(ICourse.class, // userCourseEnv.getCourseEnvironment().getCourseResourceableId()); // therefore we use OresHelper.calculateTypeName(ICourse.class) here if (ores != null && nodeInfo != null && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) { addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.cp)); ThreadLocalUserActivityLogger.log( LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass(), nodeInfo); } putInitialPanel(myContent); }