예제 #1
0
  private void exposeUserTestDataToVC(UserRequest ureq) {
    // config : show score info
    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
    Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    if (courseNode instanceof PersistentAssessableCourseNode) {
      PersistentAssessableCourseNode acn = (PersistentAssessableCourseNode) courseNode;
      AssessmentEntry assessmentEntry = acn.getUserAssessmentEntry(userCourseEnv);
      if (assessmentEntry == null) {
        myContent.contextPut("blockAfterSuccess", Boolean.FALSE);
        myContent.contextPut("score", null);
        myContent.contextPut("hasPassedValue", Boolean.FALSE);
        myContent.contextPut("passed", Boolean.FALSE);
        myContent.contextPut("comment", null);
        myContent.contextPut("attempts", 0);
      } else {
        // block if test passed (and config set to check it)
        Boolean blockAfterSuccess =
            modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_BLOCK_AFTER_SUCCESS);
        Boolean blocked = Boolean.FALSE;
        if (blockAfterSuccess != null && blockAfterSuccess.booleanValue()) {
          Boolean passed = assessmentEntry.getPassed();
          if (passed != null && passed.booleanValue()) {
            blocked = Boolean.TRUE;
          }
        }
        myContent.contextPut("blockAfterSuccess", blocked);
        myContent.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore()));
        myContent.contextPut(
            "hasPassedValue", (assessmentEntry.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        myContent.contextPut("passed", assessmentEntry.getPassed());
        StringBuilder comment = Formatter.stripTabsAndReturns(assessmentEntry.getComment());
        myContent.contextPut("comment", StringHelper.xssScan(comment));
        myContent.contextPut("attempts", assessmentEntry.getAttempts());
      }
    }

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

    exposeResults(ureq);
  }
예제 #2
0
  /**
   * Provides the self test score and results, if any, to the velocity container.
   *
   * @param ureq
   */
  private void exposeUserSelfTestDataToVC(UserRequest ureq) {
    // config : show score info
    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");
    SelfAssessableCourseNode acn = (SelfAssessableCourseNode) courseNode;
    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);
    }
  }
예제 #3
0
  public LLEditForm(
      UserRequest ureq,
      WindowControl wControl,
      ModuleConfiguration moduleConfig,
      CourseEnvironment courseEnv) {
    super(ureq, wControl, "editForm");
    this.moduleConfig = moduleConfig;
    // read existing links from config
    linkList = new ArrayList<LLModel>((List<LLModel>) moduleConfig.get(LLCourseNode.CONF_LINKLIST));
    // list of all link target text fields
    lTargetInputList = new ArrayList<TextElement>(linkList.size());
    // list of all link html target text fields
    lHtmlTargetInputList = new ArrayList<SingleSelection>(linkList.size());
    // list of all link description text fields
    lDescriptionInputList = new ArrayList<TextElement>(linkList.size());
    // list of all link comment text fields
    lCommentInputList = new ArrayList<TextElement>(linkList.size());
    // list of all link add action buttons
    lAddButtonList = new ArrayList<FormLink>(linkList.size());
    // list of all link deletion action buttons
    lDelButtonList = new ArrayList<FormLink>(linkList.size());
    // list of all custom media buttons
    lCustomMediaButtonList = new ArrayList<FormLink>(linkList.size());

    this.courseEnv = courseEnv;

    initForm(ureq);
  }
예제 #4
0
 /** @see org.olat.course.nodes.AssessableCourseNode#hasCommentConfigured() */
 @Override
 public boolean hasCommentConfigured() {
   final ModuleConfiguration config = getModuleConfiguration();
   final Boolean comment = (Boolean) config.get(CONFIG_KEY_HAS_COMMENT_FIELD);
   if (comment == null) {
     return false;
   }
   return comment.booleanValue();
 }
예제 #5
0
 /** @see org.olat.course.nodes.AssessableCourseNode#hasPassedConfigured() */
 @Override
 public boolean hasPassedConfigured() {
   final ModuleConfiguration config = getModuleConfiguration();
   final Boolean passed = (Boolean) config.get(CONFIG_KEY_HAS_PASSED_FIELD);
   if (passed == null) {
     return false;
   }
   return passed.booleanValue();
 }
예제 #6
0
 /** @see org.olat.course.nodes.AssessableCourseNode#hasScoreConfigured() */
 @Override
 public boolean hasScoreConfigured() {
   final ModuleConfiguration config = getModuleConfiguration();
   final Boolean score = (Boolean) config.get(CONFIG_KEY_HAS_SCORE_FIELD);
   if (score == null) {
     return false;
   }
   return score.booleanValue();
 }
  public GTASampleSolutionsEditController(
      UserRequest ureq,
      WindowControl wControl,
      ModuleConfiguration config,
      File solutionDir,
      VFSContainer solutionContainer) {
    super(ureq, wControl, "edit_solution_list");
    this.solutionDir = solutionDir;
    this.solutionContainer = solutionContainer;
    if (config.get(GTACourseNode.GTASK_SOLUTIONS) == null) {
      solutions = new SolutionList();
      config.set(GTACourseNode.GTASK_SOLUTIONS, solutions);
    } else {
      solutions = (SolutionList) config.get(GTACourseNode.GTASK_SOLUTIONS);
    }

    initForm(ureq);
  }
예제 #8
0
  /**
   * Retrieves the groups where the enrollment happens
   *
   * @response.representation.200.qname {http://www.example.com}groupVO
   * @response.representation.200.mediaType application/xml, application/json
   * @response.representation.200.doc The groups
   * @response.representation.200.example {@link
   *     org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
   * @response.representation.401.doc The roles of the authenticated user are not sufficient
   * @response.representation.404.doc The course or course node not found
   * @param nodeId The node's id
   * @param httpRequest The HTTP request
   * @return An array of groups
   */
  @GET
  @Path("{nodeId}/groups")
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  public Response getGroups(
      @PathParam("courseId") Long courseId,
      @PathParam("nodeId") String nodeId,
      @Context HttpServletRequest httpRequest) {

    if (!isAuthor(httpRequest)) {
      return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    ICourse course = CoursesWebService.loadCourse(courseId);
    if (course == null) {
      return Response.serverError().status(Status.NOT_FOUND).build();
    } else if (!isAuthorEditor(course, httpRequest)) {
      return Response.serverError().status(Status.UNAUTHORIZED).build();
    }

    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);

    CourseNode node = getParentNode(course, nodeId);
    ModuleConfiguration config = node.getModuleConfiguration();
    String groupNames = (String) config.get(ENCourseNode.CONFIG_GROUPNAME);
    @SuppressWarnings("unchecked")
    List<Long> groupKeys = (List<Long>) config.get(ENCourseNode.CONFIG_GROUP_IDS);
    if (groupKeys == null && StringHelper.containsNonWhitespace(groupNames)) {
      groupKeys =
          bgs.toGroupKeys(
              groupNames, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
    }

    if (groupKeys == null || groupKeys.isEmpty()) {
      return Response.ok(new GroupVO[0]).build();
    }

    List<GroupVO> voes = new ArrayList<GroupVO>();
    List<BusinessGroup> groups = bgs.loadBusinessGroups(groupKeys);
    for (BusinessGroup group : groups) {
      voes.add(get(group));
    }
    GroupVO[] voArr = new GroupVO[voes.size()];
    voes.toArray(voArr);
    return Response.ok(voArr).build();
  }
예제 #9
0
 /** @see org.olat.course.nodes.AssessableCourseNode#getCutValueConfiguration() */
 @Override
 public Float getCutValueConfiguration() {
   if (!hasPassedConfigured()) {
     throw new OLATRuntimeException(
         MSCourseNode.class, "getCutValue not defined when hasPassed set to false", null);
   }
   final ModuleConfiguration config = getModuleConfiguration();
   final Float cut = (Float) config.get(CONFIG_KEY_PASSED_CUT_VALUE);
   return cut;
 }
예제 #10
0
 /** @see org.olat.course.nodes.AssessableCourseNode#getMinScoreConfiguration() */
 @Override
 public Float getMinScoreConfiguration() {
   if (!hasScoreConfigured()) {
     throw new OLATRuntimeException(
         MSCourseNode.class, "getMinScore not defined when hasScore set to false", null);
   }
   final ModuleConfiguration config = getModuleConfiguration();
   final Float min = (Float) config.get(CONFIG_KEY_SCORE_MIN);
   return min;
 }
예제 #11
0
 /**
  * Provides the show results button if results available or a message with the visibility period.
  *
  * @param ureq
  */
 private void exposeResults(UserRequest ureq) {
   // migration: check if old tests have no summary configured
   String configuredSummary = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY);
   boolean noSummary =
       configuredSummary == null
           || (configuredSummary != null
               && configuredSummary.equals(AssessmentInstance.QMD_ENTRY_SUMMARY_NONE));
   if (!noSummary) {
     Boolean showResultsObj =
         modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE);
     boolean showResultsOnHomePage = (showResultsObj != null && showResultsObj.booleanValue());
     myContent.contextPut("showResultsOnHomePage", new Boolean(showResultsOnHomePage));
     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) {
       Date startDate = (Date) modConfig.get(IQEditController.CONFIG_KEY_RESULTS_START_DATE);
       Date endDate = (Date) modConfig.get(IQEditController.CONFIG_KEY_RESULTS_END_DATE);
       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);
       }
       String visibilityPeriod =
           getTranslator()
               .translate(
                   "showResults.visibility",
                   new String[] {visibilityStartDate, visibilityEndDate});
       myContent.contextPut("visibilityPeriod", visibilityPeriod);
       myContent.contextPut("showResultsVisible", Boolean.FALSE);
     }
   }
 }
예제 #12
0
  /**
   * Constructor for a test run controller
   *
   * @param userCourseEnv
   * @param moduleConfiguration
   * @param secCallback
   * @param ureq
   * @param wControl
   * @param testCourseNode
   */
  public IQRunController(
      UserCourseEnvironment userCourseEnv,
      ModuleConfiguration moduleConfiguration,
      IQSecurityCallback secCallback,
      UserRequest ureq,
      WindowControl wControl,
      IQTESTCourseNode testCourseNode,
      RepositoryEntry testEntry) {

    super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale()));

    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.referenceTestEntry = testEntry;

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

    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
    Boolean showResultOnHomePage =
        testCourseNode
            .getModuleConfiguration()
            .getBooleanEntry(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE);
    myContent.contextPut("showChangelog", showResultOnHomePage);
  }
예제 #13
0
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("fieldset.dropbox.title");
    setFormContextHelp("Other#bb_themenvergabe_abgabe");

    String sConfirmation = (String) config.get(TACourseNode.CONF_DROPBOX_CONFIRMATION);
    if (sConfirmation == null || sConfirmation.length() == 0) {
      // grab standard text
      sConfirmation = translate("conf.stdtext");
      config.set(TACourseNode.CONF_DROPBOX_CONFIRMATION, sConfirmation);
    }

    confirmation =
        uifactory.addTextAreaElement(
            "confirmation",
            "form.dropbox.confirmation",
            2500,
            4,
            40,
            true,
            sConfirmation != null ? sConfirmation : "",
            formLayout);

    Boolean enableMail = (Boolean) config.get(TACourseNode.CONF_DROPBOX_ENABLEMAIL);
    confirmation.setMandatory(enableMail);
    enablemail =
        uifactory.addCheckboxesHorizontal(
            "enablemail",
            "form.dropbox.enablemail",
            formLayout,
            new String[] {"xx"},
            new String[] {null});
    enablemail.select("xx", enableMail != null ? enableMail.booleanValue() : true);
    enablemail.addActionListener(FormEvent.ONCLICK);

    uifactory.addFormSubmitButton("submit", formLayout);
  }
예제 #14
0
  private void init(UserRequest ureq) {
    startButton = LinkFactory.createButton("start", myContent, this);
    startButton.setElementCssClass("o_sel_start_qti12_test");
    startButton.setPrimary(true);
    startButton.setVisible(!userCourseEnv.isCourseReadOnly());

    // fetch disclaimer file
    String sDisclaimer = (String) modConfig.get(IQEditController.CONFIG_KEY_DISCLAIMER);
    if (sDisclaimer != null) {
      VFSContainer baseContainer = userCourseEnv.getCourseEnvironment().getCourseFolderContainer();
      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
          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
    String learningObj = courseNode.getLearningObjectives();
    if (learningObj != null) {
      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(), InstantMessagingService.TOWER_EVENT_ORES);
    }
  }
예제 #15
0
  /**
   * Constructor for a survey run controller
   *
   * @param userCourseEnv
   * @param moduleConfiguration
   * @param secCallback
   * @param ureq
   * @param wControl
   * @param surveyCourseNode
   */
  public IQRunController(
      UserCourseEnvironment userCourseEnv,
      ModuleConfiguration moduleConfiguration,
      IQSecurityCallback secCallback,
      UserRequest ureq,
      WindowControl wControl,
      IQSURVCourseNode surveyCourseNode) {
    super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale()));

    this.modConfig = moduleConfiguration;
    this.secCallback = secCallback;
    this.userCourseEnv = userCourseEnv;
    this.courseNode = surveyCourseNode;
    this.referenceTestEntry = surveyCourseNode.getReferencedRepositoryEntry();
    this.type = AssessmentInstance.QMD_ENTRY_TYPE_SURVEY;
    this.singleUserEventCenter = ureq.getUserSession().getSingleUserEventCenter();
    iqManager = CoreSpringFactory.getImpl(IQManager.class);

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

    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);
  }
  @Override
  protected void initForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {

    if (config == null) {
      throw new AssertException("module configuration is null!");
    }

    select =
        uifactory.addCheckboxesVertical(
            "forumAsPopup",
            "selection.forumAsPopup.label",
            formLayout,
            new String[] {"xx"},
            new String[] {null},
            null,
            1);

    final String selectConfig = (String) config.get(DialogConfigForm.DIALOG_CONFIG_INTEGRATION);
    select.select("xx", selectConfig == CONFIG_INTEGRATION_VALUE_POPUP);
    select.addActionListener(this, FormEvent.ONCLICK);
  }
예제 #17
0
  /**
   * @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)
   */
  public void event(UserRequest ureq, Component source, Event event) {
    if (source == startButton && startButton.isEnabled() && startButton.isVisible()) {
      long courseResId = userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
      String courseNodeIdent = courseNode.getIdent();
      removeAsListenerAndDispose(displayController);

      OLATResourceable ores = OresHelper.createOLATResourceableTypeWithoutCheck("test");
      ThreadLocalUserActivityLogger.addLoggingResourceInfo(
          LoggingResourceable.wrapBusinessPath(ores));
      WindowControl bwControl = addToHistory(ureq, ores, null);
      Controller returnController =
          iqManager.createIQDisplayController(
              modConfig, secCallback, ureq, bwControl, courseResId, courseNodeIdent, this);
      /*
       * 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.isClosed()) {
          // do nothing
        } else 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
          displayContainerController =
              new LayoutMain3ColsController(ureq, getWindowControl(), displayController);
          listenTo(displayContainerController); // autodispose

          // need to wrap a course restart controller again, because IQDisplay
          // runs on top of GUIStack
          ICourse course = CourseFactory.loadCourse(courseResId);
          RepositoryEntry courseRepositoryEntry =
              course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
          Panel empty = new Panel("empty"); // empty panel set as "menu" and "tool"
          Controller courseCloser =
              new DisposedCourseRestartController(ureq, getWindowControl(), courseRepositoryEntry);
          Controller disposedRestartController =
              new LayoutMain3ColsController(
                  ureq,
                  getWindowControl(),
                  empty,
                  courseCloser.getInitialComponent(),
                  "disposed course whily in iqRun" + courseResId);
          displayContainerController.setDisposedMessageController(disposedRestartController);

          final boolean fullWindow =
              modConfig.getBooleanSafe(IQEditController.CONFIG_FULLWINDOW, true);
          if (fullWindow) {
            displayContainerController.setAsFullscreen(ureq);
          }
          displayContainerController.activate();

          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) {
      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
        long callingResId =
            userCourseEnv.getCourseEnvironment().getCourseResourceableId().longValue();
        String callingResDetail = courseNode.getIdent();
        assessmentID =
            iqManager.getLastAssessmentID(ureq.getIdentity(), callingResId, callingResDetail);
      }
      if (assessmentID != null && !assessmentID.equals("")) {
        Document doc =
            iqManager.getResultsReportingFromFile(ureq.getIdentity(), type, assessmentID);
        // StringBuilder resultsHTML =
        // LocalizedXSLTransformer.getInstance(ureq.getLocale()).renderResults(doc);
        String summaryConfig = (String) modConfig.get(IQEditController.CONFIG_KEY_SUMMARY);
        int summaryType = AssessmentInstance.getSummaryType(summaryConfig);
        String resultsHTML =
            iqManager.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);
    }
  }
예제 #18
0
  /**
   * Update the module configuration to have all mandatory configuration flags set to usefull
   * default values
   *
   * @param isNewNode true: an initial configuration is set; false: upgrading from previous node
   *     configuration version, set default to maintain previous behaviour
   */
  @Override
  public void updateModuleConfigDefaults(boolean isNewNode) {
    int CURRENTVERSION = 7;
    ModuleConfiguration config = getModuleConfiguration();
    if (isNewNode) {
      // use defaults for new course building blocks
      config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
      config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
      // how to render files (include jquery etc)
      DeliveryOptions nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
      nodeDeliveryOptions.setInherit(Boolean.TRUE);
      config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
      config.setConfigurationVersion(CURRENTVERSION);
    } else {
      config.remove(NodeEditController.CONFIG_INTEGRATION);
      if (config.getConfigurationVersion() < 2) {
        // update new configuration options using default values for existing
        // nodes
        config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
        Boolean componentMenu = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
        if (componentMenu == null) {
          config.setBooleanEntry(
              NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
        }
        config.setConfigurationVersion(2);
      }

      if (config.getConfigurationVersion() < 3) {
        config.set(
            NodeEditController.CONFIG_CONTENT_ENCODING,
            NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
        config.set(
            NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
        config.setConfigurationVersion(3);
      }
      // Version 5 was ineffective since the delivery options were not set. We have to redo this and
      // save it as version 6
      if (config.getConfigurationVersion() < 7) {
        String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
        if (contentEncoding != null && contentEncoding.equals("auto")) {
          contentEncoding = null; // new style for auto
        }
        String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
        if (jsEncoding != null && jsEncoding.equals("auto")) {
          jsEncoding = null; // new style for auto
        }

        CPPackageConfig reConfig = null;
        DeliveryOptions nodeDeliveryOptions =
            (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
        if (nodeDeliveryOptions == null) {
          // Update missing delivery options now, inherit from repo by default
          nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
          nodeDeliveryOptions.setInherit(Boolean.TRUE);

          RepositoryEntry re = getReferencedRepositoryEntry();
          // Check if delivery options are set for repo entry, if not create default
          if (re != null) {
            reConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
            if (reConfig == null) {
              reConfig = new CPPackageConfig();
            }
            DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
            if (repoDeliveryOptions == null) {
              // migrate existing config back to repo entry using the default as a base
              repoDeliveryOptions = DeliveryOptions.defaultWithGlossary();
              reConfig.setDeliveryOptions(repoDeliveryOptions);
              repoDeliveryOptions.setContentEncoding(contentEncoding);
              repoDeliveryOptions.setJavascriptEncoding(jsEncoding);
              CPManager.getInstance().setCPPackageConfig(re.getOlatResource(), reConfig);
            } else {
              // see if we have any different settings than the repo. if so, don't use inherit mode
              if (contentEncoding != repoDeliveryOptions.getContentEncoding()
                  || jsEncoding != repoDeliveryOptions.getJavascriptEncoding()) {
                nodeDeliveryOptions.setInherit(Boolean.FALSE);
                nodeDeliveryOptions.setContentEncoding(contentEncoding);
                nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
              }
            }
          }
          // remove old config parameters
          config.remove(NodeEditController.CONFIG_CONTENT_ENCODING);
          config.remove(NodeEditController.CONFIG_JS_ENCODING);
          // replace with new delivery options
          config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
        }
        config.setConfigurationVersion(7);
      }

      // else node is up-to-date - nothing to do
    }
    if (config.getConfigurationVersion() != CURRENTVERSION) {
      OLog logger = Tracing.createLoggerFor(CPCourseNode.class);
      logger.error(
          "CP course node version not updated to lastest version::"
              + CURRENTVERSION
              + ", was::"
              + config.getConfigurationVersion()
              + ". Check the code, programming error.");
    }
  }