Ejemplo n.º 1
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);
    }
  }
Ejemplo n.º 2
0
 /**
  * @see
  *     org.olat.course.nodes.AssessableCourseNode#updateUserScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation,
  *     org.olat.course.run.userview.UserCourseEnvironment, org.olat.core.id.Identity)
  */
 @Override
 public void updateUserScoreEvaluation(
     final ScoreEvaluation scoreEvaluation,
     final UserCourseEnvironment userCourseEnvironment,
     final Identity coachingIdentity,
     final boolean incrementAttempts) {
   final AssessmentManager am =
       userCourseEnvironment.getCourseEnvironment().getAssessmentManager();
   final Identity mySelf = userCourseEnvironment.getIdentityEnvironment().getIdentity();
   am.saveScoreEvaluation(
       this,
       coachingIdentity,
       mySelf,
       new ScoreEvaluation(scoreEvaluation.getScore(), scoreEvaluation.getPassed()),
       userCourseEnvironment,
       incrementAttempts);
 }
  /** @return True if all results are the same */
  private ModelInfos loadModel() {
    // load participants, load datas
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId());
    List<Identity> identities =
        businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name());

    Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>();
    List<AssessmentEntry> entries =
        course
            .getCourseEnvironment()
            .getAssessmentManager()
            .getAssessmentEntries(assessedGroup, gtaNode);
    for (AssessmentEntry entry : entries) {
      identityToEntryMap.put(entry.getIdentity(), entry);
    }

    int count = 0;
    boolean same = true;
    StringBuilder duplicateWarning = new StringBuilder();
    Float scoreRef = null;
    Boolean passedRef = null;
    String commentRef = null;

    List<AssessmentRow> rows = new ArrayList<>(identities.size());
    for (Identity identity : identities) {
      AssessmentEntry entry = identityToEntryMap.get(identity);

      ScoreEvaluation scoreEval = null;
      if (withScore || withPassed) {
        scoreEval = gtaNode.getUserScoreEvaluation(entry);
        if (scoreEval == null) {
          scoreEval = ScoreEvaluation.EMPTY_EVALUATION;
        }
      }

      String comment = null;
      if (withComment && entry != null) {
        comment = entry.getComment();
      }

      boolean duplicate = duplicateMemberKeys.contains(identity.getKey());
      if (duplicate) {
        if (duplicateWarning.length() > 0) duplicateWarning.append(", ");
        duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
      }

      AssessmentRow row = new AssessmentRow(identity, duplicate);
      rows.add(row);

      if (withScore) {
        Float score = scoreEval.getScore();
        String pointVal = AssessmentHelper.getRoundedScore(score);
        TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc);
        pointEl.setDisplaySize(5);
        row.setScoreEl(pointEl);
        if (count == 0) {
          scoreRef = score;
        } else if (!same(scoreRef, score)) {
          same = false;
        }
      }

      if (withPassed && cutValue == null) {
        Boolean passed = scoreEval.getPassed();
        MultipleSelectionElement passedEl =
            uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues);
        if (passed != null && passed.booleanValue()) {
          passedEl.select(onKeys[0], passed.booleanValue());
        }
        row.setPassedEl(passedEl);
        if (count == 0) {
          passedRef = passed;
        } else if (!same(passedRef, passed)) {
          same = false;
        }
      }

      if (withComment) {
        FormLink commentLink =
            uifactory.addFormLink(
                "comment-" + CodeHelper.getRAMUniqueID(),
                "comment",
                "comment",
                null,
                flc,
                Link.LINK);
        if (StringHelper.containsNonWhitespace(comment)) {
          commentLink.setIconLeftCSS("o_icon o_icon_comments");
        } else {
          commentLink.setIconLeftCSS("o_icon o_icon_comments_none");
        }
        commentLink.setUserObject(row);
        row.setComment(comment);
        row.setCommentEditLink(commentLink);

        if (count == 0) {
          commentRef = comment;
        } else if (!same(commentRef, comment)) {
          same = false;
        }
      }

      count++;
    }

    model.setObjects(rows);
    table.reset();

    return new ModelInfos(same, scoreRef, passedRef, commentRef, duplicateWarning.toString());
  }
Ejemplo n.º 4
0
  private void doProcess(List<BulkAssessmentFeedback> feedbacks) {
    final DB dbInstance = DBFactory.getInstance();
    final BaseSecurity securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
    final Identity coachIdentity = securityManager.loadIdentityByKey(coachedIdentity);
    final ICourse course = CourseFactory.loadCourse(courseRes);
    final AssessableCourseNode courseNode = getCourseNode();
    final Roles studentRoles = new Roles(false, false, false, false, false, false, false, false);

    final boolean hasUserComment = courseNode.hasCommentConfigured();
    final boolean hasScore = courseNode.hasScoreConfigured();
    final boolean hasPassed = courseNode.hasPassedConfigured();
    final boolean hasReturnFiles =
        (StringHelper.containsNonWhitespace(datas.getReturnFiles())
            && (courseNode instanceof TACourseNode || courseNode instanceof GTACourseNode));

    if (hasReturnFiles) {
      try {
        OlatRootFileImpl returnFilesZipped = new OlatRootFileImpl(datas.getReturnFiles(), null);
        String tmp = FolderConfig.getCanonicalTmpDir();
        unzipped = new File(tmp, UUID.randomUUID().toString() + File.separatorChar);
        unzipped.mkdirs();
        ZipUtil.unzip(returnFilesZipped.getBasefile(), unzipped);
      } catch (Exception e) {
        log.error("Cannot unzip the return files during bulk assessment", e);
      }
    }

    Float min = null;
    Float max = null;
    Float cut = null;
    if (hasScore) {
      min = courseNode.getMinScoreConfiguration();
      max = courseNode.getMaxScoreConfiguration();
    }
    if (hasPassed) {
      cut = courseNode.getCutValueConfiguration();
    }

    int count = 0;
    List<BulkAssessmentRow> rows = datas.getRows();
    for (BulkAssessmentRow row : rows) {
      Long identityKey = row.getIdentityKey();
      if (identityKey == null) {
        feedbacks.add(new BulkAssessmentFeedback("bulk.action.no.such.user", row.getAssessedId()));
        continue; // nothing to do
      }

      Identity identity = securityManager.loadIdentityByKey(identityKey);
      IdentityEnvironment ienv = new IdentityEnvironment(identity, studentRoles);
      UserCourseEnvironment uce =
          new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());

      // update comment, empty string will reset comment
      String userComment = row.getComment();
      if (hasUserComment && userComment != null) {
        // Update userComment in db
        courseNode.updateUserUserComment(userComment, uce, coachIdentity);
        // LD: why do we have to update the efficiency statement?
        // EfficiencyStatementManager esm =	EfficiencyStatementManager.getInstance();
        // esm.updateUserEfficiencyStatement(uce);
      }

      // update score
      Float score = row.getScore();
      if (hasScore && score != null) {
        // score < minimum score
        if ((min != null && score.floatValue() < min.floatValue())
            || (score.floatValue() < AssessmentHelper.MIN_SCORE_SUPPORTED)) {
          // "bulk.action.lessThanMin";
        }
        // score > maximum score
        else if ((max != null && score.floatValue() > max.floatValue())
            || (score.floatValue() > AssessmentHelper.MAX_SCORE_SUPPORTED)) {
          // "bulk.action.greaterThanMax";
        } else {
          // score between minimum and maximum score
          ScoreEvaluation se;
          if (hasPassed && cut != null) {
            Boolean passed =
                (score.floatValue() >= cut.floatValue()) ? Boolean.TRUE : Boolean.FALSE;
            se = new ScoreEvaluation(score, passed);
          } else {
            se = new ScoreEvaluation(score, null);
          }

          // Update score,passed properties in db, and the user's efficiency statement
          courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, false);
        }
      }

      Boolean passed = row.getPassed();
      if (hasPassed
          && passed != null
          && cut
              == null) { // Configuration of manual assessment --> Display passed/not passed: yes,
        // Type of display: Manual by tutor
        ScoreEvaluation seOld = courseNode.getUserScoreEvaluation(uce);
        Float oldScore = seOld.getScore();
        ScoreEvaluation se = new ScoreEvaluation(oldScore, passed);
        // Update score,passed properties in db, and the user's efficiency statement
        boolean incrementAttempts = false;
        courseNode.updateUserScoreEvaluation(se, uce, coachIdentity, incrementAttempts);
      }

      boolean identityHasReturnFile = false;
      if (hasReturnFiles && row.getReturnFiles() != null && row.getReturnFiles().size() > 0) {
        String assessedId = row.getAssessedId();
        File assessedFolder = new File(unzipped, assessedId);
        identityHasReturnFile = assessedFolder.exists();
        if (identityHasReturnFile) {
          processReturnFile(courseNode, row, uce, assessedFolder);
        }
      }

      if (courseNode instanceof GTACourseNode) {
        // push the state further
        GTACourseNode gtaNode = (GTACourseNode) courseNode;
        if ((hasScore && score != null) || (hasPassed && passed != null)) {
          // pushed to graded
          updateTasksState(gtaNode, uce, TaskProcess.grading);
        } else if (hasReturnFiles) {
          // push to revised
          updateTasksState(gtaNode, uce, TaskProcess.correction);
        }
      }

      if (count++ % 5 == 0) {
        dbInstance.commitAndCloseSession();
      } else {
        dbInstance.commit();
      }
    }
  }