use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CoursesWebService method prepareCourse.
private static ICourse prepareCourse(RepositoryEntry addedEntry, String shortTitle, String longTitle, CourseConfigVO courseConfigVO) {
// set root node title
String courseShortTitle = addedEntry.getDisplayname();
if (StringHelper.containsNonWhitespace(shortTitle)) {
courseShortTitle = shortTitle;
}
String courseLongTitle = addedEntry.getDisplayname();
if (StringHelper.containsNonWhitespace(longTitle)) {
courseLongTitle = longTitle;
}
ICourse course = CourseFactory.openCourseEditSession(addedEntry.getOlatResource().getResourceableId());
course.getRunStructure().getRootNode().setShortTitle(Formatter.truncate(courseShortTitle, 25));
course.getRunStructure().getRootNode().setLongTitle(courseLongTitle);
CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
rootNode.setShortTitle(Formatter.truncate(courseShortTitle, 25));
rootNode.setLongTitle(courseLongTitle);
if (courseConfigVO != null) {
CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
if (StringHelper.containsNonWhitespace(courseConfigVO.getSharedFolderSoftKey())) {
courseConfig.setSharedFolderSoftkey(courseConfigVO.getSharedFolderSoftKey());
}
if (courseConfigVO.getCalendar() != null) {
courseConfig.setCalendarEnabled(courseConfigVO.getCalendar().booleanValue());
}
if (courseConfigVO.getChat() != null) {
courseConfig.setChatIsEnabled(courseConfigVO.getChat().booleanValue());
}
if (courseConfigVO.getEfficencyStatement() != null) {
courseConfig.setEfficencyStatementIsEnabled(courseConfigVO.getEfficencyStatement().booleanValue());
}
if (StringHelper.containsNonWhitespace(courseConfigVO.getCssLayoutRef())) {
courseConfig.setCssLayoutRef(courseConfigVO.getCssLayoutRef());
}
if (StringHelper.containsNonWhitespace(courseConfigVO.getGlossarySoftkey())) {
courseConfig.setGlossarySoftKey(courseConfigVO.getGlossarySoftkey());
}
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
}
CourseFactory.saveCourse(course.getResourceableId());
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
return CourseFactory.loadCourse(addedEntry);
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class CourseRuntimeController method launchGlossary.
private void launchGlossary(UserRequest ureq) {
// start glossary in window
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
// do not cache cc, not save
final CourseConfig cc = course.getCourseConfig();
final boolean allowGlossaryEditing = reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GLOSSARY);
// if glossary had been opened from LR as Tab before, warn user:
DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false);
DTab dt = dts.getDTab(repoEntry.getOlatResource());
if (dt != null) {
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType(allowGlossaryEditing ? "true" : "false");
dts.activate(ureq, dt, entries);
} else {
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController(lwControl, lureq, cc, allowGlossaryEditing);
listenTo(glossaryController);
if (glossaryController == null) {
// happens in the unlikely event of a user who is in a course and
// now
// tries to access the glossary
String text = translate("error.noglossary");
return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text);
} else {
// use a one-column main layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, glossaryController);
// dispose glossary on layout dispose
layoutCtr.addDisposableChildController(glossaryController);
return layoutCtr;
}
}
};
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
openInNewBrowserWindow(ureq, layoutCtrlr);
// immediate return after opening new browser window!
return;
}
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
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);
}
}
Aggregations