Search in sources :

Example 11 with AssessmentEntryImpl

use of org.olat.modules.assessment.model.AssessmentEntryImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_12_0_0 method updateMS.

private void updateMS(RepositoryEntry entry, CourseNode msNode, Set<Identity> changeSet) {
    List<AssessmentEntryImpl> assessmentEntries = loadAssessmentEntries(entry, msNode.getIdent());
    for (AssessmentEntryImpl assessmentEntry : assessmentEntries) {
        if (assessmentEntry.getLastCoachModified() != null)
            continue;
        assessmentEntry.setLastCoachModified(assessmentEntry.getLastModified());
        updateAssessmentEntry(assessmentEntry);
        changeSet.add(assessmentEntry.getIdentity());
    }
}
Also used : AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Example 12 with AssessmentEntryImpl

use of org.olat.modules.assessment.model.AssessmentEntryImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_12_0_0 method updateTest.

private void updateTest(RepositoryEntry entry, IQTESTCourseNode courseNode, Set<Identity> changeSet) {
    boolean onyx = IQEditController.CONFIG_VALUE_QTI2.equals(courseNode.getModuleConfiguration().get(IQEditController.CONFIG_KEY_TYPE_QTI));
    if (onyx)
        return;
    RepositoryEntry testEntry = courseNode.getReferencedRepositoryEntry();
    OLATResource ores = testEntry.getOlatResource();
    boolean qti21 = ImsQTI21Resource.TYPE_NAME.equals(ores.getResourceableTypeName());
    List<AssessmentEntryImpl> assessmentEntries = loadAssessmentEntries(entry, courseNode.getIdent());
    for (AssessmentEntryImpl assessmentEntry : assessmentEntries) {
        if (assessmentEntry.getLastUserModified() != null || assessmentEntry.getLastCoachModified() != null)
            continue;
        if (qti21) {
            Long assessmentId = assessmentEntry.getAssessmentId();
            if (assessmentId != null) {
                AssessmentTestSession session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
                if (session != null && session.getFinishTime() != null) {
                    assessmentEntry.setLastUserModified(session.getFinishTime());
                    updateAssessmentEntry(assessmentEntry);
                    changeSet.add(assessmentEntry.getIdentity());
                }
            }
        } else {
            long olatResource = entry.getOlatResource().getResourceableId().longValue();
            QTIResultSet rset = iqManager.getLastResultSet(assessmentEntry.getIdentity(), olatResource, courseNode.getIdent());
            if (rset != null && rset.getLastModified() != null) {
                assessmentEntry.setLastUserModified(rset.getLastModified());
                updateAssessmentEntry(assessmentEntry);
                changeSet.add(assessmentEntry.getIdentity());
            }
        }
    }
}
Also used : QTIResultSet(org.olat.ims.qti.QTIResultSet) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Example 13 with AssessmentEntryImpl

use of org.olat.modules.assessment.model.AssessmentEntryImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_0_0 method createAssessmentEntry.

