예제 #1
0
 /**
  * refreshing the add elements link to actual structure
  *
  * @param ureq
  * @param struct maybe null -> hiding the add-button
  */
 private void refreshAddElements(final UserRequest ureq, final PortfolioStructure struct) {
   tocV.remove(tocV.getComponent("addElement"));
   removeAsListenerAndDispose(addElCtrl);
   if (struct != null) {
     addElCtrl = new EPAddElementsController(ureq, getWindowControl(), struct);
     if (struct instanceof EPPage) {
       if (secCallback.canAddStructure()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
       }
       if (secCallback.canAddArtefact()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
       }
     } else if (struct instanceof EPAbstractMap) {
       if (secCallback.canAddPage()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_PAGE);
       }
     } else { // its a structure element
       if (secCallback.canAddArtefact()) {
         addElCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
       }
     }
     listenTo(addElCtrl);
     tocV.put("addElement", addElCtrl.getInitialComponent());
   }
 }
 private void updateStatisticUpdateOngoingFlag() {
   final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
   if (statisticUpdateManager == null) {
     log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
     content.contextPut("statisticUpdateOngoing", Boolean.TRUE);
   } else {
     content.contextPut("statisticUpdateOngoing", statisticUpdateManager.updateOngoing());
   }
 }
예제 #3
0
  private void exposeUserTestDataToVC(final UserRequest ureq) {
    // config : show score info
    final Object enableScoreInfoObject = modConfig.get(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
    if (enableScoreInfoObject != null) {
      myContent.contextPut("enableScoreInfo", enableScoreInfoObject);
    } else {
      myContent.contextPut("enableScoreInfo", Boolean.TRUE);
    }

    // configuration data
    myContent.contextPut("attemptsConfig", modConfig.get(IQEditController.CONFIG_KEY_ATTEMPTS));
    // user data
    if (!(courseNode instanceof AssessableCourseNode)) {
      throw new AssertException(
          "exposeUserTestDataToVC can only be called for test nodes, not for selftest or questionnaire");
    }
    final AssessableCourseNode acn =
        (AssessableCourseNode) courseNode; // assessment nodes are assesable
    final ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv);

    final Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    myContent.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore()));
    myContent.contextPut(
        "hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
    myContent.contextPut("passed", scoreEval.getPassed());
    myContent.contextPut("comment", acn.getUserUserComment(userCourseEnv));
    myContent.contextPut("attempts", acn.getUserAttempts(userCourseEnv));

    final UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
    myContent.contextPut("log", am.getUserNodeLog(courseNode, identity));

    exposeResults(ureq);
  }
  private void refreshUIState() {
    boolean enabled = false;
    String cronExpression = "";
    if (CoreSpringFactory.containsBean("schedulerFactoryBean")) {
      log.info("refreshUIState: schedulerFactoryBean found");
      final Object schedulerFactoryBean = CoreSpringFactory.getBean("schedulerFactoryBean");
      if (schedulerFactoryBean != null && schedulerFactoryBean instanceof Scheduler) {
        final Scheduler schedulerBean = (Scheduler) schedulerFactoryBean;
        int triggerState;
        try {
          triggerState =
              schedulerBean.getTriggerState("updateStatisticsTrigger", null /* trigger group */);
          enabled = (triggerState != Trigger.STATE_NONE) && (triggerState != Trigger.STATE_ERROR);
          log.info(
              "refreshUIState: updateStatisticsTrigger state was "
                  + triggerState
                  + ", enabled now: "
                  + enabled);
        } catch (final SchedulerException e) {
          log.warn(
              "refreshUIState: Got a SchedulerException while asking for the updateStatisticsTrigger's state",
              e);
        }
      }
      final CronTriggerBean triggerBean =
          (CronTriggerBean) CoreSpringFactory.getBean("updateStatisticsTrigger");
      final JobDetail jobDetail = triggerBean.getJobDetail();
      enabled &= jobDetail.getName().equals("statistics.job.enabled");
      log.info("refreshUIState: statistics.job.enabled check, enabled now: " + enabled);
      cronExpression = triggerBean.getCronExpression();
      final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log.info("refreshUIState: statisticUpdateManager not configured");
        enabled = false;
      } else {
        enabled &= statisticUpdateManager.isEnabled();
        log.info("refreshUIState: statisticUpdateManager configured, enabled now: " + enabled);
      }
    } else {
      log.info("refreshUIState: schedulerFactoryBean not found");
    }
    if (enabled) {
      content.contextPut(
          "status",
          getTranslator().translate("statistics.status.enabled", new String[] {cronExpression}));
    } else {
      content.contextPut("status", getTranslator().translate("statistics.status.disabled"));
    }
    content.contextPut("statisticEnabled", enabled);

    recalcLastUpdated();

    updateStatisticUpdateOngoingFlag();
  }
예제 #5
0
 private void checkChats(final UserRequest ureq) {
   if (ureq != null) {
     allChats = (List) ureq.getUserSession().getEntry("chats");
   }
   if (allChats == null || allChats.size() == 0) {
     startButton.setEnabled(true);
     myContent.contextPut("hasChatWindowOpen", false);
   } else {
     startButton.setEnabled(false);
     myContent.contextPut("hasChatWindowOpen", true);
   }
 }
예제 #6
0
  /**
   * Constructor for a test run controller
   *
   * @param userCourseEnv
   * @param moduleConfiguration
   * @param secCallback
   * @param ureq
   * @param wControl
   * @param testCourseNode
   */
  IQRunController(
      final UserCourseEnvironment userCourseEnv,
      final ModuleConfiguration moduleConfiguration,
      final IQSecurityCallback secCallback,
      final UserRequest ureq,
      final WindowControl wControl,
      final IQTESTCourseNode testCourseNode,
      final AssessmentNotificationsHandler notificationHandler) {
    super(ureq, wControl);

    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.assessmentEventOres = OresHelper.createOLATResourceableType(AssessmentEvent.class);
    this.assessmentInstanceOres = OresHelper.createOLATResourceableType(AssessmentInstance.class);
    this.chatEventOres = OresHelper.createOLATResourceableType(InstantMessaging.class);
    this.notificationHandler = notificationHandler;
    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);

    final 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
    final Boolean showResultOnHomePage =
        (Boolean)
            testCourseNode
                .getModuleConfiguration()
                .get(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE);
    myContent.contextPut("showChangelog", showResultOnHomePage);
  }
  public PortfolioCourseNodeEditController(
      final UserRequest ureq,
      final WindowControl wControl,
      final ICourse course,
      final PortfolioCourseNode node,
      final ModuleConfiguration config,
      final UserCourseEnvironment euce) {
    super(ureq, wControl);
    this.config = config;
    this.courseNode = node;

    configForm = new PortfolioConfigForm(ureq, wControl, course, node);
    listenTo(configForm);
    scoringController = new MSEditFormController(ureq, wControl, config);
    scoringContent = scoringController.getInitialComponent();
    listenTo(scoringController);
    textForm = new PortfolioTextForm(ureq, wControl, course, node);
    listenTo(textForm);

    configContent = createVelocityContainer("edit");
    configContent.put("configForm", configForm.getInitialComponent());
    configContent.put("textForm", textForm.getInitialComponent());

    // Accessibility precondition
    final CourseGroupManager groupMgr = course.getCourseEnvironment().getCourseGroupManager();
    final CourseEditorTreeModel editorModel = course.getEditorTreeModel();
    final Condition accessCondition = node.getPreConditionAccess();
    accessibilityCondContr =
        new ConditionEditController(
            ureq,
            getWindowControl(),
            groupMgr,
            accessCondition,
            "accessabilityConditionForm",
            AssessmentHelper.getAssessableNodes(editorModel, node),
            euce);
    listenTo(accessibilityCondContr);

    // if there is already user data available, make for read only
    final UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    hasLogEntries = am.hasUserNodeLogs(node);
    configContent.contextPut("hasLogEntries", new Boolean(hasLogEntries));
    if (hasLogEntries) {
      scoringController.setDisplayOnly(true);
    }
    // Initialstate
    configContent.contextPut("isOverwriting", new Boolean(false));
  }
 @Override
 protected void event(final UserRequest ureq, final Controller source, final Event event) {
   if (source == accessibilityCondContr) {
     if (event == Event.CHANGED_EVENT) {
       final Condition cond = accessibilityCondContr.getCondition();
       courseNode.setPreConditionAccess(cond);
       fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
     }
   } else if (source == configForm) {
     if (event == Event.DONE_EVENT) {
       configForm.getUpdatedConfig();
       fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
     }
   } else if (source == textForm) {
     if (event == Event.DONE_EVENT) {
       textForm.getUpdatedConfig();
       configForm.setDirtyFromOtherForm(false);
       fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
     } else if (event == Event.CHANGED_EVENT) {
       // disable modification in other forms!
       configForm.setDirtyFromOtherForm(true);
     }
   } else if (source == scoringController) {
     if (event == Event.CANCELLED_EVENT) {
       if (hasLogEntries) {
         scoringController.setDisplayOnly(true);
       }
       configContent.contextPut("isOverwriting", new Boolean(false));
       return;
     } else if (event == Event.DONE_EVENT) {
       scoringController.updateModuleConfiguration(config);
       fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
     }
   }
 }
  @Override
  @SuppressWarnings("unused")
  protected void event(final UserRequest ureq, final Component source, final Event event) {
    if (STATISTICS_FULL_RECALCULATION_TRIGGER_BUTTON.equals(event.getCommand())) {
      final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {

        final String title = getTranslator().translate("statistics.fullrecalculation.really.title");
        final String text = getTranslator().translate("statistics.fullrecalculation.really.text");
        dialogCtr_ = DialogBoxUIFactory.createYesNoDialog(ureq, getWindowControl(), title, text);
        listenTo(dialogCtr_);
        dialogCtr_.activate();
      }
    } else if (STATISTICS_UPDATE_TRIGGER_BUTTON.equals(event.getCommand())) {
      final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
      if (statisticUpdateManager == null) {
        log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
      } else {
        statisticUpdateManager.updateStatistics(false, getUpdateFinishedCallback());
        refreshUIState();
        content.put(
            "updatecontrol",
            new JSAndCSSComponent("intervall", this.getClass(), null, null, false, null, 3000));
        getInitialComponent().setDirty(true);
      }
    }
  }
