Search in sources :

Example 1 with CourseNodeConfiguration

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

the class AssessmentHelper method addAssessableNodesToList.

private static List<GenericTreeNode> addAssessableNodesToList(CourseNode parentCourseNode) {
    List<GenericTreeNode> result = new ArrayList<>();
    for (int i = 0; i < parentCourseNode.getChildCount(); i++) {
        CourseNode courseNode = (CourseNode) parentCourseNode.getChildAt(i);
        List<GenericTreeNode> assessableChildren = addAssessableNodesToList(courseNode);
        if (assessableChildren.size() > 0 || isAssessable(courseNode)) {
            GenericTreeNode node = new GenericTreeNode();
            node.setTitle(courseNode.getShortTitle());
            node.setUserObject(courseNode);
            CourseNodeConfiguration nodeconfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
            node.setIconCssClass(nodeconfig.getIconCSSClass());
            result.add(node);
            assessableChildren.forEach((child) -> node.addChild(child));
        }
    }
    return result;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) ArrayList(java.util.ArrayList) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 2 with CourseNodeConfiguration

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

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 3 with CourseNodeConfiguration

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

the class CourseNodeDocument method createDocument.

public static Document createDocument(SearchResourceContext searchResourceContext, CourseNode courseNode) {
    CourseNodeDocument courseNodeDocument = new CourseNodeDocument();
    // Set all know attributes
    courseNodeDocument.setResourceUrl(searchResourceContext.getResourceUrl());
    if (StringHelper.containsNonWhitespace(searchResourceContext.getDocumentType())) {
        courseNodeDocument.setDocumentType(searchResourceContext.getDocumentType());
    } else {
        courseNodeDocument.setDocumentType(TYPE);
    }
    CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(courseNode.getType());
    if (nodeConfig != null && StringHelper.containsNonWhitespace(nodeConfig.getIconCSSClass())) {
        courseNodeDocument.setCssIcon(nodeConfig.getIconCSSClass());
    } else {
        courseNodeDocument.setCssIcon("o_course_icon");
    }
    if (StringHelper.containsNonWhitespace(courseNode.getShortTitle())) {
        courseNodeDocument.setTitle(courseNode.getShortTitle());
    } else if (StringHelper.containsNonWhitespace(courseNode.getLongTitle())) {
        courseNodeDocument.setTitle(courseNode.getLongTitle());
        courseNodeDocument.setDescription(courseNode.getLongTitle());
    }
    if (StringHelper.containsNonWhitespace(courseNode.getLongTitle())) {
        courseNodeDocument.setDescription(courseNode.getLongTitle());
    }
    if (StringHelper.containsNonWhitespace(courseNode.getLearningObjectives())) {
        String objectives = courseNode.getLearningObjectives();
        objectives = FilterFactory.getHtmlTagsFilter().filter(objectives);
        courseNodeDocument.setContent(objectives);
    }
    // Get dates from parent object via context because course node has no dates
    courseNodeDocument.setCreatedDate(searchResourceContext.getCreatedDate());
    courseNodeDocument.setLastChange(searchResourceContext.getLastModified());
    courseNodeDocument.setParentContextType(searchResourceContext.getParentContextType());
    courseNodeDocument.setParentContextName(searchResourceContext.getParentContextName());
    return courseNodeDocument.getLuceneDocument();
}
Also used : CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 4 with CourseNodeConfiguration

use of org.olat.course.nodes.CourseNodeConfiguration 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 5 with CourseNodeConfiguration

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

the class CoursesFoldersTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    conn = new RestConnection();
    admin = BaseSecurityManager.getInstance().findIdentityByName("administrator");
    user = JunitTestHelper.createAndPersistIdentityAsUser("rest-cf-one");
    course1 = CoursesWebService.createEmptyCourse(admin, "course1", "course1 long name", null);
    DBFactory.getInstance().intermediateCommit();
    // create a folder
    CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration("bc");
    bcNode = newNodeConfig.getInstance();
    bcNode.setShortTitle("Folder");
    bcNode.setLearningObjectives("Folder objectives");
    bcNode.setNoAccessExplanation("You don't have access");
    course1.getEditorTreeModel().addCourseNode(bcNode, 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)

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