From 9a445a238b61703f32469c69bc37b1e982b89e22 Mon Sep 17 00:00:00 2001 From: srosse <stephane.rosse@frentix.com> Date: Tue, 3 Jul 2018 15:34:53 +0200 Subject: [PATCH] OO-3567: increment attempts of test made within the test resource --- .../olat/ims/qti21/ui/AssessmentEntryOutcomesListener.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/olat/ims/qti21/ui/AssessmentEntryOutcomesListener.java b/src/main/java/org/olat/ims/qti21/ui/AssessmentEntryOutcomesListener.java index f9c3c3bfc4d..ec4398e7519 100644 --- a/src/main/java/org/olat/ims/qti21/ui/AssessmentEntryOutcomesListener.java +++ b/src/main/java/org/olat/ims/qti21/ui/AssessmentEntryOutcomesListener.java @@ -58,6 +58,7 @@ public class AssessmentEntryOutcomesListener implements OutcomesListener { private final boolean authorMode; private final boolean needManualCorrection; + private AtomicBoolean incrementAttempts = new AtomicBoolean(true); private AtomicBoolean start = new AtomicBoolean(true); private AtomicBoolean close = new AtomicBoolean(true); @@ -140,6 +141,11 @@ public class AssessmentEntryOutcomesListener implements OutcomesListener { assessmentEntry.setPassed(submittedPass); assessmentEntry.setCompletion(completion); assessmentEntry.setAssessmentId(assessmentId); + if(incrementAttempts.getAndSet(false)) { + int currentAttempts = assessmentEntry.getAttempts() == null ? 0 : assessmentEntry.getAttempts().intValue(); + assessmentEntry.setAttempts(currentAttempts + 1); + } + assessmentEntry = assessmentService.updateAssessmentEntry(assessmentEntry); boolean firstClose = close.getAndSet(false); -- GitLab