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());
}
}
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());
}
}
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));
}
}
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);
}
}
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);
}
}
Aggregations