예제 #10
0
 private void exposeUserQuestionnaireDataToVC() {
   final AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
   final Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
   // although this is not an assessable node we still use the assessment
   // manager since this one uses caching
   myContent.contextPut("attempts", am.getNodeAttempts(courseNode, identity));
 }
예제 #11
0
  /**
   * Provides the self test score and results, if any, to the velocity container.
   *
   * @param ureq
   */
  private void exposeUserSelfTestDataToVC(final UserRequest ureq) {
    // config : show score info
    final Object enableScoreInfoObject = modConfig.get(IQEditController.CONFIG_KEY_ENABLESCOREINFO);
    if (enableScoreInfoObject != null) {
      myContent.contextPut("enableScoreInfo", enableScoreInfoObject);
    } else {
      myContent.contextPut("enableScoreInfo", Boolean.TRUE);
    }

    if (!(courseNode instanceof SelfAssessableCourseNode)) {
      throw new AssertException(
          "exposeUserSelfTestDataToVC can only be called for selftest nodes, not for test or questionnaire");
    }
    final SelfAssessableCourseNode acn = (SelfAssessableCourseNode) courseNode;
    final ScoreEvaluation scoreEval = acn.getUserScoreEvaluation(userCourseEnv);
    if (scoreEval != null) {
      myContent.contextPut("hasResults", Boolean.TRUE);
      myContent.contextPut("score", AssessmentHelper.getRoundedScore(scoreEval.getScore()));
      myContent.contextPut(
          "hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
      myContent.contextPut("passed", scoreEval.getPassed());
      myContent.contextPut("attempts", new Integer(1)); // at least one attempt

      exposeResults(ureq);
    }
  }
예제 #12
0
 private void recalcLastUpdated() {
   try {
     final long lastUpdated = getStatisticUpdateManager().getLastUpdated();
     if (lastUpdated == -1) {
       content.contextPut(
           "lastupdated", getTranslator().translate("statistics.lastupdated.never", null));
     } else {
       final DateFormat df =
           DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, getLocale());
       content.contextPut(
           "lastupdated",
           getTranslator()
               .translate(
                   "statistics.lastupdated", new String[] {df.format(new Date(lastUpdated))}));
     }
   } catch (final Exception e) {
     content.contextPut("lastupdated", getTranslator().translate("statistics.lastupdated", null));
   }
 }
  /**
   * @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);
  }
예제 #14
0
 /**
  * Provides the show results button if results available or a message with the visibility period.
  *
  * @param ureq
  */
 private void exposeResults(final UserRequest ureq) {
   // migration: check if old tests have no summary configured
   final String configuredSummary = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY);
   final boolean noSummary =
       configuredSummary == null
           || (configuredSummary != null
               && configuredSummary.equals(AssessmentInstance.QMD_ENTRY_SUMMARY_NONE));
   if (!noSummary) {
     final Boolean showResultsObj =
         (Boolean) modConfig.get(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE);
     final boolean showResultsOnHomePage =
         (showResultsObj != null && showResultsObj.booleanValue());
     myContent.contextPut("showResultsOnHomePage", new Boolean(showResultsOnHomePage));
     final boolean dateRelatedVisibility = AssessmentHelper.isResultVisible(modConfig);
     if (showResultsOnHomePage && dateRelatedVisibility) {
       myContent.contextPut("showResultsVisible", Boolean.TRUE);
       showResultsButton = LinkFactory.createButton("command.showResults", myContent, this);
       hideResultsButton = LinkFactory.createButton("command.hideResults", myContent, this);
     } else if (showResultsOnHomePage) {
       final Date startDate = (Date) modConfig.get(IQEditController.CONFIG_KEY_RESULTS_START_DATE);
       final Date endDate = (Date) modConfig.get(IQEditController.CONFIG_KEY_RESULTS_END_DATE);
       final String visibilityStartDate =
           DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale())
               .format(startDate);
       String visibilityEndDate = "-";
       if (endDate != null) {
         visibilityEndDate =
             DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ureq.getLocale())
                 .format(endDate);
       }
       final String visibilityPeriod =
           getTranslator()
               .translate(
                   "showResults.visibility",
                   new String[] {visibilityStartDate, visibilityEndDate});
       myContent.contextPut("visibilityPeriod", visibilityPeriod);
       myContent.contextPut("showResultsVisible", Boolean.FALSE);
     }
   }
 }
예제 #15
0
  private void init(final UserRequest ureq) {
    startButton = LinkFactory.createButton("start", myContent, this);
    // fetch disclaimer file
    String sDisclaimer = (String) modConfig.get(IQEditController.CONFIG_KEY_DISCLAIMER);
    if (sDisclaimer != null) {
      VFSContainer baseContainer = userCourseEnv.getCourseEnvironment().getCourseFolderContainer();
      final int lastSlash = sDisclaimer.lastIndexOf('/');
      if (lastSlash != -1) {
        baseContainer = (VFSContainer) baseContainer.resolve(sDisclaimer.substring(0, lastSlash));
        sDisclaimer = sDisclaimer.substring(lastSlash);
        // first check if disclaimer exists on filesystem
        if (baseContainer == null || baseContainer.resolve(sDisclaimer) == null) {
          showWarning("disclaimer.file.invalid", sDisclaimer);
        } else {
          // screenreader do not like iframes, display inline
          if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) {
            final HtmlStaticPageComponent disclaimerComp =
                new HtmlStaticPageComponent("disc", baseContainer);
            myContent.put("disc", disclaimerComp);
            disclaimerComp.setCurrentURI(sDisclaimer);
            myContent.contextPut("hasDisc", Boolean.TRUE);
          } else {
            iFrameCtr = new IFrameDisplayController(ureq, getWindowControl(), baseContainer);
            listenTo(iFrameCtr); // dispose automatically
            myContent.put("disc", iFrameCtr.getInitialComponent());
            iFrameCtr.setCurrentURI(sDisclaimer);
            myContent.contextPut("hasDisc", Boolean.TRUE);
          }
        }
      }
    }

    // push title and learning objectives, only visible on intro page
    myContent.contextPut("menuTitle", courseNode.getShortTitle());
    myContent.contextPut("displayTitle", courseNode.getLongTitle());

    // Adding learning objectives
    final String learningObj = courseNode.getLearningObjectives();
    if (learningObj != null) {
      final Component learningObjectives =
          ObjectivesHelper.createLearningObjectivesComponent(learningObj, ureq);
      myContent.put("learningObjectives", learningObjectives);
      myContent.contextPut("hasObjectives", learningObj); // dummy value, just an exists operator
    }

    if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) {
      checkChats(ureq);
      singleUserEventCenter.registerFor(this, getIdentity(), chatEventOres);
    }
  }
예제 #16
0
  /**
   * Constructor for a survey run controller
   *
   * @param userCourseEnv
   * @param moduleConfiguration
   * @param secCallback
   * @param ureq
   * @param wControl
   * @param surveyCourseNode
   */
  IQRunController(
      final UserCourseEnvironment userCourseEnv,
      final ModuleConfiguration moduleConfiguration,
      final IQSecurityCallback secCallback,
      final UserRequest ureq,
      final WindowControl wControl,
      final IQSURVCourseNode surveyCourseNode) {
    super(ureq, wControl);

    this.modConfig = moduleConfiguration;
    this.secCallback = secCallback;
    this.userCourseEnv = userCourseEnv;
    this.courseNode = surveyCourseNode;
    this.type = AssessmentInstance.QMD_ENTRY_TYPE_SURVEY;

    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();

    final 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);
  }
예제 #17
0
  public EPTOCController(
      final UserRequest ureq,
      final WindowControl wControl,
      final PortfolioStructure selectedEl,
      final PortfolioStructure rootNode,
      final EPSecurityCallback secCallback) {
    super(ureq, wControl);
    this.secCallback = secCallback;
    tocV = createVelocityContainer("toc");
    ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean(EPFrontendManager.class);
    eSTMgr = (PortfolioStructureDao) CoreSpringFactory.getBean(PortfolioStructureDao.class);
    this.rootNode = rootNode;
    final AjaxTreeModel treeModel = buildTreeModel();
    treeCtr =
        new TreeController(
            ureq, getWindowControl(), translate("toc.root"), treeModel, "myjsCallback");
    treeCtr.setTreeSorting(false, false, false);
    listenTo(treeCtr);
    tocV.put("tocTree", treeCtr.getInitialComponent());
    delButton =
        LinkFactory.createCustomLink(
            "deleteButton", DELETE_LINK_CMD, "   ", Link.NONTRANSLATED, tocV, this);
    delButton.setTooltip(translate("deleteButton"), false);
    delButton.setCustomEnabledLinkCSS("b_delete_icon b_eportfolio_del_link ");
    tocV.put("deleteButton", delButton);

    if (selectedEl == null) {
      treeCtr.selectPath("/" + ROOT_NODE_IDENTIFIER + "/" + rootNode.getKey()); // select map
      refreshAddElements(ureq, rootNode);
    } else {
      final String pagePath = calculatePathByDeepestNode(selectedEl);
      treeCtr.selectPath("/" + ROOT_NODE_IDENTIFIER + "/" + rootNode.getKey() + pagePath);
      structureClicked = selectedEl;
      refreshAddElements(ureq, selectedEl);
    }

    putInitialPanel(tocV);
  }
  /**
   * Constructor
   *
   * @param ureq
   * @param wControl
   */
  protected CalendarPortletRunController(final UserRequest ureq, final WindowControl wControl) {
    super(ureq, wControl);

    calendarVC = createVelocityContainer("calendarPortlet");
    showAllLink = LinkFactory.createLink("calendar.showAll", calendarVC, this);
    ComponentUtil.registerForValidateEvents(calendarVC, this);

    final Date date = new Date();
    final String today =
        DateFormat.getTimeInstance(DateFormat.MEDIUM, ureq.getLocale()).format(date);
    calendarVC.contextPut("today", today);

    final TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("calendar.noEvents"));
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("b_portlet_table");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    // dummy header key, won't be used since setDisplayTableHeader is set to
    // false
    tableController.addColumnDescriptor(
        new PortletDateColumnDescriptor("calendar.date", 0, getTranslator()));
    tableController.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "calendar.subject", 1, CMD_LAUNCH, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));

    final List events = getMatchingEvents(ureq, wControl);
    tableController.setTableDataModel(new EventsModel(events));
    listenTo(tableController);

    calendarVC.put("table", tableController.getInitialComponent());

    putInitialPanel(this.calendarVC);
  }
