Search in sources :

Example 26 with CourseConfig

use of org.olat.course.config.CourseConfig in project openolat by klemens.

the class CourseRuntimeController method doLayout.

private void doLayout(UserRequest ureq) {
    if (delayedClose == Delayed.layout || requestForClose(ureq)) {
        if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR)) {
            removeCustomCSS();
            ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
            boolean managedLayout = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.layout);
            CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig().clone();
            CourseLayoutGeneratorController ctrl = new CourseLayoutGeneratorController(ureq, getWindowControl(), getRepositoryEntry(), courseConfig, course.getCourseEnvironment(), !managedLayout);
            listenTo(ctrl);
            courseLayoutCtrl = pushController(ureq, translate("command.layout"), ctrl);
            setActiveTool(layoutLink);
            currentToolCtr = courseLayoutCtrl;
        }
    } else {
        delayedClose = Delayed.layout;
    }
}
Also used : CourseLayoutGeneratorController(org.olat.course.config.ui.courselayout.CourseLayoutGeneratorController) ICourse(org.olat.course.ICourse) CourseConfig(org.olat.course.config.CourseConfig)

Example 27 with CourseConfig

use of org.olat.course.config.CourseConfig in project openolat by klemens.

the class CourseRuntimeController method doCertificatesOptions.

private void doCertificatesOptions(UserRequest ureq) {
    if (delayedClose == Delayed.certificates || requestForClose(ureq)) {
        if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR)) {
            removeCustomCSS();
            ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
            CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig().clone();
            WindowControl bwControl = getSubWindowControl("CertificationSettings");
            CertificatesOptionsController ctrl = new CertificatesOptionsController(ureq, addToHistory(ureq, bwControl), getRepositoryEntry(), courseConfig, true);
            certificatesOptionsCtrl = pushController(ureq, translate("command.options"), ctrl);
            setActiveTool(certificatesOptionsLink);
            currentToolCtr = certificatesOptionsCtrl;
        }
    } else {
        delayedClose = Delayed.certificates;
    }
}
Also used : CertificatesOptionsController(org.olat.course.certificate.ui.CertificatesOptionsController) ICourse(org.olat.course.ICourse) WindowControl(org.olat.core.gui.control.WindowControl) CourseConfig(org.olat.course.config.CourseConfig)

Example 28 with CourseConfig

use of org.olat.course.config.CourseConfig in project openolat by klemens.

the class CourseRuntimeController method initToolsMyCourse.

