Search in sources :

Example 1 with AssessmentEntryImpl

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

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

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

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

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

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

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

the class OLATUpgrade_11_0_0 method processNonPropertiesIQTESTStates.

/**
 * Find if someone has started a test without getting a score, passed status...
 *
 * @param assessableIdentities
 * @param iqNode
 * @param course
 * @param courseEntry
 * @param nodeAssessmentMap
 */
private void processNonPropertiesIQTESTStates(List<Identity> assessableIdentities, IQTESTCourseNode iqNode, ICourse course, RepositoryEntry courseEntry, Map<AssessmentDataKey, AssessmentEntryImpl> nodeAssessmentMap, Map<AssessmentDataKey, AssessmentEntryImpl> curentNodeAssessmentMap) {
    for (Identity assessedIdentity : assessableIdentities) {
        if (iqTestPersisterExists(assessedIdentity, iqNode, course)) {
            AssessmentDataKey key = new AssessmentDataKey(assessedIdentity, course.getResourceableId(), iqNode.getIdent());
            if (curentNodeAssessmentMap.containsKey(key)) {
                continue;
            }
            AssessmentEntryImpl nodeAssessment;
            if (nodeAssessmentMap.containsKey(key)) {
                nodeAssessment = nodeAssessmentMap.get(key);
            } else {
                nodeAssessment = createAssessmentEntry(assessedIdentity, null, course, courseEntry, iqNode.getIdent());
                nodeAssessmentMap.put(key, nodeAssessment);
                Long courseResourceableId = course.getResourceableId();
                String resourcePath = courseResourceableId + File.separator + iqNode.getIdent();
                FilePersister qtiPersister = new FilePersister(assessedIdentity, resourcePath);
                nodeAssessment.setCreationDate(qtiPersister.getLastModified());
                nodeAssessment.setLastModified(qtiPersister.getLastModified());
            }
            nodeAssessment.setAssessmentStatus(AssessmentEntryStatus.inProgress);
        }
    }
}
Also used : FilePersister(org.olat.ims.qti.process.FilePersister) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) AssessmentEntryImpl(org.olat.modules.assessment.model.AssessmentEntryImpl)

Example 5 with AssessmentEntryImpl

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

the class OLATUpgrade_12_0_0 method updateScorm.

private void updateScorm(ICourse course, RepositoryEntry entry, CourseNode scormNode, Set<Identity> changeSet) {
    Long courseId = course.getResourceableId();
    String courseIdNodeId = courseId + "-" + scormNode.getIdent();
    Calendar cal = Calendar.getInstance();
    List<AssessmentEntryImpl> assessmentEntries = loadAssessmentEntries(entry, scormNode.getIdent());
    for (AssessmentEntryImpl assessmentEntry : assessmentEntries) {
        if (assessmentEntry.getLastUserModified() != null || assessmentEntry.getLastCoachModified() != null)
            continue;
        String userId = assessmentEntry.getIdentity().getName();
        String path = FolderConfig.getCanonicalRoot() + "/scorm/" + userId + "/" + courseIdNodeId;
        File quiz = new File(path, "thequiz.xml");
        if (quiz.exists()) {
            long lastModified = quiz.lastModified();
            if (lastModified > 0) {
                cal.setTimeInMillis(lastModified);
                assessmentEntry.setLastUserModified(cal.getTime());
                updateAssessmentEntry(assessmentEntry);
                changeSet.add(assessmentEntry.getIdentity());
            }
        }
    }
}
Also used : Calendar(java.util.Calendar) File(java.io.File) 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