예제 #19
0
 @Override
 protected void event(final UserRequest ureq, final Controller source, final Event event) {
   if (source == dialogCtr_) {
     if (DialogBoxUIFactory.isYesEvent(event)) {
       final StatisticUpdateService statisticUpdateManager = getStatisticUpdateManager();
       if (statisticUpdateManager == null) {
         log.info("event: UpdateStatisticsJob configured, but no StatisticManager available");
       } else {
         statisticUpdateManager.updateStatistics(true, getUpdateFinishedCallback());
         refreshUIState();
         content.put(
             "updatecontrol",
             new JSAndCSSComponent("intervall", this.getClass(), null, null, false, null, 3000));
         getInitialComponent().setDirty(true);
       }
     }
   }
 }
 private void updateUI() {
   myContent.contextPut("subscribed", (isSubscribed ? Boolean.TRUE : Boolean.FALSE));
 }
  @Override
  protected void event(final UserRequest ureq, final Controller source, final Event event) {
    if (source == usersForm) {
      if (event == Event.DONE_EVENT) {
        // calc stuff, preview

        final List existIdents = securityManager.getIdentitiesOfSecurityGroup(securityGroup);
        oks = new ArrayList<Identity>();
        final List<String> anonymous = new ArrayList<String>();
        final List<String> notFounds = new ArrayList<String>();
        final List<String> alreadyIn = new ArrayList<String>();

        // get the logins
        final String inp = usersForm.getLoginsString();
        final String[] lines = inp.split("\r?\n");
        for (int i = 0; i < lines.length; i++) {
          final String username = lines[i].trim();
          if (!username.equals("")) { // skip empty lines
            final Identity ident = securityManager.findIdentityByName(username);
            if (ident == null) { // not found, add to not-found-list
              notFounds.add(username);
            } else if (getBaseSecurityEBL().isAnonymous(ident)) {
              anonymous.add(username);
            } else {
              // check if already in group
              final boolean inGroup = containsIdentity(existIdents, ident);
              if (inGroup) {
                // added to warning: already in group
                alreadyIn.add(ident.getName());
              } else {
                // ok to add -> preview (but filter duplicate entries)
                if (!containsIdentity(oks, ident)) {
                  oks.add(ident);
                }
              }
            }
          }
        }
        // push table and other infos to velocity
        removeAsListenerAndDispose(newTableC);
        newTableC =
            UserControllerFactory.createTableControllerFor(
                null, oks, ureq, getWindowControl(), null);
        listenTo(newTableC);

        mainVc.put("table", newTableC.getInitialComponent());
        mainVc.contextPut("isanonymous", listNames(anonymous));
        mainVc.contextPut("notfound", listNames(notFounds));
        mainVc.contextPut("alreadyin", listNames(alreadyIn));
        mainVc.contextPut("usercount", new Integer(oks.size()));
        // set table page as next wizard step
        setNextWizardStep(translate("import.title.finish"), mainVc);
      }

    } else if (source == mailCtr) {
      if (event == Event.DONE_EVENT) {
        final MultiIdentityChosenEvent multiEvent = new MultiIdentityChosenEvent(this.oks);
        multiEvent.setMailTemplate(mailCtr.getMailTemplate());
        fireEvent(ureq, multiEvent);
      }
    }
  }
예제 #22
0
  /**
   * @param ureq
   * @param wControl
   * @param rootDir The VFS root directory from which the linkable files should be read
   * @param uploadRelPath The relative path within the rootDir where uploaded files should be put
   *     into. If NULL, the root Dir is used
   * @param suffixes Array of allowed file types
   * @param fileName the path of the file currently edited (in order to compute the correct relative
   *     paths for links), e.g. bla/blu.html or index.html
   */
  public FileLinkChooserController(
      UserRequest ureq,
      WindowControl wControl,
      VFSContainer rootDir,
      String uploadRelPath,
      String[] suffixes,
      String fileName) {
    super(ureq, wControl);
    this.fileName = fileName;
    this.suffixes = suffixes;
    this.rootDir = rootDir;
    this.mainVC = createVelocityContainer("filechooser");

    // file uploads are relative to the currently edited file
    String[] dirs = this.fileName.split("/");
    VFSContainer fileUploadBase = rootDir;
    for (String subPath : dirs) {
      // try to resolve the given file path in the root container
      VFSItem subFolder = fileUploadBase.resolve(subPath);
      if (subFolder != null) {
        if (subFolder instanceof VFSContainer) {
          // a higher level found, use this one unless a better one is found
          fileUploadBase = (VFSContainer) subFolder;
        } else {
          // it is not a container - leaf reached
          break;
        }
      } else {
        // resolving was not possible??? stop here
        break;
      }
    }
    // create directory filter combined with suffix filter
    String[] dirFilters = {"_courseelementdata"};
    VFSItemFilter customFilter = null;
    VFSItemFilter dirFilter = new VFSItemExcludePrefixFilter(dirFilters);
    if (suffixes != null) {
      VFSItemFileTypeFilter typeFilter = new VFSItemFileTypeFilter(suffixes);
      typeFilter.setCompositeFilter(dirFilter);
      customFilter = typeFilter;
    } else {
      customFilter = dirFilter;
    }
    // hide file chooser title, we have our own title
    fileChooserController =
        FileChooserUIFactory.createFileChooserControllerWithoutTitle(
            ureq, getWindowControl(), rootDir, customFilter, true);
    listenTo(fileChooserController);
    mainVC.put("stTree", fileChooserController.getInitialComponent());

    // convert file endings to mime types as needed by file upload controller
    Set<String> mimeTypes = null;
    if (suffixes != null) {
      mimeTypes = new HashSet<String>();
      for (String suffix : suffixes) {
        String mimeType = WebappHelper.getMimeType("dummy." + suffix);
        if (mimeType != null) {
          if (!mimeTypes.contains(mimeType)) mimeTypes.add(mimeType);
        }
      }
    }
    uploadCtr =
        new FileUploadController(
            wControl,
            fileUploadBase,
            ureq,
            (int) FolderConfig.getLimitULKB(),
            Quota.UNLIMITED,
            mimeTypes,
            true);
    listenTo(uploadCtr);
    // set specific upload path
    uploadCtr.setUploadRelPath(uploadRelPath);

    mainVC.put("uploader", uploadCtr.getInitialComponent());

    putInitialPanel(mainVC);
  }
예제 #23
0
  /**
   * @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);
  }
예제 #24
0
  @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);
    }
  }