Search in sources :

Example 21 with ConditionInterpreter

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

the class ConditionTest method simpleExpresion.

@Test
public void simpleExpresion() throws Exception {
    UserCourseEnvironment uce = getUserDemoCourseEnvironment();
    ConditionInterpreter interpreter = new ConditionInterpreter(uce);
    String condition = "now >= date(\"03.07.2012 08:26\")";
    boolean result = interpreter.evaluateCondition(condition);
    Assert.assertTrue(result);
    Collection<Object> tokens = interpreter.getParsedTokens(condition);
    Assert.assertNotNull(tokens);
    Assert.assertFalse(tokens.isEmpty());
}
Also used : ConditionInterpreter(org.olat.course.condition.interpreter.ConditionInterpreter) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Test(org.junit.Test)

Example 22 with ConditionInterpreter

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

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)

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