use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class MultiSPController method create.
private void create(MultipleSelectionElement selection, ICourse course, CourseNode parentNode) {
SelectNodeObject node = (SelectNodeObject) selection.getUserObject();
if (selection.isMultiselect() && selection.isSelected(0)) {
VFSItem item = node.getItem();
CourseNode newNode = null;
if (item instanceof VFSLeaf) {
// create node
newNode = createCourseNode(item, "sp");
ModuleConfiguration moduleConfig = newNode.getModuleConfiguration();
String path = getRelativePath(item);
moduleConfig.set(SPEditController.CONFIG_KEY_FILE, path);
moduleConfig.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, true);
} else if (item instanceof VFSContainer) {
// add structure
newNode = createCourseNode(item, "st");
}
int pos = -1;
if (position >= 0 && selectedNode.getCourseNode().getIdent().equals(parentNode.getIdent())) {
pos = position++;
}
if (pos < 0 || pos >= parentNode.getChildCount()) {
course.getEditorTreeModel().addCourseNode(newNode, parentNode);
} else {
course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode, pos);
}
if (item instanceof VFSContainer) {
parentNode = newNode;
}
}
// recurse
for (MultipleSelectionElement childElement : node.getChildren()) {
create(childElement, course, parentNode);
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class BCWebService method getFolder.
/**
* Retrieves metadata of the course node
* @response.representation.200.qname {http://www.example.com}folderVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The course node metadatas
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_FOLDERVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or parentNode not found
* @param courseId The course resourceable's id
* @param nodeId The node's id
* @param httpRequest The HTTP request
* @return The persisted structure element (fully populated)
*/
@GET
@Path("{nodeId}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getFolder(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) {
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!CourseWebService.isCourseAccessible(course, false, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CourseNode courseNode = course.getRunStructure().getNode(nodeId);
if (courseNode == null || !(courseNode instanceof BCCourseNode)) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
UserRequest ureq = getUserRequest(httpRequest);
boolean accessible = (new CourseTreeVisitor(course, ureq.getUserSession().getIdentityEnvironment())).isAccessible(courseNode, new VisibleTreeFilter());
if (accessible) {
Set<String> subscribed = new HashSet<String>();
NotificationsManager man = NotificationsManager.getInstance();
List<String> notiTypes = Collections.singletonList("FolderModule");
List<Subscriber> subs = man.getSubscribers(ureq.getIdentity(), notiTypes);
for (Subscriber sub : subs) {
Long courseKey = sub.getPublisher().getResId();
if (courseId.equals(courseKey)) {
subscribed.add(sub.getPublisher().getSubidentifier());
}
}
FolderVO folderVo = createFolderVO(ureq.getUserSession().getIdentityEnvironment(), course, (BCCourseNode) courseNode, subscribed);
return Response.ok(folderVo).build();
} else {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class CourseRuntimeController method doEdit.
@Override
protected void doEdit(UserRequest ureq) {
if ((reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR))) {
removeCustomCSS();
popToRoot(ureq);
cleanUp();
CourseNode currentCourseNode = getCurrentCourseNode();
WindowControl bwControl = getSubWindowControl("Editor");
EditorMainController ctrl = CourseFactory.createEditorController(ureq, addToHistory(ureq, bwControl), toolbarPanel, getRepositoryEntry(), currentCourseNode);
// user activity logger which was initialized with course run
if (ctrl != null) {
editorCtrl = pushController(ureq, "Editor", ctrl);
listenTo(editorCtrl);
setIsInEditor(true);
currentToolCtr = editorCtrl;
setActiveTool(editLink);
}
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class CourseRuntimeController method initTools.
private void initTools(Dropdown tools, ICourse course, final UserCourseEnvironmentImpl uce) {
// 1) administrative tools
if (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) || hasCourseRight(CourseRights.RIGHT_MEMBERMANAGEMENT) || hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || hasCourseRight(CourseRights.RIGHT_ARCHIVING) || hasCourseRight(CourseRights.RIGHT_STATISTICS) || hasCourseRight(CourseRights.RIGHT_DB) || hasCourseRight(CourseRights.RIGHT_ASSESSMENT) || hasCourseRight(CourseRights.RIGHT_ASSESSMENT_MODE)) {
tools.setI18nKey("header.tools");
tools.setElementCssClass("o_sel_course_tools");
if (uce != null && (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR))) {
boolean managed = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.editcontent);
boolean readOnly = uce.isCourseReadOnly();
editLink = LinkFactory.createToolLink("edit.cmd", translate("command.openeditor"), this, "o_icon_courseeditor");
editLink.setElementCssClass("o_sel_course_editor");
editLink.setEnabled(!corrupted && !managed);
editLink.setVisible(!readOnly);
tools.addComponent(editLink);
folderLink = LinkFactory.createToolLink("cfd", translate("command.coursefolder"), this, "o_icon_coursefolder");
folderLink.setElementCssClass("o_sel_course_folder");
tools.addComponent(folderLink);
tools.addComponent(new Spacer(""));
}
if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || hasCourseRight(CourseRights.RIGHT_MEMBERMANAGEMENT)) {
membersLink = LinkFactory.createToolLink("unifiedusermngt", translate("command.opensimplegroupmngt"), this, "o_icon_membersmanagement");
membersLink.setElementCssClass("o_sel_course_members");
tools.addComponent(membersLink);
}
if (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach() || hasCourseRight(CourseRights.RIGHT_ASSESSMENT)) {
assessmentLink = LinkFactory.createToolLink("assessment", translate("command.openassessment"), this, "o_icon_assessment_tool");
assessmentLink.setElementCssClass("o_sel_course_assessment_tool");
tools.addComponent(assessmentLink);
}
if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_ARCHIVING)) {
archiverLink = LinkFactory.createToolLink("archiver", translate("command.openarchiver"), this, "o_icon_archive_tool");
tools.addComponent(archiverLink);
}
tools.addComponent(new Spacer(""));
if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_STATISTICS)) {
courseStatisticLink = LinkFactory.createToolLink("statistic", translate("command.openstatistic"), this, "o_icon_statistics_tool");
tools.addComponent(courseStatisticLink);
}
if (uce != null && (reSecurity.isEntryAdmin() || reSecurity.isCourseCoach() || reSecurity.isGroupCoach() || hasCourseRight(CourseRights.RIGHT_STATISTICS))) {
final AtomicInteger testNodes = new AtomicInteger();
final AtomicInteger surveyNodes = new AtomicInteger();
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
if (((CourseNode) node).isStatisticNodeResultAvailable(uce, QTIType.test, QTIType.onyx)) {
testNodes.incrementAndGet();
} else if (((CourseNode) node).isStatisticNodeResultAvailable(uce, QTIType.survey)) {
surveyNodes.incrementAndGet();
}
}
}, course.getRunStructure().getRootNode(), true).visitAll();
if (testNodes.intValue() > 0) {
testStatisticLink = LinkFactory.createToolLink("qtistatistic", translate("command.openteststatistic"), this, "o_icon_statistics_tool");
tools.addComponent(testStatisticLink);
}
if (surveyNodes.intValue() > 0) {
surveyStatisticLink = LinkFactory.createToolLink("qtistatistic", translate("command.opensurveystatistic"), this, "o_icon_statistics_tool");
tools.addComponent(surveyStatisticLink);
}
}
tools.addComponent(new Spacer(""));
if (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_COURSEEDITOR)) {
areaLink = LinkFactory.createToolLink("careas", translate("command.courseareas"), this, "o_icon_courseareas");
areaLink.setElementCssClass("o_sel_course_areas");
tools.addComponent(areaLink);
}
if (courseDBManager.isEnabled() && (reSecurity.isEntryAdmin() || hasCourseRight(CourseRights.RIGHT_DB))) {
dbLink = LinkFactory.createToolLink("customDb", translate("command.opendb"), this, "o_icon_coursedb");
tools.addComponent(dbLink);
}
ordersLink = LinkFactory.createToolLink("bookings", translate("details.orders"), this, "o_sel_repo_booking");
ordersLink.setIconLeftCSS("o_icon o_icon-fw o_icon_booking");
ordersLink.setElementCssClass("o_sel_course_ac_tool");
boolean booking = acService.isResourceAccessControled(getRepositoryEntry().getOlatResource(), null);
ordersLink.setVisible(!corrupted && booking);
tools.addComponent(ordersLink);
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class CourseEditorTreeModel method buildUp.
private CourseNode buildUp(CourseEditorTreeNode cetn) {
CourseNode attachedNode = cetn.getCourseNode();
// clone current
CourseNode cloneCn = (CourseNode) ObjectCloner.deepCopy(attachedNode);
// visit all children
int chdCnt = cetn.getChildCount();
for (int i = 0; i < chdCnt; i++) {
CourseEditorTreeNode child = cetn.getCourseEditorTreeNodeChildAt(i);
// only add if not deleted and configuration is valid
if (!child.isDeleted() && !(child.getCourseNode().isConfigValid().isError())) {
CourseNode res = buildUp(child);
cloneCn.addChild(res);
}
}
return cloneCn;
}
Aggregations