Search in sources :

Example 21 with STCourseNode

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

the class AssessmentIdentityCourseController method doNextNode.

private void doNextNode(UserRequest ureq) {
    stackPanel.popController(currentNodeCtrl);
    CourseNode nextNode = treeOverviewCtrl.getNextNode(currentNodeCtrl.getCourseNode());
    if (nextNode != null && nextNode.getParent() != null) {
        if (nextNode instanceof STCourseNode) {
            int count = 0;
            for (nextNode = treeOverviewCtrl.getNextNode(nextNode); nextNode instanceof STCourseNode; nextNode = treeOverviewCtrl.getNextNode(nextNode)) {
                // search the next node which is not a structure node
                if (count++ > 500) {
                    break;
                }
            }
        }
        if (nextNode.getParent() != null && !(nextNode instanceof STCourseNode)) {
            doSelectCourseNode(ureq, nextNode);
        }
    }
}
Also used : STCourseNode(org.olat.course.nodes.STCourseNode) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseNode(org.olat.course.nodes.CourseNode) STCourseNode(org.olat.course.nodes.STCourseNode)

Example 22 with STCourseNode

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

the class ScoreRuleSPI method filter.

@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String nodeIdent = r.getLeftOperand();
        String operator = r.getOperator();
        float value = Float.parseFloat(r.getRightOperand());
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
        if (courseNode == null) {
            identities.clear();
            log.error("Score rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
            return;
        }
        Map<Long, Float> scores;
        if (courseNode instanceof STCourseNode) {
            scores = new HashMap<>();
            STCourseNode structureNode = (STCourseNode) courseNode;
            if (structureNode.hasScoreConfigured()) {
                for (Identity identity : identities) {
                    UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
                    ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
                    Float score = scoreEval.getScore();
                    if (score != null) {
                        scores.put(identity.getKey(), score);
                    }
                }
            }
        } else {
            scores = helperDao.getScores(entry, courseNode, identities);
        }
        for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
            Identity identity = identityIt.next();
            Float score = scores.get(identity.getKey());
            if (score == null) {
                if (!operator.equals("!=")) {
                    // always different
                    identityIt.remove();
                }
            } else if (!evaluateScore(score.floatValue(), operator, value)) {
                identityIt.remove();
            }
        }
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) STCourseNode(org.olat.course.nodes.STCourseNode) STCourseNode(org.olat.course.nodes.STCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 23 with STCourseNode

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

the class AssessmentHelper method getAssessmentNodeDataList.

public static int getAssessmentNodeDataList(int recursionLevel, CourseNode courseNode, ScoreAccounting scoreAccounting, UserCourseEnvironment userCourseEnv, boolean followUserVisibility, boolean discardEmptyNodes, boolean discardComments, List<AssessmentNodeData> data, AssessmentNodesLastModified lastModifications) {
    // 1) Get list of children data using recursion of this method
    AssessmentNodeData assessmentNodeData = new AssessmentNodeData(recursionLevel, courseNode);
    data.add(assessmentNodeData);
    int numOfChildren = 0;
    for (int i = 0; i < courseNode.getChildCount(); i++) {
        CourseNode child = (CourseNode) courseNode.getChildAt(i);
        numOfChildren += getAssessmentNodeDataList(recursionLevel + 1, child, scoreAccounting, userCourseEnv, followUserVisibility, discardEmptyNodes, discardComments, data, lastModifications);
    }
    // 2) Get data of this node only if
    // - it has any wrapped children  or
    // - it is of an assessable course node type
    boolean hasDisplayableValuesConfigured = false;
    boolean hasDisplayableUserValues = false;
    if (numOfChildren > 0 || courseNode instanceof AssessableCourseNode) {
        if (courseNode instanceof ProjectBrokerCourseNode) {
            // ProjectBroker : no assessment-tool in V1.0 , remove project broker completely form assessment-tool gui
            assessmentNodeData.setSelectable(false);
        } else if (courseNode instanceof AssessableCourseNode) {
            AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
            AssessmentEvaluation scoreEvaluation = scoreAccounting.evalCourseNode(assessableCourseNode);
            if (scoreEvaluation != null) {
                assessmentNodeData.setAssessmentStatus(scoreEvaluation.getAssessmentStatus());
                assessmentNodeData.setNumOfAssessmentDocs(scoreEvaluation.getNumOfAssessmentDocs());
            }
            assessmentNodeData.setUserVisibility(scoreEvaluation.getUserVisible());
            assessmentNodeData.setLastModified(scoreEvaluation.getLastModified());
            assessmentNodeData.setLastUserModified(scoreEvaluation.getLastUserModified());
            assessmentNodeData.setLastCoachModified(scoreEvaluation.getLastCoachModified());
            if (lastModifications != null) {
                lastModifications.addLastModified(scoreEvaluation.getLastModified());
                lastModifications.addLastUserModified(scoreEvaluation.getLastUserModified());
                lastModifications.addLastCoachModified(scoreEvaluation.getLastCoachModified());
            }
            if (!followUserVisibility || scoreEvaluation.getUserVisible() == null || scoreEvaluation.getUserVisible().booleanValue()) {
                // details
                if (assessableCourseNode.hasDetails()) {
                    hasDisplayableValuesConfigured = true;
                    String detailValue = assessableCourseNode.getDetailsListView(userCourseEnv);
                    if (detailValue == null) {
                        // ignore unset details in discardEmptyNodes mode
                        assessmentNodeData.setDetails(AssessmentHelper.DETAILS_NA_VALUE);
                    } else {
                        assessmentNodeData.setDetails(detailValue);
                        hasDisplayableUserValues = true;
                    }
                }
                // attempts
                if (assessableCourseNode.hasAttemptsConfigured()) {
                    hasDisplayableValuesConfigured = true;
                    Integer attemptsValue = scoreEvaluation.getAttempts();
                    if (attemptsValue != null) {
                        assessmentNodeData.setAttempts(attemptsValue);
                        if (attemptsValue.intValue() > 0) {
                            // ignore attempts = 0  in discardEmptyNodes mode
                            hasDisplayableUserValues = true;
                        }
                    }
                }
                // score
                if (assessableCourseNode.hasScoreConfigured()) {
                    hasDisplayableValuesConfigured = true;
                    Float score = scoreEvaluation.getScore();
                    if (score != null) {
                        assessmentNodeData.setRoundedScore(AssessmentHelper.getRoundedScore(score));
                        assessmentNodeData.setScore(score);
                        hasDisplayableUserValues = true;
                    }
                    if (!(assessableCourseNode instanceof STCourseNode)) {
                        assessmentNodeData.setMaxScore(assessableCourseNode.getMaxScoreConfiguration());
                        assessmentNodeData.setMinScore(assessableCourseNode.getMinScoreConfiguration());
                    }
                }
                // passed
                if (assessableCourseNode.hasPassedConfigured()) {
                    hasDisplayableValuesConfigured = true;
                    Boolean passed = scoreEvaluation.getPassed();
                    if (passed != null) {
                        assessmentNodeData.setPassed(passed);
                        hasDisplayableUserValues = true;
                    }
                }
            }
            // selection command available
            AssessableCourseNode acn = (AssessableCourseNode) courseNode;
            if (acn.isEditableConfigured()) {
                // Assessable course nodes are selectable
                assessmentNodeData.setSelectable(true);
            } else {
                // assessable nodes that do not have score or passed are not selectable
                // (e.g. a st node with no defined rule
                assessmentNodeData.setSelectable(false);
            }
            if (!hasDisplayableUserValues && assessableCourseNode.hasCommentConfigured() && !discardComments) {
                // comments are invisible in the table but if configured the node must be in the list
                // for the efficiency statement this can be ignored, this is the case when discardComments is true
                hasDisplayableValuesConfigured = true;
                if (assessableCourseNode.getUserUserComment(userCourseEnv) != null) {
                    hasDisplayableUserValues = true;
                }
            }
        } else {
            // Not assessable nodes are not selectable. (e.g. a node that
            // has an assessable child node but is itself not assessable)
            assessmentNodeData.setSelectable(false);
        }
    }
    // 3) Add data of this node to mast list if node assessable or children list has any data.
    // Do only add nodes when they have any assessable element, otherwhise discard (e.g. empty course,
    // structure nodes without scoring rules)! When the discardEmptyNodes flag is set then only
    // add this node when there is user data found for this node.
    boolean addNode = (numOfChildren > 0 || (discardEmptyNodes && hasDisplayableValuesConfigured && hasDisplayableUserValues) || (!discardEmptyNodes && hasDisplayableValuesConfigured));
    if (!addNode) {
        data.remove(assessmentNodeData);
        return 0;
    }
    // add itself
    return numOfChildren + 1;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) STCourseNode(org.olat.course.nodes.STCourseNode) 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) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData) ProjectBrokerCourseNode(org.olat.course.nodes.ProjectBrokerCourseNode)

