Search in sources :

Example 6 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class RunMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (needsRebuildAfter) {
        currentCourseNode = updateAfterChanges(currentCourseNode);
        needsRebuildAfter = false;
    }
    if (source == currentNodeController) {
        if (event instanceof OlatCmdEvent) {
            OlatCmdEvent oe = (OlatCmdEvent) event;
            String cmd = oe.getCommand();
            if (OlatCmdEvent.GOTONODE_CMD.equals(cmd)) {
                // "69680861018558/node-specific-data";
                String subcmd = oe.getSubcommand();
                CourseNode identNode;
                String nodecmd = null;
                int slPos = subcmd.indexOf('/');
                if (slPos != -1) {
                    nodecmd = subcmd.substring(slPos + 1);
                    identNode = course.getRunStructure().getNode(subcmd.substring(0, slPos));
                } else {
                    identNode = course.getRunStructure().getNode(subcmd);
                }
                if (identNode == null) {
                    showWarning("msg.nodenotavailableanymore");
                } else {
                    addLoggingResourceable(LoggingResourceable.wrap(identNode));
                    currentCourseNode = identNode;
                    updateTreeAndContent(ureq, identNode, nodecmd);
                    oe.accept();
                }
            }
        } else if (event == Event.DONE_EVENT) {
            // preconditions may have changed
            if (needsRebuildAfterRunDone) {
                needsRebuildAfterRunDone = false;
                updateTreeAndContent(ureq, currentCourseNode, null);
            }
        } else if (REBUILD.equals(event.getCommand())) {
            needsRebuildAfterRunDone = false;
            updateTreeAndContent(ureq, currentCourseNode, null);
        } else if (event instanceof TreeNodeEvent) {
            TreeNodeEvent tne = (TreeNodeEvent) event;
            TreeNode newCpTreeNode = tne.getChosenTreeNode();
            luTree.setSelectedNodeId(newCpTreeNode.getIdent());
        } else if (event == Event.CHANGED_EVENT) {
            updateTreeAndContent(ureq, currentCourseNode, null);
        } else if (event instanceof BusinessGroupModifiedEvent) {
            fireEvent(ureq, event);
            updateTreeAndContent(ureq, currentCourseNode, null);
        }
    }
}
Also used : OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) CourseNode(org.olat.course.nodes.CourseNode) TreeNodeEvent(org.olat.modules.cp.TreeNodeEvent) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 7 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class RunMainController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component,
 *      org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (needsRebuildAfter) {
        currentCourseNode = updateAfterChanges(currentCourseNode);
        needsRebuildAfter = false;
    }
    // Links in editTools dropdown
    if (nextLink == source) {
        doNext(ureq);
    } else if (previousLink == source) {
        doPrevious(ureq);
    } else if (source == luTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED) || event.getCommand().equals(MenuTree.COMMAND_TREENODE_EXPANDED)) {
            TreeEvent tev = (TreeEvent) event;
            doNodeClick(ureq, tev);
        }
    } else if (source == coursemain) {
        if ("activateCourseNode".equals(event.getCommand())) {
            // Events from the JS function o_activateCourseNode() - activate the given node id
            String nodeid = ureq.getParameter("nodeid");
            if (nodeid != null) {
                CourseNode identNode = course.getRunStructure().getNode(nodeid);
                CourseNode node = updateTreeAndContent(ureq, identNode, null);
                if (node != null) {
                    currentCourseNode = node;
                } else {
                    getWindowControl().setWarning(translate("msg.nodenotavailableanymore"));
                }
            }
        }
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) CourseNode(org.olat.course.nodes.CourseNode)

Example 8 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class CourseSite method createController.

@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
    RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
    if (entry == null) {
        return getAlternativeController(ureq, wControl, config);
    }
    MainLayoutController c;
    ICourse course = CourseFactory.loadCourse(entry);
    UserSession usess = ureq.getUserSession();
    // course-launch-state depending course-settings
    RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
    boolean isAllowedToLaunch = reSecurity.canLaunch();
    boolean hasAccess = false;
    if (isAllowedToLaunch) {
        // either check with securityCallback or use access-settings from course-nodes
        if (siteSecCallback != null) {
            hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
        } else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
            hasAccess = false;
        } else {
            // check within course: accessibility of course root node
            CourseNode rootNode = course.getRunStructure().getRootNode();
            UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
            NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
            boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
            hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
        }
    }
    // load course (admins always see content) or alternative controller if course is not launchable
    if (hasAccess || usess.getRoles().isOLATAdmin()) {
        rs.incrementLaunchCounter(entry);
        // build up the context path for linked course
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
        CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {

            @Override
            public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
                return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
            }
        }, false, true);
        // Configure run controller
        // a: don't show close link, is opened as site not tab
        runCtr.setCourseCloseEnabled(false);
        // b: don't show toolbar
        if (!showToolController) {
            runCtr.setToolControllerEnabled(false);
        }
        c = runCtr;
    } else {
        // access restricted (not in group / author) -> show controller
        // defined in olat_extensions (type autoCreator)
        c = getAlternativeController(ureq, wControl, config);
    }
    return c;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) StateSite(org.olat.core.id.context.StateSite) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) RunMainController(org.olat.course.run.RunMainController) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RunMainController(org.olat.course.run.RunMainController) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) Controller(org.olat.core.gui.control.Controller) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) UserSession(org.olat.core.util.UserSession) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryManager(org.olat.repository.RepositoryManager) CourseNode(org.olat.course.nodes.CourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) UserRequest(org.olat.core.gui.UserRequest) RepositoryService(org.olat.repository.RepositoryService)

