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);
}
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);
}
}
}
}
}
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;
}
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);
}
}
}
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());
}
}
}
}
Aggregations