Search in sources :

Example 76 with ICourse

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;
}
Also used : Condition(org.olat.course.condition.Condition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) CourseNodeVO(org.olat.restapi.support.vo.CourseNodeVO) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode) ICourse(org.olat.course.ICourse) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode)

Example 77 with ICourse

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);
}
Also used : Translator(org.olat.core.gui.translator.Translator) OLATResourceable(org.olat.core.id.OLATResourceable) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) ICourse(org.olat.course.ICourse) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ViteroBookingsRunController(org.olat.modules.vitero.ui.ViteroBookingsRunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ViteroEditController(org.olat.course.nodes.vitero.ViteroEditController) ViteroPeekViewController(org.olat.course.nodes.vitero.ViteroPeekViewController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 78 with ICourse

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;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) BCCourseNode(org.olat.course.nodes.BCCourseNode)

Example 79 with ICourse

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;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CalendarManager(org.olat.commons.calendar.CalendarManager) ICourse(org.olat.course.ICourse) Roles(org.olat.core.id.Roles) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Identity(org.olat.core.id.Identity)

Example 80 with ICourse

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);
    }
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse)

Aggregations

ICourse (org.olat.course.ICourse)674 Identity (org.olat.core.id.Identity)262 RepositoryEntry (org.olat.repository.RepositoryEntry)246 CourseNode (org.olat.course.nodes.CourseNode)182 Test (org.junit.Test)158 ArrayList (java.util.ArrayList)102 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)90 Date (java.util.Date)84 URI (java.net.URI)76 HttpResponse (org.apache.http.HttpResponse)76 OLATResource (org.olat.resource.OLATResource)64 File (java.io.File)62 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)52 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)52 Produces (javax.ws.rs.Produces)48 Roles (org.olat.core.id.Roles)44 Path (javax.ws.rs.Path)42 UserRequest (org.olat.core.gui.UserRequest)42 INode (org.olat.core.util.nodes.INode)40 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)40