Search in sources :

Example 21 with ScoreEvaluation

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

the class ReminderRuleEngineTest method initialAttempts.

@Test
public void initialAttempts() {
    // create a course with 3 members and generate some datas
    Identity tutor = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-tutor-");
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-3");
    RepositoryEntry re = JunitTestHelper.deployDemoCourse(id1);
    repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
    dbInstance.commit();
    String nodeIdent = assessmentData(tutor, id1, new ScoreEvaluation(1.0f, false), re);
    assessmentData(tutor, id2, new ScoreEvaluation(5.0f, true), re);
    assessmentData(tutor, id3, new ScoreEvaluation(10.0f, true), re);
    List<Identity> identities = new ArrayList<>();
    identities.add(id1);
    identities.add(id2);
    identities.add(id3);
    {
        // check attempts > 1
        List<ReminderRule> rules = getInitialAttemptsRules(1, LaunchUnit.day.name(), nodeIdent);
        List<Identity> all = new ArrayList<>(identities);
        ruleEngine.filterByRules(re, all, rules);
        Assert.assertEquals(0, all.size());
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 22 with ScoreEvaluation

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

the class ReminderRuleEngineTest method passed.

@Test
public void passed() {
    // create a course with 3 members and generate some datas
    Identity tutor = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-tutor-");
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-3");
    RepositoryEntry re = JunitTestHelper.deployDemoCourse(id1);
    repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
    dbInstance.commit();
    String nodeIdent = assessmentData(tutor, id1, new ScoreEvaluation(1.0f, false), re);
    assessmentData(tutor, id2, new ScoreEvaluation(5.0f, true), re);
    assessmentData(tutor, id3, new ScoreEvaluation(10.0f, true), re);
    List<Identity> identities = new ArrayList<>();
    identities.add(id1);
    identities.add(id2);
    identities.add(id3);
    {
        // check passed
        List<ReminderRule> rules = getPassedRules("passed", nodeIdent);
        List<Identity> all = new ArrayList<>(identities);
        ruleEngine.filterByRules(re, all, rules);
        Assert.assertEquals(2, all.size());
        Assert.assertTrue(all.contains(id2));
        Assert.assertTrue(all.contains(id3));
    }
    {
        // check failed
        List<ReminderRule> rules = getPassedRules("failed", nodeIdent);
        List<Identity> all = new ArrayList<>(identities);
        ruleEngine.filterByRules(re, all, rules);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(all.contains(id1));
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 23 with ScoreEvaluation

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

the class ReminderRuleEngineTest method attempts.

@Test
public void attempts() {
    // create a course with 3 members and generate some datas
    Identity tutor = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-tutor-");
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("attempts-3");
    RepositoryEntry re = JunitTestHelper.deployDemoCourse(id1);
    repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
    dbInstance.commit();
    String nodeIdent = assessmentData(tutor, id1, new ScoreEvaluation(1.0f, false), re);
    assessmentData(tutor, id2, new ScoreEvaluation(5.0f, true), re);
    assessmentData(tutor, id3, new ScoreEvaluation(10.0f, true), re);
    assessmentData(tutor, id3, new ScoreEvaluation(11.0f, true), re);
    assessmentData(tutor, id3, new ScoreEvaluation(12.0f, true), re);
    List<Identity> identities = new ArrayList<>();
    identities.add(id1);
    identities.add(id2);
    identities.add(id3);
    {
        // check attempts > 1
        List<ReminderRule> rules = getAttemptsRules(">", 1, nodeIdent);
        List<Identity> all = new ArrayList<>(identities);
        ruleEngine.filterByRules(re, all, rules);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(all.contains(id3));
    }
    {
        // check attempts = 1
        List<ReminderRule> rules = getAttemptsRules("=", 1, nodeIdent);
        List<Identity> all = new ArrayList<>(identities);
        ruleEngine.filterByRules(re, all, rules);
        Assert.assertEquals(2, all.size());
        Assert.assertTrue(all.contains(id1));
        Assert.assertTrue(all.contains(id2));
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 24 with ScoreEvaluation

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

the class ScormRunController method doStartPage.

private void doStartPage(UserRequest ureq) {
    // push title and learning objectives, only visible on intro page
    startPage.contextPut("menuTitle", scormNode.getShortTitle());
    startPage.contextPut("displayTitle", scormNode.getLongTitle());
    // Adding learning objectives
    String learningObj = scormNode.getLearningObjectives();
    if (learningObj != null) {
        Component learningObjectives = ObjectivesHelper.createLearningObjectivesComponent(learningObj, getLocale());
        startPage.put("learningObjectives", learningObjectives);
        startPage.contextPut("hasObjectives", Boolean.TRUE);
    } else {
        startPage.contextPut("hasObjectives", Boolean.FALSE);
    }
    if (isAssessable) {
        ScoreEvaluation scoreEval = scormNode.getUserScoreEvaluation(userCourseEnv);
        Float score = scoreEval.getScore();
        if (ScormEditController.CONFIG_ASSESSABLE_TYPE_SCORE.equals(assessableType)) {
            startPage.contextPut("score", score != null ? AssessmentHelper.getRoundedScore(score) : "0");
        }
        startPage.contextPut("hasPassedValue", (scoreEval.getPassed() == null ? Boolean.FALSE : Boolean.TRUE));
        startPage.contextPut("passed", scoreEval.getPassed());
        boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
        startPage.contextPut("resultsVisible", resultsVisible);
        if (resultsVisible && scormNode.hasCommentConfigured()) {
            StringBuilder comment = Formatter.stripTabsAndReturns(scormNode.getUserUserComment(userCourseEnv));
            startPage.contextPut("comment", StringHelper.xssScan(comment));
        }
        startPage.contextPut("attempts", scormNode.getUserAttempts(userCourseEnv));
        if (ureq == null) {
            // High score need one
            ureq = new SyntheticUserRequest(getIdentity(), getLocale(), userSession);
        }
        HighScoreRunController highScoreCtr = new HighScoreRunController(ureq, getWindowControl(), userCourseEnv, scormNode);
        if (highScoreCtr.isViewHighscore()) {
            Component highScoreComponent = highScoreCtr.getInitialComponent();
            startPage.put("highScore", highScoreComponent);
        }
    }
    startPage.contextPut("isassessable", Boolean.valueOf(isAssessable));
    main.setContent(startPage);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) HighScoreRunController(org.olat.course.highscore.ui.HighScoreRunController) SyntheticUserRequest(org.olat.core.gui.util.SyntheticUserRequest) Component(org.olat.core.gui.components.Component)

Example 25 with ScoreEvaluation

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

the class PortfolioCourseNodeRunController method updateAssessmentInfos.

private void updateAssessmentInfos(UserRequest ureq, Date returnDate) {
    if (returnDate != null || copyBinder != null) {
        String rDate = formatter.formatDateAndTime(returnDate);
        uifactory.addStaticTextElement("map.returnDate", rDate, infosContainer);
        // Fetch all score and passed and calculate score accounting for the entire course
        ScoreAccounting scoreAccounting = userCourseEnv.getScoreAccounting();
        scoreAccounting.evaluateAll();
        ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode(courseNode);
        boolean resultsVisible = scoreEval.getUserVisible() == null || scoreEval.getUserVisible().booleanValue();
        assessmentInfosContainer.contextPut("resultsVisible", resultsVisible);
        // score
        assessmentInfosContainer.contextPut("hasScoreField", new Boolean(courseNode.hasScoreConfigured()));
        if (courseNode.hasScoreConfigured()) {
            Float score = scoreEval.getScore();
            Float minScore = courseNode.getMinScoreConfiguration();
            Float maxScore = courseNode.getMaxScoreConfiguration();
            assessmentInfosContainer.contextPut("scoreMin", AssessmentHelper.getRoundedScore(minScore));
            assessmentInfosContainer.contextPut("scoreMax", AssessmentHelper.getRoundedScore(maxScore));
            assessmentInfosContainer.contextPut("score", AssessmentHelper.getRoundedScore(score));
        }
        // passed
        assessmentInfosContainer.contextPut("hasPassedField", new Boolean(courseNode.hasPassedConfigured()));
        if (courseNode.hasPassedConfigured()) {
            Boolean passed = scoreEval.getPassed();
            assessmentInfosContainer.contextPut("passed", passed);
            assessmentInfosContainer.contextPut("hasPassedValue", new Boolean(passed != null));
            Float cutValue = courseNode.getCutValueConfiguration();
            assessmentInfosContainer.contextPut("passedCutValue", AssessmentHelper.getRoundedScore(cutValue));
        }
        // get comment
        if (resultsVisible) {
            if (courseNode.hasCommentConfigured()) {
                AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
                String comment = am.getNodeComment(courseNode, getIdentity());
                assessmentInfosContainer.contextPut("comment", comment);
                assessmentInfosContainer.contextPut("in-comment", isPanelOpen(ureq, "comment", true));
            }
            if (courseNode.hasIndividualAsssessmentDocuments()) {
                List<File> docs = courseNode.getIndividualAssessmentDocuments(userCourseEnv);
                String mapperUri = registerCacheableMapper(ureq, null, new DocumentsMapper(docs));
                assessmentInfosContainer.contextPut("docsMapperUri", mapperUri);
                assessmentInfosContainer.contextPut("docs", docs);
                assessmentInfosContainer.contextPut("in-assessmentDocuments", isPanelOpen(ureq, "assessmentDocuments", true));
            }
        }
        assessmentInfosContainer.setVisible(true);
    } else {
        assessmentInfosContainer.setVisible(false);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) AssessmentManager(org.olat.course.assessment.AssessmentManager) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) DocumentsMapper(org.olat.course.nodes.ms.DocumentsMapper) File(java.io.File)

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