Search in sources :

Example 91 with CourseNode

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

the class ConditionConfigEasyController method addAssessmentSwitch.

private void addAssessmentSwitch(FormItemContainer formLayout) {
    assessSubContainer = FormLayoutContainer.createDefaultFormLayout("assessSubContainer", getTranslator());
    formLayout.add(assessSubContainer);
    Translator translator = getTranslator();
    final String[] assessmentSwitchKeys = new String[] { NODEPASSED_VAL_PASSED, NODEPASSED_VAL_SCORE };
    final String[] assessmentSwitchValues = new String[] { translator.translate("form.easy.assessmentSwitch.passed"), translator.translate("form.easy.assessmentSwitch.score") };
    String nodePassedInitVal = validatedCondition.getEasyModeNodePassedId();
    String cutInitStrValue = validatedCondition.getEasyModeCutValue();
    int cutInitValue = 0;
    assessmentSwitch = uifactory.addCheckboxesHorizontal("assessmentSwitch", null, formLayout, new String[] { "ison" }, new String[] { translate("form.easy.assessmentSwitch") });
    assessmentSwitch.addActionListener(FormEvent.ONCLICK);
    boolean selectedNodeIsInList = false;
    List<String> keysList = new ArrayList<String>();
    List<String> valuesList = new ArrayList<String>();
    if (nodeIdentList.size() > 0) {
        // there are nodes to be selected
        keysList.add(NO_NODE_SELECTED_IDENTIFYER);
        valuesList.add("- " + translator.translate("form.easy.nodePassed.select") + " -");
        for (int i = 0; i < nodeIdentList.size(); i++) {
            CourseNode courseNode = nodeIdentList.get(i);
            keysList.add(courseNode.getIdent());
            valuesList.add(courseNode.getShortName() + " (Id:" + courseNode.getIdent() + ")");
            if (courseNode.getIdent().equals(nodePassedInitVal))
                selectedNodeIsInList = true;
        }
    } else {
        // no nodes to be selected
        keysList.add(NO_NODE_SELECTED_IDENTIFYER);
        valuesList.add("- " + translator.translate("form.easy.nodePassed.noNodes"));
        // disable switch
        assessmentSwitch.setEnabled(false);
    }
    // add dummy value if needed
    if (nodePassedInitVal != null && !selectedNodeIsInList) {
        keysList.add(DELETED_NODE_IDENTIFYER);
        valuesList.add("- " + translator.translate("form.easy.nodePassed.deletedNode") + " -");
    }
    final String[] nodePassedKeys = new String[keysList.size()];
    keysList.toArray(nodePassedKeys);
    final String[] nodePassedValues = new String[valuesList.size()];
    valuesList.toArray(nodePassedValues);
    nodePassed = uifactory.addDropdownSingleselect("nodePassed", "form.easy.nodePassed", assessSubContainer, nodePassedKeys, nodePassedValues, null);
    if (nodePassedInitVal != null) {
        if (selectedNodeIsInList) {
            nodePassed.select(nodePassedInitVal, true);
        } else {
            nodePassed.select(DELETED_NODE_IDENTIFYER, true);
        }
    } else {
        nodePassed.select(NO_NODE_SELECTED_IDENTIFYER, true);
    }
    assessmentTypeSwitch = uifactory.addRadiosVertical("assessmentTypeSwitch", null, assessSubContainer, assessmentSwitchKeys, assessmentSwitchValues);
    assessmentTypeSwitch.setLabel("form.easy.assessmentSwitch.type", null);
    assessmentTypeSwitch.addActionListener(FormEvent.ONCLICK);
    if (nodePassedInitVal != null) {
        // has a node configured
        if (cutInitStrValue == null) {
            // with cut value
            assessmentTypeSwitch.select(NODEPASSED_VAL_PASSED, true);
        } else {
            cutInitValue = Integer.valueOf(cutInitStrValue);
            assessmentTypeSwitch.select(NODEPASSED_VAL_SCORE, true);
        }
        assessmentSwitch.select("ison", true);
        assessmentTypeSwitch.setVisible(true);
    } else {
        assessmentSwitch.select("ison", false);
        assessmentTypeSwitch.setVisible(false);
        assessmentTypeSwitch.select(NODEPASSED_VAL_PASSED, true);
    }
    cutValue = uifactory.addIntegerElement("cutval", "form.easy.cutValue", cutInitValue, assessSubContainer);
    cutValue.setDisplaySize(3);
}
Also used : Translator(org.olat.core.gui.translator.Translator) ArrayList(java.util.ArrayList) CourseNode(org.olat.course.nodes.CourseNode)

