re-include logged out submissions for quiz statistics page

Fixes a regression where an error would be thrown if trying to access a
user's submission from the quiz submission data if the user had been
logged out when submitting the quiz (aka, a temporary user).

Test Plan:
  - As a student, take a quiz, but before you submit it, log yourself
    out in another tab.
  - As the teacher in the course, go to the quiz statistics page for
    that quiz. You should not get a page error.

fixes CNVS-7320

Change-Id: Ie75ed9af46accb92755f7a1a9d32dd6b1f3e50b8
Reviewed-on: https://gerrit.instructure.com/23164
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Reviewed-by: Cameron Sutter <csutter@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
This commit is contained in:
Stanley Stuart 2013-08-08 11:45:21 -05:00
parent 5ea1dcebe6
commit a040b94cfa
2 changed files with 31 additions and 21 deletions

View File

@ -116,11 +116,11 @@ class QuizzesController < ApplicationController
@statistics = @quiz.statistics(all_versions) @statistics = @quiz.statistics(all_versions)
user_ids = @statistics[:submission_user_ids] user_ids = @statistics[:submission_user_ids]
@submitted_users = User.where(:id => user_ids.to_a).order_by_sortable_name @submitted_users = User.where(:id => user_ids.to_a).order_by_sortable_name
#include logged out users
@submitted_users += @statistics[:submission_logged_out_users]
@users = Hash[ @users = Hash[
@submitted_users.map { |u| [u.id, u] } @submitted_users.map { |u| [u.id, u] }
] ]
#include logged out users
@submitted_users += @statistics[:submission_logged_out_users]
end end
js_env :quiz_reports => QuizStatistics::REPORTS.map { |report_type| js_env :quiz_reports => QuizStatistics::REPORTS.map { |report_type|

View File

@ -61,6 +61,8 @@ describe QuizzesController do
@quiz_submission = @quiz.generate_submission(user) @quiz_submission = @quiz.generate_submission(user)
@quiz_submission.mark_completed @quiz_submission.mark_completed
@quiz_submission.submission_data = yield if block_given? @quiz_submission.submission_data = yield if block_given?
@quiz_submission.grade_submission
@quiz_submission.save!
end end
describe "GET 'index'" do describe "GET 'index'" do
@ -1028,31 +1030,39 @@ describe QuizzesController do
response.should render_template('statistics') response.should render_template('statistics')
end end
it "should include logged_out users' submissions in a public course" do context "logged out submissions" do
#logged_out user integrate_views
user = temporary_user_code
#make questions it "should include logged_out users' submissions in a public course" do
questions = [{:question_data => { :name => "test 1" }}, #logged_out user
{:question_data => { :name => "test 2" }}, user = temporary_user_code
{:question_data => { :name => "test 3" }},
{:question_data => { :name => "test 4" }}]
logged_out_survey_with_submission user, questions #make questions
questions = [{:question_data => { :name => "test 1" }},
{:question_data => { :name => "test 2" }},
{:question_data => { :name => "test 3" }},
{:question_data => { :name => "test 4" }}]
#non logged_out submissions logged_out_survey_with_submission user, questions
@user1 = user_with_pseudonym(:active_all => true, :name => 'Student1', :username => 'student1@instructure.com')
@quiz_submission1 = @quiz.generate_submission(@user1)
@quiz_submission1.mark_completed
@user2 = user_with_pseudonym(:active_all => true, :name => 'Student2', :username => 'student2@instructure.com') #non logged_out submissions
@quiz_submission2 = @quiz.generate_submission(@user2) @user1 = user_with_pseudonym(:active_all => true, :name => 'Student1', :username => 'student1@instructure.com')
@quiz_submission2.mark_completed @quiz_submission1 = @quiz.generate_submission(@user1)
@quiz_submission1.grade_submission
@user2 = user_with_pseudonym(:active_all => true, :name => 'Student2', :username => 'student2@instructure.com')
@quiz_submission2 = @quiz.generate_submission(@user2)
@quiz_submission2.grade_submission
@course.large_roster = false
@course.save!
get 'statistics', :course_id => @course.id, :quiz_id => @quiz.id get 'statistics', :course_id => @course.id, :quiz_id => @quiz.id, :all_versions => '1'
response.should be_success response.should be_success
response.should render_template('statistics') response.body.should match /Logged Out User/
response.should render_template('statistics')
end
end end
it "should show the statistics page if the course is a MOOC" do it "should show the statistics page if the course is a MOOC" do