Search in sources :

Example 41 with ScoreEvaluation

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

the class ReminderRuleEngineTest method score.

@Test
public void score() {
    // create a course with 3 members and generate some datas
    Identity tutor = JunitTestHelper.createAndPersistIdentityAsRndUser("score-tutor-1");
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("score-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("score-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("score-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 score > 0.5
        List<ReminderRule> rules = getScoreRules(">", 0.5f, nodeIdent);
        List<Identity> all = new ArrayList<>(identities);
        ruleEngine.filterByRules(re, all, rules);
        Assert.assertEquals(3, all.size());
    }
    {
        // check score > 20.0
        List<ReminderRule> rules = getScoreRules(">", 20.0f, 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 42 with ScoreEvaluation

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

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 43 with ScoreEvaluation

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

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 44 with ScoreEvaluation

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

the class ScormAPIMapper method calculatePassed.

private void calculatePassed(String olatSahsId, Properties lessonStatusProp, boolean finish) {
    int found = 0;
    boolean passedScos = true;
    for (Iterator<Object> it_status = lessonStatusProp.values().iterator(); it_status.hasNext(); ) {
        String status = (String) it_status.next();
        passedScos &= "passed".equals(status);
        found++;
    }
    boolean passed = (found == scormAdapter.getNumOfSCOs()) && passedScos;
    // if advanceScore option is set update the score only if it is higher
    // <OLATEE-27>
    ModuleConfiguration config = scormNode.getModuleConfiguration();
    if (config.getBooleanSafe(ScormEditController.CONFIG_ADVANCESCORE, true)) {
        if (currentPassed == null || !currentPassed.booleanValue()) {
            // </OLATEE-27>
            boolean increment = !attemptsIncremented && finish;
            ScoreEvaluation sceval = new ScoreEvaluation(new Float(0.0f), Boolean.valueOf(passed));
            scormNode.updateUserScoreEvaluation(sceval, userCourseEnv, identity, increment, Role.user);
            if (increment) {
                attemptsIncremented = true;
            }
        } else if (!config.getBooleanSafe(ScormEditController.CONFIG_ATTEMPTSDEPENDONSCORE, false)) {
            boolean increment = !attemptsIncremented && finish;
            ScoreEvaluation sceval = scormNode.getUserScoreEvaluation(userCourseEnv);
            scormNode.updateUserScoreEvaluation(sceval, userCourseEnv, identity, increment, Role.user);
            if (increment) {
                attemptsIncremented = true;
            }
        }
    } else {
        boolean increment = !attemptsIncremented && finish;
        ScoreEvaluation sceval = new ScoreEvaluation(new Float(0.0f), Boolean.valueOf(passed));
        scormNode.updateUserScoreEvaluation(sceval, userCourseEnv, identity, false, Role.user);
        if (increment) {
            attemptsIncremented = true;
        }
    }
    if (log.isDebug()) {
        String msg = "for scorm node:" + scormNode.getIdent() + " (" + scormNode.getShortTitle() + ") a lmsCommit for scoId " + olatSahsId + " occured, passed: " + passed + ", all lesson status now = " + lessonStatusProp.toString();
        log.debug(msg, null);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Example 45 with ScoreEvaluation

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

the class CourseAssessmentWebService method attachAssessableResults.

private void attachAssessableResults(Long courseResourceableId, String nodeKey, Identity requestIdentity, AssessableResultsVO resultsVO) {
    try {
        ICourse course = CourseFactory.openCourseEditSession(courseResourceableId);
        CourseNode node = getParentNode(course, nodeKey);
        if (!(node instanceof AssessableCourseNode)) {
            throw new IllegalArgumentException("The supplied node key does not refer to an AssessableCourseNode");
        }
        BaseSecurity securityManager = BaseSecurityManager.getInstance();
        Identity userIdentity = securityManager.loadIdentityByKey(resultsVO.getIdentityKey());
        // create an identenv with no roles, no attributes, no locale
        IdentityEnvironment ienv = new IdentityEnvironment();
        ienv.setIdentity(userIdentity);
        UserCourseEnvironment userCourseEnvironment = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
        // Fetch all score and passed and calculate score accounting for the
        // entire course
        userCourseEnvironment.getScoreAccounting().evaluateAll();
        if (node instanceof IQTESTCourseNode) {
            importTestItems(course, nodeKey, requestIdentity, resultsVO);
        } else {
            AssessableCourseNode assessableNode = (AssessableCourseNode) node;
            // not directly pass this key
            ScoreEvaluation scoreEval = new ScoreEvaluation(resultsVO.getScore(), Boolean.TRUE, Boolean.TRUE, new Long(nodeKey));
            assessableNode.updateUserScoreEvaluation(scoreEval, userCourseEnvironment, requestIdentity, true, Role.coach);
        }
        CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
        CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    } catch (Throwable e) {
        throw new WebApplicationException(e);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) WebApplicationException(javax.ws.rs.WebApplicationException) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) BaseSecurity(org.olat.basesecurity.BaseSecurity) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) CourseNode(org.olat.course.nodes.CourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

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