use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class AssessmentManagerTest method testSaveScoreEvaluation.
/**
* Tests the AssessmentManager methods.
*/
@Test
public void testSaveScoreEvaluation() {
log.info("Start testSaveScoreEvaluation");
assertNotNull(course);
// find an assessableCourseNode
List<CourseNode> assessableNodeList = AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), null);
Iterator<CourseNode> nodesIterator = assessableNodeList.iterator();
boolean testNodeFound = false;
while (nodesIterator.hasNext()) {
CourseNode currentNode = nodesIterator.next();
if (currentNode instanceof AssessableCourseNode) {
if (currentNode.getType().equalsIgnoreCase("iqtest")) {
log.info("Yes, we found a test node! - currentNode.getType(): " + currentNode.getType());
assessableCourseNode = (AssessableCourseNode) currentNode;
testNodeFound = true;
break;
}
}
}
assertTrue("found no test-node of type 'iqtest' (hint: add one to DemoCourse) ", testNodeFound);
assessmentManager = course.getCourseEnvironment().getAssessmentManager();
Long assessmentID = new Long("123456");
Integer attempts = 1;
String coachComment = "SomeUselessCoachComment";
String userComment = "UselessUserComment";
// store ScoreEvaluation for the assessableCourseNode and student
ScoreEvaluation scoreEvaluation = new ScoreEvaluation(score, passed, fullyAssessed, assessmentID);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(student);
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
boolean incrementAttempts = true;
assessmentManager.saveScoreEvaluation(assessableCourseNode, tutor, student, scoreEvaluation, userCourseEnv, incrementAttempts, Role.coach);
DBFactory.getInstance().closeSession();
// the attempts mut have been incremented
assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
assessmentManager.saveNodeCoachComment(assessableCourseNode, student, coachComment);
assessmentManager.saveNodeComment(assessableCourseNode, tutor, student, userComment);
attempts++;
assessmentManager.saveNodeAttempts(assessableCourseNode, tutor, student, attempts, Role.coach);
assertEquals(attempts, assessmentManager.getNodeAttempts(assessableCourseNode, student));
assertEquals(score, assessmentManager.getNodeScore(assessableCourseNode, student));
assertEquals(passed, assessmentManager.getNodePassed(assessableCourseNode, student));
assertEquals(assessmentID, assessmentManager.getAssessmentID(assessableCourseNode, student));
assertEquals(coachComment, assessmentManager.getNodeCoachComment(assessableCourseNode, student));
assertEquals(userComment, assessmentManager.getNodeComment(assessableCourseNode, student));
log.info("Finish testing AssessmentManager read/write methods");
checkEfficiencyStatementManager();
assertNotNull("no course at the end of test", course);
try {
course = CourseFactory.loadCourse(course.getResourceableId());
} catch (Exception ex) {
fail("Could not load course at the end of test Exception=" + ex);
}
assertNotNull("no course after loadCourse", course);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class ConditionTest method testUserPropertyEndswithFunction.
@Test
public void testUserPropertyEndswithFunction() throws Exception {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "userPropertyEndswith(\"firstName\", \"ondition\")";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"firstcondition\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"someThing\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"firstconditiongugus\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"firstName\", \"gugusfirstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "userPropertyEndswith(\"lastName\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class ConditionTest method testIsNotInUserPropertyFunction.
@Test
public void testIsNotInUserPropertyFunction() throws Exception {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "isNotInUserProperty(\"firstName\", \"stcondit\")";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"firstcondition\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"someThing\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"firstconditiongugus\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "isNotInUserProperty(\"firstName\", \"gugusfirstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
condition = "isNotInUserProperty(\"lastName\", \"firstcondition\")";
result = interpreter.evaluateCondition(condition);
Assert.assertTrue(condition, result);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class ConditionTest method testTrueFalse.
@Test
public void testTrueFalse() {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "true";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertTrue(result);
condition = "TRUE";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
condition = "false";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
condition = "FALSE";
result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
}
use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.
the class ConditionTest method complexExpression.
@Test
public void complexExpression() throws Exception {
UserCourseEnvironment uce = getUserDemoCourseEnvironment();
ConditionInterpreter interpreter = new ConditionInterpreter(uce);
String condition = "(((inLearningGroup(\"Rule1Group1\") | inLearningGroup(\"Rule1Group2\"))|inLearningArea(\"Rule1Area1\")))";
boolean result = interpreter.evaluateCondition(condition);
Assert.assertFalse(result);
}
Aggregations