Search in sources :

Example 16 with UserCourseEnvironment

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);
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) IOException(java.io.IOException) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) Test(org.junit.Test)

Example 17 with UserCourseEnvironment

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);
}
Also used : ConditionInterpreter(org.olat.course.condition.interpreter.ConditionInterpreter) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Test(org.junit.Test)

Example 18 with UserCourseEnvironment

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);
}
Also used : ConditionInterpreter(org.olat.course.condition.interpreter.ConditionInterpreter) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Test(org.junit.Test)

Example 19 with UserCourseEnvironment

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);
}
Also used : ConditionInterpreter(org.olat.course.condition.interpreter.ConditionInterpreter) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Test(org.junit.Test)

Example 20 with UserCourseEnvironment

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);
}
Also used : ConditionInterpreter(org.olat.course.condition.interpreter.ConditionInterpreter) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Test(org.junit.Test)

Aggregations

UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)158 ICourse (org.olat.course.ICourse)84 Identity (org.olat.core.id.Identity)60 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)58 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)54 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)52 CourseNode (org.olat.course.nodes.CourseNode)42 RepositoryEntry (org.olat.repository.RepositoryEntry)42 Test (org.junit.Test)28 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)24 ConditionInterpreter (org.olat.course.condition.interpreter.ConditionInterpreter)20 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)16 Roles (org.olat.core.id.Roles)14 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)14 ArrayList (java.util.ArrayList)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)12 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)12 OLATResource (org.olat.resource.OLATResource)12 Date (java.util.Date)10 AssessmentManager (org.olat.course.assessment.AssessmentManager)10