Example 9 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class PreviewRunController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
 */
@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source == luTree) {
        if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
            TreeEvent tev = (TreeEvent) event;
            // goto node:
            // after a click in the tree, evaluate the model anew, set the tree
            // model anew, and set the selection of the tree again
            NodeClickedRef nclr = navHandler.evaluateJumpToTreeNode(ureq, getWindowControl(), treeModel, tev, this, null, currentNodeController);
            if (!nclr.isVisible()) {
                getWindowControl().setWarning(translate("warn.notvisible"));
                return;
            }
            if (nclr.isHandledBySubTreeModelListener()) {
                // not used:
                return;
            }
            // set the new treemodel
            treeModel = nclr.getTreeModel();
            luTree.setTreeModel(treeModel);
            // set the new tree selection
            luTree.setSelectedNodeId(nclr.getSelectedNodeId());
            luTree.setOpenNodeIds(nclr.getOpenNodeIds());
            // get the controller (in this case it is a preview controller). Dispose only if not already disposed in navHandler.evaluateJumpToTreeNode()
            if (nclr.getRunController() != null) {
                if (currentNodeController != null && !currentNodeController.isDisposed() && !navHandler.isListening(currentNodeController)) {
                    currentNodeController.dispose();
                }
                currentNodeController = nclr.getRunController();
            }
            CourseNode cn = nclr.getCalledCourseNode();
            if (cn != null) {
                Condition c = cn.getPreConditionVisibility();
                String visibilityExpr = (c.getConditionExpression() == null ? translate("details.visibility.none") : c.getConditionExpression());
                detail.contextPut("visibilityExpr", visibilityExpr);
                detail.contextPut("coursenode", cn);
                currentCourseNode = cn;
            }
            Component nodeComp = currentNodeController.getInitialComponent();
            content.setContent(nodeComp);
        }
    } else if (source == configButton) {
        fireEvent(ureq, new Event("command.config"));
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Condition(org.olat.course.condition.Condition) TreeEvent(org.olat.core.gui.components.tree.TreeEvent) Event(org.olat.core.gui.control.Event) OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) CourseNode(org.olat.course.nodes.CourseNode) NodeClickedRef(org.olat.course.run.navigation.NodeClickedRef) Component(org.olat.core.gui.components.Component)

Example 10 with CourseNode

use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.

the class AttemptsRuleEditor method searchAttemptableNodes.

private void searchAttemptableNodes(CourseNode courseNode, List<CourseNode> nodes) {
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasAttemptsConfigured()) {
            nodes.add(courseNode);
        }
    } else if (courseNode instanceof QTICourseNode) {
        QTICourseNode assessableCourseNode = (QTICourseNode) courseNode;
        if (assessableCourseNode.hasAttemptsConfigured()) {
            nodes.add(courseNode);
        }
    }
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        searchAttemptableNodes(child, nodes);
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) QTICourseNode(org.olat.course.nodes.QTICourseNode) QTICourseNode(org.olat.course.nodes.QTICourseNode)

Aggregations

CourseNode (org.olat.course.nodes.CourseNode)402 ICourse (org.olat.course.ICourse)182 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)98 Identity (org.olat.core.id.Identity)74 STCourseNode (org.olat.course.nodes.STCourseNode)72 ArrayList (java.util.ArrayList)68 RepositoryEntry (org.olat.repository.RepositoryEntry)64 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)54 INode (org.olat.core.util.nodes.INode)44 GTACourseNode (org.olat.course.nodes.GTACourseNode)44 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)42 TACourseNode (org.olat.course.nodes.TACourseNode)40 TreeNode (org.olat.core.gui.components.tree.TreeNode)38 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)36 MSCourseNode (org.olat.course.nodes.MSCourseNode)36 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)30 Test (org.junit.Test)28 AbstractAccessableCourseNode (org.olat.course.nodes.AbstractAccessableCourseNode)28 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)28 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)26