Exemplo n.º 1
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);
  }
 public static void setReference(
     final RepositoryEntry repoEntry,
     final PortfolioStructure map,
     final ModuleConfiguration moduleConfig) {
   moduleConfig.set(PortfolioCourseNodeConfiguration.MAP_KEY, map.getKey());
   if (repoEntry != null && repoEntry.getSoftkey() != null) {
     moduleConfig.set(PortfolioCourseNodeConfiguration.REPO_SOFT_KEY, repoEntry.getSoftkey());
   }
 }
Exemplo n.º 3
0
  protected ModuleConfiguration getUpdatedConfig() {
    final String durationStr = durationSelection.getSelectedKey();
    config.set(InfoCourseNodeConfiguration.CONFIG_DURATION, durationStr);

    final String lengthStr = lengthSelection.getSelectedKey();
    config.set(InfoCourseNodeConfiguration.CONFIG_LENGTH, lengthStr);

    return config;
  }
Exemplo n.º 4
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);
    }
  }
Exemplo n.º 5
0
  @Override
  protected void initForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    setFormTitle("pane.tab.infos_config.title");
    setFormContextHelp(
        InfoConfigForm.class.getPackage().getName(),
        "ced-info-config.html",
        "help.hover.info.config");

    final String page = velocity_root + "/editShow.html";
    final FormLayoutContainer showLayout =
        FormLayoutContainer.createCustomFormLayout(
            "pane.tab.infos_config.shown", getTranslator(), page);
    showLayout.setLabel("pane.tab.infos_config.shown", null);
    formLayout.add(showLayout);

    durationSelection =
        uifactory.addDropdownSingleselect(
            "pane.tab.infos_config.max_duration",
            showLayout,
            maxDurationValues,
            maxDurationValues,
            null);
    durationSelection.setLabel("pane.tab.infos_config.max", null);
    final String durationStr = (String) config.get(InfoCourseNodeConfiguration.CONFIG_DURATION);
    if (StringHelper.containsNonWhitespace(durationStr)) {
      durationSelection.select(durationStr, true);
    } else {
      durationSelection.select("30", true);
    }

    lengthSelection =
        uifactory.addDropdownSingleselect(
            "pane.tab.infos_config.max_shown", showLayout, maxLengthValues, maxLengthValues, null);
    lengthSelection.setLabel("pane.tab.infos_config.max", null);
    final String lengthStr = (String) config.get(InfoCourseNodeConfiguration.CONFIG_LENGTH);
    if (StringHelper.containsNonWhitespace(lengthStr)) {
      lengthSelection.select(lengthStr, true);
    } else {
      lengthSelection.select("5", true);
    }

    uifactory.addFormSubmitButton("save", formLayout);
  }
Exemplo n.º 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);
  }
Exemplo n.º 7
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);
     }
   }
 }
Exemplo n.º 8
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);
    }
  }
Exemplo n.º 9
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);
  }
Exemplo n.º 10
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);
    }
  }
 public static void removeReference(final ModuleConfiguration moduleConfig) {
   moduleConfig.remove(PortfolioCourseNodeConfiguration.MAP_KEY);
   moduleConfig.remove(PortfolioCourseNodeConfiguration.REPO_SOFT_KEY);
 }
 /**
  * @param moduleConfiguration
  * @return boolean
  */
 public static boolean isModuleConfigValid(final ModuleConfiguration moduleConfiguration) {
   return (moduleConfiguration.get(PortfolioCourseNodeConfiguration.MAP_KEY) != null);
 }