private void initToolsMyCourse(ICourse course, UserCourseEnvironmentImpl uce) {
    boolean assessmentLock = isAssessmentLock();
    myCourse = new Dropdown("myCourse", "header.tools.mycourse", false, getTranslator());
    myCourse.setElementCssClass("dropdown-menu-right");
    myCourse.setIconCSS("o_icon o_icon_user");
    // Personal tools on right side
    CourseConfig cc = course.getCourseConfig();
    if ((course.hasAssessableNodes() || cc.isCertificateEnabled()) && !isGuestOnly && !assessmentLock && uce != null) {
        // link to efficiency statements should
        // - not appear when not configured in course configuration
        // - not appear when configured in course configuration but no assessable
        // node exist
        // - appear but dimmed when configured, assessable node exist but no
        // assessment data exists for user
        // - appear as link when configured, assessable node exist and assessment
        // data exists for user
        efficiencyStatementsLink = LinkFactory.createToolLink("efficiencystatement", translate("command.efficiencystatement"), this, "o_icon_certificate");
        efficiencyStatementsLink.setVisible(cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled());
        myCourse.addComponent(efficiencyStatementsLink);
        if (cc.isEfficencyStatementEnabled() || cc.isCertificateEnabled()) {
            boolean certification = uce.hasEfficiencyStatementOrCertificate(false);
            efficiencyStatementsLink.setVisible(certification);
        }
    }
    if (!isGuestOnly && !assessmentLock) {
        noteLink = LinkFactory.createToolLink("personalnote", translate("command.personalnote"), this, "o_icon_notes");
        noteLink.setPopup(new LinkPopupSettings(750, 550, "notes"));
        myCourse.addComponent(noteLink);
    }
    if (allowBookmark && !isGuestOnly) {
        boolean marked = markManager.isMarked(getRepositoryEntry(), getIdentity(), null);
        String css = marked ? Mark.MARK_CSS_ICON : Mark.MARK_ADD_CSS_ICON;
        bookmarkLink = LinkFactory.createToolLink("bookmark", translate("command.bookmark"), this, css);
        bookmarkLink.setTitle(translate(marked ? "details.bookmark.remove" : "details.bookmark"));
        myCourse.addComponent(bookmarkLink);
    }
    if (uce != null) {
        if (myCourse.size() > 0 && (uce.getCoachedGroups().size() > 0 || uce.getParticipatingGroups().size() > 0 || uce.getWaitingLists().size() > 0)) {
            myCourse.addComponent(new Spacer(""));
        }
        // 2) add coached groups
        if (uce.getCoachedGroups().size() > 0) {
            for (BusinessGroup group : uce.getCoachedGroups()) {
                Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", StringHelper.escapeHtml(group.getName()), this);
                link.setIconLeftCSS("o_icon o_icon-fw o_icon_group");
                link.setUserObject(group);
                link.setEnabled(!assessmentLock);
                myCourse.addComponent(link);
            }
        }
        // 3) add participating groups
        if (uce.getParticipatingGroups().size() > 0) {
            for (BusinessGroup group : uce.getParticipatingGroups()) {
                Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", StringHelper.escapeHtml(group.getName()), this);
                link.setIconLeftCSS("o_icon o_icon-fw o_icon_group");
                link.setUserObject(group);
                link.setEnabled(!assessmentLock);
                myCourse.addComponent(link);
            }
        }
        // 5) add waiting-list groups
        if (uce.getWaitingLists().size() > 0) {
            for (BusinessGroup group : uce.getWaitingLists()) {
                int pos = businessGroupService.getPositionInWaitingListFor(getIdentity(), group);
                String name = StringHelper.escapeHtml(group.getName()) + " (" + pos + ")";
                Link link = LinkFactory.createToolLink(CMD_START_GROUP_PREFIX + group.getKey(), "group", name, this);
                link.setIconLeftCSS("o_icon o_icon-fw o_icon_group");
                link.setUserObject(group);
                link.setEnabled(false);
                myCourse.addComponent(link);
            }
        }
        if (repositoryService.isParticipantAllowedToLeave(getRepositoryEntry()) && !assessmentLock && !roles.isGuestOnly() && !uce.isCourseReadOnly() && isAllowedToLeave(uce)) {
            leaveLink = LinkFactory.createToolLink("sign.out", "leave", translate("sign.out"), this);
            leaveLink.setIconLeftCSS("o_icon o_icon-fw o_icon_sign_out");
            myCourse.addComponent(new Spacer("leaving-space"));
            myCourse.addComponent(leaveLink);
        }
    }
    if (myCourse.size() > 0) {
        toolbarPanel.addTool(myCourse, Align.right);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) Spacer(org.olat.core.gui.components.dropdown.Dropdown.Spacer) LinkPopupSettings(org.olat.core.gui.components.link.LinkPopupSettings) Dropdown(org.olat.core.gui.components.dropdown.Dropdown) Link(org.olat.core.gui.components.link.Link) CourseConfig(org.olat.course.config.CourseConfig)

Example 29 with CourseConfig

use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.

the class CourseHandler method importGlossary.

private void importGlossary(ICourse course, Identity owner) {
    GlossaryManager gm = GlossaryManager.getInstance();
    RepositoryEntryImportExport importExport = gm.getRepositoryImportExport(course.getCourseExportDataDir().getBasefile());
    GlossaryResource resource = gm.createGlossary();
    if (resource == null) {
        log.error("Error adding glossary directry during repository reference import: " + importExport.getDisplayName());
        return;
    }
    // unzip contents
    VFSContainer glossaryContainer = gm.getGlossaryRootFolder(resource);
    File fExportedFile = importExport.importGetExportedFile();
    if (fExportedFile.exists()) {
        ZipUtil.unzip(new LocalFileImpl(fExportedFile), glossaryContainer);
    } else {
        log.warn("The actual contents of the glossary were not found in the export.");
    }
    // create repository entry
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(resource);
    RepositoryEntry importedRepositoryEntry = repositoryService.create(owner, null, importExport.getResourceName(), importExport.getDisplayName(), importExport.getDescription(), ores, 0);
    // set the new glossary reference
    CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    courseConfig.setGlossarySoftKey(importedRepositoryEntry.getSoftkey());
    CoreSpringFactory.getImpl(ReferenceManager.class).addReference(course, importedRepositoryEntry.getOlatResource(), GlossaryManager.GLOSSARY_REPO_REF_IDENTIFYER);
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
}
Also used : RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) GlossaryManager(org.olat.modules.glossary.GlossaryManager) File(java.io.File) GlossaryResource(org.olat.fileresource.types.GlossaryResource) RepositoryService(org.olat.repository.RepositoryService) CourseConfig(org.olat.course.config.CourseConfig) ReferenceManager(org.olat.resource.references.ReferenceManager)

Example 30 with CourseConfig

use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.

the class CourseHandler method importSharedFolder.

private void importSharedFolder(ICourse course, Identity owner) {
    SharedFolderManager sfm = SharedFolderManager.getInstance();
    RepositoryEntryImportExport importExport = sfm.getRepositoryImportExport(course.getCourseExportDataDir().getBasefile());
    SharedFolderFileResource resource = sfm.createSharedFolder();
    if (resource == null) {
        log.error("Error adding file resource during repository reference import: " + importExport.getDisplayName());
    }
    // unzip contents
    VFSContainer sfContainer = sfm.getSharedFolder(resource);
    File fExportedFile = importExport.importGetExportedFile();
    if (fExportedFile.exists()) {
        ZipUtil.unzip(new LocalFileImpl(fExportedFile), sfContainer);
    } else {
        log.warn("The actual contents of the shared folder were not found in the export.");
    }
    // create repository entry
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(resource);
    RepositoryEntry importedRepositoryEntry = repositoryService.create(owner, null, importExport.getResourceName(), importExport.getDisplayName(), importExport.getDescription(), ores, 0);
    // set the new shared folder reference
    CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    courseConfig.setSharedFolderSoftkey(importedRepositoryEntry.getSoftkey());
    CoreSpringFactory.getImpl(ReferenceManager.class).addReference(importedRepositoryEntry.getOlatResource(), course, SharedFolderManager.SHAREDFOLDERREF);
    CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
}
Also used : SharedFolderFileResource(org.olat.fileresource.types.SharedFolderFileResource) RepositoryEntryImportExport(org.olat.repository.RepositoryEntryImportExport) VFSContainer(org.olat.core.util.vfs.VFSContainer) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File) SharedFolderManager(org.olat.modules.sharedfolder.SharedFolderManager) RepositoryService(org.olat.repository.RepositoryService) CourseConfig(org.olat.course.config.CourseConfig) ReferenceManager(org.olat.resource.references.ReferenceManager)

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