Search in sources :

Example 66 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method userPropertyRules.

@Test
public void userPropertyRules() {
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("rule-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("rule-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("rule-3");
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
    dbInstance.commit();
    id1.getUser().setProperty(UserConstants.FIRSTNAME, "Aoi");
    id1.getUser().setProperty(UserConstants.LASTNAME, "Volks");
    userManager.updateUserFromIdentity(id1);
    id2.getUser().setProperty(UserConstants.FIRSTNAME, "Yukino");
    id2.getUser().setProperty(UserConstants.LASTNAME, "Volks");
    userManager.updateUserFromIdentity(id2);
    id3.getUser().setProperty(UserConstants.FIRSTNAME, "Ryomou");
    id3.getUser().setProperty(UserConstants.LASTNAME, "Shimei");
    userManager.updateUserFromIdentity(id3);
    dbInstance.commit();
    // check user properties rules
    {
        List<ReminderRule> rules = getRules(UserConstants.LASTNAME, "Volks");
        List<Identity> all = ruleEngine.getIdentities(re, null, rules, true);
        Assert.assertEquals(2, all.size());
        Assert.assertTrue(all.contains(id1));
        Assert.assertTrue(all.contains(id2));
    }
    // check user properties rules with role
    {
        List<ReminderRule> rules = getRules(UserConstants.LASTNAME, "Volks");
        ReminderRuleImpl rule = new ReminderRuleImpl();
        rule.setType(RepositoryEntryRoleRuleSPI.class.getSimpleName());
        rule.setOperator("=");
        rule.setRightOperand(RepositoryEntryRoleRuleSPI.Roles.owner.name());
        rules.add(rule);
        List<Identity> all = ruleEngine.getIdentities(re, null, rules, true);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(all.contains(id1));
    }
    // check with 2 rules
    {
        List<ReminderRule> rules = getRules(UserConstants.LASTNAME, "Volks");
        ReminderRuleImpl rule = new ReminderRuleImpl();
        rule.setType(UserPropertyRuleSPI.class.getSimpleName());
        rule.setLeftOperand(UserConstants.FIRSTNAME);
        rule.setOperator("=");
        rule.setRightOperand("Yukino");
        rules.add(rule);
        List<Identity> all = ruleEngine.getIdentities(re, null, rules, true);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(all.contains(id2));
    }
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 67 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getRecentLaunchRules.

private List<ReminderRule> getRecentLaunchRules(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RecentCourseLaunchRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) RecentCourseLaunchRuleSPI(org.olat.modules.reminder.rule.RecentCourseLaunchRuleSPI)

Example 68 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getInitialAttemptsRules.

private List<ReminderRule> getInitialAttemptsRules(int value, String unit, String nodeIdent) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(InitialAttemptsRuleSPI.class.getSimpleName());
    rule.setLeftOperand(nodeIdent);
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(value));
    rule.setRightUnit(unit);
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) InitialAttemptsRuleSPI(org.olat.course.reminder.rule.InitialAttemptsRuleSPI)

Example 69 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getRepositoryEntryLifecycleRuleValidToRule.

private List<ReminderRule> getRepositoryEntryLifecycleRuleValidToRule(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RepositoryEntryLifecycleAfterValidToRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) RepositoryEntryLifecycleAfterValidToRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryLifecycleAfterValidToRuleSPI)

Example 70 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getPassedRules.

private List<ReminderRule> getPassedRules(String status, String nodeIdent) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(PassedRuleSPI.class.getSimpleName());
    rule.setLeftOperand(nodeIdent);
    rule.setOperator("=");
    rule.setRightOperand(status);
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) PassedRuleSPI(org.olat.course.reminder.rule.PassedRuleSPI) ArrayList(java.util.ArrayList)

Aggregations

ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)114 ArrayList (java.util.ArrayList)46 Identity (org.olat.core.id.Identity)26 ReminderRule (org.olat.modules.reminder.ReminderRule)26 ICourse (org.olat.course.ICourse)22 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)20 CourseNode (org.olat.course.nodes.CourseNode)20 Test (org.junit.Test)16 Date (java.util.Date)14 Translator (org.olat.core.gui.translator.Translator)14 GTACourseNode (org.olat.course.nodes.GTACourseNode)14 List (java.util.List)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 TaskList (org.olat.course.nodes.gta.TaskList)10 Calendar (java.util.Calendar)8 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)8 ParseException (java.text.ParseException)6 InitialAttemptsRuleSPI (org.olat.course.reminder.rule.InitialAttemptsRuleSPI)6 ScoreRuleSPI (org.olat.course.reminder.rule.ScoreRuleSPI)6 File (java.io.File)4