Search in sources :

Example 11 with STCourseNode

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

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)

Example 12 with STCourseNode

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

the class AssessmentIdentityCourseController method doPreviousNode.

private void doPreviousNode(UserRequest ureq) {
    stackPanel.popController(currentNodeCtrl);
    CourseNode previousNode = treeOverviewCtrl.getPreviousNode(currentNodeCtrl.getCourseNode());
    if (previousNode != null && previousNode.getParent() != null) {
        if (previousNode instanceof STCourseNode) {
            CourseNode node = previousNode;
            for (previousNode = treeOverviewCtrl.getPreviousNode(previousNode); previousNode instanceof STCourseNode && node != previousNode; previousNode = treeOverviewCtrl.getPreviousNode(previousNode)) {
                // search the previous node which is not a structure node
                node = previousNode;
            }
        }
        if (!(previousNode instanceof STCourseNode)) {
            doSelectCourseNode(ureq, previousNode);
        }
    }
}
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 13 with STCourseNode

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

the class AssessmentIdentityCourseController method hasPrevious.

private boolean hasPrevious(CourseNode courseNode) {
    int index = treeOverviewCtrl.getIndexOf(courseNode);
    int numOfNodes = treeOverviewCtrl.getNumberOfNodes();
    if (index > 0 && index <= numOfNodes) {
        for (int i = index; i-- > 0; ) {
            CourseNode previousNode = treeOverviewCtrl.getNode(i);
            if (previousNode instanceof AssessableCourseNode && !(previousNode instanceof STCourseNode)) {
                return true;
            }
        }
    }
    return false;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) 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 14 with STCourseNode

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

the class PassedRuleSPI 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 status = r.getRightOperand();
        ICourse course = CourseFactory.loadCourse(entry);
        CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
        if (courseNode == null) {
            identities.clear();
            log.error("Passed rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
            return;
        }
        Map<Long, Boolean> passeds;
        if (courseNode instanceof STCourseNode) {
            passeds = new HashMap<>();
            STCourseNode structureNode = (STCourseNode) courseNode;
            if (structureNode.hasPassedConfigured()) {
                for (Identity identity : identities) {
                    UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
                    ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
                    Boolean passed = scoreEval.getPassed();
                    if (passed != null) {
                        passeds.put(identity.getKey(), passed);
                    }
                }
            }
        } else {
            passeds = helperDao.getPassed(entry, courseNode, identities);
        }
        if ("passed".equals(status)) {
            for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
                Boolean passed = passeds.get(identityIt.next().getKey());
                if (passed == null || !passed.booleanValue()) {
                    identityIt.remove();
                }
            }
        } else if ("failed".equals(status)) {
            for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
                Boolean passed = passeds.get(identityIt.next().getKey());
                if (passed != null && passed.booleanValue()) {
                    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) Iterator(java.util.Iterator) STCourseNode(org.olat.course.nodes.STCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 15 with STCourseNode

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

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)

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