use of org.olat.properties.Property in project openolat by klemens.
the class NewCachePersistingAssessmentManager method preloadCache.
public void preloadCache(List<Identity> identities) {
int count = 0;
int batch = 200;
Map<Identity, List<Property>> map = new HashMap<Identity, List<Property>>(201);
do {
int toIndex = Math.min(count + batch, identities.size());
List<Identity> toLoad = identities.subList(count, toIndex);
List<Property> allProperties = loadPropertiesFor(toLoad);
map.clear();
for (Property prop : allProperties) {
if (!map.containsKey(prop.getIdentity())) {
map.put(prop.getIdentity(), new ArrayList<Property>());
}
map.get(prop.getIdentity()).add(prop);
}
for (Identity id : toLoad) {
List<Property> props = map.get(id);
if (props == null) {
props = new ArrayList<Property>(1);
}
getOrLoadScorePassedAttemptsMap(id, props, false);
}
count += batch;
} while (count < identities.size());
}
use of org.olat.properties.Property in project openolat by klemens.
the class NewCachePersistingAssessmentManager method incrementNodeAttemptsProperty.
/**
* Private method. Increments the attempts property.
* @param courseNode
* @param identity
* @param cpm
* @return the resulting new number of node attempts
*/
private long incrementNodeAttemptsProperty(CourseNode courseNode, Identity identity, CoursePropertyManager cpm) {
Long attempts;
Property attemptsProperty = cpm.findCourseNodeProperty(courseNode, identity, null, ATTEMPTS);
if (attemptsProperty == null) {
attempts = new Long(1);
attemptsProperty = cpm.createCourseNodePropertyInstance(courseNode, identity, null, ATTEMPTS, null, attempts, null, null);
cpm.saveProperty(attemptsProperty);
} else {
attempts = new Long(attemptsProperty.getLongValue().longValue() + 1);
attemptsProperty.setLongValue(attempts);
cpm.updateProperty(attemptsProperty);
}
// add to cache
putPropertyIntoCache(identity, attemptsProperty);
return attempts;
}
use of org.olat.properties.Property in project openolat by klemens.
the class NewCachePersistingAssessmentManager method saveAssessmentID.
/**
* @param courseNode
* @param assessedIdentity
* @param assessmentID
* @param coursePropManager
*/
void saveAssessmentID(CourseNode courseNode, Identity assessedIdentity, Long assessmentID, CoursePropertyManager coursePropManager) {
if (assessmentID != null) {
Property assessmentIDProperty = coursePropManager.findCourseNodeProperty(courseNode, assessedIdentity, null, ASSESSMENT_ID);
if (assessmentIDProperty == null) {
assessmentIDProperty = coursePropManager.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ASSESSMENT_ID, null, assessmentID, null, null);
coursePropManager.saveProperty(assessmentIDProperty);
} else {
assessmentIDProperty.setLongValue(assessmentID);
coursePropManager.updateProperty(assessmentIDProperty);
}
// add to cache
putPropertyIntoCache(assessedIdentity, assessmentIDProperty);
}
}
use of org.olat.properties.Property in project openolat by klemens.
the class NewCachePersistingAssessmentManager method saveNodePassed.
/**
* @param courseNode
* @param identity
* @param assessedIdentity
* @param passed
* @param coursePropManager
*/
void saveNodePassed(CourseNode courseNode, Identity assessedIdentity, Boolean passed, CoursePropertyManager coursePropManager) {
Property passedProperty = coursePropManager.findCourseNodeProperty(courseNode, assessedIdentity, null, PASSED);
if (passedProperty == null && passed != null) {
String pass = passed.toString();
passedProperty = coursePropManager.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, PASSED, null, null, pass, null);
coursePropManager.saveProperty(passedProperty);
} else if (passedProperty != null) {
if (passed != null) {
passedProperty.setStringValue(passed.toString());
coursePropManager.updateProperty(passedProperty);
} else {
removePropertyFromCache(assessedIdentity, passedProperty);
coursePropManager.deleteProperty(passedProperty);
}
}
// add to cache
if (passed != null && passedProperty != null) {
putPropertyIntoCache(assessedIdentity, passedProperty);
}
}
use of org.olat.properties.Property in project openolat by klemens.
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)));
}
Aggregations