Search in sources :

Example 56 with CourseNode

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

the class EditorMainController 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) {
    try {
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        if (source == nodeEditCntrllr) {
            // event from the tabbed pane (any tab)
            if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
                // if the user changed the name of the node, we need to update the tree also.
                // the event is too generic to find out what happened -> update tree in all cases (applies to ajax mode only)
                menuTree.setDirty(true);
                cetm.nodeConfigChanged(menuTree.getSelectedNode());
                CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
                euce.getCourseEditorEnv().validateCourse();
                StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
                updateCourseStatusMessages(ureq.getLocale(), courseStatus);
            }
        } else if (source == statusCtr) {
            if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
                doStartHelpWizard(ureq, event);
            }
            calloutCtrl.deactivate();
            cleanUp();
        } else if (source == chooseNodeTypeCtr) {
            cmc.deactivate();
            String cmd = event.getCommand();
            if (cmd.startsWith(TB_ACTION)) {
                CourseNode newNode = chooseNodeTypeCtr.getCreatedNode();
                cleanUp();
                doInsert(ureq, newNode);
            } else if (CMD_MULTI_SP.equals(cmd)) {
                cleanUp();
                launchSinglePagesWizard(ureq, course);
            } else if (CMD_MULTI_CHECKLIST.equals(cmd)) {
                cleanUp();
                launchChecklistsWizard(ureq);
            }
        } else if (source == publishStepsController) {
            getWindowControl().pop();
            Object requestOnClose = publishStepsController.getRunContext().get("requestOnClose");
            removeAsListenerAndDispose(publishStepsController);
            publishStepsController = null;
            // reset to root node... may have published a deleted node -> this
            // resets the view
            // else Event.DONE -> nothing changed / else Event.CANCELLED -> cancelled wizard
            updateAfterPublishing(ureq, course, event == Event.CHANGED_EVENT);
            if (Boolean.TRUE.equals(requestOnClose)) {
                fireEvent(ureq, Event.DONE_EVENT);
            }
        } else if (source == quickPublishCtr) {
            if (event == Event.CANCELLED_EVENT) {
                cmc.deactivate();
                fireEvent(ureq, Event.DONE_EVENT);
            } else if (event == MANUAL_PUBLISH) {
                cmc.deactivate();
                launchPublishingWizard(ureq, course, true);
            } else if (event == Event.CHANGED_EVENT) {
                updateAfterPublishing(ureq, course, event == Event.CHANGED_EVENT);
                cleanUpNodeController();
                cmc.deactivate();
                fireEvent(ureq, Event.DONE_EVENT);
            }
        } else if (source == previewController) {
            if (event == Event.DONE_EVENT) {
                // no need to deactivate preview controller, already done internally
                removeAsListenerAndDispose(previewController);
                previewController = null;
            }
        } else if (source == checklistWizard) {
            if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                getWindowControl().pop();
                removeAsListenerAndDispose(checklistWizard);
                checklistWizard = null;
                if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                    menuTree.setDirty(true);
                    CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
                    euce.getCourseEditorEnv().validateCourse();
                    StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
                    updateCourseStatusMessages(ureq.getLocale(), courseStatus);
                }
            }
        } else if (source == cmc) {
            cleanUp();
        } else if (source == moveCopyController) {
            cmc.deactivate();
            if (event == Event.DONE_EVENT) {
                // setDirty when moving
                menuTree.setDirty(true);
                // Repositioning to move/copy course node
                String nodeId = moveCopyController.getCopyNodeId();
                if (nodeId != null) {
                    menuTree.setSelectedNodeId(nodeId);
                    euce.getCourseEditorEnv().setCurrentCourseNodeId(nodeId);
                    CourseNode copyNode = cetm.getCourseNode(nodeId);
                    initNodeEditor(ureq, copyNode);
                }
                euce.getCourseEditorEnv().validateCourse();
                StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
                updateCourseStatusMessages(ureq.getLocale(), courseStatus);
            } else if (event == Event.FAILED_EVENT) {
                getWindowControl().setError("Error in copy of subtree.");
            } else if (event == Event.CANCELLED_EVENT) {
            // user canceled
            }
            // aggressive clean-up
            cleanUp();
        } else if (source == deleteDialogController) {
            removeAsListenerAndDispose(deleteDialogController);
            deleteDialogController = null;
            if (DialogBoxUIFactory.isYesEvent(event)) {
                // delete confirmed
                String ident = menuTree.getSelectedNode().getIdent();
                // udpate the current node in the course editor environment
                doDelete(course, ident);
            } else {
                tabbedNodeConfig.setVisible(true);
            }
        } else if (source == multiSPChooserCtr) {
            cmc.deactivate();
            removeAsListenerAndDispose(cmc);
            removeAsListenerAndDispose(multiSPChooserCtr);
            cmc = null;
            if (event == Event.CHANGED_EVENT) {
                menuTree.setDirty(true);
                euce.getCourseEditorEnv().validateCourse();
                StatusDescription[] courseStatus = euce.getCourseEditorEnv().getCourseStatus();
                updateCourseStatusMessages(ureq.getLocale(), courseStatus);
            }
        } else if (source == alternateCtr) {
            cmc.deactivate();
            if (event == Event.DONE_EVENT) {
                CourseNode chosenNode = alternateCtr.getCourseNode();
                String selectAlternative = alternateCtr.getSelectedAlternative();
                doCreateAlternateBuildingBlock(ureq, course, chosenNode, selectAlternative);
            }
            removeAsListenerAndDispose(cmc);
            removeAsListenerAndDispose(alternateCtr);
            cmc = null;
            alternateCtr = null;
        }
    } catch (RuntimeException e) {
        log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Controller,Event)]", e);
        this.dispose();
        throw e;
    }
}
Also used : ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode)

Example 57 with CourseNode

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

the class EditorMainController method doCreateAlternateBuildingBlock.

/**
 * The following operation are done:
 * <ul>
 * 	<li>create a new instance of the replacement type
 * 	<li>add the new element below the original element
 * 	<li>copy the element title, description and the generic configuration options
 * 	<li>copy the access, visibility and scoring rules (easy and expert)
 * 	<li>optionally copy some other configuration if this is possible at all
 * 	<li>move all child elements from the original to the replacement element
 * 	<li>mark the original element as deleted
 * </ul>
 *
 * @param chosenNode
 * @param selectAlternative
 */
private void doCreateAlternateBuildingBlock(UserRequest ureq, ICourse course, CourseNode chosenNode, String selectAlternative) {
    if (!StringHelper.containsNonWhitespace(selectAlternative))
        return;
    // create the alternative node
    CourseNodeConfiguration newConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(selectAlternative);
    CourseNode newNode = newConfig.getInstance();
    // copy configurations
    chosenNode.copyConfigurationTo(newNode, course);
    // insert the node
    CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(chosenNode.getIdent());
    CourseEditorTreeNode parentNode = (CourseEditorTreeNode) cetn.getParent();
    int position = cetn.getPosition() + 1;
    CourseEditorTreeNode newCetn = course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode.getCourseNode(), position);
    doInsert(ureq, newNode);
    // copy the children
    while (cetn.getChildCount() > 0) {
        CourseEditorTreeNode childNode = (CourseEditorTreeNode) cetn.getChildAt(0);
        newCetn.addChild(childNode);
    }
    // set all dirty
    TreeVisitor tv = new TreeVisitor(new Visitor() {

        public void visit(INode node) {
            ((CourseEditorTreeNode) node).setDirty(true);
        }
    }, newCetn, true);
    tv.visitAll();
    // mark as deleted
    doDelete(course, chosenNode.getIdent());
    // save
    CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
Also used : TreeVisitor(org.olat.core.util.tree.TreeVisitor) INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode)

Example 58 with CourseNode

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

the class EditorMainController 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) {
    try {
        ICourse course = CourseFactory.getCourseEditSession(ores.getResourceableId());
        if (source == menuTree) {
            if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
                // goto node in edit mode
                TreeEvent te = (TreeEvent) event;
                String nodeId = te.getNodeId();
                updateViewForSelectedNodeId(ureq, nodeId);
            } else if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_DROP)) {
                TreeDropEvent te = (TreeDropEvent) event;
                dropNodeAsChild(ureq, course, te.getDroppedNodeId(), te.getTargetNodeId(), te.isAsChild(), te.isAtTheEnd());
            }
        } else if (source == main) {
            if (event.getCommand().startsWith(NLS_START_HELP_WIZARD)) {
                doStartHelpWizard(ureq, event);
            }
        } else if (source == undelButton) {
            doUndelete(ureq, course);
        } else if (source == alternativeLink) {
            CourseNode chosenNode = (CourseNode) alternativeLink.getUserObject();
            askForAlternative(ureq, chosenNode);
        } else if (previewLink == source) {
            launchPreview(ureq, course);
        } else if (publishLink == source) {
            launchPublishingWizard(ureq, course, false);
        } else if (closeLink == source) {
            doReleaseEditLock();
            fireEvent(ureq, Event.DONE_EVENT);
        } else if (createNodeLink == source) {
            doOpenNodeTypeChooser(ureq);
        } else if (deleteNodeLink == source) {
            doDeleteNode(ureq);
        } else if (moveNodeLink == source) {
            doMove(ureq, course, false);
        } else if (copyNodeLink == source) {
            doMove(ureq, course, true);
        } else if (statusLink == source) {
            doOpenStatusOverview(ureq);
        }
    } catch (RuntimeException e) {
        log.warn(RELEASE_LOCK_AT_CATCH_EXCEPTION + " [in event(UserRequest,Component,Event)]", e);
        dispose();
        throw e;
    }
}
Also used : TreeEvent(org.olat.core.gui.components.tree.TreeEvent) ICourse(org.olat.course.ICourse) TreeDropEvent(org.olat.core.gui.components.tree.TreeDropEvent) CourseNode(org.olat.course.nodes.CourseNode)

Example 59 with CourseNode

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

the class MoveCopySubtreeController method recursiveCopy.

private void recursiveCopy(CourseEditorTreeNode copyFrom2, CourseEditorTreeNode insertParent, int pos, boolean firstIteration, ICourse course) {
    // create copy of course node
    CourseNode copyOfNode = copyFrom2.getCourseNode().createInstanceForCopy(firstIteration, course, getIdentity());
    copyNodeId = copyOfNode.getIdent();
    // Insert at desired position
    course.getEditorTreeModel().insertCourseNodeAt(copyOfNode, insertParent.getCourseNode(), pos);
    CourseEditorTreeNode insertedEditorTreeNode = course.getEditorTreeModel().getCourseEditorNodeById(copyOfNode.getIdent());
    for (int i = 0; i < copyFrom2.getChildCount(); i++) {
        recursiveCopy(course.getEditorTreeModel().getCourseEditorNodeById(copyFrom2.getChildAt(i).getIdent()), insertedEditorTreeNode, i, false, course);
    }
}
Also used : CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode)

Example 60 with CourseNode

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

the class GTANotifications method getItems.

public List<SubscriptionListItem> getItems() {
    Publisher p = subscriber.getPublisher();
    ICourse course = CourseFactory.loadCourse(p.getResId());
    CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
    RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    if (entry.getRepositoryEntryStatus().isClosed() || entry.getRepositoryEntryStatus().isUnpublished()) {
        return Collections.emptyList();
    }
    if (entry != null && node instanceof GTACourseNode) {
        gtaNode = (GTACourseNode) node;
        displayName = entry.getDisplayname();
        courseEnv = course.getCourseEnvironment();
        taskList = gtaManager.getTaskList(entry, gtaNode);
        if (GTAType.group.name().equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
            createBusinessGroupsSubscriptionInfo(subscriber.getIdentity());
        } else {
            createIndividualSubscriptionInfo(subscriber.getIdentity());
        }
    }
    return items;
}
Also used : GTACourseNode(org.olat.course.nodes.GTACourseNode) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry)

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