Esempio n. 1
0
  /**
   * @param ureq
   * @return
   */
  private StringBuilder createChangelogMsg(UserRequest ureq) {
    /*
     * TODO:pb:is ImsRepositoryResolver the right place for getting the change log?
     */

    // re could be null, but if we are here it should not be null!
    Roles userRoles = ureq.getUserSession().getRoles();
    boolean showAll = userRoles.isAuthor() || userRoles.isOLATAdmin();
    // get changelog
    Formatter formatter = Formatter.getInstance(ureq.getLocale());
    ImsRepositoryResolver resolver = new ImsRepositoryResolver(referenceTestEntry);
    QTIChangeLogMessage[] qtiChangeLog = resolver.getDocumentChangeLog();
    StringBuilder qtiChangelog = new StringBuilder();

    if (qtiChangeLog.length > 0) {
      // there are resource changes
      Arrays.sort(qtiChangeLog);
      for (int i = qtiChangeLog.length - 1; i >= 0; i--) {
        // show latest change first
        if (!showAll && qtiChangeLog[i].isPublic()) {
          // logged in person is a normal user, hence public messages only
          Date msgDate = new Date(qtiChangeLog[i].getTimestmp());
          qtiChangelog
              .append("\nChange date: ")
              .append(formatter.formatDateAndTime(msgDate))
              .append("\n");
          String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage());
          qtiChangelog.append(msg);
          qtiChangelog.append("\n********************************\n");
        } else if (showAll) {
          // logged in person is an author, olat admin, owner, show all messages
          Date msgDate = new Date(qtiChangeLog[i].getTimestmp());
          qtiChangelog
              .append("\nChange date: ")
              .append(formatter.formatDateAndTime(msgDate))
              .append("\n");
          String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage());
          qtiChangelog.append(msg);
          qtiChangelog.append("\n********************************\n");
        } // else non public messages are not shown to normal user
      }
    }
    return qtiChangelog;
  }
  /**
   * @see
   *     org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
   *     org.olat.core.gui.control.WindowControl,
   *     org.olat.course.run.userview.UserCourseEnvironment,
   *     org.olat.course.run.userview.NodeEvaluation)
   */
  @Override
  public NodeRunConstructionResult createNodeRunConstructionResult(
      final UserRequest ureq,
      final WindowControl wControl,
      final UserCourseEnvironment userCourseEnv,
      final NodeEvaluation ne,
      final String nodecmd) {
    Controller controller;
    // Do not allow guests to have manual scoring
    final Roles roles = ureq.getUserSession().getRoles();
    if (roles.isGuestOnly()) {
      final Translator trans = new PackageTranslator(PACKAGE, ureq.getLocale());
      final String title = trans.translate("guestnoaccess.title");
      final String message = trans.translate("guestnoaccess.message");
      controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
    } else {
      controller = new MSCourseNodeRunController(ureq, wControl, userCourseEnv, this, true);
    }

    final Controller wrappedCtrl =
        TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_ms_icon");
    return new NodeRunConstructionResult(wrappedCtrl);
  }