Example 24 with STCourseNode

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

the class OLATUpgrade_11_0_0 method processCourseAssessmentData.

// select count(*) from o_property where name in ('SCORE','PASSED','ATTEMPTS','COMMENT','COACH_COMMENT','ASSESSMENT_ID','FULLY_ASSESSED');
private boolean processCourseAssessmentData(RepositoryEntry courseEntry) {
    boolean allOk = true;
    try {
        final Long courseResourceId = courseEntry.getOlatResource().getResourceableId();
        final ICourse course = CourseFactory.loadCourse(courseEntry);
        // load all assessable identities
        List<Identity> assessableIdentities = getAllAssessableIdentities(course, courseEntry);
        Map<AssessmentDataKey, AssessmentEntryImpl> curentNodeAssessmentMap = new HashMap<>();
        {
            // load already migrated data
            List<AssessmentEntryImpl> currentNodeAssessmentList = loadAssessmentEntries(courseEntry);
            for (AssessmentEntryImpl currentNodeAssessment : currentNodeAssessmentList) {
                AssessmentDataKey key = new AssessmentDataKey(currentNodeAssessment.getIdentity().getKey(), courseResourceId, currentNodeAssessment.getSubIdent());
                curentNodeAssessmentMap.put(key, currentNodeAssessment);
            }
        }
        Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap = new HashMap<>();
        {
            // processed properties
            List<Property> courseProperties = loadAssessmentProperties(courseEntry);
            for (Property property : courseProperties) {
                String propertyCategory = property.getCategory();
                if (StringHelper.containsNonWhitespace(propertyCategory)) {
                    int nodeIdentIndex = propertyCategory.indexOf("::");
                    if (nodeIdentIndex > 0) {
                        String nodeIdent = propertyCategory.substring(propertyCategory.indexOf("::") + 2);
                        AssessmentDataKey key = new AssessmentDataKey(property.getIdentity().getKey(), property.getResourceTypeId(), nodeIdent);
                        if (curentNodeAssessmentMap.containsKey(key)) {
                            continue;
                        }
                        AssessmentEntryImpl nodeAssessment;
                        if (nodeAssessmentMap.containsKey(key)) {
                            nodeAssessment = nodeAssessmentMap.get(key);
                            if (nodeAssessment.getCreationDate().after(property.getCreationDate())) {
                                nodeAssessment.setCreationDate(property.getCreationDate());
                            }
                            if (nodeAssessment.getLastModified().before(property.getLastModified())) {
                                nodeAssessment.setLastModified(property.getLastModified());
                            }
                        } else {
                            nodeAssessment = createAssessmentEntry(property.getIdentity(), property, course, courseEntry, nodeIdent);
                        }
                        copyAssessmentProperty(property, nodeAssessment, course);
                        nodeAssessmentMap.put(key, nodeAssessment);
                    }
                }
            }
        }
        // check the transient qti ser
        CourseNode rootNode = course.getRunStructure().getRootNode();
        new TreeVisitor(new Visitor() {

            @Override
            public void visit(INode node) {
                if (node instanceof AssessableCourseNode) {
                    processNonPropertiesStates(assessableIdentities, (AssessableCourseNode) node, course, courseEntry, nodeAssessmentMap, curentNodeAssessmentMap);
                }
            }
        }, rootNode, true).visitAll();
        dbInstance.commitAndCloseSession();
        int count = 0;
        for (AssessmentEntryImpl courseNodeAssessment : nodeAssessmentMap.values()) {
            dbInstance.getCurrentEntityManager().persist(courseNodeAssessment);
            if (++count % 50 == 0) {
                dbInstance.commit();
            }
        }
        dbInstance.commitAndCloseSession();
        allOk = verifyCourseAssessmentData(assessableIdentities, courseEntry);
        dbInstance.commitAndCloseSession();
        if (allOk) {
            List<STCourseNode> nodes = hasAssessableSTCourseNode(course);
            if (nodes.size() > 0) {
                log.info("Has assessables ST nodes");
                for (Identity identity : assessableIdentities) {
                    IdentityEnvironment identityEnv = new IdentityEnvironment(identity, null);
                    UserCourseEnvironmentImpl userCourseEnv = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
                    userCourseEnv.getScoreAccounting().evaluateAll(true);
                    dbInstance.commit();
                }
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
    return allOk;
}
Also used : INode(org.olat.core.util.nodes.INode) TreeVisitor(org.olat.core.util.tree.TreeVisitor) Visitor(org.olat.core.util.tree.Visitor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ICourse(org.olat.course.ICourse) CorruptedCourseException(org.olat.course.CorruptedCourseException) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl) TreeVisitor(org.olat.core.util.tree.TreeVisitor) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) STCourseNode(org.olat.course.nodes.STCourseNode) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) ArrayList(java.util.ArrayList) List(java.util.List) 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) Property(org.olat.properties.Property) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 25 with STCourseNode

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

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)

Aggregations

STCourseNode (org.olat.course.nodes.STCourseNode)32 CourseNode (org.olat.course.nodes.CourseNode)26 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)20 Identity (org.olat.core.id.Identity)10 ICourse (org.olat.course.ICourse)10 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)10 TACourseNode (org.olat.course.nodes.TACourseNode)10 MSCourseNode (org.olat.course.nodes.MSCourseNode)8 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)8 CourseEditorTreeNode (org.olat.course.tree.CourseEditorTreeNode)8 BasicLTICourseNode (org.olat.course.nodes.BasicLTICourseNode)6 GTACourseNode (org.olat.course.nodes.GTACourseNode)6 PortfolioCourseNode (org.olat.course.nodes.PortfolioCourseNode)6 ScoreAccounting (org.olat.course.run.scoring.ScoreAccounting)6 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)6 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)6 ArrayList (java.util.ArrayList)5 File (java.io.File)4 TransientIdentity (org.olat.admin.user.imp.TransientIdentity)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4