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();
}
}
}
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();
}
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);
}
}
}
}
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);
}
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;
}
Aggregations