Search in sources :

Example 1 with ConditionInterpreter

use of org.olat.course.condition.interpreter.ConditionInterpreter 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 2 with ConditionInterpreter

use of org.olat.course.condition.interpreter.ConditionInterpreter 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 3 with ConditionInterpreter

use of org.olat.course.condition.interpreter.ConditionInterpreter 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 4 with ConditionInterpreter

use of org.olat.course.condition.interpreter.ConditionInterpreter 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)

Example 5 with ConditionInterpreter

use of org.olat.course.condition.interpreter.ConditionInterpreter in project openolat by klemens.

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)

Aggregations

ConditionInterpreter (org.olat.course.condition.interpreter.ConditionInterpreter)22 Test (org.junit.Test)20 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)20 AssessmentEvaluation (org.olat.course.run.scoring.AssessmentEvaluation)2