Search in sources :

Example 31 with Condition

use of org.olat.course.condition.Condition 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 32 with Condition

use of org.olat.course.condition.Condition in project openolat by klemens.

the class FeedNodeEditController method event.

@Override
public void event(UserRequest urequest, Controller source, Event event) {
    if (source == moderatroCtr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = moderatroCtr.getCondition();
            node.setPreConditionModerator(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == posterCtr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = posterCtr.getCondition();
            node.setPreConditionPoster(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == readerCtr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = readerCtr.getCondition();
            node.setPreConditionReader(cond);
            fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == searchController) {
        cmc.deactivate();
        // repository search controller done
        if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
            RepositoryEntry re = searchController.getSelectedEntry();
            if (re != null) {
                config.set(AbstractFeedCourseNode.CONFIG_KEY_REPOSITORY_SOFTKEY, re.getSoftkey());
                contentVC.contextPut("showPreviewLink", Boolean.TRUE);
                String displayname = StringHelper.escapeHtml(re.getDisplayname());
                previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, contentVC, this);
                previewLink.setIconLeftCSS("o_icon o_icon-fw o_icon_preview");
                previewLink.setCustomEnabledLinkCSS("o_preview");
                previewLink.setTitle(getTranslator().translate("command.preview"));
                // no securitycheck on feeds, editable by everybody
                editLink = LinkFactory.createButtonSmall("edit", contentVC, this);
                // fire event so the updated config is saved by the
                // editormaincontroller
                fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
            }
        }
    // else cancelled repo search
    } else if (source == cmcFeedCtr) {
        if (event == CloseableModalController.CLOSE_MODAL_EVENT) {
            cmcFeedCtr.dispose();
            feedController.dispose();
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 33 with Condition

use of org.olat.course.condition.Condition in project openolat by klemens.

the class GoToMeetingEditController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            courseNode.setPreConditionAccess(cond);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    }
}
Also used : Condition(org.olat.course.condition.Condition)

Example 34 with Condition

use of org.olat.course.condition.Condition in project openolat by klemens.

the class InfoCourseNode method getConditionExpressions.

@Override
public List<ConditionExpression> getConditionExpressions() {
    List<ConditionExpression> parentConditions = super.getConditionExpressions();
    List<ConditionExpression> conditions = new ArrayList<>();
    if (parentConditions != null && parentConditions.size() > 0) {
        conditions.addAll(parentConditions);
    }
    Condition editCondition = getPreConditionEdit();
    if (editCondition != null && StringHelper.containsNonWhitespace(editCondition.getConditionExpression())) {
        ConditionExpression ce = new ConditionExpression(editCondition.getConditionId());
        ce.setExpressionString(editCondition.getConditionExpression());
        conditions.add(ce);
    }
    Condition adminCondition = getPreConditionAdmin();
    if (adminCondition != null && StringHelper.containsNonWhitespace(adminCondition.getConditionExpression())) {
        ConditionExpression ce = new ConditionExpression(adminCondition.getConditionId());
        ce.setExpressionString(adminCondition.getConditionExpression());
        conditions.add(ce);
    }
    return conditions;
}
Also used : Condition(org.olat.course.condition.Condition) ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression) ArrayList(java.util.ArrayList)

Example 35 with Condition

use of org.olat.course.condition.Condition in project openolat by klemens.

the class InfoCourseNode method getPreConditionAdmin.

/**
 * Default set the write privileges to coaches and admin only
 * @return
 */
public Condition getPreConditionAdmin() {
    if (preConditionAdmin == null) {
        preConditionAdmin = new Condition();
        preConditionAdmin.setEasyModeCoachesAndAdmins(true);
        preConditionAdmin.setConditionExpression(preConditionAdmin.getConditionFromEasyModeConfiguration());
        preConditionAdmin.setExpertMode(false);
    }
    preConditionAdmin.setConditionId(ADMIN_CONDITION_ID);
    return preConditionAdmin;
}
Also used : Condition(org.olat.course.condition.Condition)

Aggregations

Condition (org.olat.course.condition.Condition)94 ModuleConfiguration (org.olat.modules.ModuleConfiguration)10 ArrayList (java.util.ArrayList)8 CourseNode (org.olat.course.nodes.CourseNode)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 ConditionExpression (org.olat.course.condition.interpreter.ConditionExpression)6 Checklist (de.bps.olat.modules.cl.Checklist)4 DeliveryOptions (org.olat.core.gui.control.generic.iframe.DeliveryOptions)4 ICourse (org.olat.course.ICourse)4 ConditionEditController (org.olat.course.condition.ConditionEditController)4 NodeEditController (org.olat.course.editor.NodeEditController)4 StatusDescription (org.olat.course.editor.StatusDescription)4 AbstractAccessableCourseNode (org.olat.course.nodes.AbstractAccessableCourseNode)4 ScoreCalculator (org.olat.course.run.scoring.ScoreCalculator)4 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)4 CourseNodeVO (org.olat.restapi.support.vo.CourseNodeVO)4 ChecklistEditController (de.bps.course.nodes.cl.ChecklistEditController)2 Checkpoint (de.bps.olat.modules.cl.Checkpoint)2 Date (java.util.Date)2 List (java.util.List)2