use of org.olat.course.assessment.manager.EfficiencyStatementManager in project OpenOLAT by OpenOLAT.
the class NewCachePersistingAssessmentManager method saveScoreEvaluationInSync.
private Long saveScoreEvaluationInSync(CourseNode courseNode, Identity identity, Identity assessedIdentity, ScoreEvaluation scoreEvaluation, boolean incrementUserAttempts, final UserCourseEnvironment userCourseEnv, final CoursePropertyManager cpm) {
Long attempts = null;
saveNodeScore(courseNode, assessedIdentity, scoreEvaluation.getScore(), cpm);
log.debug("successfully saved node score : " + scoreEvaluation.getScore());
saveNodePassed(courseNode, assessedIdentity, scoreEvaluation.getPassed(), cpm);
log.debug("successfully saved node passed : " + scoreEvaluation.getPassed());
saveAssessmentID(courseNode, assessedIdentity, scoreEvaluation.getAssessmentID(), cpm);
log.debug("successfully saved node asssessmentId : " + scoreEvaluation.getPassed());
saveNodeFullyAssessed(courseNode, identity, assessedIdentity, scoreEvaluation.getFullyAssessed(), cpm);
log.debug("successfully saved node marked completely : " + scoreEvaluation.getPassed());
if (incrementUserAttempts) {
attempts = incrementNodeAttemptsProperty(courseNode, assessedIdentity, cpm);
log.debug("successfully saved user attemps : " + attempts);
}
saveNodeFullyAssessed(courseNode, identity, assessedIdentity, scoreEvaluation.getFullyAssessed(), cpm);
log.debug("successfully saved node fullyAssessed : " + scoreEvaluation.getFullyAssessed());
DBFactory.getInstance().commitAndCloseSession();
if (courseNode instanceof AssessableCourseNode) {
userCourseEnv.getScoreAccounting().evaluateAll();
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
esm.updateUserEfficiencyStatement(userCourseEnv);
}
return attempts;
}
use of org.olat.course.assessment.manager.EfficiencyStatementManager in project openolat by klemens.
the class NewCachePersistingAssessmentManager method incrementNodeAttempts.
private void incrementNodeAttempts(final CourseNode courseNode, final Identity identity, final UserCourseEnvironment userCourseEnv, boolean logActivity) {
ICourse course = CourseFactory.loadCourse(ores);
final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
long attempts = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(identity), new SyncerCallback<Long>() {
public Long execute() {
long attempts = incrementNodeAttemptsProperty(courseNode, identity, cpm);
if (courseNode instanceof AssessableCourseNode) {
// Update users efficiency statement
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
esm.updateUserEfficiencyStatement(userCourseEnv);
}
return attempts;
}
});
// notify about changes
AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, identity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
if (logActivity) {
// user activity logging
ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(identity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
}
use of org.olat.course.assessment.manager.EfficiencyStatementManager in project openolat by klemens.
the class EfficiencyStatementWebService method putEfficiencyStatement.
/**
* Create a new efficiency statement.
*
* @response.representation.200.doc If the statement was persisted
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The identity or the resource cannot be found
* @param identityKey The owner of the certificate
* @param resourceKey The primary key of the resource of the repository entry of the course.
* @return Nothing special
*/
@PUT
@Path("{identityKey}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response putEfficiencyStatement(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, EfficiencyStatementVO efficiencyStatementVO, @Context HttpServletRequest request) {
if (!isAdmin(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
Identity assessedIdentity = baseSecurity.loadIdentityByKey(identityKey);
if (assessedIdentity == null) {
return Response.serverError().status(Response.Status.NOT_FOUND).build();
}
EfficiencyStatementManager efficiencyStatementManager = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
EfficiencyStatement efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementByResourceKey(resourceKey, assessedIdentity);
if (efficiencyStatement != null) {
return Response.serverError().status(Response.Status.CONFLICT).build();
}
Date creationDate = efficiencyStatementVO.getCreationDate();
Float score = efficiencyStatementVO.getScore();
Boolean passed = efficiencyStatementVO.getPassed();
OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
OLATResource resource = resourceManager.findResourceById(resourceKey);
if (resource == null) {
String courseTitle = efficiencyStatementVO.getCourseTitle();
efficiencyStatementManager.createStandAloneUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resourceKey, courseTitle);
} else {
efficiencyStatementManager.createUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resource);
}
return Response.ok().build();
}
use of org.olat.course.assessment.manager.EfficiencyStatementManager in project openolat by klemens.
the class GetScoreWithCourseIdFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
if (inStack.length > 2) {
// need > 2 for compatibility reason
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
Long courseRepoEntryKey;
try {
courseRepoEntryKey = Long.decode((String) inStack[0]);
} catch (NumberFormatException nfe) {
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
}
// no integrity check can be done - other course might not exist anymore
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
// the real function evaluation which is used during run time
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
RepositoryEntryRef courseRef = new RepositoryEntryRefImpl(courseRepoEntryKey);
UserEfficiencyStatement es = esm.getUserEfficiencyStatementLightByRepositoryEntry(courseRef, getUserCourseEnv().getIdentityEnvironment().getIdentity());
if (es == null)
return defaultValue();
Float score = es.getScore();
if (score == null)
return defaultValue();
// finally check existing value
return new Double(score.doubleValue());
}
Aggregations