Search in sources :

Example 51 with CourseConfig

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

the class EfficiencyStatementManagerTest method testBigDatas.

@Test
public void testBigDatas() {
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters();
    params.setRoles(new Roles(true, false, false, false, false, false, false));
    params.setResourceTypes(Collections.singletonList("CourseModule"));
    List<RepositoryEntry> entries = repositoryManager.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    List<Identity> loadIdentities = securityManager.getVisibleIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, 0, 10000);
    int count = 0;
    for (RepositoryEntry entry : entries) {
        Long resourceableId = entry.getOlatResource().getResourceableId();
        try {
            ICourse course = CourseFactory.loadCourse(resourceableId);
            boolean enabled = course.getCourseEnvironment().getCourseConfig().isEfficencyStatementEnabled();
            if (!enabled) {
                course = CourseFactory.openCourseEditSession(entry.getOlatResource().getResourceableId());
                CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
                courseConfig.setEfficencyStatementIsEnabled(true);
                CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
                CourseFactory.saveCourse(course.getResourceableId());
                CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
            }
            DBFactory.getInstance().commitAndCloseSession();
            try {
                int fromIndex = (int) (Math.random() * loadIdentities.size() - 1);
                if (fromIndex < 100) {
                    fromIndex = 100;
                }
                List<Identity> assessedIdentities = loadIdentities.subList(fromIndex - 100, fromIndex);
                // force the storing of the efficiencyStatement - this is usually done only at Learnresource/modify properties/Efficiency statement (ON)
                RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
                efficiencyStatementManager.updateEfficiencyStatements(courseEntry, assessedIdentities);
            } catch (Exception e) {
                e.printStackTrace();
            }
            DBFactory.getInstance().commitAndCloseSession();
            DBFactory.getInstance().closeSession();
        } catch (CorruptedCourseException e) {
            System.out.println("Error");
        }
        if (count++ % 100 == 0) {
            dbInstance.commitAndCloseSession();
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CorruptedCourseException(org.olat.course.CorruptedCourseException) CourseConfig(org.olat.course.config.CourseConfig) CorruptedCourseException(org.olat.course.CorruptedCourseException) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 52 with CourseConfig

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

the class CourseWebService method updateConfiguration.

/**
 * Update the course configuration
 * @response.representation.200.qname {http://www.example.com}courseConfigVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The metadatas of the created course
 * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSECONFIGVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course not found
 * @param courseId The course resourceable's id
 * @param calendar Enable/disable the calendar (value: true/false) (optional)
 * @param chat Enable/disable the chat (value: true/false) (optional)
 * @param cssLayoutRef Set the custom CSS file for the layout (optional)
 * @param efficencyStatement Enable/disable the efficencyStatement (value: true/false) (optional)
 * @param glossarySoftkey Set the glossary (optional)
 * @param sharedFolderSoftkey Set the shared folder (optional)
 * @param request The HTTP request
 * @return It returns the XML/Json representation of the <code>CourseConfig</code>
 *         object representing the course configuration.
 */
@POST
@Path("configuration")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response updateConfiguration(@PathParam("courseId") Long courseId, @FormParam("calendar") Boolean calendar, @FormParam("chat") Boolean chat, @FormParam("cssLayoutRef") String cssLayoutRef, @FormParam("efficencyStatement") Boolean efficencyStatement, @FormParam("glossarySoftkey") String glossarySoftkey, @FormParam("sharedFolderSoftkey") String sharedFolderSoftkey, @Context HttpServletRequest request) {
    if (!isAuthor(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    ICourse editedCourse = CourseFactory.openCourseEditSession(courseId);
    // change course config
    CourseConfig courseConfig = editedCourse.getCourseEnvironment().getCourseConfig();
    if (calendar != null) {
        courseConfig.setCalendarEnabled(calendar.booleanValue());
    }
    if (chat != null) {
        courseConfig.setChatIsEnabled(chat.booleanValue());
    }
    if (StringHelper.containsNonWhitespace(cssLayoutRef)) {
        courseConfig.setCssLayoutRef(cssLayoutRef);
    }
    if (efficencyStatement != null) {
        courseConfig.setEfficencyStatementIsEnabled(efficencyStatement.booleanValue());
    }
    if (StringHelper.containsNonWhitespace(glossarySoftkey)) {
        courseConfig.setGlossarySoftKey(glossarySoftkey);
    }
    if (StringHelper.containsNonWhitespace(sharedFolderSoftkey)) {
        courseConfig.setSharedFolderSoftkey(sharedFolderSoftkey);
    }
    CourseFactory.setCourseConfig(editedCourse.getResourceableId(), courseConfig);
    CourseFactory.closeCourseEditSession(editedCourse.getResourceableId(), true);
    CourseConfigVO vo = ObjectFactory.getConfig(editedCourse);
    return Response.ok(vo).build();
}
Also used : CourseConfigVO(org.olat.restapi.support.vo.CourseConfigVO) ICourse(org.olat.course.ICourse) CourseConfig(org.olat.course.config.CourseConfig) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 53 with CourseConfig

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

the class UserCalendarWebService method getCalendars.

private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
    Roles roles = ureq.getUserSession().getRoles();
    Identity retrievedUser = ureq.getIdentity();
    CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
    if (calendarModule.isEnabled()) {
        if (calendarModule.isEnablePersonalCalendar()) {
            KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
            calVisitor.visit(personalWrapper);
        }
        if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
            RepositoryManager rm = RepositoryManager.getInstance();
            ACService acManager = CoreSpringFactory.getImpl(ACService.class);
            SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
            repoParams.setOnlyExplicitMember(true);
            repoParams.setIdentity(retrievedUser);
            IdentityEnvironment ienv = new IdentityEnvironment();
            ienv.setIdentity(retrievedUser);
            ienv.setRoles(roles);
            List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
            for (RepositoryEntry entry : entries) {
                AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
                if (result.isAccessible()) {
                    try {
                        final ICourse course = CourseFactory.loadCourse(entry);
                        CourseConfig config = course.getCourseEnvironment().getCourseConfig();
                        UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
                        if (config.isCalendarEnabled()) {
                            KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
                            calVisitor.visit(wrapper);
                        } else {
                            CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
                            new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
                            if (visitor.isFound()) {
                                KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
                                calVisitor.visit(wrapper);
                            }
                        }
                    } catch (Exception e) {
                        log.error("", e);
                    }
                }
            }
        }
        if (calendarModule.isEnableGroupCalendar()) {
            CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
            // start found forums in groups
            BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
            SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
            params.addTools(CollaborationTools.TOOL_CALENDAR);
            List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
            for (BusinessGroup group : groups) {
                KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
                calVisitor.visit(wrapper);
            }
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) CourseTreeVisitor(org.olat.course.run.userview.CourseTreeVisitor) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) WebApplicationException(javax.ws.rs.WebApplicationException) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) CourseConfig(org.olat.course.config.CourseConfig) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) ACService(org.olat.resource.accesscontrol.ACService) AccessResult(org.olat.resource.accesscontrol.AccessResult) CalendarModule(org.olat.commons.calendar.CalendarModule) RepositoryManager(org.olat.repository.RepositoryManager) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Example 54 with CourseConfig

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

the class CourseLayoutHelper method getCSSBaseFolder.

/**
 * get configured path for this courseEnvironment
 * @param courseEnvironment
 * @return
 */
public static VFSContainer getCSSBaseFolder(CourseEnvironment courseEnvironment) {
    CourseConfig courseConfig = courseEnvironment.getCourseConfig();
    String cssSet = courseConfig.getCssLayoutRef();
    return getThemeBaseFolder(courseEnvironment, cssSet);
}
Also used : CourseConfig(org.olat.course.config.CourseConfig)

Example 55 with CourseConfig

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

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)

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