only count active quizzes in course stats
fixes CNVS-26308 test plan: - create 2 quizzes, with questions - take them both - delete 1 of them - go to the course stats page - only the non-deleted quiz should count (for quizzes, questions, and submissions) Change-Id: Ib6155e1036fce43c81c2ad346b7252e818831114 Reviewed-on: https://gerrit.instructure.com/70822 Tested-by: Jenkins Reviewed-by: Ryan Taylor <rtaylor@instructure.com> QA-Review: Michael Hargiss <mhargiss@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
ec50e13f2d
commit
eb598ab5b3
|
@ -67,13 +67,13 @@
|
|||
<td class="indent"><%= inactive_students %></td>
|
||||
</tr><tr>
|
||||
<td><%= t('quizzes', %{Quizzes}) %></td>
|
||||
<td><%= @context.quizzes.count %></td>
|
||||
<td class="quiz_count"><%= @context.quizzes.active.before(@range_end).count %></td>
|
||||
</tr><tr>
|
||||
<td class="indent"><%= t('quiz_questions', %{Quiz Questions}) %></td>
|
||||
<td class="indent"><%= @context.quizzes.before(@range_end).map{|q| (q.quiz_data || []).length}.sum %></td>
|
||||
<td class="indent quiz_question_count"><%= @context.quizzes.active.before(@range_end).map{|q| (q.quiz_data || []).length}.sum %></td>
|
||||
</tr><tr>
|
||||
<td class="indent"><%= t('quiz_submissions', %{Quiz Submissions}) %></td>
|
||||
<td class="indent"><%= Quizzes::QuizSubmission.where(quiz_id: @context.quizzes.before(@range_end)).count %></td>
|
||||
<td class="indent quiz_submission_count"><%= Quizzes::QuizSubmission.where(quiz_id: @context.quizzes.active.before(@range_end)).count %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Copyright (C) 2011-12 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../views_helper')
|
||||
|
||||
describe "courses/statistics.html.erb" do
|
||||
before do
|
||||
course_with_teacher(:active_all => true)
|
||||
assigns[:range_start] = Date.parse("Jan 1 2000")
|
||||
assigns[:range_end] = 3.days.from_now
|
||||
end
|
||||
|
||||
it "only lists active quiz objects, questions, and submissions" do
|
||||
quiz_with_submission
|
||||
@quiz.destroy
|
||||
quiz_with_submission
|
||||
|
||||
view_context(@course, @user)
|
||||
render
|
||||
|
||||
doc = Nokogiri::HTML.parse(response.body)
|
||||
expect(doc.at_css('.quiz_count').text).to eq "1"
|
||||
expect(doc.at_css('.quiz_question_count').text).to eq "1"
|
||||
expect(doc.at_css('.quiz_submission_count').text).to eq "1"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue