use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_4_0 method migrateCalendarConfigurations.
private boolean migrateCalendarConfigurations(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
if (!uhd.getBooleanDataValue(CALENDAR_USER_CONFIGS)) {
int counter = 0;
List<Property> properties;
do {
properties = getUserGUIProperties(counter, BATCH_SIZE);
for (Property property : properties) {
processCalendarGUIProperty(property);
if (counter % 20 == 0) {
dbInstance.commit();
}
}
counter += properties.size();
log.audit("Calendar GUI properties processed: " + properties.size() + ", total processed (" + counter + ")");
dbInstance.commitAndCloseSession();
} while (properties.size() == BATCH_SIZE);
uhd.setBooleanDataValue(CALENDAR_USER_CONFIGS, true);
upgradeManager.setUpgradesHistory(uhd, VERSION);
}
return true;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_2_1 method processTaskCourseNode.
private boolean processTaskCourseNode(ICourse course, RepositoryEntry entry, TACourseNode courseNode) {
List<AssessmentEntry> assessmentEntries = getAssessmentEntries(entry, courseNode);
if (assessmentEntries.size() > 0) {
CourseEnvironment courseEnv = course.getCourseEnvironment();
CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
File dropbox = new File(FolderConfig.getCanonicalRoot(), DropboxController.getDropboxPathRelToFolderRoot(courseEnv, courseNode));
File returnBox = new File(FolderConfig.getCanonicalRoot(), ReturnboxController.getReturnboxPathRelToFolderRoot(courseEnv, courseNode));
for (AssessmentEntry assessmentEntry : assessmentEntries) {
Identity assessedIdentity = assessmentEntry.getIdentity();
boolean changed = false;
List<Property> properties = cpm.findCourseNodeProperties(courseNode, assessedIdentity, null, TaskController.PROP_ASSIGNED);
if (properties != null && properties.size() > 0) {
assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
} else {
File identityDropbox = new File(dropbox, assessedIdentity.getName());
File identityReturnBox = new File(returnBox, assessedIdentity.getName());
if (hasBoxedFiles(identityDropbox, identityReturnBox)) {
assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
}
}
if (changed) {
courseEnv.getAssessmentManager().updateAssessmentEntry(assessmentEntry);
}
}
dbInstance.commitAndCloseSession();
}
return true;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method getOrLoadScorePassedAttemptsMap.
/**
* retrieves the Map which contains all data for this course and the given user.
* if the cache evicted the map in the meantime, then it is recreated
* by querying the database and fetching all that data in one query, and then reput into the cache.
* <br>
* this method is threadsafe.
*
* @param identity the identity
* @param notify if true, then the
* @return a Map containing nodeident+"_"+ e.g. PASSED as key, Boolean (for PASSED), Float (for SCORE), or Integer (for ATTEMPTS) as values
*/
private Map<String, Serializable> getOrLoadScorePassedAttemptsMap(Identity identity, List<Property> properties, boolean prepareForNewData) {
// a user is only active on one node at the same time.
NewCacheKey cacheKey = new NewCacheKey(ores.getResourceableId(), identity.getKey());
HashMap<String, Serializable> m = courseCache.get(cacheKey);
if (m == null) {
// cache entry (=all data of the given identity in this course) has expired or has never been stored yet into the cache.
// or has been invalidated (in cluster mode when puts occurred from an other node for the same cache)
m = new HashMap<String, Serializable>();
// load data
List<Property> loadedProperties = properties == null ? loadPropertiesFor(Collections.singletonList(identity)) : properties;
for (Property property : loadedProperties) {
addPropertyToCache(m, property);
}
// If property not found, prefill with default value.
if (!m.containsKey(ATTEMPTS)) {
m.put(ATTEMPTS, INTEGER_ZERO);
}
if (!m.containsKey(SCORE)) {
m.put(SCORE, FLOAT_ZERO);
}
if (!m.containsKey(LAST_MODIFIED)) {
m.put(LAST_MODIFIED, null);
}
// we did not generate new data, but simply asked to reload it.
if (prepareForNewData) {
courseCache.update(cacheKey, m);
} else {
courseCache.put(cacheKey, m);
}
} else {
// still in cache.
if (prepareForNewData) {
// but we need to notify that data has changed: we reput the data into the cache - a little hacky yes
courseCache.update(cacheKey, m);
}
}
return m;
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method saveNodeCoachComment.
/**
* @see org.olat.course.assessment.AssessmentManager#saveNodeCoachComment(org.olat.course.nodes.CourseNode,
* org.olat.core.id.Identity, java.lang.String)
*/
public void saveNodeCoachComment(final CourseNode courseNode, final Identity assessedIdentity, final String comment) {
ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {
public void execute() {
Property commentProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, COACH_COMMENT);
if (commentProperty == null) {
commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COACH_COMMENT, null, null, null, comment);
cpm.saveProperty(commentProperty);
} else {
commentProperty.setTextValue(comment);
cpm.updateProperty(commentProperty);
}
// add to cache
putPropertyIntoCache(assessedIdentity, commentProperty);
}
});
// olat::: no node log here? (because what we did above is a node log with custom text AND by a coach)?
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_COACH_COMMENT_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_COACHCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiCoachComment, "", StringHelper.stripLineBreaks(comment)));
}
use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method saveNodeAttempts.
/**
* @see org.olat.course.assessment.AssessmentManager#saveNodeAttempts(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity,
* java.lang.Integer)
*/
public void saveNodeAttempts(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final Integer attempts) {
// A note on updating the EfficiencyStatement:
// In the equivalent method incrementNodeAttempts() in this class, the following code is executed:
// // Update users efficiency statement
// EfficiencyStatementManager esm = EfficiencyStatementManager.getInstance();
// esm.updateUserEfficiencyStatement(userCourseEnv);
// One would expect that saveNodeAttempts would also have to update the EfficiencyStatement - or
// the caller of this method would have to make sure that this happens in the same transaction.
// While this is not explicitly so, implicitly it is: currently the only user this method is
// the AssessmentEditController - which as the 2nd last method calls into saveScoreEvaluation
// - which in turn does update the EfficiencyStatement - at which point we're happy and everything works fine.
// But it seems like this mechanism is a bit unobvious and might well be worth some refactoring...
ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {
public void execute() {
Property attemptsProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, ATTEMPTS);
if (attemptsProperty == null) {
attemptsProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ATTEMPTS, null, new Long(attempts.intValue()), null, null);
cpm.saveProperty(attemptsProperty);
} else {
attemptsProperty.setLongValue(new Long(attempts.intValue()));
cpm.updateProperty(attemptsProperty);
}
// add to cache
putPropertyIntoCache(assessedIdentity, attemptsProperty);
}
});
// node log
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
am.appendToUserNodeLog(courseNode, identity, assessedIdentity, ATTEMPTS + " set to: " + String.valueOf(attempts));
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
Aggregations