Search in sources :

Example 11 with ConditionInterpreter

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

the class ConditionTest method syntaxProposal.

@Test
public void syntaxProposal() throws Exception {
    UserCourseEnvironment uce = getUserDemoCourseEnvironment();
    ConditionInterpreter interpreter = new ConditionInterpreter(uce);
    String condition = "inLearningGroup(\"16872486<Rule1Group1>\")";
    boolean result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(result);
    Collection<Object> tokens = interpreter.getParsedTokens(condition);
    Assert.assertNotNull(tokens);
    Assert.assertFalse(tokens.isEmpty());
    for (Object token : tokens) {
        System.out.println(token.getClass().getName());
    }
}
Also used : ConditionInterpreter(org.olat.course.condition.interpreter.ConditionInterpreter) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Test(org.junit.Test)

Example 12 with ConditionInterpreter

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

the class ConditionTest method testHasNotPropertyFunction.

@Test
public void testHasNotPropertyFunction() throws Exception {
    UserCourseEnvironment uce = getUserDemoCourseEnvironment();
    ConditionInterpreter interpreter = new ConditionInterpreter(uce);
    String condition = "hasNotUserProperty(\"firstName\", \"firstcondition\")";
    boolean result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasNotUserProperty(\"firstName\", \"\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasNotUserProperty(\"firstName\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasNotUserProperty(\"firstName\", \"firstcondition\", \"firstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasNotUserProperty(\"firstName\", \"someThing\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "hasNotUserProperty(\"firstName\", \"firstconditiongugus\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "hasNotUserProperty(\"firstName\", \"gugusfirstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "hasNotUserProperty(\"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 13 with ConditionInterpreter

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

the class ConditionTest method testHasPropertyFunction.

@Test
public void testHasPropertyFunction() throws Exception {
    UserCourseEnvironment uce = getUserDemoCourseEnvironment();
    ConditionInterpreter interpreter = new ConditionInterpreter(uce);
    String condition = "hasUserProperty(\"firstName\", \"firstcondition\")";
    boolean result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "hasUserProperty(\"firstName\", \"\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\", \"firstcondition \")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\", \" firstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\", \"firstcondition\", \"firstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\", \"someThing\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\", \"firstconditiongugus\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"firstName\", \"gugusfirstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "hasUserProperty(\"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 14 with ConditionInterpreter

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

the class ConditionTest method testIsInUserPropertyFunction.

@Test
public void testIsInUserPropertyFunction() throws Exception {
    UserCourseEnvironment uce = getUserDemoCourseEnvironment();
    ConditionInterpreter interpreter = new ConditionInterpreter(uce);
    String condition = "isInUserProperty(\"firstName\", \"firstcondition\")";
    boolean result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "isInUserProperty(\"firstName\", \"stcondit\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "isInUserProperty(\"firstName\", \"\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "isInUserProperty(\"firstName\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "isInUserProperty(\"firstName\", \"firstcondition\", \"firstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "isInUserProperty(\"firstName\", \"someThing\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "isInUserProperty(\"firstName\", \"firstconditiongugus\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "isInUserProperty(\"firstName\", \"gugusfirstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "isInUserProperty(\"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 15 with ConditionInterpreter

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

the class ConditionTest method testUserPropertyStartswithFunction.

@Test
public void testUserPropertyStartswithFunction() throws Exception {
    UserCourseEnvironment uce = getUserDemoCourseEnvironment();
    ConditionInterpreter interpreter = new ConditionInterpreter(uce);
    String condition = "userPropertyStartswith(\"firstName\", \"firs\")";
    boolean result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "userPropertyStartswith(\"firstName\", \"firstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(condition, result);
    condition = "userPropertyStartswith(\"firstName\", \"\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "userPropertyStartswith(\"firstName\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "userPropertyStartswith(\"firstName\", \"firstcondition\", \"firstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "userPropertyStartswith(\"firstName\", \"someThing\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "userPropertyStartswith(\"firstName\", \"firstconditiongugus\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "userPropertyStartswith(\"firstName\", \"gugusfirstcondition\")";
    result = interpreter.evaluateCondition(condition);
    Assert.assertFalse(condition, result);
    condition = "userPropertyStartswith(\"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)

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