private AssessmentEntryImpl createAssessmentEntry(Identity assessedIdentity, Property property, ICourse course, RepositoryEntry courseEntry, String nodeIdent) {
    AssessmentEntryImpl entry = new AssessmentEntryImpl();
    if (property == null) {
        entry.setCreationDate(new Date());
        entry.setLastModified(entry.getCreationDate());
    } else {
        entry.setCreationDate(property.getCreationDate());
        entry.setLastModified(property.getLastModified());
    }
    entry.setIdentity(assessedIdentity);
    entry.setRepositoryEntry(courseEntry);
    entry.setSubIdent(nodeIdent);
    entry.setAttempts(new Integer(0));
    entry.setUserVisibility(Boolean.TRUE);
    CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
    if (courseNode != null) {
        if (courseNode.needsReferenceToARepositoryEntry()) {
            RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
            entry.setReferenceEntry(referenceEntry);
        }
        if (courseNode instanceof GTACourseNode) {
            processAssessmentPropertyForGTA(assessedIdentity, entry, (GTACourseNode) courseNode, courseEntry);
        } else if (courseNode instanceof TACourseNode) {
            processAssessmentPropertyForTA(assessedIdentity, entry, (TACourseNode) courseNode, course);
        } else if (courseNode instanceof IQTESTCourseNode) {
            processAssessmentPropertyForIQTEST(assessedIdentity, entry, (IQTESTCourseNode) courseNode, course);
        } else if (courseNode instanceof PortfolioCourseNode) {
            processAssessmentPropertyForPortfolio(assessedIdentity, entry, (PortfolioCourseNode) courseNode, course);
        } else if (courseNode instanceof MSCourseNode) {
            entry.setAssessmentStatus(AssessmentEntryStatus.inReview);
        } else if (courseNode instanceof BasicLTICourseNode) {
            processAssessmentPropertyForBasicLTI(assessedIdentity, entry, (BasicLTICourseNode) courseNode, course);
        } else if (courseNode instanceof ScormCourseNode) {
            String username = assessedIdentity.getName();
            Map<Date, List<CmiData>> rawDatas = ScormAssessmentManager.getInstance().visitScoDatasMultiResults(username, course.getCourseEnvironment(), (ScormCourseNode) courseNode);
            if (rawDatas != null && rawDatas.size() > 0) {
                entry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
            } else {
                entry.setAssessmentStatus(AssessmentEntryStatus.notStarted);
            }
        }
    }
    return entry;
}
Also used : BasicLTICourseNode(org.olat.course.nodes.BasicLTICourseNode) PortfolioCourseNode(org.olat.course.nodes.PortfolioCourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) GTACourseNode(org.olat.course.nodes.GTACourseNode) TACourseNode(org.olat.course.nodes.TACourseNode) ScormCourseNode(org.olat.course.nodes.ScormCourseNode) Date(java.util.Date) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl) IQTESTCourseNode(org.olat.course.nodes.IQTESTCourseNode) MSCourseNode(org.olat.course.nodes.MSCourseNode) 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)

Example 14 with AssessmentEntryImpl

use of org.olat.modules.assessment.model.AssessmentEntryImpl 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)

Example 15 with AssessmentEntryImpl

use of org.olat.modules.assessment.model.AssessmentEntryImpl in project OpenOLAT by OpenOLAT.

the class AssessmentEntryDAO method createAssessmentEntry.

public AssessmentEntry createAssessmentEntry(Identity assessedIdentity, String anonymousIdentifier, RepositoryEntry entry, String subIdent, RepositoryEntry referenceEntry) {
    AssessmentEntryImpl data = new AssessmentEntryImpl();
    data.setCreationDate(new Date());
    data.setLastModified(data.getCreationDate());
    data.setIdentity(assessedIdentity);
    data.setAnonymousIdentifier(anonymousIdentifier);
    data.setRepositoryEntry(entry);
    data.setSubIdent(subIdent);
    data.setReferenceEntry(referenceEntry);
    data.setUserVisibility(Boolean.TRUE);
    dbInstance.getCurrentEntityManager().persist(data);
    return data;
}
Also used : Date(java.util.Date) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Aggregations

AssessmentEntryImpl (org.olat.modules.assessment.model.AssessmentEntryImpl)22 Date (java.util.Date)8 TransientIdentity (org.olat.admin.user.imp.TransientIdentity)8 Identity (org.olat.core.id.Identity)8 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ICourse (org.olat.course.ICourse)4 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)4 BasicLTICourseNode (org.olat.course.nodes.BasicLTICourseNode)4 CourseNode (org.olat.course.nodes.CourseNode)4 GTACourseNode (org.olat.course.nodes.GTACourseNode)4 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)4 MSCourseNode (org.olat.course.nodes.MSCourseNode)4 PortfolioCourseNode (org.olat.course.nodes.PortfolioCourseNode)4 STCourseNode (org.olat.course.nodes.STCourseNode)4 ScormCourseNode (org.olat.course.nodes.ScormCourseNode)4 TACourseNode (org.olat.course.nodes.TACourseNode)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4