use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
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 klemens.
the class PassedRuleSPI 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 status = r.getRightOperand();
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
if (courseNode == null) {
identities.clear();
log.error("Passed rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
return;
}
Map<Long, Boolean> passeds;
if (courseNode instanceof STCourseNode) {
passeds = new HashMap<>();
STCourseNode structureNode = (STCourseNode) courseNode;
if (structureNode.hasPassedConfigured()) {
for (Identity identity : identities) {
UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
Boolean passed = scoreEval.getPassed();
if (passed != null) {
passeds.put(identity.getKey(), passed);
}
}
}
} else {
passeds = helperDao.getPassed(entry, courseNode, identities);
}
if ("passed".equals(status)) {
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Boolean passed = passeds.get(identityIt.next().getKey());
if (passed == null || !passed.booleanValue()) {
identityIt.remove();
}
}
} else if ("failed".equals(status)) {
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Boolean passed = passeds.get(identityIt.next().getKey());
if (passed != null && passed.booleanValue()) {
identityIt.remove();
}
}
}
}
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class AttemptsRuleEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = null;
if (courseNodeEl.isOneSelected() && operatorEl.isOneSelected() && StringHelper.containsNonWhitespace(valueEl.getValue())) {
configuredRule = new ReminderRuleImpl();
configuredRule.setType(AttemptsRuleSPI.class.getSimpleName());
configuredRule.setLeftOperand(courseNodeEl.getSelectedKey());
configuredRule.setOperator(operatorEl.getSelectedKey());
configuredRule.setRightOperand(valueEl.getValue());
}
return configuredRule;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class ScoreRuleEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = null;
if (courseNodeEl.isOneSelected() && operatorEl.isOneSelected() && StringHelper.containsNonWhitespace(valueEl.getValue())) {
configuredRule = new ReminderRuleImpl();
configuredRule.setType(ScoreRuleSPI.class.getSimpleName());
configuredRule.setLeftOperand(courseNodeEl.getSelectedKey());
configuredRule.setOperator(operatorEl.getSelectedKey());
configuredRule.setRightOperand(valueEl.getValue());
}
return configuredRule;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class CourseLaunchRuleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/course_launch.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
Translator trans = formLayout.getTranslator();
FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("course.launch.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
formLayout.add(ruleCont);
ruleCont.getFormItemComponent().contextPut("id", id);
String currentValue = null;
String currentUnit = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentValue = r.getRightOperand();
currentUnit = r.getRightUnit();
}
valueEl = uifactory.addTextElement("launchvalue.".concat(id), null, 128, currentValue, ruleCont);
valueEl.setDomReplacementWrapperRequired(false);
valueEl.setDisplaySize(3);
String[] unitValues = new String[] { trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()), trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name()) };
unitEl = uifactory.addDropdownSingleselect("launchunit.".concat(id), null, ruleCont, unitKeys, unitValues, null);
unitEl.setDomReplacementWrapperRequired(false);
boolean selected = false;
if (currentUnit != null) {
for (String unitKey : unitKeys) {
if (currentUnit.equals(unitKey)) {
unitEl.select(unitKey, true);
selected = true;
}
}
}
if (!selected) {
unitEl.select(unitKeys[1], true);
}
return ruleCont;
}
Aggregations