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