Search in sources :

Example 11 with EfficiencyStatementManager

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;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager)

Example 12 with EfficiencyStatementManager

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)));
    }
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 13 with EfficiencyStatementManager

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();
}
Also used : EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) Date(java.util.Date) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 14 with EfficiencyStatementManager

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());
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) RepositoryEntryRefImpl(org.olat.repository.model.RepositoryEntryRefImpl) ArgumentParseException(org.olat.course.condition.interpreter.ArgumentParseException) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Aggregations

EfficiencyStatementManager (org.olat.course.assessment.manager.EfficiencyStatementManager)14 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)6 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)6 ICourse (org.olat.course.ICourse)4 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)4 CertificatesManager (org.olat.course.certificate.CertificatesManager)4 ArgumentParseException (org.olat.course.condition.interpreter.ArgumentParseException)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)4 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)4 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)4 Date (java.util.Date)2 Consumes (javax.ws.rs.Consumes)2 PUT (javax.ws.rs.PUT)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BaseSecurity (org.olat.basesecurity.BaseSecurity)2 Identity (org.olat.core.id.Identity)2 EfficiencyStatement (org.olat.course.assessment.EfficiencyStatement)2 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)2