/** * @param ureq * @param subscriptionContext * @param publisherData */ public ContextualSubscriptionController( UserRequest ureq, WindowControl wControl, SubscriptionContext subscriptionContext, PublisherData publisherData) { super(ureq, wControl); this.subscriptionContext = subscriptionContext; this.publisherData = publisherData; isNewNotificationService = useNewNotificationService(publisherData); myContent = createVelocityContainer("consubs"); if (subscriptionContext == null) { setInitialComponent(new Panel("empty:nosubscription")); return; } detailsPanel = new Panel("subscription_detail"); allPanel = new Panel("subscription_all"); subscribeButton = LinkFactory.createButtonSmall("command.subscribe", myContent, this); // subscribeButton.setCustomEnabledLinkCSS("b_noti_subscribe_link"); this.unsubscribeButton = LinkFactory.createButtonSmall("command.unsubscribe", myContent, this); // unsubscribeButton.setCustomEnabledLinkCSS("b_noti_unsubscribe_link"); if (isNewNotificationService) { log.info( "Notification-Service: " + publisherData.getType() + " is running with NEW notification"); newNotificationService = getService(LearnServices.notificationLearnService); subscriptionContext.setContextId( getRepositoryService() .getRepositoryEntryIdFromResourceable( subscriptionContext.getResId(), subscriptionContext.getResName())); // TODO: LD: move this at construction of // subscriptionContext newSubscriptionContext = newNotificationService.createNotificationSubscriptionContext( ureq.getIdentity(), subscriptionContext, publisherData); isSubscribed = newNotificationService.isSubscribed(newSubscriptionContext); } else { log.info( "Notification-Service: " + publisherData.getType() + " is running with LEGACY notification"); notifManager = getNotificationService(); // if subscribed, offer a unsubscribe button and vica versa. isSubscribed = notifManager.isSubscribed(ureq.getIdentity(), subscriptionContext); } updateUI(); myContent.put("detailsPanel", detailsPanel); allPanel.setContent(myContent); putInitialPanel(allPanel); }
@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); } }