Skip to content
Snippets Groups Projects
Commit 01cbe7ac authored by srosse's avatar srosse
Browse files

OO-1494: implements rule for group task, tasks assignment deadline and...

OO-1494: implements rule for group task, tasks assignment deadline and documents submission deadline
parent 3d36ec45
No related branches found
No related tags found
No related merge requests found
Showing
with 660 additions and 30 deletions
......@@ -8,7 +8,7 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="org.olat.course.nodes.en,org.olat.course.nodes.cl,org.olat.course.nodes.projectbroker.service,org.olat.course.nodes.gta.manager" />
<context:component-scan base-package="org.olat.course.nodes.en,org.olat.course.nodes.cl,org.olat.course.nodes.projectbroker.service,org.olat.course.nodes.gta" />
<!-- Course node spring config: Course Nodes are searched on the whole classpath, just place your CourceNodeConfiguration somewhere
on the classpath best as a jar. The xml file with ending ...Context.xml has do to be outside of the jar to get automatically loaded -->
......
......@@ -157,6 +157,9 @@ public interface GTAManager {
public Task nextStep(Task task, GTACourseNode cNode);
public List<Task> getTasks(TaskList taskList);
/**
* Return the tasks assigned to a person, individually or via a
* business group.
......
......@@ -443,6 +443,18 @@ public class GTAManagerImpl implements GTAManager {
return tasks.isEmpty() ? null : tasks.get(0);
}
@Override
public List<Task> getTasks(TaskList taskList) {
StringBuilder sb = new StringBuilder();
sb.append("select task from gtatask task ")
.append(" inner join task.taskList tasklist ")
.append(" where tasklist.key=:taskListKey ");
return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Task.class)
.setParameter("taskListKey", taskList.getKey())
.getResultList();
}
@Override
public List<Task> getTasks(IdentityRef identity, RepositoryEntryRef entry, GTACourseNode cNode) {
StringBuilder sb = new StringBuilder();
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.gta.rule;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.olat.basesecurity.GroupRoles;
import org.olat.core.id.Identity;
import org.olat.course.CourseFactory;
import org.olat.course.ICourse;
import org.olat.course.nodes.CourseNode;
import org.olat.course.nodes.GTACourseNode;
import org.olat.course.nodes.gta.GTAManager;
import org.olat.course.nodes.gta.GTAType;
import org.olat.course.nodes.gta.Task;
import org.olat.course.nodes.gta.TaskList;
import org.olat.group.BusinessGroup;
import org.olat.group.BusinessGroupService;
import org.olat.modules.ModuleConfiguration;
import org.olat.modules.reminder.IdentitiesProviderRuleSPI;
import org.olat.modules.reminder.ReminderRule;
import org.olat.modules.reminder.model.ReminderRuleImpl;
import org.olat.modules.reminder.rule.LaunchUnit;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryRelationType;
import org.olat.repository.manager.RepositoryEntryRelationDAO;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* Initial date: 10.04.2015<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public abstract class AbstractDueDateTaskRuleSPI implements IdentitiesProviderRuleSPI {
@Autowired
private GTAManager gtaManager;
@Autowired
private BusinessGroupService businessGroupService;
@Autowired
private RepositoryEntryRelationDAO repositoryEntryRelationDao;
@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
List<Identity> identities = null;
if(rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl)rule;
String nodeIdent = r.getLeftOperand();
ICourse course = CourseFactory.loadCourse(entry.getOlatResource());
CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
if(courseNode instanceof GTACourseNode) {
identities = evaluateRule(entry, (GTACourseNode)courseNode, r);
}
}
return identities == null ? Collections.<Identity>emptyList() : identities;
}
protected List<Identity> evaluateRule(RepositoryEntry entry, GTACourseNode gtaNode, ReminderRuleImpl r) {
List<Identity> identities = null;
Date dueDate = getDueDate(gtaNode);
if(dueDate != null) {
int value = Integer.parseInt(r.getRightOperand());
String unit = r.getRightUnit();
Date now = new Date();
if(near(dueDate, now, value, LaunchUnit.valueOf(unit))) {
identities = getPeopleToRemind(entry, gtaNode);
}
}
return identities == null ? Collections.<Identity>emptyList() : identities;
}
protected abstract Date getDueDate(GTACourseNode gtaNode);
protected List<Identity> getPeopleToRemind(RepositoryEntry entry, GTACourseNode gtaNode) {
ModuleConfiguration config = gtaNode.getModuleConfiguration();
TaskList taskList = gtaManager.getTaskList(entry, gtaNode);
if(GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
return getGroupsToRemind(taskList, gtaNode);
} else {
return getIndividualsToRemind(taskList, entry);
}
}
protected List<Identity> getGroupsToRemind(TaskList taskList, GTACourseNode gtaNode) {
List<Task> tasks = gtaManager.getTasks(taskList);
Set<BusinessGroup> doneTasks = new HashSet<BusinessGroup>();
for(Task task:tasks) {
if(task.getBusinessGroup() != null) {
doneTasks.add(task.getBusinessGroup());
}
}
List<BusinessGroup> groups = gtaManager.getBusinessGroups(gtaNode);
for(Iterator<BusinessGroup> groupIt=groups.iterator(); groupIt.hasNext(); ) {
if(doneTasks.contains(groupIt.next())) {
groupIt.remove();
}
}
return businessGroupService.getMembers(groups, GroupRoles.participant.name());
}
protected List<Identity> getIndividualsToRemind(TaskList taskList, RepositoryEntry entry) {
List<Task> tasks = gtaManager.getTasks(taskList);
Set<Identity> doneTasks = new HashSet<Identity>();
for(Task task:tasks) {
if(task.getIdentity() != null) {
doneTasks.add(task.getIdentity());
}
}
List<Identity> identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.participant.name());
for(Iterator<Identity> identityIt=identities.iterator(); identityIt.hasNext(); ) {
if(doneTasks.contains(identityIt.next())) {
identityIt.remove();
}
}
return identities;
}
private boolean near(Date date, Date now, int distance, LaunchUnit unit) {
double between = -1;
switch(unit) {
case day:
between = daysBetween(now, date);
break;
case week:
between = weeksBetween(now, date);
break;
case month:
between = monthsBetween(now, date);
break;
case year:
between = yearsBetween(now, date);
break;
}
return between <= distance || between < 0.0;
}
private double daysBetween(Date d1, Date d2) {
return ((d2.getTime() - d1.getTime()) / (1000d * 60d * 60d * 24d));
}
private double weeksBetween(Date d1, Date d2) {
return ((d2.getTime() - d1.getTime()) / (1000d * 60d * 60d * 24d * 7d));
}
private double monthsBetween(Date d1, Date d2) {
return ((d2.getTime() - d1.getTime()) / (1000d * 60d * 60d * 24d * 30d));
}
private double yearsBetween(Date d1, Date d2) {
return ((d2.getTime() - d1.getTime()) / (1000d * 60d * 60d * 24d * 365d));
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.gta.rule;
import java.util.Date;
import org.olat.course.nodes.GTACourseNode;
import org.olat.course.nodes.gta.ui.BeforeDateTaskRuleEditor;
import org.olat.modules.ModuleConfiguration;
import org.olat.modules.reminder.ReminderRule;
import org.olat.modules.reminder.RuleEditorFragment;
import org.olat.repository.RepositoryEntry;
import org.springframework.stereotype.Service;
/**
*
* Initial date: 10.04.2015<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
@Service
public class AssignTaskRuleSPI extends AbstractDueDateTaskRuleSPI {
@Override
public String getLabelI18nKey() {
return "rule.assign.task";
}
@Override
public String getCategory() {
return "assessment";
}
@Override
public RuleEditorFragment getEditorFragment(ReminderRule rule, RepositoryEntry entry) {
return new BeforeDateTaskRuleEditor(rule, entry, AssignTaskRuleSPI.class.getSimpleName());
}
@Override
protected Date getDueDate(GTACourseNode gtaNode) {
Date dueDate = null;
ModuleConfiguration config = gtaNode.getModuleConfiguration();
boolean assignment = config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT);
if(assignment) {
dueDate = config.getDateValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE);
}
return dueDate;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.gta.rule;
import java.util.Date;
import org.olat.course.nodes.GTACourseNode;
import org.olat.course.nodes.gta.GTAManager;
import org.olat.course.nodes.gta.ui.BeforeDateTaskRuleEditor;
import org.olat.group.BusinessGroupService;
import org.olat.modules.ModuleConfiguration;
import org.olat.modules.reminder.ReminderRule;
import org.olat.modules.reminder.RuleEditorFragment;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.manager.RepositoryEntryRelationDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
* Initial date: 10.04.2015<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
@Service
public class SubmissionTaskRuleSPI extends AbstractDueDateTaskRuleSPI {
@Autowired
private GTAManager gtaManager;
@Autowired
private BusinessGroupService businessGroupService;
@Autowired
private RepositoryEntryRelationDAO repositoryEntryRelationDao;
@Override
public String getLabelI18nKey() {
return "rule.submission.task";
}
@Override
public String getCategory() {
return "assessment";
}
@Override
public RuleEditorFragment getEditorFragment(ReminderRule rule, RepositoryEntry entry) {
return new BeforeDateTaskRuleEditor(rule, entry, SubmissionTaskRuleSPI.class.getSimpleName());
}
@Override
protected Date getDueDate(GTACourseNode gtaNode) {
Date dueDate = null;
ModuleConfiguration config = gtaNode.getModuleConfiguration();
boolean submit = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
if(submit) {
dueDate = config.getDateValue(GTACourseNode.GTASK_SUBMIT_DEADLINE);
}
return dueDate;
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.gta.ui;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.SingleSelection;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.CodeHelper;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
import org.olat.course.CourseFactory;
import org.olat.course.ICourse;
import org.olat.course.nodes.CourseNode;
import org.olat.course.nodes.GTACourseNode;
import org.olat.course.nodes.gta.rule.AssignTaskRuleSPI;
import org.olat.course.nodes.gta.rule.SubmissionTaskRuleSPI;
import org.olat.modules.ModuleConfiguration;
import org.olat.modules.reminder.ReminderRule;
import org.olat.modules.reminder.RuleEditorFragment;
import org.olat.modules.reminder.model.ReminderRuleImpl;
import org.olat.modules.reminder.rule.LaunchUnit;
import org.olat.repository.RepositoryEntry;
/**
*
* Initial date: 10.04.2015<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public class BeforeDateTaskRuleEditor extends RuleEditorFragment {
private static final String[] unitKeys = new String[]{
LaunchUnit.day.name(), LaunchUnit.week.name(), LaunchUnit.month.name(), LaunchUnit.year.name()
};
private TextElement valueEl;
private SingleSelection courseNodeEl, unitEl;
private final String ruleType;
private final RepositoryEntry entry;
public BeforeDateTaskRuleEditor(ReminderRule rule, RepositoryEntry entry, String ruleType) {
super(rule);
this.entry = entry;
this.ruleType = ruleType;
}
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/date_rule.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
Translator trans = Util
.createPackageTranslator(BeforeDateTaskRuleEditor.class, formLayout.getTranslator().getLocale(), formLayout.getTranslator());
FormLayoutContainer ruleCont = FormLayoutContainer
.createCustomFormLayout("taks.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
ruleCont.setTranslator(trans);
formLayout.add(ruleCont);
ICourse course = CourseFactory.loadCourse(entry.getOlatResource());
String currentValue = null;
String currentUnit = null;
String currentCourseNode = null;
if(rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl)rule;
currentUnit = r.getRightUnit();
currentValue = r.getRightOperand();
currentCourseNode = r.getLeftOperand();
}
List<CourseNode> attemptableNodes = new ArrayList<>();
searchAttemptableNodes(course.getRunStructure().getRootNode(), attemptableNodes);
String[] nodeKeys = new String[attemptableNodes.size()];
String[] nodeValues = new String[attemptableNodes.size()];
for(int i=0; i<attemptableNodes.size(); i++) {
CourseNode attemptableNode = attemptableNodes.get(0);
nodeKeys[i] = attemptableNode.getIdent();
nodeValues[i] = attemptableNode.getShortTitle() + " ( " + attemptableNode.getIdent() + " )";
}
courseNodeEl = uifactory.addDropdownSingleselect("coursenodes", null, ruleCont, nodeKeys, nodeValues, null);
courseNodeEl.setDomReplacementWrapperRequired(false);
boolean nodeSelected = false;
if(currentCourseNode != null) {
for(String nodeKey:nodeKeys) {
if(currentCourseNode.equals(nodeKey)) {
courseNodeEl.select(nodeKey, true);
nodeSelected = true;
}
}
}
if(!nodeSelected && nodeKeys.length > 0) {
courseNodeEl.select(nodeKeys[0], true);
}
if(StringHelper.containsNonWhitespace(currentCourseNode) && !nodeSelected) {
courseNodeEl.setErrorKey("error.course.node.found", null);
}
valueEl = uifactory.addTextElement("value", 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("unit", 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;
}
private void searchAttemptableNodes(CourseNode courseNode, List<CourseNode> nodes) {
if (courseNode instanceof GTACourseNode) {
GTACourseNode assessableCourseNode = (GTACourseNode) courseNode;
ModuleConfiguration config = assessableCourseNode.getModuleConfiguration();
if(AssignTaskRuleSPI.class.getSimpleName().equals(ruleType)) {
boolean assignment = config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT);
Date dueDate = config.getDateValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE);
if(assignment && dueDate != null) {
nodes.add(courseNode);
}
} else if(SubmissionTaskRuleSPI.class.getSimpleName().equals(ruleType)) {
boolean submit = config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT);
Date dueDate = config.getDateValue(GTACourseNode.GTASK_SUBMIT_DEADLINE);
if(submit && dueDate != null) {
nodes.add(courseNode);
}
}
}
for(int i=0; i<courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode)courseNode.getChildAt(i);
searchAttemptableNodes(child, nodes);
}
}
@Override
public boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
courseNodeEl.clearError();
if(!courseNodeEl.isOneSelected()) {
courseNodeEl.setErrorKey("form.mandatory.hover", null);
allOk &= false;
}
unitEl.clearError();
if(!unitEl.isOneSelected()) {
unitEl.setErrorKey("form.mandatory.hover", null);
allOk &= false;
}
valueEl.clearError();
if(!StringHelper.containsNonWhitespace(valueEl.getValue())) {
valueEl.setErrorKey("form.mandatory.hover", null);
allOk &= false;
}
return allOk;
}
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = null;
if(courseNodeEl.isOneSelected() && unitEl.isOneSelected() && StringHelper.containsNonWhitespace(valueEl.getValue())) {
configuredRule = new ReminderRuleImpl();
configuredRule.setType(ruleType);
configuredRule.setLeftOperand(courseNodeEl.getSelectedKey());
configuredRule.setOperator("<");
configuredRule.setRightOperand(valueEl.getValue());
configuredRule.setRightUnit(unitEl.getSelectedKey());
}
return configuredRule;
}
}
\ No newline at end of file
<div class='form-inline'>
$r.render("coursenodes") $r.render("value") $r.render("unit") <span class="form-control-static">$r.translate("before")</span>
#if($f.hasError("value"))
<br/>$r.render("value_ERROR")
#end
#if($f.hasError("coursenodes"))
<br/>$r.render("coursenodes_ERROR")
#end
</div>
\ No newline at end of file
......@@ -4,6 +4,7 @@ add.task=Aufgaben hochladen
assessment.group.tool=Gruppe bewerten
assignment.config.title=Aufgabe zuweisen
assignment.deadline=Zuweisungstermin
before=Vor
bulk.review=Beurteilung herunterladen
bulk.solutions=Musterl\u00F6sungen herunterladen
bulk.submitted.documents=Abgegebene Dokumenten
......
......@@ -3,6 +3,7 @@ add.solution=Add solution
add.task=Add task
assignment.config.title=Task assignment configuration
assignment.deadline=Assignment deadline
before=Before
bulk.review=Download review
bulk.solutions=Download solutions
bulk.submitted.documents=Download submitted documents
......
......@@ -155,7 +155,7 @@ public class CourseReminderListController extends FormBasicController implements
String entryPoint = entry.getOLATResourceable().getResourceableTypeName();
if("SentReminders".equalsIgnoreCase(entryPoint)) {
Long key = entry.getOLATResourceable().getResourceableId();
System.out.println(key);
doSendReminderList(ureq, key);
}
}
......@@ -239,14 +239,14 @@ public class CourseReminderListController extends FormBasicController implements
toolbarPanel.pushController(translate("new.reminder"), reminderEditCtrl);
}
private void doSendReminderList(UserRequest ureq, ReminderRow row) {
private void doSendReminderList(UserRequest ureq, Long reminderKey) {
removeAsListenerAndDispose(sendReminderListCtrl);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("SentReminders", row.getKey());
OLATResourceable ores = OresHelper.createOLATResourceableInstance("SentReminders", reminderKey);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
Reminder reminder = reminderManager.loadByKey(row.getKey());
Reminder reminder = reminderManager.loadByKey(reminderKey);
sendReminderListCtrl = new CourseSendReminderListController(ureq, bwControl, reminder);
listenTo(sendReminderListCtrl);
addToHistory(ureq, sendReminderListCtrl);
......@@ -336,7 +336,7 @@ public class CourseReminderListController extends FormBasicController implements
if("edit".equals(cmd)) {
doEdit(ureq, row);
} else if("show.sent".equals(cmd)) {
doSendReminderList(ureq, row);
doSendReminderList(ureq, row.getKey());
} else if("delete".equals(cmd)) {
doConfirmDelete(ureq, row);
} else if("duplicate".equals(cmd)) {
......
......@@ -29,6 +29,7 @@ import org.olat.core.gui.components.form.flexible.elements.SingleSelection;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.CodeHelper;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
......@@ -72,6 +73,7 @@ public class InitialAttemptsRuleEditor extends RuleEditorFragment {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/initial_attempts.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
Translator trans = formLayout.getTranslator();
FormLayoutContainer ruleCont = FormLayoutContainer
.createCustomFormLayout("attempts.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
......@@ -124,9 +126,10 @@ public class InitialAttemptsRuleEditor extends RuleEditorFragment {
valueEl = uifactory.addTextElement("attemptvalue", null, 128, currentValue, ruleCont);
valueEl.setDomReplacementWrapperRequired(false);
valueEl.setDisplaySize(3);
String[] unitValues = new String[] {
LaunchUnit.day.name(), LaunchUnit.week.name(), LaunchUnit.month.name(), LaunchUnit.year.name()
trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()),
trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name())
};
unitEl = uifactory.addDropdownSingleselect("attemptunit", null, ruleCont, unitKeys, unitValues, null);
......
......@@ -7,6 +7,7 @@ course.role.owner=Besitzer
course.role.ownerAndCoach=Besitzer und Coach
course.role.participant=Teilnehmer
course.role.participantAndCoach=Coach und Teilnehmer
day=Tagen
delete.rule=-
dialog.modal.delete.text=Wollen Sie wirklich diese Errinerung "{0}" l\u00F6schen?
duplicate=Duplizieren
......@@ -15,6 +16,7 @@ email.content=E-Mail
error.course.node.found=Kurs Element existiert nicht mehr
failed=Failed
logs=Logs
month=Monaten
new.reminder=Neue Erinnerung
passed=Passed
points=Punkte
......@@ -23,10 +25,12 @@ reminder.id=ID
reminder.resend=Errinerung wurde erfolgreisch geschickt.
reminders=Errinerungen
resend=Wieder schicken
rule.assign.task=Grupenaufgabe Zuweisung
rule.attempts=Attempts
rule.initial.attempts.date=Initial attempt date
rule.passed=Passed
rule.score=Score
rule.submission.task=Grupenaufgabe Dokumenten abgeben
rules.description=When matching all of the following conditions
send=Erinnerung jetzt schicken
send.reminder=Geschickte Errinerungen
......@@ -43,3 +47,5 @@ table.header.sendTime=Send time
table.header.status=Status
table.header.username=Benutzername
tools=Werkzeug
week=Wochen
year=Jahren
......@@ -7,6 +7,7 @@ course.role.owner=Owners
course.role.ownerAndCoach=Owners and coachs
course.role.participant=Participants
course.role.participantAndCoach=Coachs and participants
day=Days
delete.rule=-
dialog.modal.delete.text=Do your really want to delete this reminder "{0}"?
duplicate=Douplicate
......@@ -15,6 +16,7 @@ email.content=E-Mail
error.course.node.found=The cours element doesn't exist
failed=Failed
logs=Logs
month=Months
new.reminder=New reminder
passed=Passed
points=Points
......@@ -24,9 +26,11 @@ reminder.resend=Reminder was successfully sent.
reminders=Errinerungen
resend=Resend
rule.attempts=Attempts
rule.assign.task=Group task assignment
rule.initial.attempts.date=Initial attempt date
rule.passed=Passed
rule.score=Score
rule.submission.task=Group task documents submission
rules.description=When matching all of the following conditions
send=Send reminders now
send.reminder=Send reminders
......@@ -43,3 +47,5 @@ table.header.sendTime=Send time
table.header.status=Status
table.header.username=Username
tools=Tools
weeks=Weeks
year=Years
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.modules.reminder;
import java.util.List;
import org.olat.core.id.Identity;
import org.olat.repository.RepositoryEntry;
/**
*
* Rules which deliver a list of identities to remind
*
* Initial date: 10.04.2015<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
public interface IdentitiesProviderRuleSPI extends RuleSPI {
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule);
}
......@@ -29,6 +29,7 @@ import java.util.Set;
import org.olat.basesecurity.GroupRoles;
import org.olat.core.id.Identity;
import org.olat.modules.reminder.FilterRuleSPI;
import org.olat.modules.reminder.IdentitiesProviderRuleSPI;
import org.olat.modules.reminder.Reminder;
import org.olat.modules.reminder.ReminderModule;
import org.olat.modules.reminder.ReminderRule;
......@@ -122,18 +123,19 @@ public class ReminderRuleEngine {
}
protected List<Identity> getIdentities(RepositoryEntry entry, Reminder reminder, List<ReminderRule> ruleList, boolean resend) {
List<ReminderRule> roleRules = new ArrayList<>();
List<ReminderRule> identitiesProviderRules = new ArrayList<>();
for(Iterator<ReminderRule> ruleIt=ruleList.iterator(); ruleIt.hasNext(); ) {
ReminderRule rule = ruleIt.next();
if(REPO_ROLE_RULE_TYPE.equals(rule.getType()) || BUSINESSGROUP_ROLE_RULE_TYPE.equals(rule.getType())) {
roleRules.add(rule);
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
if(ruleSpi instanceof IdentitiesProviderRuleSPI) {
identitiesProviderRules.add(rule);
ruleIt.remove();
}
}
List<Identity> identities;
if(roleRules.isEmpty()) {
if(identitiesProviderRules.isEmpty()) {
//all members of repository entry
List<Identity> duplicatedIdentities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both,
GroupRoles.owner.name(), GroupRoles.coach.name(), GroupRoles.participant.name());
......@@ -141,14 +143,10 @@ public class ReminderRuleEngine {
} else {
identities = null;
for(ReminderRule rule:roleRules) {
List<Identity> members = null;
if(REPO_ROLE_RULE_TYPE.equals(rule.getType())) {
members = repoRoleRuleSpi.evaluate(entry, rule);
} else if(BUSINESSGROUP_ROLE_RULE_TYPE.equals(rule.getType())) {
members = groupRoleRuleSpi.evaluate(rule);
}
for(ReminderRule rule:identitiesProviderRules) {
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
IdentitiesProviderRuleSPI identitiesProviderRuleSpi = (IdentitiesProviderRuleSPI)ruleSpi;
List<Identity> members = identitiesProviderRuleSpi.evaluate(entry, rule);
if(identities == null) {
identities = members;
} else {
......
......@@ -73,14 +73,14 @@ public abstract class AbstractLaunchDateRuleSPI implements FilterRuleSPI {
Date initialLaunchDate = initialLaunchDates.get(identity.getKey());
if(initialLaunchDate == null) {
identityIt.remove();
} else if(!evaluate(initialLaunchDate, now, distance, unit)) {
} else if(!after(initialLaunchDate, now, distance, unit)) {
identityIt.remove();
}
}
}
}
private boolean evaluate(Date date, Date now, int distance, LaunchUnit unit) {
private boolean after(Date date, Date now, int distance, LaunchUnit unit) {
double between = -1;
switch(unit) {
case day:
......
......@@ -28,9 +28,9 @@ import org.olat.core.util.StringHelper;
import org.olat.group.BusinessGroupRef;
import org.olat.group.manager.BusinessGroupRelationDAO;
import org.olat.group.model.BusinessGroupRefImpl;
import org.olat.modules.reminder.IdentitiesProviderRuleSPI;
import org.olat.modules.reminder.ReminderRule;
import org.olat.modules.reminder.RuleEditorFragment;
import org.olat.modules.reminder.RuleSPI;
import org.olat.modules.reminder.model.ReminderRuleImpl;
import org.olat.modules.reminder.ui.BusinessGroupRoleEditor;
import org.olat.repository.RepositoryEntry;
......@@ -44,7 +44,7 @@ import org.springframework.stereotype.Service;
*
*/
@Service
public class BusinessGroupRoleRuleSPI implements RuleSPI {
public class BusinessGroupRoleRuleSPI implements IdentitiesProviderRuleSPI {
@Autowired
private BusinessGroupRelationDAO businessGroupRelationDao;
......@@ -64,7 +64,8 @@ public class BusinessGroupRoleRuleSPI implements RuleSPI {
return new BusinessGroupRoleEditor(rule, entry);
}
public List<Identity> evaluate(ReminderRule rule) {
@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
List<Identity> identities = null;
if(rule instanceof ReminderRuleImpl) {
......
......@@ -25,9 +25,9 @@ import java.util.List;
import org.olat.basesecurity.GroupRoles;
import org.olat.core.id.Identity;
import org.olat.core.util.StringHelper;
import org.olat.modules.reminder.IdentitiesProviderRuleSPI;
import org.olat.modules.reminder.ReminderRule;
import org.olat.modules.reminder.RuleEditorFragment;
import org.olat.modules.reminder.RuleSPI;
import org.olat.modules.reminder.model.ReminderRuleImpl;
import org.olat.modules.reminder.ui.RepositoryEntryRoleEditor;
import org.olat.repository.RepositoryEntry;
......@@ -43,7 +43,7 @@ import org.springframework.stereotype.Service;
*
*/
@Service
public class RepositoryEntryRoleRuleSPI implements RuleSPI {
public class RepositoryEntryRoleRuleSPI implements IdentitiesProviderRuleSPI {
@Autowired
private RepositoryEntryRelationDAO repositoryEntryRelationDao;
......@@ -63,7 +63,7 @@ public class RepositoryEntryRoleRuleSPI implements RuleSPI {
return new RepositoryEntryRoleEditor(rule);
}
@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
List<Identity> identities = null;
if(rule instanceof ReminderRuleImpl) {
......
......@@ -26,6 +26,7 @@ import org.olat.core.gui.components.form.flexible.elements.SingleSelection;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.CodeHelper;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util;
......@@ -61,6 +62,7 @@ public class CourseLaunchRuleEditor extends RuleEditorFragment {
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());
......@@ -79,10 +81,10 @@ public class CourseLaunchRuleEditor extends RuleEditorFragment {
valueEl.setDisplaySize(3);
String[] unitValues = new String[] {
LaunchUnit.day.name(), LaunchUnit.week.name(), LaunchUnit.month.name(), LaunchUnit.year.name()
trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()),
trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name())
};
unitEl = uifactory.addDropdownSingleselect("launchunit", null, ruleCont, unitKeys, unitValues, null);
unitEl.setDomReplacementWrapperRequired(false);
boolean selected = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment