Skip to content

Commit

Permalink
Merge pull request #2972 from NationalSecurityAgency/t#2933/quiz_summ…
Browse files Browse the repository at this point in the history
…ary_counts

#2933: only return counts for completed quizzes and surveys
  • Loading branch information
rmmayo authored Nov 13, 2024
2 parents a035652 + 3fd6cf7 commit cb099b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ interface UserQuizAttemptRepo extends JpaRepository<UserQuizAttempt, Long> {
sum(case when quizDef.type = 'Quiz' then 1 else 0 end) as numQuizAttempts
from UserQuizAttempt attempt, QuizDef quizDef
where attempt.userId = ?1
and attempt.status in ('PASSED', 'FAILED')
and attempt.quizDefinitionRefId = quizDef.id''')
AttemptCounts getAttemptCountsForUser(String userId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1273,10 +1273,12 @@ class MyProgressSpec extends DefaultIntSpec {
])
return quiz.quizId
}
def runQuiz = { String quizId ->
def runQuiz = { String quizId, boolean completeQuiz = true ->
def quizAttempt = skillsService.startQuizAttempt(quizId).body
skillsService.reportQuizAnswer(quizId, quizAttempt.id, quizAttempt.questions[0].answerOptions[0].id)
skillsService.completeQuizAttempt(quizId, quizAttempt.id)
if (completeQuiz) {
skillsService.completeQuizAttempt(quizId, quizAttempt.id)
}
}

def quiz1Id = declareQuiz(1)
Expand Down Expand Up @@ -1308,6 +1310,14 @@ class MyProgressSpec extends DefaultIntSpec {
runQuiz(survey3Id)
def summary_t7 = skillsService.getMyProgressSummary()

// not completed attempts
runQuiz(quiz1Id, false)
runQuiz(quiz2Id, false)
runQuiz(survey1Id, false)
runQuiz(survey2Id, false)
runQuiz(survey3Id, false)
def summary_t8 = skillsService.getMyProgressSummary()

then:
summary_t1.numQuizAttempts == 0
summary_t1.numSurveyAttempts == 0
Expand All @@ -1329,6 +1339,9 @@ class MyProgressSpec extends DefaultIntSpec {

summary_t7.numQuizAttempts == 6
summary_t7.numSurveyAttempts == 5

summary_t8.numQuizAttempts == 6
summary_t8.numSurveyAttempts == 5
}

}
Expand Down

0 comments on commit cb099b6

Please # to comment.