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