Search in sources :

Example 6 with AssessmentEntryImpl

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

the class OLATUpgrade_11_0_0 method verifyCourseAssessmentData.

/**
 * The method compare the content of the cache used in assessment tool
 * with the migrated values and vice versa.
 *
 * @param courseEntry
 * @return
 */
private boolean verifyCourseAssessmentData(List<Identity> assessableIdentities, RepositoryEntry courseEntry) {
    // load the cache and fill it with the same amount of datas as in assessment tool
    final ICourse course = CourseFactory.loadCourse(courseEntry);
    final Long courseResourceableId = course.getResourceableId();
    StaticCacheWrapper cache = new StaticCacheWrapper();
    NewCachePersistingAssessmentManager assessmentManager = new NewCachePersistingAssessmentManager(course, cache);
    assessmentManager.preloadCache(assessableIdentities);
    dbInstance.commitAndCloseSession();
    Set<Identity> assessableIdentitySet = new HashSet<>(assessableIdentities);
    List<AssessmentEntryImpl> nodeAssessments = loadAssessmentEntries(courseEntry);
    Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap = new HashMap<>();
    for (AssessmentEntryImpl nodeAssessment : nodeAssessments) {
        if (!assessableIdentitySet.contains(nodeAssessment.getIdentity())) {
            assessmentManager.preloadCache(nodeAssessment.getIdentity());
        }
        if (nodeAssessment.getIdentity() != null && nodeAssessment.getRepositoryEntry() != null && nodeAssessment.getRepositoryEntry().getOlatResource() != null) {
            nodeAssessmentMap.put(new AssessmentDataKey(nodeAssessment), nodeAssessment);
        }
    }
    dbInstance.commitAndCloseSession();
    // compare the value in CourseNodeAssessment with the content of the cache
    boolean allOk = true;
    for (AssessmentEntryImpl nodeAssessment : nodeAssessments) {
        allOk &= compareCourseNodeAssessment(nodeAssessment, assessmentManager, course, courseEntry);
    }
    dbInstance.commitAndCloseSession();
    // compare the content of the cache with the CourseNodeAssessments
    for (NewCacheKey cacheKey : cache.getKeys()) {
        Map<String, Serializable> dataMap = cache.get(cacheKey);
        Long identityKey = cacheKey.getIdentityKey();
        for (Map.Entry<String, Serializable> data : dataMap.entrySet()) {
            String key = data.getKey();
            int index = key.indexOf("_");
            if (index > 0 && !key.equals("LAST_MODIFIED")) {
                String nodeIdent = key.substring(0, index);
                String dataType = key.substring(index + 1);
                AssessmentDataKey assessmentDataKey = new AssessmentDataKey(identityKey, courseResourceableId, nodeIdent);
                AssessmentEntryImpl nodeAssessment = nodeAssessmentMap.get(assessmentDataKey);
                allOk &= compareProperty(dataType, data.getValue(), nodeAssessment, courseEntry, nodeIdent, identityKey);
            }
        }
    }
    dbInstance.commitAndCloseSession();
    if (!allOk) {
        log.error("Critical error during course verification: " + courseEntry.getDisplayname() + "(" + courseEntry.getKey() + ")");
    }
    return allOk;
}
Also used : Serializable(java.io.Serializable) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) NewCacheKey(org.olat.upgrade.legacy.NewCacheKey) NewCachePersistingAssessmentManager(org.olat.upgrade.legacy.NewCachePersistingAssessmentManager) ICourse(org.olat.course.ICourse) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) HashSet(java.util.HashSet)

Example 7 with AssessmentEntryImpl

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

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 8 with AssessmentEntryImpl

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

the class OLATUpgrade_11_0_0 method processNonPropertiesTAStates.

/**
 * Find if someone dropped a file in a Task element without task assignment, or has a returned
 * document.
 *
 * @param assessableIdentities
 * @param tNode
 * @param course
 * @param courseEntry
 * @param nodeAssessmentMap
 */
private void processNonPropertiesTAStates(List<Identity> assessableIdentities, TACourseNode tNode, ICourse course, RepositoryEntry courseEntry, Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap, Map<AssessmentDataKey, AssessmentEntryImpl> curentNodeAssessmentMap) {
    for (Identity assessedIdentity : assessableIdentities) {
        AssessmentDataKey key = new AssessmentDataKey(assessedIdentity, course.getResourceableId(), tNode.getIdent());
        if (curentNodeAssessmentMap.containsKey(key)) {
            continue;
        }
        AssessmentEntryImpl nodeAssessment;
        if (!nodeAssessmentMap.containsKey(key)) {
            nodeAssessment = createAssessmentEntry(assessedIdentity, null, course, courseEntry, tNode.getIdent());
            nodeAssessmentMap.put(key, nodeAssessment);
            String dropbox = DropboxController.getDropboxPathRelToFolderRoot(course.getCourseEnvironment(), tNode) + File.separator + assessedIdentity.getName();
            OlatRootFolderImpl dropBox = new OlatRootFolderImpl(dropbox, null);
            if (dropBox.getBasefile().exists() && dropBox.getBasefile().listFiles(SystemFileFilter.FILES_ONLY).length > 0) {
                nodeAssessment.setAssessmentStatus(AssessmentEntryStatus.inProgress);
            } else {
                String returnbox = ReturnboxController.getReturnboxPathRelToFolderRoot(course.getCourseEnvironment(), tNode) + File.separator + assessedIdentity.getName();
                OlatRootFolderImpl returnBox = new OlatRootFolderImpl(returnbox, null);
                if (returnBox.getBasefile().exists() && returnBox.getBasefile().listFiles(SystemFileFilter.FILES_ONLY).length > 0) {
                    nodeAssessment.setAssessmentStatus(AssessmentEntryStatus.inProgress);
                }
            }
        }
    }
}
Also used : OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Example 9 with AssessmentEntryImpl

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

the class AssessmentEntryDAO method resetAssessmentEntry.

public AssessmentEntry resetAssessmentEntry(AssessmentEntry nodeAssessment) {
    nodeAssessment.setScore(null);
    nodeAssessment.setPassed(null);
    nodeAssessment.setAttempts(0);
    nodeAssessment.setCompletion(null);
    nodeAssessment.setAssessmentStatus(AssessmentEntryStatus.notStarted);
    ((AssessmentEntryImpl) nodeAssessment).setLastModified(new Date());
    return dbInstance.getCurrentEntityManager().merge(nodeAssessment);
}
Also used : Date(java.util.Date) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Example 10 with AssessmentEntryImpl

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

the class AssessmentEntryDAO method createAssessmentEntry.

public AssessmentEntry createAssessmentEntry(Identity assessedIdentity, String anonymousIdentifier, RepositoryEntry entry, String subIdent, RepositoryEntry referenceEntry, Float score, Boolean passed, Date lastUserModified, Date lastCoachModified) {
    AssessmentEntryImpl data = new AssessmentEntryImpl();
    data.setCreationDate(new Date());
    data.setLastModified(data.getCreationDate());
    data.setLastUserModified(lastUserModified);
    data.setLastCoachModified(lastCoachModified);
    data.setIdentity(assessedIdentity);
    data.setAnonymousIdentifier(anonymousIdentifier);
    data.setRepositoryEntry(entry);
    data.setSubIdent(subIdent);
    data.setReferenceEntry(referenceEntry);
    data.setUserVisibility(Boolean.TRUE);
    if (score != null) {
        data.setScore(new BigDecimal(score));
    }
    data.setPassed(passed);
    dbInstance.getCurrentEntityManager().persist(data);
    return data;
}
Also used : Date(java.util.Date) BigDecimal(java.math.BigDecimal) 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