Search in sources :

Example 86 with ReminderRuleImpl

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

the class InitialAttemptsRuleSPI method getLaunchDates.

@Override
protected Map<Long, Date> getLaunchDates(ReminderRule rule, RepositoryEntry entry, List<Identity> identities) {
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String nodeIdent = r.getLeftOperand();
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
        return helperDao.getInitialAttemptDates(entry, courseNode, identities);
    } else {
        return null;
    }
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode)

Example 87 with ReminderRuleImpl

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

the class ScoreRuleSPI method filter.

@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String nodeIdent = r.getLeftOperand();
        String operator = r.getOperator();
        float value = Float.parseFloat(r.getRightOperand());
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
        if (courseNode == null) {
            identities.clear();
            log.error("Score rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
            return;
        }
        Map<Long, Float> scores;
        if (courseNode instanceof STCourseNode) {
            scores = new HashMap<>();
            STCourseNode structureNode = (STCourseNode) courseNode;
            if (structureNode.hasScoreConfigured()) {
                for (Identity identity : identities) {
                    UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
                    ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
                    Float score = scoreEval.getScore();
                    if (score != null) {
                        scores.put(identity.getKey(), score);
                    }
                }
            }
        } else {
            scores = helperDao.getScores(entry, courseNode, identities);
        }
        for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
            Identity identity = identityIt.next();
            Float score = scores.get(identity.getKey());
            if (score == null) {
                if (!operator.equals("!=")) {
                    // always different
                    identityIt.remove();
                }
            } else if (!evaluateScore(score.floatValue(), operator, value)) {
                identityIt.remove();
            }
        }
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) STCourseNode(org.olat.course.nodes.STCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 88 with ReminderRuleImpl

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

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)

Example 89 with ReminderRuleImpl

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

the class ReminderRuleEngineTest method getRepositoryEntryLifecycleRuleValidFromRule.

private List<ReminderRule> getRepositoryEntryLifecycleRuleValidFromRule(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RepositoryEntryLifecycleAfterValidFromRuleSPI.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) RepositoryEntryLifecycleAfterValidFromRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryLifecycleAfterValidFromRuleSPI)

Example 90 with ReminderRuleImpl

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

the class ReminderRuleEngineTest method getScoreRules.

private List<ReminderRule> getScoreRules(String operator, float value, String nodeIdent) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(ScoreRuleSPI.class.getSimpleName());
    rule.setLeftOperand(nodeIdent);
    rule.setOperator(operator);
    rule.setRightOperand(Float.toString(value));
    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) ScoreRuleSPI(org.olat.course.reminder.rule.ScoreRuleSPI) 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