Search in sources :

Example 86 with ScoreEvaluation

use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class AssessmentForm method doUpdateAssessmentData.

protected void doUpdateAssessmentData(boolean setAsDone) {
    Float updatedScore = null;
    Boolean updatedPassed = null;
    if (isHasAttempts() && isAttemptsDirty()) {
        assessableCourseNode.updateUserAttempts(new Integer(getAttempts()), assessedUserCourseEnv, getIdentity(), Role.coach);
    }
    if (isHasScore()) {
        if (isScoreDirty()) {
            updatedScore = getScore();
        } else {
            updatedScore = scoreValue;
        }
    }
    if (isHasPassed()) {
        if (getCut() != null && getScore() != null) {
            updatedPassed = updatedScore.floatValue() >= getCut().floatValue() ? Boolean.TRUE : Boolean.FALSE;
        } else {
            // "passed" info was changed or not
            String selectedKeyString = getPassed().getSelectedKey();
            if ("true".equalsIgnoreCase(selectedKeyString) || "false".equalsIgnoreCase(selectedKeyString)) {
                updatedPassed = Boolean.valueOf(selectedKeyString);
            }
        }
    }
    boolean visibility = userVisibility.isSelected(0);
    // Update score,passed properties in db
    ScoreEvaluation scoreEval;
    if (setAsDone) {
        scoreEval = new ScoreEvaluation(updatedScore, updatedPassed, AssessmentEntryStatus.done, visibility, true, null, null, null);
    } else {
        scoreEval = new ScoreEvaluation(updatedScore, updatedPassed, null, visibility, null, null, null, null);
    }
    assessableCourseNode.updateUserScoreEvaluation(scoreEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    if (isHasComment() && isUserCommentDirty()) {
        String newComment = getUserComment().getValue();
        // Update properties in db
        assessableCourseNode.updateUserUserComment(newComment, assessedUserCourseEnv, getIdentity());
    }
    if (isCoachCommentDirty()) {
        String newCoachComment = getCoachComment().getValue();
        // Update properties in db
        assessableCourseNode.updateUserCoachComment(newCoachComment, assessedUserCourseEnv);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation)

Example 87 with ScoreEvaluation

use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class AssessmentForm method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("form.title", null);
    formLayout.setElementCssClass("o_sel_assessment_form");
    ScoreEvaluation scoreEval = assessedUserCourseEnv.getScoreAccounting().evalCourseNode(assessableCourseNode);
    if (scoreEval == null) {
        scoreEval = ScoreEvaluation.EMPTY_EVALUATION;
    }
    if (hasAttempts) {
        attemptsValue = assessableCourseNode.getUserAttempts(assessedUserCourseEnv);
        if (attemptsValue == null) {
            attemptsValue = new Integer(0);
        }
        attempts = uifactory.addIntegerElement("attempts", "form.attempts", attemptsValue.intValue(), formLayout);
        attempts.setDisplaySize(3);
        attempts.setMinValueCheck(0, null);
    }
    if (hasScore) {
        min = assessableCourseNode.getMinScoreConfiguration();
        max = assessableCourseNode.getMaxScoreConfiguration();
        if (hasPassed) {
            cut = assessableCourseNode.getCutValueConfiguration();
        }
        String minStr = AssessmentHelper.getRoundedScore(min);
        String maxStr = AssessmentHelper.getRoundedScore(max);
        uifactory.addStaticTextElement("minval", "form.min", ((min == null) ? translate("form.valueUndefined") : minStr), formLayout);
        uifactory.addStaticTextElement("maxval", "form.max", ((max == null) ? translate("form.valueUndefined") : maxStr), formLayout);
        // Use init variables from wrapper, already loaded from db
        scoreValue = scoreEval.getScore();
        score = uifactory.addTextElement("score", "form.score", 10, "", formLayout);
        score.setDisplaySize(4);
        score.setElementCssClass("o_sel_assessment_form_score");
        score.setExampleKey("form.score.rounded", null);
        if (scoreValue != null) {
            score.setValue(AssessmentHelper.getRoundedScore(scoreValue));
        }
        // assessment overview with max score
        score.setRegexMatchCheck("(\\d+)||(\\d+\\.\\d{1,3})||(\\d+\\,\\d{1,3})", "form.error.wrongFloat");
    }
    if (hasPassed) {
        if (cut != null) {
            // Display cut value if defined
            cutVal = uifactory.addStaticTextElement("cutval", "form.cut", ((cut == null) ? translate("form.valueUndefined") : AssessmentHelper.getRoundedScore(cut)), formLayout);
        }
        String[] trueFalseKeys = new String[] { "undefined", "true", "false" };
        String[] passedNotPassedValues = new String[] { translate("form.passed.undefined"), translate("form.passed.true"), translate("form.passed.false") };
        // passed = new StaticSingleSelectionElement("form.passed", trueFalseKeys, passedNotPassedValues);
        passed = uifactory.addRadiosVertical("passed", "form.passed", formLayout, trueFalseKeys, passedNotPassedValues);
        passed.setElementCssClass("o_sel_assessment_form_passed");
        Boolean passedValue = scoreEval.getPassed();
        passed.select(passedValue == null ? "undefined" : passedValue.toString(), true);
        // When cut value is defined, no manual passed possible
        passed.setEnabled(cut == null);
    }
    if (hasComment) {
        // Use init variables from db, not available from wrapper
        userCommentValue = assessableCourseNode.getUserUserComment(assessedUserCourseEnv);
        userComment = uifactory.addTextAreaElement("usercomment", "form.usercomment", 2500, 5, 40, true, userCommentValue, formLayout);
        userComment.setNotLongerThanCheck(2500, "input.toolong");
    }
    if (hasIndividualAssessmentDocs) {
        String mapperUri = registerCacheableMapper(ureq, null, new DocumentMapper());
        String page = velocity_root + "/individual_assessment_docs.html";
        docsLayoutCont = FormLayoutContainer.createCustomFormLayout("form.individual.assessment.docs", getTranslator(), page);
        docsLayoutCont.setLabel("form.individual.assessment.docs", null);
        docsLayoutCont.contextPut("mapperUri", mapperUri);
        formLayout.add(docsLayoutCont);
        uploadDocsEl = uifactory.addFileElement(getWindowControl(), "form.upload", null, formLayout);
        uploadDocsEl.addActionListener(FormEvent.ONCHANGE);
    }
    coachCommentValue = assessableCourseNode.getUserCoachComment(assessedUserCourseEnv);
    coachComment = uifactory.addTextAreaElement("coachcomment", "form.coachcomment", 2500, 5, 40, true, coachCommentValue, formLayout);
    coachComment.setNotLongerThanCheck(2500, "input.toolong");
    String[] userVisibilityValues = new String[] { translate("user.visibility.visible"), translate("user.visibility.hidden") };
    userVisibility = uifactory.addRadiosHorizontal("user.visibility", "user.visibility", formLayout, userVisibilityKeys, userVisibilityValues);
    if (scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue()) {
        userVisibility.select(userVisibilityKeys[0], true);
    } else {
        userVisibility.select(userVisibilityKeys[1], true);
    }
    FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    submitButton = uifactory.addFormSubmitButton("save", buttonGroupLayout);
    submitButton.setElementCssClass("o_sel_assessment_form_save_and_close");
    saveAndDoneLink = uifactory.addFormLink("save.done", buttonGroupLayout, Link.BUTTON);
    saveAndDoneLink.setElementCssClass("o_sel_assessment_form_save_and_done");
    saveAndDoneLink.setIconLeftCSS("o_icon o_icon_status_done o_icon-fw");
    reopenLink = uifactory.addFormLink("reopen", buttonGroupLayout, Link.BUTTON);
    reopenLink.setElementCssClass("o_sel_assessment_form_reopen");
    reopenLink.setIconLeftCSS("o_icon o_icon_status_in_review o_icon-fw");
    uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
    reloadAssessmentDocs();
    updateStatus(scoreEval);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 88 with ScoreEvaluation

use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class IdentityCertificatesController method doGenerateCertificate.

private void doGenerateCertificate(UserRequest ureq) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    Roles roles = securityManager.getRoles(assessedIdentity);
    IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, roles);
    UserCourseEnvironment assessedUserCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
    ScoreAccounting scoreAccounting = assessedUserCourseEnv.getScoreAccounting();
    scoreAccounting.evaluateAll();
    ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode((AssessableCourseNode) rootNode);
    CertificateTemplate template = null;
    Long templateKey = course.getCourseConfig().getCertificateTemplate();
    if (templateKey != null) {
        template = certificatesManager.getTemplateById(templateKey);
    }
    Float score = scoreEval == null ? null : scoreEval.getScore();
    Boolean passed = scoreEval == null ? null : scoreEval.getPassed();
    CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
    certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
    loadList();
    showInfo("msg.certificate.pending");
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CertificateTemplate(org.olat.course.certificate.CertificateTemplate) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 89 with ScoreEvaluation

use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class AbstractToolsController method doSetDone.

private void doSetDone(UserRequest ureq) {
    if (scoreEval != null) {
        ScoreEvaluation doneEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), AssessmentEntryStatus.done, scoreEval.getUserVisible(), scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), scoreEval.getCurrentRunStatus(), scoreEval.getAssessmentID());
        courseNode.updateUserScoreEvaluation(doneEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation)

Example 90 with ScoreEvaluation

use of org.olat.course.run.scoring.ScoreEvaluation in project OpenOLAT by OpenOLAT.

the class AbstractToolsController method doReopen.

private void doReopen(UserRequest ureq) {
    if (scoreEval != null) {
        ScoreEvaluation reopenedEval = new ScoreEvaluation(scoreEval.getScore(), scoreEval.getPassed(), AssessmentEntryStatus.inReview, scoreEval.getUserVisible(), scoreEval.getFullyAssessed(), scoreEval.getCurrentRunCompletion(), AssessmentRunStatus.running, scoreEval.getAssessmentID());
        courseNode.updateUserScoreEvaluation(reopenedEval, assessedUserCourseEnv, getIdentity(), false, Role.coach);
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation)

Aggregations

ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)130 Identity (org.olat.core.id.Identity)54 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)52 ICourse (org.olat.course.ICourse)40 AssessmentManager (org.olat.course.assessment.AssessmentManager)34 CourseNode (org.olat.course.nodes.CourseNode)28 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)26 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)22 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)22 RepositoryEntry (org.olat.repository.RepositoryEntry)20 ArrayList (java.util.ArrayList)16 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)14 ModuleConfiguration (org.olat.modules.ModuleConfiguration)14 ScoreAccounting (org.olat.course.run.scoring.ScoreAccounting)12 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)12 List (java.util.List)10 Test (org.junit.Test)10 AssessmentEntryStatus (org.olat.modules.assessment.model.AssessmentEntryStatus)10 BigDecimal (java.math.BigDecimal)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)8