Search in sources :

Example 1 with CourseConfig

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;
}
Also used : CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) STCourseNode(org.olat.course.nodes.STCourseNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) OLATResource(org.olat.resource.OLATResource) STCourseNode(org.olat.course.nodes.STCourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode) CourseNode(org.olat.course.nodes.CourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseConfig(org.olat.course.config.CourseConfig)

Example 2 with CourseConfig

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));
                }
            }
        }
    }
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) NamedContainerImpl(org.olat.core.util.vfs.NamedContainerImpl) CourseConfig(org.olat.course.config.CourseConfig) RepositoryService(org.olat.repository.RepositoryService)

Example 3 with CourseConfig

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);
}
Also used : ICourse(org.olat.course.ICourse) CourseConfig(org.olat.course.config.CourseConfig)

Example 4 with CourseConfig

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;
}
Also used : CorruptedCourseException(org.olat.course.CorruptedCourseException) Calendar(java.util.Calendar) ICourse(org.olat.course.ICourse) Date(java.util.Date) CourseConfig(org.olat.course.config.CourseConfig) Certificate(org.olat.course.certificate.Certificate)

Example 5 with CourseConfig

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);
    }
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) CourseConfig(org.olat.course.config.CourseConfig) Before(org.junit.Before)

Aggregations

CourseConfig (org.olat.course.config.CourseConfig)60 ICourse (org.olat.course.ICourse)28 RepositoryEntry (org.olat.repository.RepositoryEntry)24 OLATResource (org.olat.resource.OLATResource)12 File (java.io.File)10 Identity (org.olat.core.id.Identity)10 Date (java.util.Date)8 RepositoryService (org.olat.repository.RepositoryService)8 BusinessGroup (org.olat.group.BusinessGroup)7 Roles (org.olat.core.id.Roles)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 RepositoryEntryImportExport (org.olat.repository.RepositoryEntryImportExport)6 CourseConfigVO (org.olat.restapi.support.vo.CourseConfigVO)6 Calendar (java.util.Calendar)4 Before (org.junit.Before)4 Dropdown (org.olat.core.gui.components.dropdown.Dropdown)4 LinkPopupSettings (org.olat.core.gui.components.link.LinkPopupSettings)4 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)4 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)4 Structure (org.olat.course.Structure)4