Skip to content

Commit 7822296

Browse files
author
Derek DeVries
committed
fix question count for unpublished quizzes on quizzes#index page
fixes CNVS-7250 Test plan - create an unpublished quiz with some questions - the unpublished quiz should show the correct question count on the index page Change-Id: Ia4d3760d3d2d0bca186591f2245da2be20f31f0a Reviewed-on: https://gerrit.instructure.com/22834 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Stanley Stuart <stanley@instructure.com> QA-Review: Myller de Araujo <myller@instructure.com> Product-Review: Derek DeVries <ddevries@instructure.com>
1 parent 83acc5b commit 7822296

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

lib/api/v1/quiz.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ module Api::V1::Quiz
3535
scoring_policy
3636
allowed_attempts
3737
one_question_at_a_time
38-
question_count
3938
points_possible
4039
cant_go_back
4140
access_code
@@ -79,6 +78,7 @@ def quiz_json(quiz, context, user, session)
7978
hash = api_json(quiz, user, session, API_ALLOWED_QUIZ_OUTPUT_FIELDS).merge(
8079
:html_url => polymorphic_url([context, quiz]),
8180
:mobile_url => polymorphic_url([context, quiz], :persist_headless => 1, :force_user => 1),
81+
:question_count => quiz.question_count + quiz.unpublished_question_count,
8282
:published => quiz.published?
8383
)
8484
locked_json(hash, quiz, user, 'quiz', :context => context)

spec/apis/v1/quizzes_api_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ def api_get_json
103103
it "includes published" do
104104
@json['published'].should == false
105105
end
106+
107+
it "includes question count" do
108+
@json['question_count'].should == 0
109+
end
110+
end
111+
112+
context "unpublished quiz" do
113+
before do
114+
@quiz = @course.quizzes.create! :title => 'title'
115+
@quiz.quiz_questions.create!(:question_data => { :name => "test 1" })
116+
@quiz.save!
117+
118+
@json = api_call(:get, "/api/v1/courses/#{@course.id}/quizzes/#{@quiz.id}",
119+
:controller=>"quizzes_api", :action=>"show", :format=>"json", :course_id=>"#{@course.id}", :id => "#{@quiz.id}")
120+
end
121+
122+
it "includes unpublished questions in question count" do
123+
@json['question_count'].should == 1
124+
end
106125
end
107126

108127
context "non-existent quiz" do

0 commit comments

Comments
 (0)