use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method createCourse.
/**
* Creates an empty course with a single root node. The course is linked to
* the resourceable ores. The efficiency statment are enabled per default!
*
* @param ores
* @param shortTitle Short title of root node
* @param longTitle Long title of root node
* @param learningObjectives Learning objectives of root node
* @return An empty course with a single root node.
*/
public static ICourse createCourse(RepositoryEntry courseEntry, String shortTitle, String longTitle, String learningObjectives) {
OLATResource courseResource = courseEntry.getOlatResource();
PersistingCourseImpl newCourse = new PersistingCourseImpl(courseResource);
// Put new course in course cache
loadedCourses.put(newCourse.getResourceableId(), newCourse);
Structure initialStructure = new Structure();
CourseNode runRootNode = new STCourseNode();
runRootNode.setShortTitle(shortTitle);
runRootNode.setLongTitle(longTitle);
runRootNode.setLearningObjectives(learningObjectives);
initialStructure.setRootNode(runRootNode);
newCourse.setRunStructure(initialStructure);
newCourse.saveRunStructure();
CourseEditorTreeModel editorTreeModel = new CourseEditorTreeModel();
CourseEditorTreeNode editorRootNode = new CourseEditorTreeNode((CourseNode) ObjectCloner.deepCopy(runRootNode));
editorTreeModel.setRootNode(editorRootNode);
newCourse.setEditorTreeModel(editorTreeModel);
newCourse.saveEditorTreeModel();
// enable efficiency statement per default
CourseConfig courseConfig = newCourse.getCourseConfig();
courseConfig.setEfficencyStatementIsEnabled(true);
newCourse.setCourseConfig(courseConfig);
return newCourse;
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class MergedCourseContainer method initSharedFolder.
/**
* Grab any shared folder that is configured, but only when in unchecked
* security mode (no identity environment) or when the user has course
* admin rights
*
* @param persistingCourse
*/
private void initSharedFolder(PersistingCourseImpl persistingCourse) {
CourseConfig courseConfig = persistingCourse.getCourseConfig();
String sfSoftkey = courseConfig.getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
RepositoryEntry re = persistingCourse.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (identityEnv == null || identityEnv.getRoles().isOLATAdmin() || RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identityEnv.getIdentity(), re)) {
OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class).loadRepositoryEntryResourceBySoftKey(sfSoftkey);
if (sharedResource != null) {
OlatRootFolderImpl sharedFolder = SharedFolderManager.getInstance().getSharedFolder(sharedResource);
if (sharedFolder != null) {
if (courseConfig.isSharedFolderReadOnlyMount() || courseReadOnly) {
sharedFolder.setLocalSecurityCallback(new ReadOnlyCallback());
}
// add local course folder's children as read/write source and any sharedfolder as subfolder
addContainer(new NamedContainerImpl("_sharedfolder", sharedFolder));
}
}
}
}
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class CertificatesManagerImpl method getDateNextRecertification.
@Override
public Date getDateNextRecertification(Certificate certificate, RepositoryEntry entry) {
ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
return getDateNextRecertification(certificate, config);
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class AssessmentManagerTest method setUp.
@Before
public void setUp() throws Exception {
try {
log.info("setUp start ------------------------");
Identity author = JunitTestHelper.createAndPersistIdentityAsRndUser("junit_auth");
tutor = JunitTestHelper.createAndPersistIdentityAsRndUser("junit_tutor");
student = JunitTestHelper.createAndPersistIdentityAsRndUser("junit_student");
// import "Demo course" into the bcroot_junittest
RepositoryEntry repositoryEntry = JunitTestHelper.deployDemoCourse(author);
Long resourceableId = repositoryEntry.getOlatResource().getResourceableId();
log.info("Demo course imported - resourceableId: " + resourceableId);
course = CourseFactory.loadCourse(resourceableId);
DBFactory.getInstance().closeSession();
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
config.setEfficencyStatementIsEnabled(true);
CourseFactory.setCourseConfig(course.getResourceableId(), config);
course = CourseFactory.loadCourse(resourceableId);
config = course.getCourseEnvironment().getCourseConfig();
Assert.assertTrue(config.isEfficencyStatementEnabled());
log.info("setUp done ------------------------");
} catch (RuntimeException e) {
log.error("Exception in setUp(): " + e);
}
}
Aggregations