fix issue when a student visits a manually unlocked quiz with one time results

fixes CNVS-15869

test plan
  - as a teacher
    - create a quiz
      - with a lock date in the past
      - give a time limit
      - allow multiple attempts
      - let students see their quiz responses
        - only after their last attempt
        - only once after each attempt

    - moderate the quiz
      - manually unlock the quiz for a student

  - as a student
    - attempt to take the manually unlocked quiz
    - you should be able to take it

Change-Id: Idd0ee39f818439ad12f4da5436f2bd02fd4a36b9
Reviewed-on: https://gerrit.instructure.com/41882
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
This commit is contained in:
Derek DeVries 2014-09-29 09:32:41 -06:00 committed by Ahmad Amireh
parent a25ec862a0
commit dfca01f13c
2 changed files with 22 additions and 1 deletions

View File

@ -911,7 +911,7 @@ class Quizzes::QuizzesController < ApplicationController
submission = @submission || get_submission
return unless submission.present?
return if submission.blank? || submission.settings_only?
if submission.results_visible? && !submission.has_seen_results?
Quizzes::QuizSubmission.where({ id: submission }).update_all({

View File

@ -371,6 +371,27 @@ describe Quizzes::QuizzesController do
response.should be_success
submission.reload.has_seen_results.should == true
end
it "does not attempt to lock results if there is a settings only submission" do
Account.default.disable_feature! :quiz_stats
user_session(@student)
course_quiz(true)
@quiz.lock_at = 2.days.ago
@quiz.one_time_results = true
@quiz.save!
@quiz.publish!
sub_manager = Quizzes::SubmissionManager.new(@quiz)
submission = sub_manager.find_or_create_submission(@student, nil, 'settings_only')
submission.manually_unlocked = true
submission.save!
get 'show', course_id: @course.id, id: @quiz.id
response.should be_success
submission.reload.has_seen_results.should be_nil
end
end
describe "GET 'show' with quiz stats enabled" do