Example 92 with CourseNode

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

the class PassedRuleEditor method initForm.

@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String page = Util.getPackageVelocityRoot(this.getClass()) + "/passed.html";
    String id = Long.toString(CodeHelper.getRAMUniqueID());
    FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("attempts.".concat(id), formLayout.getTranslator(), page);
    ruleCont.setRootForm(formLayout.getRootForm());
    formLayout.add(ruleCont);
    ruleCont.getFormItemComponent().contextPut("id", id);
    ICourse course = CourseFactory.loadCourse(entry);
    String currentStatus = null;
    String currentCourseNode = null;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        currentStatus = r.getRightOperand();
        currentCourseNode = r.getLeftOperand();
    }
    List<CourseNode> attemptableNodes = new ArrayList<>();
    searchPassedNodes(course.getRunStructure().getRootNode(), attemptableNodes);
    String[] nodeKeys = new String[attemptableNodes.size()];
    String[] nodeValues = new String[attemptableNodes.size()];
    for (int i = 0; i < attemptableNodes.size(); i++) {
        CourseNode attemptableNode = attemptableNodes.get(i);
        nodeKeys[i] = attemptableNode.getIdent();
        nodeValues[i] = attemptableNode.getShortTitle() + " ( " + attemptableNode.getIdent() + " )";
    }
    courseNodeEl = uifactory.addDropdownSingleselect("coursenodes.".concat(id), null, ruleCont, nodeKeys, nodeValues, null);
    courseNodeEl.setDomReplacementWrapperRequired(false);
    boolean nodeSelected = false;
    if (currentCourseNode != null) {
        for (String nodeKey : nodeKeys) {
            if (currentCourseNode.equals(nodeKey)) {
                courseNodeEl.select(nodeKey, true);
                nodeSelected = true;
            }
        }
    }
    if (!nodeSelected && nodeKeys.length > 0) {
        courseNodeEl.select(nodeKeys[0], true);
    }
    if (StringHelper.containsNonWhitespace(currentCourseNode) && !nodeSelected) {
        courseNodeEl.setErrorKey("error.course.node.found", null);
    }
    Translator trans = formLayout.getTranslator();
    String[] statusValues = new String[] { trans.translate("passed"), trans.translate("failed") };
    statusEl = uifactory.addDropdownSingleselect("status.".concat(id), null, ruleCont, statusKeys, statusValues, null);
    statusEl.setDomReplacementWrapperRequired(false);
    boolean statusSelected = false;
    if (currentStatus != null) {
        for (String statusKey : statusKeys) {
            if (currentStatus.equals(statusKey)) {
                statusEl.select(statusKey, true);
                statusSelected = true;
            }
        }
    }
    if (!statusSelected) {
        statusEl.select(statusKeys[1], true);
    }
    return ruleCont;
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) Translator(org.olat.core.gui.translator.Translator) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) ICourse(org.olat.course.ICourse) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode)

Example 93 with CourseNode

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

the class PassedRuleEditor method searchPassedNodes.

private void searchPassedNodes(CourseNode courseNode, List<CourseNode> nodes) {
    if (courseNode instanceof AssessableCourseNode) {
        AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
        if (assessableCourseNode.hasPassedConfigured()) {
            nodes.add(courseNode);
        }
    }
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        searchPassedNodes(child, nodes);
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode)

Example 94 with CourseNode

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

the class OLATUpgrade_11_0_0 method hasAssessableSTCourseNode.

private List<STCourseNode> hasAssessableSTCourseNode(ICourse course) {
    List<STCourseNode> assessableSTNodes = new ArrayList<>();
    CourseNode rootNode = course.getRunStructure().getRootNode();
    new TreeVisitor(new Visitor() {

        @Override
        public void visit(INode node) {
            if (node instanceof STCourseNode) {
                STCourseNode stNode = (STCourseNode) node;
                ScoreCalculator calculator = stNode.getScoreCalculator();
                if (StringHelper.containsNonWhitespace(calculator.getPassedExpression())) {
                    assessableSTNodes.add(stNode);
                } else if (StringHelper.containsNonWhitespace(calculator.getScoreExpression())) {
                    assessableSTNodes.add(stNode);
                }
            }
        }
    }, rootNode, true).visitAll();
    return assessableSTNodes;
}
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) STCourseNode(org.olat.course.nodes.STCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) ScoreCalculator(org.olat.course.run.scoring.ScoreCalculator) ArrayList(java.util.ArrayList) STCourseNode(org.olat.course.nodes.STCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode)

Example 95 with CourseNode

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

the class OLATUpgrade_11_0_0 method compareCourseNodeAssessment.

private boolean compareCourseNodeAssessment(AssessmentEntryImpl entry, NewCachePersistingAssessmentManager assessmentManager, ICourse course, RepositoryEntry courseEntry) {
    CourseNode node = course.getRunStructure().getNode(entry.getSubIdent());
    if (node == null) {
        CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeById(entry.getSubIdent());
        if (editorNode != null) {
            node = editorNode.getCourseNode();
        }
    }
    boolean allOk = true;
    if (node instanceof AssessableCourseNode && !(node instanceof STCourseNode)) {
        Identity assessedIdentity = entry.getIdentity();
        Integer attempts = assessmentManager.getNodeAttempts(node, assessedIdentity);
        if ((attempts == null && entry.getAttempts() == null) || (attempts != null && entry.getAttempts() != null && attempts.equals(entry.getAttempts()))) {
        // ok
        } else {
            log.audit("ERROR number of attempts: " + attempts + " / " + entry.getAttempts() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
        Boolean passed = assessmentManager.getNodePassed(node, assessedIdentity);
        if ((passed == null && entry.getPassed() == null) || (passed != null && entry.getPassed() != null && passed.equals(entry.getPassed()))) {
        // ok
        } else {
            log.audit("ERROR passed: " + passed + " / " + entry.getPassed() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
        Boolean fullyAssessed = assessmentManager.getNodeFullyAssessed(node, assessedIdentity);
        if ((fullyAssessed == null && entry.getFullyAssessed() == null) || (fullyAssessed != null && entry.getFullyAssessed() != null && fullyAssessed.equals(entry.getFullyAssessed()))) {
        // ok
        } else {
            log.audit("ERROR fullyAssessed: " + fullyAssessed + " / " + entry.getFullyAssessed() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
        Float score = assessmentManager.getNodeScore(node, assessedIdentity);
        if ((score == null && entry.getScore() == null) || (score != null && entry.getScore() != null && Math.abs(score.floatValue() - entry.getScore().floatValue()) < 0.00001f)) {
        // ok
        } else {
            log.audit("ERROR score: " + score + " / " + entry.getScore() + getErrorAt(courseEntry, node));
            allOk &= false;
        }
    }
    return allOk;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) CourseEditorTreeNode(org.olat.course.tree.CourseEditorTreeNode) STCourseNode(org.olat.course.nodes.STCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) CourseNode(org.olat.course.nodes.CourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity)

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