Search in sources :

Example 76 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

the class ConditionTest method getUserDemoCourseEnvironment.

private UserCourseEnvironment getUserDemoCourseEnvironment() {
    Identity author = JunitTestHelper.createAndPersistIdentityAsUser("junit_auth-" + UUID.randomUUID().toString());
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("condition");
    Roles roles = new Roles(false, false, false, false, false, false, false);
    RepositoryEntry re = JunitTestHelper.deployDemoCourse(author);
    ICourse course = CourseFactory.loadCourse(re);
    IdentityEnvironment identityEnv = new IdentityEnvironment(id, roles);
    UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
    return uce;
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 77 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment in project OpenOLAT by OpenOLAT.

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 78 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment 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 79 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment 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 80 with UserCourseEnvironment

use of org.olat.course.run.userview.UserCourseEnvironment 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)

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