Search in sources :

Example 16 with CourseNodeConfiguration

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

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

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

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

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

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

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

the class PublishProcess method assemblePublishConfirmation.

String assemblePublishConfirmation() {
    List<String> nodeIdsToPublish = originalNodeIdsToPublish;
    StringBuilder msg = new StringBuilder();
    OLATResourceable courseRunOres = OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN, repositoryEntry.getOlatResource().getResourceableId());
    // -1: Remove myself from list
    int cnt = CoordinatorManager.getInstance().getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres) - 1;
    if (cnt > 0) {
        msg.append(translate("pbl.confirm.users", String.valueOf(cnt)));
    } else {
        msg.append(translator.translate("pbl.confirm"));
    }
    if (nodeIdsToPublish != null && nodeIdsToPublish.size() > 0) {
        msg.append("<ul class='list-unstyled'>");
        CourseEditorTreeModel cetm = course.getEditorTreeModel();
        for (int i = 0; i < nodeIdsToPublish.size(); i++) {
            msg.append("<li>");
            String nodeId = nodeIdsToPublish.get(i);
            CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(nodeId);
            CourseNode cn = cetm.getCourseNode(nodeId);
            if (cetn.isDeleted() && !cetn.isNewnode()) {
                msg.append("<i class='o_icon o_icon_delete_item'> </i> ");
            } else {
                CourseNodeConfiguration nodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfigurationEvenForDisabledBB(cn.getType());
                if (nodeConfig != null) {
                    msg.append("<i class='o_icon ").append(nodeConfig.getIconCSSClass()).append("'> </i> ");
                }
            }
            msg.append(cn.getShortTitle()).append("</li>");
        }
        msg.append("</ul>");
    }
    return msg.toString();
}
Also used : CourseEditorTreeModel(org.olat.course.tree.CourseEditorTreeModel) OLATResourceable(org.olat.core.id.OLATResourceable) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) CourseNode(org.olat.course.nodes.CourseNode) CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration)

Example 20 with CourseNodeConfiguration

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

the class CheckListStepRunnerCallback method createCourseNode.

private CourseNode createCourseNode(String shortTitle, String title, String objectives, String type) {
    CourseNodeConfiguration newNodeConfig = CourseNodeFactory.getInstance().getCourseNodeConfiguration(type);
    CourseNode newNode = newNodeConfig.getInstance();
    newNode.setShortTitle(shortTitle);
    newNode.setLongTitle(title);
    newNode.setLearningObjectives(objectives);
    newNode.setNoAccessExplanation("You don't have access");
    return newNode;
}
Also used : CourseNodeConfiguration(org.olat.course.nodes.CourseNodeConfiguration) CourseNode(org.olat.course.nodes.CourseNode) CheckListCourseNode(org.olat.course.nodes.CheckListCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode)

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