Search in sources :

Example 1 with EfficiencyStatementManager

use of org.olat.course.assessment.manager.EfficiencyStatementManager in project OpenOLAT by OpenOLAT.

the class UserCourseEnvironmentImpl method hasEfficiencyStatementOrCertificate.

@Override
public boolean hasEfficiencyStatementOrCertificate(boolean update) {
    if (certification == null || update) {
        EfficiencyStatementManager efficiencyStatementManager = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
        boolean hasStatement = efficiencyStatementManager.hasUserEfficiencyStatement(getCourseRepositoryEntry().getKey(), identityEnvironment.getIdentity());
        if (hasStatement) {
            certification = Boolean.TRUE;
        } else {
            CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
            certification = certificatesManager.hasCertificate(identityEnvironment.getIdentity(), getCourseRepositoryEntry().getOlatResource().getKey());
        }
    }
    return certification.booleanValue();
}
Also used : EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) CertificatesManager(org.olat.course.certificate.CertificatesManager)

Example 2 with EfficiencyStatementManager

use of org.olat.course.assessment.manager.EfficiencyStatementManager in project OpenOLAT by OpenOLAT.

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 3 with EfficiencyStatementManager

use of org.olat.course.assessment.manager.EfficiencyStatementManager in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method saveScoreEvaluation.

/**
 * @see 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)
 */
public void saveScoreEvaluation(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final ScoreEvaluation scoreEvaluation, final UserCourseEnvironment userCourseEnv, final boolean incrementUserAttempts) {
    final ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    final RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    // o_clusterREVIEW we could sync on a element finer than course, e.g. the composite course+assessIdentity.
    // +: concurrency would be higher
    // -: many entries (num of courses * visitors of given course) in the locktable.
    // we could also sync on the assessedIdentity.
    Long attempts = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerCallback<Long>() {

        public Long execute() {
            Long attempts = null;
            Float score = scoreEvaluation.getScore();
            Boolean passed = scoreEvaluation.getPassed();
            saveNodeScore(courseNode, assessedIdentity, score, cpm);
            saveNodePassed(courseNode, assessedIdentity, passed, cpm);
            saveAssessmentID(courseNode, assessedIdentity, scoreEvaluation.getAssessmentID(), cpm);
            if (incrementUserAttempts) {
                attempts = incrementNodeAttemptsProperty(courseNode, assessedIdentity, cpm);
            }
            if (courseNode instanceof AssessableCourseNode) {
                userCourseEnv.getScoreAccounting().evaluateAll();
                // Update users efficiency statement
                EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
                esm.updateUserEfficiencyStatement(userCourseEnv);
            }
            if (passed != null && passed.booleanValue() && course.getCourseConfig().isAutomaticCertificationEnabled()) {
                CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
                if (certificatesManager.isCertificationAllowed(assessedIdentity, courseEntry)) {
                    CertificateTemplate template = null;
                    Long templateId = course.getCourseConfig().getCertificateTemplate();
                    if (templateId != null) {
                        template = certificatesManager.getTemplateById(templateId);
                    }
                    CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, score, passed);
                    certificatesManager.generateCertificate(certificateInfos, courseEntry, template, true);
                }
            }
            return attempts;
        }
    });
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, SCORE + " set to: " + String.valueOf(scoreEvaluation.getScore()));
    if (scoreEvaluation.getPassed() != null) {
        am.appendToUserNodeLog(courseNode, identity, assessedIdentity, PASSED + " set to: " + scoreEvaluation.getPassed().toString());
    } else {
        am.appendToUserNodeLog(courseNode, identity, assessedIdentity, PASSED + " set to \"undefined\"");
    }
    if (scoreEvaluation.getAssessmentID() != null) {
        am.appendToUserNodeLog(courseNode, assessedIdentity, assessedIdentity, ASSESSMENT_ID + " set to: " + scoreEvaluation.getAssessmentID().toString());
    }
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    if (scoreEvaluation.getScore() != null) {
        ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_SCORE_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiScore, "", String.valueOf(scoreEvaluation.getScore())));
    }
    if (scoreEvaluation.getPassed() != null) {
        ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", String.valueOf(scoreEvaluation.getPassed())));
    } else {
        ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_PASSED_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiPassed, "", "undefined"));
    }
    if (incrementUserAttempts && attempts != null) {
        ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(identity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
    }
}
Also used : CertificateTemplate(org.olat.course.certificate.CertificateTemplate) EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) CertificateInfos(org.olat.course.certificate.model.CertificateInfos) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) CertificatesManager(org.olat.course.certificate.CertificatesManager) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 4 with EfficiencyStatementManager

use of org.olat.course.assessment.manager.EfficiencyStatementManager in project OpenOLAT by OpenOLAT.

the class GetPassedWithCourseIdFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    /*
		 * argument check
		 */
    if (inStack.length > 2) {
        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"));
    }
    /*
		 * argument type check
		 */
    Long courseRepoEntryKey;
    try {
        Object arg = inStack[0];
        if (arg instanceof Number) {
            courseRepoEntryKey = new Long(((Number) arg).longValue());
        } else if (arg instanceof String) {
            courseRepoEntryKey = Long.decode((String) arg);
        } else {
            courseRepoEntryKey = null;
        }
    } 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();
    Boolean passed = es.getPassed();
    if (passed == null) {
        return defaultValue();
    }
    // finally check existing value
    return passed.booleanValue() ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
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)

Example 5 with EfficiencyStatementManager

use of org.olat.course.assessment.manager.EfficiencyStatementManager in project OpenOLAT by OpenOLAT.

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