use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class AbstractCourseNodeWebService method createCourseNode.
private CourseNodeVO createCourseNode(String type, String shortTitle, String longTitle, String learningObjectives, String visibilityExpertRules, String accessExpertRules, CustomConfigDelegate delegateConfig, CourseEditSession editSession, CourseNode parentNode, Integer position) {
CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
CourseNode insertedNode = newNodeConfig.getInstance();
insertedNode.setShortTitle(shortTitle);
insertedNode.setLongTitle(longTitle);
insertedNode.setLearningObjectives(learningObjectives);
insertedNode.setNoAccessExplanation("You don't have access");
if (StringHelper.containsNonWhitespace(visibilityExpertRules)) {
Condition cond = this.createExpertCondition(CONDITION_ID_VISIBILITY, visibilityExpertRules);
insertedNode.setPreConditionVisibility(cond);
}
if (StringHelper.containsNonWhitespace(accessExpertRules) && insertedNode instanceof AbstractAccessableCourseNode) {
Condition cond = createExpertCondition(CONDITION_ID_ACCESS, accessExpertRules);
((AbstractAccessableCourseNode) insertedNode).setPreConditionAccess(cond);
}
ICourse course = editSession.getCourse();
if (delegateConfig != null) {
ModuleConfiguration moduleConfig = insertedNode.getModuleConfiguration();
delegateConfig.configure(course, insertedNode, moduleConfig);
}
if (position == null || position.intValue() < 0) {
course.getEditorTreeModel().addCourseNode(insertedNode, parentNode);
} else {
course.getEditorTreeModel().insertCourseNodeAt(insertedNode, parentNode, position);
}
CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeContaining(insertedNode);
CourseNodeVO vo = get(insertedNode);
vo.setParentId(editorNode.getParent() == null ? null : editorNode.getParent().getIdent());
return vo;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class ViteroCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller runCtr;
Roles roles = ureq.getUserSession().getRoles();
if (roles.isGuestOnly()) {
Translator trans = Util.createPackageTranslator(ViteroPeekViewController.class, ureq.getLocale());
String title = trans.translate("guestnoaccess.title");
String message = trans.translate("guestnoaccess.message");
runCtr = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
} else {
// check if user is moderator of the virtual classroom
boolean moderator = roles.isOLATAdmin();
Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
if (!moderator) {
if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
RepositoryManager rm = RepositoryManager.getInstance();
ICourse course = CourseFactory.loadCourse(key);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (re != null) {
moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
if (!moderator) {
moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
}
}
}
}
// create run controller
Long resourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resourceId);
String courseTitle = userCourseEnv.getCourseEnvironment().getCourseTitle();
runCtr = new ViteroBookingsRunController(ureq, wControl, null, ores, getIdent(), courseTitle, moderator, userCourseEnv.isCourseReadOnly());
}
Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vitero_icon");
return new NodeRunConstructionResult(controller);
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CourseOptionsController method checkForFolderNodesAdd.
private boolean checkForFolderNodesAdd(UserRequest ureq) {
OLATResourceable courseOres = entry.getOlatResource();
ICourse course = CourseFactory.loadCourse(courseOres.getResourceableId());
CourseNode rootNode = course.getCourseEnvironment().getRunStructure().getRootNode();
if (checkFolderNodes(rootNode, course) && folderNameEl.getUserObject() != null) {
folderRefAddWarnBox = activateYesNoDialog(ureq, translate("warning.folderRef.title"), "<div class=\"o_error\">" + translate("warning.folderRefAdd") + "</div>", folderRefAddWarnBox);
folderRefAddWarnBox.setCssClass("o_icon_warn");
return false;
}
return true;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CourseCalendars method getCourseCalendarWrapper.
/**
* Return only the course calendar without any group calendar
* @param ureq
* @param wControl
* @param ores
* @param ne
* @return
*/
public static KalendarRenderWrapper getCourseCalendarWrapper(UserRequest ureq, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
// add course calendar
ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
KalendarRenderWrapper courseKalendarWrapper = calendarManager.getCourseCalendar(course);
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
Identity identity = ureq.getIdentity();
Roles roles = ureq.getUserSession().getRoles();
boolean isPrivileged = !courseEnv.isCourseReadOnly() && (roles.isOLATAdmin() || courseEnv.isAdmin() || (ne != null && ne.isCapabilityAccessible(CalCourseNode.EDIT_CONDITION_ID)) || RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, cgm.getCourseEntry()));
if (isPrivileged) {
courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
courseKalendarWrapper.setPrivateEventsVisible(true);
} else {
courseKalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
courseKalendarWrapper.setPrivateEventsVisible(courseEnv.isAdmin() || courseEnv.isCoach() || courseEnv.isParticipant());
}
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(courseKalendarWrapper.getKalendar(), ureq.getIdentity());
if (config != null) {
courseKalendarWrapper.setConfiguration(config);
}
return courseKalendarWrapper;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class MultiSPController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (nodeSelections.contains(source)) {
MultipleSelectionElement nodeSelection = (MultipleSelectionElement) source;
if (nodeSelection.isMultiselect()) {
selectRec(nodeSelection, nodeSelection.isSelected(0));
}
} else if (source == selectAll) {
for (MultipleSelectionElement nodeSelection : nodeSelections) {
if (nodeSelection.isMultiselect() && !nodeSelection.isSelected(0)) {
SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
String id = treeNode.getId();
nodeSelection.select(id, true);
}
}
} else if (source == deselectAll) {
for (MultipleSelectionElement nodeSelection : nodeSelections) {
if (nodeSelection.isMultiselect() && nodeSelection.isSelected(0)) {
SelectNodeObject treeNode = (SelectNodeObject) nodeSelection.getUserObject();
String id = treeNode.getId();
nodeSelection.select(id, false);
}
}
} else if (source == asChild) {
position = -1;
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
create(rootSelection, course, selectedNode.getCourseNode());
fireEvent(ureq, Event.CHANGED_EVENT);
} else if (source == sameLevel) {
ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) selectedNode.getParent();
position = 0;
for (position = parentNode.getChildCount(); position-- > 0; ) {
if (selectedNode.getIdent().equals(parentNode.getChildAt(position).getIdent())) {
position++;
break;
}
}
create(rootSelection, course, parentNode.getCourseNode());
fireEvent(ureq, Event.CHANGED_EVENT);
} else {
super.formInnerEvent(ureq, source, event);
}
}
Aggregations