use of org.olat.course.config.CourseConfig in project openolat by klemens.
the class CertificatesManagerImpl method isCertificationAllowed.
@Override
public boolean isCertificationAllowed(Identity identity, RepositoryEntry entry) {
boolean allowed = false;
try {
ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
if (config.isRecertificationEnabled()) {
Certificate certificate = getLastCertificate(identity, entry.getOlatResource().getKey());
if (certificate == null) {
allowed = true;
} else {
Calendar cal = Calendar.getInstance();
Date now = cal.getTime();
Date nextCertificationDate = getDateNextRecertification(certificate, config);
allowed = (nextCertificationDate != null ? nextCertificationDate.before(now) : false);
}
} else {
allowed = !hasCertificate(identity, entry.getOlatResource().getKey());
}
} catch (CorruptedCourseException e) {
log.error("", e);
}
return allowed;
}
use of org.olat.course.config.CourseConfig in project openolat by klemens.
the class CourseRuntimeController method doOptions.
private void doOptions(UserRequest ureq) {
if (delayedClose == Delayed.options || requestForClose(ureq)) {
if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR)) {
removeCustomCSS();
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig().clone();
CourseOptionsController ctrl = new CourseOptionsController(ureq, getWindowControl(), getRepositoryEntry(), courseConfig, true);
optionsToolCtr = pushController(ureq, translate("command.options"), ctrl);
setActiveTool(optionsLink);
currentToolCtr = optionsToolCtr;
}
} else {
delayedClose = Delayed.options;
}
}
use of org.olat.course.config.CourseConfig in project openolat by klemens.
the class CourseRuntimeController method initGeneralTools.
private void initGeneralTools(ICourse course) {
boolean assessmentLock = isAssessmentLock();
CourseConfig cc = course.getCourseConfig();
if (!assessmentLock && showInfos) {
detailsLink = LinkFactory.createToolLink("courseconfig", translate("command.courseconfig"), this, "o_icon_details");
toolbarPanel.addTool(detailsLink);
}
boolean calendarIsEnabled = !assessmentLock && !isGuestOnly && calendarModule.isEnabled() && calendarModule.isEnableCourseToolCalendar() && reSecurity.canLaunch();
if (calendarIsEnabled && getUserCourseEnvironment() != null) {
calendarLink = LinkFactory.createToolLink("calendar", translate("command.calendar"), this, "o_icon_calendar");
calendarLink.setPopup(new LinkPopupSettings(950, 750, "cal"));
calendarLink.setVisible(cc.isCalendarEnabled());
toolbarPanel.addTool(calendarLink);
}
if (!assessmentLock) {
glossary = new Dropdown("glossary", "command.glossary", false, getTranslator());
glossary.setIconCSS("o_icon o_FileResource-GLOSSARY_icon");
glossary.setVisible(cc.hasGlossary());
openGlossaryLink = LinkFactory.createToolLink("command.glossary.open", translate("command.glossary.open"), this);
openGlossaryLink.setPopup(new LinkPopupSettings(950, 750, "gloss"));
glossary.addComponent(openGlossaryLink);
enableGlossaryLink = LinkFactory.createToolLink("command.glossary.on.off", translate("command.glossary.on.alt"), this);
glossary.addComponent(enableGlossaryLink);
toolbarPanel.addTool(glossary);
}
if (!assessmentLock && isLecturesLinkEnabled()) {
lecturesLink = LinkFactory.createToolLink("command.lectures", translate("command.lectures"), this, "o_icon_lecture");
toolbarPanel.addTool(lecturesLink);
}
// add group chat to toolbox
boolean chatIsEnabled = !assessmentLock && !isGuestOnly && imModule.isEnabled() && imModule.isCourseEnabled() && reSecurity.canLaunch();
if (chatIsEnabled && getUserCourseEnvironment() != null && !getUserCourseEnvironment().isCourseReadOnly()) {
chatLink = LinkFactory.createToolLink("chat", translate("command.coursechat"), this, "o_icon_chat");
chatLink.setVisible(imModule.isCourseEnabled() && cc.isChatEnabled());
toolbarPanel.addTool(chatLink);
}
// add course search to toolbox
boolean isSearchEnabled = !assessmentLock && searchModule.isSearchAllowed(roles);
if (isSearchEnabled) {
searchLink = LinkFactory.createToolLink("coursesearch", translate("command.coursesearch"), this, "o_icon_search");
searchLink.setVisible(cc.isCourseSearchEnabled());
toolbarPanel.addTool(searchLink);
}
}
use of org.olat.course.config.CourseConfig in project openolat by klemens.
the class PreviewConfigController method generateEnvironment.
private void generateEnvironment() {
List<BGArea> tmpAreas = areaManager.loadAreas(psf.getAreaKeys());
List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(psf.getGroupKeys());
// get learning areas for groups
Set<BGArea> areas = new HashSet<BGArea>();
areas.addAll(tmpAreas);
List<BGArea> areaByGroups = areaManager.findBGAreasOfBusinessGroups(groups);
areas.addAll(areaByGroups);
role = psf.getRole();
ICourse course = CourseFactory.loadCourse(ores);
// default is student
isGlobalAuthor = false;
isGuestOnly = false;
isCoach = false;
isCourseAdmin = false;
/*
* if (role.equals(PreviewSettingsForm.ROLE_STUDENT)) { } else
*/
if (role.equals(PreviewSettingsForm.ROLE_GUEST)) {
isGuestOnly = true;
} else if (role.equals(PreviewSettingsForm.ROLE_COURSECOACH)) {
isCoach = true;
} else if (role.equals(PreviewSettingsForm.ROLE_COURSEADMIN)) {
isCourseAdmin = true;
} else if (role.equals(PreviewSettingsForm.ROLE_GLOBALAUTHOR)) {
isGlobalAuthor = true;
}
final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(groups), new ArrayList<BGArea>(areas), isCoach, isCourseAdmin);
final UserNodeAuditManager auditman = new PreviewAuditManager();
final AssessmentManager am = new PreviewAssessmentManager();
final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
final String title = course.getCourseTitle();
final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
simCourseEnv = new PreviewCourseEnvironment(title, runStructure, psf.getDate(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
simIdentEnv = new IdentityEnvironment();
simIdentEnv.setRoles(new Roles(false, false, false, isGlobalAuthor, isGuestOnly, false, false));
final Identity ident = new PreviewIdentity();
simIdentEnv.setIdentity(ident);
// identity must be set before attributes OLAT-4811
simIdentEnv.setAttributes(psf.getAttributesMap());
}
use of org.olat.course.config.CourseConfig in project openolat by klemens.
the class PreviewConfigHelper method getPreviewCourseEnvironment.
public static CourseEnvironment getPreviewCourseEnvironment(boolean isCoach, boolean isCourseAdmin, ICourse course) {
// generateEnvironment();
final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(), new ArrayList<BGArea>(), isCoach, isCourseAdmin);
final UserNodeAuditManager auditman = new PreviewAuditManager();
final AssessmentManager am = new PreviewAssessmentManager();
final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
final String title = course.getCourseTitle();
final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
CourseEnvironment previewCourseEnvironment = new PreviewCourseEnvironment(title, runStructure, new Date(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
return previewCourseEnvironment;
}
Aggregations