org.olat.course.assessment
Class NewCachePersistingAssessmentManager

java.lang.Object
  extended by org.olat.course.assessment.NewCachePersistingAssessmentManager
All Implemented Interfaces:
AssessmentManager

public class NewCachePersistingAssessmentManager
extends java.lang.Object
implements AssessmentManager

Description:
The assessment manager is used by the assessable course nodes to store and retrieve user assessment data from the database. The assessment Manager should not be used directly from the controllers but only via the assessable course nodes interface.
Exception are nodes that want to save or get node attempts variables for nodes that are not assessable nodes (e.g. questionnaire)
This implementation will store its values using the property manager and has a cache built in for frequently used assessment data like score, passed and attempts variables.

the underlying cache is segmented as follows: 1.) by this class (=owner in singlevm, coowner in cluster mode) 2.) by course (so that e.g. deletion of a course removes all caches) 3.) by identity, for preloading and invalidating (e.g. a user entering a course will cause the identity's cache to be loaded) each cache only has -one- key, which is a hashmap with all the information (score,passed, etc) for the given user/course. the reason for this is that it must be possible to see a difference between a null value (key expired) and a value which corresponds to e.g. "this user has never attempted this test in this course". since only the concrete set, but not the possible set is known. (at least not in the database). so all keys of a given user/course will therefore expire together which also makes sense from a use point of view. Cache usage with e.g. the wiki: wikipages should be saved as separate keys, since no batch updates are needed for perf. reasons. reason for 3: preloading all data of all users of a course lasts up to 5 seconds and will waste memory. a user in a course only needs its own data. only when a tutor enters the assessment functionality, all data of all users is needed -> do a full load only then. TODO: e.g. IQTEST.onDelete(..) cleans all data without going over the assessmentmanager here. meaning that the cache has stale data in it. since coursenode.getIdent (partial key of this cache) is forever unique, then this doesn't really matter. - but it is rather unintended... point is that a node can save lots of data that have nothing to do with assessments

Author:
Felix Jost

Field Summary
 
Fields inherited from interface org.olat.course.assessment.AssessmentManager
ASSESSMENT_ID, ATTEMPTS, COACH_COMMENT, COMMENT, PASSED, SCORE
 
Method Summary
 OLATResourceable createOLATResourceableForLocking(Identity assessedIdentity)
          Always use this to get a OLATResourceable for doInSync locking! Uses the assessIdentity.
 void deregisterFromAssessmentChangeEvents(GenericEventListener gel)
          Deregister the given event listener from all assessment changed events of this course
 java.lang.Long getAssessmentID(CourseNode courseNode, Identity identity)
          No caching for the assessmentID.
static AssessmentManager getInstance(ICourse course)
          Get an instance of the persisting assessment manager.
 java.lang.Integer getNodeAttempts(CourseNode courseNode, Identity identity)
           
 java.lang.String getNodeCoachComment(CourseNode courseNode, Identity identity)
           
 java.lang.String getNodeComment(CourseNode courseNode, Identity identity)
           
 java.lang.Boolean getNodePassed(CourseNode courseNode, Identity identity)
           
 java.lang.Float getNodeScore(CourseNode courseNode, Identity identity)
           
 void incrementNodeAttempts(CourseNode courseNode, Identity identity, UserCourseEnvironment userCourseEnv)
          Increment the users attempts for this course node.
 void preloadCache()
          Load all persisted assessment data of a course into a local cache if such a cache is available
 void preloadCache(Identity identity)
          Load all persisted assessment data into a local cache if such a cache is available
 void registerForAssessmentChangeEvents(GenericEventListener gel, Identity identity)
          Register the given event listener for all assessment changed events of this course
 void saveNodeAttempts(CourseNode courseNode, Identity identity, Identity assessedIdentity, java.lang.Integer attempts)
          Save the users attempts for this node.
 void saveNodeCoachComment(CourseNode courseNode, Identity assessedIdentity, java.lang.String comment)
          Save an coach comment for this node for a user.
 void saveNodeComment(CourseNode courseNode, Identity identity, Identity assessedIdentity, java.lang.String comment)
          Save an assessment comment for this node for a user.
 void saveScoreEvaluation(CourseNode courseNode, Identity identity, Identity assessedIdentity, ScoreEvaluation scoreEvaluation, UserCourseEnvironment userCourseEnv, boolean incrementUserAttempts)
          Save the users achieved ScoreEvaluation for this node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static AssessmentManager getInstance(ICourse course)
Get an instance of the persisting assessment manager. This will use the course property manager to persist assessment data. THIS METHOD MUST ONLY BE USED WITHIN THE COURSE CONSTRUCTOR. Use course.getAssessmentManager() to use the assessment manager during runtime!

Parameters:
course -
Returns:
The assessment manager for this course

preloadCache

public void preloadCache(Identity identity)
Description copied from interface: AssessmentManager
Load all persisted assessment data into a local cache if such a cache is available

Specified by:
preloadCache in interface AssessmentManager
Parameters:
identity - Restrict preloading to a certain identity or null to preload assessment data from all users
See Also:
AssessmentManager.preloadCache(org.olat.core.id.Identity)

preloadCache

public void preloadCache()
Description copied from interface: AssessmentManager
Load all persisted assessment data of a course into a local cache if such a cache is available

Specified by:
preloadCache in interface AssessmentManager

saveNodeAttempts

public void saveNodeAttempts(CourseNode courseNode,
                             Identity identity,
                             Identity assessedIdentity,
                             java.lang.Integer attempts)
Description copied from interface: AssessmentManager
Save the users attempts for this node. If there is already an attempts property available, it will be overwritten with the new value

Specified by:
saveNodeAttempts in interface AssessmentManager
identity - The user who changes this score
assessedIdentity - The user whose score is changed
attempts - The new attempts
See Also:
AssessmentManager.saveNodeAttempts(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity, java.lang.Integer)

saveNodeComment

public void saveNodeComment(CourseNode courseNode,
                            Identity identity,
                            Identity assessedIdentity,
                            java.lang.String comment)
Description copied from interface: AssessmentManager
Save an assessment comment for this node for a user. If there is already a comment property available, it will be overwritten with the new value

Specified by:
saveNodeComment in interface AssessmentManager
identity - The user who changes this comment
assessedIdentity - The user whose comment is changed
See Also:
AssessmentManager.saveNodeComment(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity, java.lang.String)

saveNodeCoachComment

public void saveNodeCoachComment(CourseNode courseNode,
                                 Identity assessedIdentity,
                                 java.lang.String comment)
Description copied from interface: AssessmentManager
Save an coach comment for this node for a user. If there is already a coach comment property available, it will be overwritten with the new value.

Specified by:
saveNodeCoachComment in interface AssessmentManager
assessedIdentity - The user whose coach comment is changed
See Also:
AssessmentManager.saveNodeCoachComment(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, java.lang.String)

incrementNodeAttempts

public void incrementNodeAttempts(CourseNode courseNode,
                                  Identity identity,
                                  UserCourseEnvironment userCourseEnv)
Description copied from interface: AssessmentManager
Increment the users attempts for this course node.

Specified by:
incrementNodeAttempts in interface AssessmentManager
See Also:
org.olat.course.assessment.AssessmentManager#incrementNodeAttempts(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

getNodeScore

public java.lang.Float getNodeScore(CourseNode courseNode,
                                    Identity identity)
Specified by:
getNodeScore in interface AssessmentManager
Parameters:
courseNode - The course node
identity - The identity
Returns:
The achieved score or null if no score available
See Also:
AssessmentManager.getNodeScore(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

getNodePassed

public java.lang.Boolean getNodePassed(CourseNode courseNode,
                                       Identity identity)
Specified by:
getNodePassed in interface AssessmentManager
Parameters:
courseNode - The course node
identity - The identity
Returns:
whether passed or not, or null if there is no info yet
See Also:
AssessmentManager.getNodePassed(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

getNodeAttempts

public java.lang.Integer getNodeAttempts(CourseNode courseNode,
                                         Identity identity)
Specified by:
getNodeAttempts in interface AssessmentManager
Parameters:
courseNode - The course node
identity - The identity
Returns:
The number of attempts. If no Property is set, the method will return 0
See Also:
AssessmentManager.getNodeAttempts(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

getNodeComment

public java.lang.String getNodeComment(CourseNode courseNode,
                                       Identity identity)
Specified by:
getNodeComment in interface AssessmentManager
Parameters:
courseNode - The course node
identity - The identity
Returns:
The achieved passed or null if no passed available
See Also:
AssessmentManager.getNodeComment(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

getNodeCoachComment

public java.lang.String getNodeCoachComment(CourseNode courseNode,
                                            Identity identity)
Specified by:
getNodeCoachComment in interface AssessmentManager
Parameters:
courseNode - The course node
identity - The identity
Returns:
The coach comment or null if no coach comment available
See Also:
AssessmentManager.getNodeCoachComment(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

registerForAssessmentChangeEvents

public void registerForAssessmentChangeEvents(GenericEventListener gel,
                                              Identity identity)
Description copied from interface: AssessmentManager
Register the given event listener for all assessment changed events of this course

Specified by:
registerForAssessmentChangeEvents in interface AssessmentManager
See Also:
AssessmentManager.registerForAssessmentChangeEvents(org.olat.core.util.event.GenericEventListener, org.olat.core.id.Identity)

deregisterFromAssessmentChangeEvents

public void deregisterFromAssessmentChangeEvents(GenericEventListener gel)
Description copied from interface: AssessmentManager
Deregister the given event listener from all assessment changed events of this course

Specified by:
deregisterFromAssessmentChangeEvents in interface AssessmentManager
See Also:
AssessmentManager.deregisterFromAssessmentChangeEvents(org.olat.core.util.event.GenericEventListener)

getAssessmentID

public java.lang.Long getAssessmentID(CourseNode courseNode,
                                      Identity identity)
No caching for the assessmentID.

Specified by:
getAssessmentID in interface AssessmentManager
Returns:
null if none found
See Also:
AssessmentManager.getAssessmentID(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity)

saveScoreEvaluation

public void saveScoreEvaluation(CourseNode courseNode,
                                Identity identity,
                                Identity assessedIdentity,
                                ScoreEvaluation scoreEvaluation,
                                UserCourseEnvironment userCourseEnv,
                                boolean incrementUserAttempts)
Description copied from interface: AssessmentManager
Save the users achieved ScoreEvaluation for this node. If there is already a score property available, it will be overwritten with the new value

Specified by:
saveScoreEvaluation in interface AssessmentManager
See Also:
org.olat.course.assessment.AssessmentManager#saveScoreEvaluation(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity, org.olat.course.run.scoring.ScoreEvaluation)

createOLATResourceableForLocking

public OLATResourceable createOLATResourceableForLocking(Identity assessedIdentity)
Always use this to get a OLATResourceable for doInSync locking! Uses the assessIdentity.

Specified by:
createOLATResourceableForLocking in interface AssessmentManager
Parameters:
course -
assessedIdentity -
courseNode -
Returns: