use of org.olat.repository.model.RepositoryEntryLifecycle in project OpenOLAT by OpenOLAT.
the class LifecycleAdminController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == createLifeCycle) {
doEdit(ureq, null);
} else if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if ("delete-lifecycle".equals(se.getCommand())) {
RepositoryEntryLifecycle row = model.getObject(se.getIndex());
doConfirmDelete(ureq, row);
} else if ("edit-lifecycle".equals(se.getCommand())) {
RepositoryEntryLifecycle row = model.getObject(se.getIndex());
doEdit(ureq, row);
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project OpenOLAT by OpenOLAT.
the class GetCourseBeginDateFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
RepositoryEntryLifecycle lifecycle = getUserCourseEnv().getLifecycle();
if (lifecycle != null && lifecycle.getValidFrom() != null) {
return Double.valueOf(lifecycle.getValidFrom().getTime());
} else {
// what to do in case of no date available??? -> return date in the future
return new Double(Double.POSITIVE_INFINITY);
}
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project OpenOLAT by OpenOLAT.
the class GetCourseEndDateFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
RepositoryEntryLifecycle lifecycle = getUserCourseEnv().getLifecycle();
if (lifecycle != null && lifecycle.getValidTo() != null) {
Double end = Double.valueOf(lifecycle.getValidTo().getTime());
return end;
} else {
// what to do in case of no date available??? -> return date in the future
return new Double(Double.POSITIVE_INFINITY);
}
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class GetCourseEndDateFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
RepositoryEntryLifecycle lifecycle = getUserCourseEnv().getLifecycle();
if (lifecycle != null && lifecycle.getValidTo() != null) {
Double end = Double.valueOf(lifecycle.getValidTo().getTime());
return end;
} else {
// what to do in case of no date available??? -> return date in the future
return new Double(Double.POSITIVE_INFINITY);
}
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class ReminderRuleEngineTest method afterBeginDate.
@Test
public void afterBeginDate() {
// create a course with 3 members
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("before-begin-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("before-begin-2");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("before-begin-3");
ICourse course = CoursesWebService.createEmptyCourse(null, "initial-launch-dates", "course long name", null);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
Calendar cal = Calendar.getInstance();
// now
cal.setTime(new Date());
cal.add(Calendar.DATE, -21);
Date validFrom = cal.getTime();
cal.add(Calendar.DATE, 90);
Date validTo = cal.getTime();
RepositoryEntryLifecycle cycle = lifecycleDao.create("Cycle 1", "Cycle soft 1", false, validFrom, validTo);
re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, null, cycle);
repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
dbInstance.commit();
{
// check after 2 days
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(2, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 7 days (between begin and and date)
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(7, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 2 week s
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(2, LaunchUnit.week);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 21 days
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(21, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 3 weeks
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(3, LaunchUnit.week);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 22 days
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(22, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertFalse(match);
}
{
// check after 4 weeks
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(4, LaunchUnit.week);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertFalse(match);
}
{
// check after 1 month
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(1, LaunchUnit.month);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertFalse(match);
}
}
Aggregations