Search in sources :

Example 6 with CourseConfig

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

the class CalendarTest method startup.

@Before
public void startup() {
    if (id1 == null) {
        id1 = JunitTestHelper.createAndPersistIdentityAsUser("cal-1-" + UUID.randomUUID().toString());
    }
    if (id2 == null) {
        id2 = JunitTestHelper.createAndPersistIdentityAsUser("cal-2-" + UUID.randomUUID().toString());
    }
    if (course1 == null) {
        // create a course with a calendar
        CourseConfigVO config = new CourseConfigVO();
        config.setCalendar(Boolean.TRUE);
        course1 = CoursesWebService.createEmptyCourse(id1, "Cal course", "Cal course", config);
        dbInstance.commit();
        ICourse course = CourseFactory.loadCourse(course1.getResourceableId());
        CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
        Assert.assertTrue(courseConfig.isCalendarEnabled());
        KalendarRenderWrapper calendarWrapper = calendarManager.getCourseCalendar(course);
        Calendar cal = Calendar.getInstance();
        for (int i = 0; i < 10; i++) {
            Date begin = cal.getTime();
            cal.add(Calendar.HOUR_OF_DAY, 1);
            Date end = cal.getTime();
            KalendarEvent event = new KalendarEvent(UUID.randomUUID().toString(), null, "Unit test " + i, begin, end);
            calendarManager.addEventTo(calendarWrapper.getKalendar(), event);
            cal.add(Calendar.DATE, 1);
        }
        cal = Calendar.getInstance();
        cal.add(Calendar.MONTH, -1);
        Date begin2 = cal.getTime();
        cal.add(Calendar.HOUR_OF_DAY, 1);
        Date end2 = cal.getTime();
        KalendarEvent event2 = new KalendarEvent(UUID.randomUUID().toString(), null, "Unit test 2", begin2, end2);
        calendarManager.addEventTo(calendarWrapper.getKalendar(), event2);
        RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(course1, false);
        entry = repositoryManager.setAccess(entry, RepositoryEntry.ACC_USERS, false);
        repositoryService.addRole(id1, entry, GroupRoles.participant.name());
        dbInstance.commit();
    }
    if (course2 == null) {
        // create a course with a calendar
        CourseConfigVO config = new CourseConfigVO();
        config.setCalendar(Boolean.TRUE);
        course2 = CoursesWebService.createEmptyCourse(id2, "Cal course - 2", "Cal course - 2", config);
        dbInstance.commit();
        KalendarRenderWrapper calendarWrapper = calendarManager.getCourseCalendar(course2);
        Assert.assertNotNull(calendarWrapper);
        RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(course2, false);
        entry = repositoryManager.setAccess(entry, RepositoryEntry.ACC_USERS, false);
        dbInstance.commit();
    }
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) Calendar(java.util.Calendar) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Date(java.util.Date) CourseConfig(org.olat.course.config.CourseConfig) Before(org.junit.Before)

Example 7 with CourseConfig

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

the class CourseResourceFolderWebService method getFiles.

public Response getFiles(Long courseId, List<PathSegment> path, FolderType type, UriInfo uriInfo, HttpServletRequest httpRequest, Request request) {
    if (!isAuthor(httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    ICourse course = CoursesWebService.loadCourse(courseId);
    if (course == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    VFSContainer container = null;
    RepositoryEntry re = null;
    switch(type) {
        case COURSE_FOLDER:
            container = course.getCourseFolderContainer();
            break;
        case SHARED_FOLDER:
            {
                container = null;
                String sfSoftkey = course.getCourseConfig().getSharedFolderSoftkey();
                OLATResource sharedResource = CoreSpringFactory.getImpl(RepositoryService.class).loadRepositoryEntryResourceBySoftKey(sfSoftkey);
                if (sharedResource != null) {
                    re = CoreSpringFactory.getImpl(RepositoryService.class).loadByResourceKey(sharedResource.getKey());
                    container = SharedFolderManager.getInstance().getNamedSharedFolder(re, true);
                    CourseConfig courseConfig = course.getCourseConfig();
                    if (courseConfig.isSharedFolderReadOnlyMount()) {
                        container.setLocalSecurityCallback(new ReadOnlyCallback());
                    }
                }
                break;
            }
    }
    if (container == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    VFSLeaf leaf = null;
    for (PathSegment seg : path) {
        VFSItem item = container.resolve(seg.getPath());
        if (item instanceof VFSLeaf) {
            leaf = (VFSLeaf) item;
            break;
        } else if (item instanceof VFSContainer) {
            container = (VFSContainer) item;
        }
    }
    if (leaf != null) {
        Date lastModified = new Date(leaf.getLastModified());
        Response.ResponseBuilder response = request.evaluatePreconditions(lastModified);
        if (response == null) {
            String mimeType = WebappHelper.getMimeType(leaf.getName());
            if (mimeType == null)
                mimeType = MediaType.APPLICATION_OCTET_STREAM;
            response = Response.ok(leaf.getInputStream(), mimeType).lastModified(lastModified).cacheControl(cc);
        }
        return response.build();
    }
    List<VFSItem> items = container.getItems(new SystemItemFilter());
    int count = 0;
    LinkVO[] links = new LinkVO[items.size()];
    for (VFSItem item : items) {
        UriBuilder baseUriBuilder = uriInfo.getBaseUriBuilder();
        UriBuilder repoUri = baseUriBuilder.path(CourseResourceFolderWebService.class).path("files");
        if (type.equals(FolderType.SHARED_FOLDER) && re != null) {
            repoUri = baseUriBuilder.replacePath("restapi").path(SharedFolderWebService.class).path(re.getKey().toString()).path("files");
        }
        for (PathSegment pathSegment : path) {
            repoUri.path(pathSegment.getPath());
        }
        String uri = repoUri.path(item.getName()).build(courseId).toString();
        links[count++] = new LinkVO("self", uri, item.getName());
    }
    return Response.ok(links).build();
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) SharedFolderWebService(org.olat.restapi.repository.SharedFolderWebService) VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResource(org.olat.resource.OLATResource) VFSItem(org.olat.core.util.vfs.VFSItem) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) PathSegment(javax.ws.rs.core.PathSegment) SystemItemFilter(org.olat.core.util.vfs.filters.SystemItemFilter) Date(java.util.Date) CourseConfig(org.olat.course.config.CourseConfig) Response(javax.ws.rs.core.Response) LinkVO(org.olat.restapi.support.vo.LinkVO) UriBuilder(javax.ws.rs.core.UriBuilder) RepositoryService(org.olat.repository.RepositoryService)

Example 8 with CourseConfig

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

the class ObjectFactory method getConfig.

public static CourseConfigVO getConfig(ICourse course) {
    CourseConfigVO vo = new CourseConfigVO();
    CourseConfig config = course.getCourseEnvironment().getCourseConfig();
    vo.setCalendar(new Boolean(config.isCalendarEnabled()));
    vo.setChat(new Boolean(config.isChatEnabled()));
    vo.setCssLayoutRef(config.getCssLayoutRef());
    vo.setEfficencyStatement(new Boolean(config.isEfficencyStatementEnabled()));
    vo.setGlossarySoftkey(config.getGlossarySoftKey());
    vo.setSharedFolderSoftKey(config.getSharedFolderSoftkey());
    return vo;
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) CourseConfig(org.olat.course.config.CourseConfig)

Example 9 with CourseConfig

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

the class CourseController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    openCourse = uifactory.addFormLink("open.course", formLayout, Link.BUTTON);
    openCourse.setIconLeftCSS("o_icon o_CourseModule_icon");
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("courseName", StringHelper.escapeHtml(course.getDisplayname()));
    }
    // add the table
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    if (isAdministrativeUser) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.name, "select"));
    }
    int colIndex = UserListController.USER_PROPS_OFFSET;
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = userManager.isMandatoryUserProperty(UserListController.usageIdentifyer, userPropertyHandler);
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex++, "select", true, userPropertyHandler.i18nColumnDescriptorLabelKey()));
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.repoName));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.passed, new PassedCellRenderer()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.score, new ScoreCellRenderer()));
    CourseConfig courseConfig = CourseFactory.loadCourse(course).getCourseConfig();
    if (courseConfig.isCertificateEnabled()) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.certificate, new DownloadCertificateCellRenderer(getLocale())));
        if (courseConfig.isRecertificationEnabled()) {
            columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.recertification, new DateFlexiCellRenderer(getLocale())));
        }
    }
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.lastModification));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Columns.lastUserModified));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, Columns.lastCoachModified));
    model = new EfficiencyStatementEntryTableDataModel(columnsModel);
    tableEl = uifactory.addTableElement(getWindowControl(), "table", model, 20, false, getTranslator(), formLayout);
    tableEl.setExportEnabled(true);
    tableEl.setEmtpyTableMessageKey("error.no.found");
    tableEl.setAndLoadPersistedPreferences(ureq, "fCourseController");
}
Also used : DateFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer) ScoreCellRenderer(org.olat.modules.assessment.ui.ScoreCellRenderer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) PassedCellRenderer(org.olat.course.assessment.bulk.PassedCellRenderer) DownloadCertificateCellRenderer(org.olat.course.certificate.ui.DownloadCertificateCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) CourseConfig(org.olat.course.config.CourseConfig)

Example 10 with CourseConfig

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

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

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