Search in sources :

Example 26 with CourseNodeConfiguration

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

the class NodeEvaluation method build.

/**
 * 1. Calculate if the node should be accessible at all. <br/>
 * 2. If the coursenode is visible, build a treenode.
 */
public void build() {
    // if at least one access	capability is true
    for (Iterator<Boolean> iter = accesses.values().iterator(); iter.hasNext(); ) {
        Boolean entry = iter.next();
        atLeastOneAccessible = atLeastOneAccessible || entry.booleanValue();
    }
    // if the coursenode is visible, build a treenode
    if (isVisible()) {
        gtn = new GenericTreeNode(courseNode.getIdent());
        gtn.setTitle(courseNode.getShortTitle());
        gtn.setAltText(courseNode.getLongTitle());
        String type = courseNode.getType();
        CourseNodeConfiguration cnConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(type);
        if (cnConfig != null) {
            String nodeCssClass = null;
            if (courseNode.getParent() == null) {
                // Spacial case for root node
                nodeCssClass = "o_CourseModule_icon";
            } else {
                nodeCssClass = cnConfig.getIconCSSClass();
            }
            gtn.setIconCssClass(nodeCssClass);
        }
        // the current NodeEval is set into the treenode
        gtn.setUserObject(this);
        // as the userobject
        // all treenodes added here are set to be visible/accessible, since the
        // invisible are not pushed by convention
        gtn.setAccessible(true);
    }
// else treenode is null
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 27 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.

the class CoursesForumsTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    conn = new RestConnection();
    admin = BaseSecurityManager.getInstance().findIdentityByName("administrator");
    course1 = CoursesWebService.createEmptyCourse(admin, "Course forum 1", "Course forum 1 long name", null);
    DBFactory.getInstance().intermediateCommit();
    // create a folder
    CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration("fo");
    forumNode = newNodeConfig.getInstance();
    forumNode.setShortTitle("Forum");
    forumNode.setLearningObjectives("forum objectives");
    forumNode.setNoAccessExplanation("You don't have access");
    course1.getEditorTreeModel().addCourseNode(forumNode, course1.getRunStructure().getRootNode());
    CourseFactory.publishCourse(course1, RepositoryEntry.ACC_USERS, false, admin, Locale.ENGLISH);
    DBFactory.getInstance().intermediateCommit();
}
Also used : CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) Before(org.junit.Before)

Example 28 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.

the class CourseExtensionHelper method createNode.

/**
 * Creates a course node and appends it to the course. (not persisted yet)
 *
 * @param c course object
 * @param shortTitle short title for node
 * @param longTitle long title for node
 * @return created course node
 */
public static final CourseNode createNode(ICourse course, final String shortTitle, final String longTitle, final String type) {
    // create a node with default data
    CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
    CourseNode node = nodeConfig.getInstance();
    node.setShortTitle(shortTitle);
    node.setLongTitle(longTitle);
    // append node to course
    course = CourseFactory.openCourseEditSession(course.getResourceableId());
    final CourseEditorTreeModel cetm = course.getEditorTreeModel();
    final CourseNode rootNode = cetm.getCourseNode(course.getRunStructure().getRootNode().getIdent());
    course.getEditorTreeModel().addCourseNode(node, rootNode);
    CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
    CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
    OLog log = Tracing.createLoggerFor(CourseExtensionHelper.class);
    if (log.isDebug())
        log.debug("Created new course node: " + nodeConfig.getAlias());
    return node;
}
Also used : OLog(org.olat.core.logging.OLog) CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode)

Example 29 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.

the class AlternativeCourseNodeController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("alternative.choose.description");
    CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
    List<String> alternativeKeyList = new ArrayList<String>(4);
    List<String> alternativeValueList = new ArrayList<String>(4);
    for (String alt : config.getAlternativeCourseNodes()) {
        CourseNodeConfiguration altConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(alt);
        if (altConfig.isEnabled()) {
            alternativeKeyList.add(alt);
            alternativeValueList.add(altConfig.getLinkText(getLocale()));
        }
    }
    String[] alternativeKeys = alternativeKeyList.toArray(new String[alternativeKeyList.size()]);
    String[] alternativeValues = alternativeValueList.toArray(new String[alternativeValueList.size()]);
    alternativesEl = uifactory.addRadiosVertical("alternative.bbs", formLayout, alternativeKeys, alternativeValues);
    if (alternativeKeys.length == 1) {
        alternativesEl.select(alternativeKeys[0], true);
    }
    FormLayoutContainer buttonsLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsLayout);
    uifactory.addFormSubmitButton("ok", buttonsLayout);
    uifactory.addFormCancelButton("cancel", buttonsLayout, ureq, getWindowControl());
}
Also used : ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 30 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration in project openolat by klemens.

the class ChooseNodeController method doCreateNode.

private void doCreateNode(String type) {
    ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
    // user chose a position to insert a new node
    CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
    createdNode = newNodeConfig.getInstance();
    // Set some default values
    String title = new String(newNodeConfig.getLinkText(getLocale()));
    createdNode.setShortTitle(title);
    createdNode.setNoAccessExplanation(translate("form.noAccessExplanation.default"));
    // Insert it now
    CourseEditorTreeModel editorTreeModel = course.getEditorTreeModel();
    if (editorTreeModel.getRootNode().equals(currentNode)) {
        // root, add as last child
        int pos = currentNode.getChildCount();
        CourseNode selectedNode = currentNode.getCourseNode();
        editorTreeModel.insertCourseNodeAt(createdNode, selectedNode, pos);
    } else {
        CourseEditorTreeNode parentNode = (CourseEditorTreeNode) currentNode.getParent();
        CourseNode selectedNode = parentNode.getCourseNode();
        int pos = currentNode.getPosition();
        editorTreeModel.insertCourseNodeAt(createdNode, selectedNode, pos + 1);
    }
    CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
}
Also used : CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) ICourse(org.olat.course.ICourse) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode)

Aggregations

CourseNodeConfiguration (org.olat.course.nodes.CourseNodeConfiguration)38 CourseNode (org.olat.course.nodes.CourseNode)16 ICourse (org.olat.course.ICourse)10 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)8 Controller (org.olat.core.gui.control.Controller)6 CourseEditorTreeModel (org.olat.course.tree.CourseEditorTreeModel)6 ArrayList (java.util.ArrayList)4 UriBuilder (javax.ws.rs.core.UriBuilder)4 HttpResponse (org.apache.http.HttpResponse)4 HttpGet (org.apache.http.client.methods.HttpGet)4 Before (org.junit.Before)4 Test (org.junit.Test)4 PublisherData (org.olat.core.commons.services.notifications.PublisherData)4 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)4 SubscriptionInfoVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionInfoVO)4 SubscriptionListItemVO (org.olat.core.commons.services.notifications.restapi.vo.SubscriptionListItemVO)4 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)4 Identity (org.olat.core.id.Identity)4 STCourseNode (org.olat.course.nodes.STCourseNode)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4