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;
}
}
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();
}
}
}
}
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;
}
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;
}
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;
}
Aggregations