Ensure submission is complete before showing answers
Fixes CNVS-18802 Test plan - Create a quiz with multiple attempts and 'Let Students See The Correct Answers' 'Only After Their Last Attempt' - Take quiz untill you are on your final attempt - Answers should not be visible during final attempt - When final attempt is completed answers should now be visible Change-Id: Ibf729afbe491b958d58b6b813379c9b40e678088 Reviewed-on: https://gerrit.instructure.com/49507 Tested-by: Jenkins Reviewed-by: Ryan Taylor <rtaylor@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Brian Finney <bfinney@instructure.com>
This commit is contained in:
parent
88ba655dff
commit
a9b68e3abc
|
@ -353,7 +353,7 @@ class Quizzes::Quiz < ActiveRecord::Base
|
|||
return false unless self.show_correct_answers
|
||||
|
||||
if user.present? && self.show_correct_answers_last_attempt && quiz_submission = user.quiz_submissions.where(quiz_id: self.id).first
|
||||
return quiz_submission.attempts_left == 0
|
||||
return quiz_submission.attempts_left == 0 && quiz_submission.complete?
|
||||
end
|
||||
|
||||
# If we're showing the results only one time, and are letting students
|
||||
|
|
|
@ -1432,17 +1432,23 @@ describe Quizzes::Quiz do
|
|||
context "show_correct_answers_last_attempt is true" do
|
||||
let(:user) { User.create! }
|
||||
|
||||
it "shows the correct answers on last attempt" do
|
||||
it "shows the correct answers on last attempt completed" do
|
||||
quiz = @course.quizzes.create!({
|
||||
title: 'test quiz',
|
||||
show_correct_answers: true,
|
||||
show_correct_answers_last_attempt: true,
|
||||
allowed_attempts: 1
|
||||
allowed_attempts: 2
|
||||
})
|
||||
|
||||
quiz.publish!
|
||||
|
||||
submission = quiz.generate_submission(user)
|
||||
expect(quiz.show_correct_answers?(user, submission)).to be_falsey
|
||||
submission.complete!
|
||||
|
||||
submission = quiz.generate_submission(user)
|
||||
expect(quiz.show_correct_answers?(user, submission)).to be_falsey
|
||||
submission.complete!
|
||||
|
||||
expect(quiz.show_correct_answers?(user, submission)).to be_truthy
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue