Search in sources :

Example 96 with ScoreEvaluation

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

the class CheckListCourseNode method doUpdateAssessmentBySum.

private void doUpdateAssessmentBySum(Identity identity, UserCourseEnvironment assessedUserCourseEnv, Identity assessedIdentity, Role by) {
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", assessedUserCourseEnv.getCourseEnvironment().getCourseResourceableId());
    ModuleConfiguration config = getModuleConfiguration();
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    int checkedBox = checkboxManager.countChecked(assessedIdentity, courseOres, getIdent());
    CheckboxList checkboxList = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    Integer cut = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
    int minNumOfCheckbox = cut == null ? checkboxList.getNumOfCheckbox() : cut.intValue();
    boolean passed = checkedBox >= minNumOfCheckbox;
    Float score = null;
    if (passed) {
        Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
        if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
            score = checkboxManager.calculateScore(assessedIdentity, courseOres, getIdent());
            Float maxScore = (Float) config.get(MSCourseNode.CONFIG_KEY_SCORE_MAX);
            if (maxScore != null && maxScore.floatValue() < score) {
                score = maxScore.floatValue();
            }
        }
    }
    ScoreEvaluation sceval = new ScoreEvaluation(score, new Boolean(passed));
    AssessmentManager am = assessedUserCourseEnv.getCourseEnvironment().getAssessmentManager();
    am.saveScoreEvaluation(this, identity, assessedIdentity, sceval, assessedUserCourseEnv, false, by);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentManager(org.olat.course.assessment.AssessmentManager)

Example 97 with ScoreEvaluation

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

the class CourseNodeOutcomeMapper method doUpdateResult.

@Override
protected boolean doUpdateResult(Float score) {
    ICourse course = CourseFactory.loadCourse(courseOresId);
    CourseNode node = course.getRunStructure().getNode(courseNodeId);
    if (node instanceof BasicLTICourseNode) {
        BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
        Identity assessedId = getIdentity();
        Float cutValue = getCutValue(ltiNode);
        Float scaledScore = null;
        Boolean passed = null;
        if (score != null) {
            float scale = getScalingFactor(ltiNode);
            scaledScore = score * scale;
            if (cutValue != null) {
                passed = scaledScore >= cutValue;
            }
        }
        ScoreEvaluation eval = new ScoreEvaluation(scaledScore, passed);
        UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
        ltiNode.updateUserScoreEvaluation(eval, userCourseEnv, assessedId, false, Role.user);
    }
    return super.doUpdateResult(score);
}
Also used : BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity)

Example 98 with ScoreEvaluation

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

the class CourseNodeOutcomeMapper method doReadResult.

@Override
protected String doReadResult(IMSPOXRequest pox) {
    ICourse course = CourseFactory.loadCourse(courseOresId);
    CourseNode node = course.getRunStructure().getNode(courseNodeId);
    if (node instanceof BasicLTICourseNode) {
        BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
        UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
        ScoreEvaluation eval = ltiNode.getUserScoreEvaluation(userCourseEnv);
        String score = "";
        if (eval != null && eval.getScore() != null) {
            float scaledScore = eval.getScore();
            if (scaledScore > 0.0f) {
                float scale = getScalingFactor(ltiNode);
                scaledScore = scaledScore / scale;
            }
            score = Float.toString(scaledScore);
        }
        Map<String, Object> theMap = new TreeMap<String, Object>();
        theMap.put("/readResultResponse/result/sourcedId", getSourcedId());
        theMap.put("/readResultResponse/result/resultScore/textString", score);
        theMap.put("/readResultResponse/result/resultScore/language", "en");
        String theXml = XMLMap.getXMLFragment(theMap, true);
        return pox.getResponseSuccess("Result read", theXml);
    }
    return super.doReadResult(pox);
}
Also used : BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) TreeMap(java.util.TreeMap)

Example 99 with ScoreEvaluation

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

the class CourseNodeOutcomeMapper method doDeleteResult.

@Override
protected boolean doDeleteResult() {
    ICourse course = CourseFactory.loadCourse(courseOresId);
    CourseNode node = course.getRunStructure().getNode(courseNodeId);
    if (node instanceof BasicLTICourseNode) {
        BasicLTICourseNode ltiNode = (BasicLTICourseNode) node;
        Identity assessedId = getIdentity();
        ScoreEvaluation eval = new ScoreEvaluation(0.0f, false);
        UserCourseEnvironment userCourseEnv = getUserCourseEnvironment(course);
        ltiNode.updateUserScoreEvaluation(eval, userCourseEnv, assessedId, false, Role.user);
    }
    return super.doDeleteResult();
}
Also used : BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity)

Example 100 with ScoreEvaluation

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

the class PortfolioServiceImpl method updateAssessmentEntry.

private void updateAssessmentEntry(Identity assessedIdentity, Binder binder, Set<AssessmentSection> assessmentSections, Identity coachingIdentity) {
    boolean allPassed = true;
    int totalSectionPassed = 0;
    int totalSectionClosed = 0;
    BigDecimal totalScore = new BigDecimal("0.0");
    AssessmentEntryStatus binderStatus = null;
    for (AssessmentSection assessmentSection : assessmentSections) {
        if (assessmentSection.getScore() != null) {
            totalScore = totalScore.add(assessmentSection.getScore());
        }
        if (assessmentSection.getPassed() != null && assessmentSection.getPassed().booleanValue()) {
            allPassed &= true;
            totalSectionPassed++;
        }
        Section section = assessmentSection.getSection();
        if (section.getSectionStatus() == SectionStatus.closed) {
            totalSectionClosed++;
        }
    }
    Boolean totalPassed = null;
    if (totalSectionClosed == assessmentSections.size()) {
        totalPassed = new Boolean(allPassed);
    } else {
        if (assessmentSections.size() == totalSectionPassed) {
            totalPassed = Boolean.TRUE;
        }
        binderStatus = AssessmentEntryStatus.inProgress;
    }
    // order status from the entry / section
    RepositoryEntry entry = binder.getEntry();
    if ("CourseModule".equals(entry.getOlatResource().getResourceableTypeName())) {
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(binder.getSubIdent());
        if (courseNode instanceof PortfolioCourseNode) {
            PortfolioCourseNode pfNode = (PortfolioCourseNode) courseNode;
            ScoreEvaluation scoreEval = new ScoreEvaluation(totalScore.floatValue(), totalPassed, binderStatus, true, true, null, null, binder.getKey());
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            pfNode.updateUserScoreEvaluation(scoreEval, userCourseEnv, coachingIdentity, false, Role.coach);
        }
    } else {
        OLATResource resource = ((BinderImpl) binder.getTemplate()).getOlatResource();
        RepositoryEntry referenceEntry = repositoryService.loadByResourceKey(resource.getKey());
        AssessmentEntry assessmentEntry = assessmentService.getOrCreateAssessmentEntry(assessedIdentity, null, binder.getEntry(), binder.getSubIdent(), referenceEntry);
        assessmentEntry.setScore(totalScore);
        assessmentEntry.setPassed(totalPassed);
        assessmentEntry.setAssessmentStatus(binderStatus);
        assessmentService.updateAssessmentEntry(assessmentEntry);
    }
}
Also used : PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) Section(org.olat.modules.portfolio.Section) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) BigDecimal(java.math.BigDecimal) AssessmentSection(org.olat.modules.portfolio.AssessmentSection) BinderImpl(org.olat.modules.portfolio.model.BinderImpl) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean)

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