use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.
the class RepositoryAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer searchCont = FormLayoutContainer.createDefaultFormLayout("search", getTranslator());
searchCont.setFormContextHelp("Modules: Repository");
searchCont.setFormTitle(translate("repository.admin.title"));
formLayout.add(searchCont);
searchCont.setRootForm(mainForm);
boolean searchEnabled = repositoryModule.isMyCoursesSearchEnabled();
String[] values = new String[] { translate("on") };
myCourseSearchEl = uifactory.addCheckboxesHorizontal("my.course.search.enabled", searchCont, keys, values);
myCourseSearchEl.addActionListener(FormEvent.ONCHANGE);
myCourseSearchEl.select(keys[0], searchEnabled);
boolean commentEnabled = repositoryModule.isCommentEnabled();
commentEl = uifactory.addCheckboxesHorizontal("my.course.comment.enabled", searchCont, keys, values);
commentEl.addActionListener(FormEvent.ONCHANGE);
commentEl.select(keys[0], commentEnabled);
boolean ratingEnabled = repositoryModule.isRatingEnabled();
ratingEl = uifactory.addCheckboxesHorizontal("my.course.rating.enabled", searchCont, keys, values);
ratingEl.addActionListener(FormEvent.ONCHANGE);
ratingEl.select(keys[0], ratingEnabled);
FormLayoutContainer leaveCont = FormLayoutContainer.createDefaultFormLayout("leave", getTranslator());
leaveCont.setFormTitle(translate("repository.admin.leave.title"));
formLayout.add(leaveCont);
leaveCont.setRootForm(mainForm);
String[] leaveValues = new String[] { translate("rentry.leave.atanytime"), translate("rentry.leave.afterenddate"), translate("rentry.leave.never") };
leaveEl = uifactory.addDropdownSingleselect("leave.courses", "repository.admin.leave.label", leaveCont, leaveKeys, leaveValues, null);
leaveEl.addActionListener(FormEvent.ONCHANGE);
RepositoryEntryAllowToLeaveOptions leaveOption = repositoryModule.getAllowToLeaveDefaultOption();
if (leaveOption != null) {
leaveEl.select(leaveOption.name(), true);
} else {
leaveEl.select(RepositoryEntryAllowToLeaveOptions.atAnyTime.name(), true);
}
lifecycleAdminCtrl = new RepositoryLifecycleAdminController(ureq, getWindowControl(), mainForm);
listenTo(lifecycleAdminCtrl);
formLayout.add(lifecycleAdminCtrl.getInitialFormItem());
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.
the class RepositoryServiceImpl method isParticipantAllowedToLeave.
@Override
public boolean isParticipantAllowedToLeave(RepositoryEntry re) {
boolean allowed = false;
RepositoryEntryAllowToLeaveOptions setting = re.getAllowToLeaveOption();
if (setting == RepositoryEntryAllowToLeaveOptions.atAnyTime) {
allowed = true;
} else if (setting == RepositoryEntryAllowToLeaveOptions.afterEndDate) {
RepositoryEntryLifecycle lifecycle = re.getLifecycle();
if (lifecycle == null || lifecycle.getValidTo() == null) {
allowed = false;
} else {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date now = cal.getTime();
if (now.compareTo(lifecycle.getValidTo()) >= 0) {
allowed = true;
} else {
allowed = false;
}
}
} else {
allowed = false;
}
return allowed;
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.
the class PublishStep01AccessForm method formOK.
@Override
protected void formOK(UserRequest ureq) {
RepositoryEntryAllowToLeaveOptions setting;
if (leaveEl.isOneSelected()) {
setting = RepositoryEntryAllowToLeaveOptions.valueOf(leaveEl.getSelectedKey());
} else {
setting = RepositoryEntryAllowToLeaveOptions.atAnyTime;
}
boolean membersOnly = (usersSwitch.getSelectedKey().equals(YES_KEY) && publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY));
CourseAccessAndProperties accessProperties = new CourseAccessAndProperties(entry, setting, getAccess(), membersOnly, canCopy.isSelected(0), canReference.isSelected(0), canDownload.isSelected(0));
accessProperties.setOfferAccess(offerAccess);
accessProperties.setDeletedOfferAccess(deletedOfferAccess);
if (confirmationEmailEl.isVisible()) {
accessProperties.setConfirmationEmail(confirmationEmailEl.isAtLeastSelected(1));
} else {
accessProperties.setConfirmationEmail(null);
}
addToRunContext("accessAndProperties", accessProperties);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.
the class AuthoringEditAllowToLeaveOptionController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("rentry.leaving.title");
String[] leaveValues = new String[] { translate("rentry.leave.atanytime"), translate("rentry.leave.afterenddate"), translate("rentry.leave.never") };
final boolean managedLeaving = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.membersmanagement);
leaveEl = uifactory.addDropdownSingleselect("entry.leave", "rentry.leave.option", formLayout, leaveKeys, leaveValues, null);
boolean found = false;
for (String leaveKey : leaveKeys) {
if (leaveKey.equals(entry.getAllowToLeaveOption().name())) {
leaveEl.select(leaveKey, true);
found = true;
}
}
if (!found) {
if (managedLeaving) {
leaveEl.select(RepositoryEntryAllowToLeaveOptions.never.name(), true);
} else {
RepositoryEntryAllowToLeaveOptions defaultOption = repositoryModule.getAllowToLeaveDefaultOption();
leaveEl.select(defaultOption.name(), true);
}
}
leaveEl.setEnabled(!managedLeaving);
if (!managedLeaving) {
uifactory.addFormSubmitButton("submit", formLayout);
}
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.
the class PublishStep01AccessForm method formOK.
@Override
protected void formOK(UserRequest ureq) {
RepositoryEntryAllowToLeaveOptions setting;
if (leaveEl.isOneSelected()) {
setting = RepositoryEntryAllowToLeaveOptions.valueOf(leaveEl.getSelectedKey());
} else {
setting = RepositoryEntryAllowToLeaveOptions.atAnyTime;
}
boolean membersOnly = (usersSwitch.getSelectedKey().equals(YES_KEY) && publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY));
CourseAccessAndProperties accessProperties = new CourseAccessAndProperties(entry, setting, getAccess(), membersOnly, canCopy.isSelected(0), canReference.isSelected(0), canDownload.isSelected(0));
accessProperties.setOfferAccess(offerAccess);
accessProperties.setDeletedOfferAccess(deletedOfferAccess);
if (confirmationEmailEl.isVisible()) {
accessProperties.setConfirmationEmail(confirmationEmailEl.isAtLeastSelected(1));
} else {
accessProperties.setConfirmationEmail(null);
}
addToRunContext("accessAndProperties", accessProperties);
fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Aggregations