allow students to see answers after final attempt
fixes CNVS-19091 test plan: - make a quiz where correct answers are visible after a final attempt and give them two attempts - include some questions that require manual grading and some that do not - as a student submit two attempts - note that you do NOT get an error saying 'Answers will be shown after your last attempt' once you have submitted your second attempt Change-Id: I4ed1c7c775ef730afb963ed1d15f844e2244602f Reviewed-on: https://gerrit.instructure.com/55480 Tested-by: Jenkins Reviewed-by: Brian Finney <bfinney@instructure.com> QA-Review: Michael Hargiss <mhargiss@instructure.com> Product-Review: Hilary Scharton <hilary@instructure.com>
This commit is contained in:
parent
9786c83114
commit
ea246c32d5
|
@ -122,8 +122,10 @@ module QuizzesHelper
|
|||
end
|
||||
end
|
||||
|
||||
def render_correct_answer_protection(quiz)
|
||||
return I18n.t('Answers will be shown after your last attempt') if quiz.show_correct_answers_last_attempt
|
||||
def render_correct_answer_protection(quiz, submission)
|
||||
if quiz.show_correct_answers_last_attempt && !submission.last_attempt_completed?
|
||||
return I18n.t('Answers will be shown after your last attempt')
|
||||
end
|
||||
show_at = quiz.show_correct_answers_at
|
||||
hide_at = quiz.hide_correct_answers_at
|
||||
now = Time.now
|
||||
|
|
|
@ -352,8 +352,9 @@ 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 && quiz_submission.complete?
|
||||
quiz_submission = user.present? && user.quiz_submissions.where(quiz_id: self.id).first
|
||||
if self.show_correct_answers_last_attempt && quiz_submission
|
||||
return quiz_submission.attempts_left == 0 && quiz_submission.completed?
|
||||
end
|
||||
|
||||
# If we're showing the results only one time, and are letting students
|
||||
|
|
|
@ -229,12 +229,16 @@ class Quizzes::QuizSubmission < ActiveRecord::Base
|
|||
# prevents the student from starting to take the quiz for the last
|
||||
# time, then opening a new tab and looking at the results from
|
||||
# a prior attempt)
|
||||
!quiz.allowed_attempts || quiz.allowed_attempts < 1 || attempt > quiz.allowed_attempts || (completed? && attempt == quiz.allowed_attempts)
|
||||
!quiz.allowed_attempts || quiz.allowed_attempts < 1 || attempt > quiz.allowed_attempts || last_attempt_completed?
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def last_attempt_completed?
|
||||
completed? && quiz.allowed_attempts && attempt >= quiz.allowed_attempts
|
||||
end
|
||||
|
||||
def self.needs_grading
|
||||
resp = where("(
|
||||
quiz_submissions.workflow_state = 'untaken'
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
<% if correct_answers_protected? %>
|
||||
<div class="alert">
|
||||
<i class="icon-warning" aria-label="<%= render_correct_answer_protection(@quiz) %>"></i>
|
||||
<span><%= render_correct_answer_protection(@quiz) %></span>
|
||||
<i class="icon-warning" aria-label="<%= render_correct_answer_protection(@quiz, (@current_submission || @submission)) %>"></i>
|
||||
<span><%= render_correct_answer_protection(@quiz, (@current_submission || @submission)) %></span>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -398,8 +398,9 @@ describe QuizzesHelper do
|
|||
quiz = stub({
|
||||
show_correct_answers_last_attempt: true,
|
||||
})
|
||||
quiz_submission = stub(last_attempt_completed?: false)
|
||||
|
||||
message = render_correct_answer_protection(quiz)
|
||||
message = render_correct_answer_protection(quiz, quiz_submission)
|
||||
expect(message).to match /last attempt/
|
||||
end
|
||||
it 'should provide a useful message when "no"' do
|
||||
|
@ -409,8 +410,9 @@ describe QuizzesHelper do
|
|||
show_correct_answers_at: nil,
|
||||
hide_correct_answers_at: nil
|
||||
})
|
||||
quiz_submission = stub(last_attempt_completed?: false)
|
||||
|
||||
message = render_correct_answer_protection(quiz)
|
||||
message = render_correct_answer_protection(quiz, quiz_submission)
|
||||
expect(message).to match /are hidden/
|
||||
end
|
||||
|
||||
|
@ -421,8 +423,9 @@ describe QuizzesHelper do
|
|||
show_correct_answers_at: nil,
|
||||
hide_correct_answers_at: nil
|
||||
})
|
||||
quiz_submission = stub(last_attempt_completed?: false)
|
||||
|
||||
message = render_correct_answer_protection(quiz)
|
||||
message = render_correct_answer_protection(quiz, quiz_submission)
|
||||
expect(message).to eq nil
|
||||
end
|
||||
|
||||
|
@ -433,8 +436,9 @@ describe QuizzesHelper do
|
|||
show_correct_answers_at: 1.day.from_now,
|
||||
hide_correct_answers_at: nil
|
||||
})
|
||||
quiz_submission = stub(last_attempt_completed?: false)
|
||||
|
||||
message = render_correct_answer_protection(quiz)
|
||||
message = render_correct_answer_protection(quiz, quiz_submission)
|
||||
expect(message).to match /will be available/
|
||||
end
|
||||
|
||||
|
@ -445,8 +449,9 @@ describe QuizzesHelper do
|
|||
show_correct_answers_at: nil,
|
||||
hide_correct_answers_at: 1.day.from_now
|
||||
})
|
||||
quiz_submission = stub(last_attempt_completed?: false)
|
||||
|
||||
message = render_correct_answer_protection(quiz)
|
||||
message = render_correct_answer_protection(quiz, quiz_submission)
|
||||
expect(message).to match /are available until/
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue