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:
parent
5ea1dcebe6
commit
a040b94cfa
|
@ -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|
|
||||||
|
|
|
@ -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,6 +1030,9 @@ describe QuizzesController do
|
||||||
response.should render_template('statistics')
|
response.should render_template('statistics')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "logged out submissions" do
|
||||||
|
integrate_views
|
||||||
|
|
||||||
it "should include logged_out users' submissions in a public course" do
|
it "should include logged_out users' submissions in a public course" do
|
||||||
#logged_out user
|
#logged_out user
|
||||||
user = temporary_user_code
|
user = temporary_user_code
|
||||||
|
@ -1043,17 +1048,22 @@ describe QuizzesController do
|
||||||
#non logged_out submissions
|
#non logged_out submissions
|
||||||
@user1 = user_with_pseudonym(:active_all => true, :name => 'Student1', :username => 'student1@instructure.com')
|
@user1 = user_with_pseudonym(:active_all => true, :name => 'Student1', :username => 'student1@instructure.com')
|
||||||
@quiz_submission1 = @quiz.generate_submission(@user1)
|
@quiz_submission1 = @quiz.generate_submission(@user1)
|
||||||
@quiz_submission1.mark_completed
|
@quiz_submission1.grade_submission
|
||||||
|
|
||||||
@user2 = user_with_pseudonym(:active_all => true, :name => 'Student2', :username => 'student2@instructure.com')
|
@user2 = user_with_pseudonym(:active_all => true, :name => 'Student2', :username => 'student2@instructure.com')
|
||||||
@quiz_submission2 = @quiz.generate_submission(@user2)
|
@quiz_submission2 = @quiz.generate_submission(@user2)
|
||||||
@quiz_submission2.mark_completed
|
@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.body.should match /Logged Out User/
|
||||||
response.should render_template('statistics')
|
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
|
||||||
course_with_teacher_logged_in(:active_all => true)
|
course_with_teacher_logged_in(:active_all => true)
|
||||||
|
|
Loading…
Reference in New Issue