From 5935a81e21d422e630f4492ab32b3a8f179be3a1 Mon Sep 17 00:00:00 2001 From: Cameron Sutter Date: Thu, 3 Sep 2015 15:55:43 -0600 Subject: [PATCH] hide ungraded survey points fixes CNVS-9746 test plan: * create an ungraded survey with questions that have points note: you must create the questions before you save the ungraded survey for the first time * navigate to the show page * points possible should be blank * navigate to the quizzes index * points possible for this survey should not show up Change-Id: Ic34d55640ba7a0c1972cf26ad080a8adfee7dd8b Reviewed-on: https://gerrit.instructure.com/62568 Reviewed-by: John Corrigan Tested-by: Jenkins QA-Review: Derek Hansen Product-Review: Jason Sparks --- app/coffeescripts/models/Quiz.coffee | 5 ++++- app/helpers/quizzes_helper.rb | 4 ++++ .../quizzes/quizzes/_quiz_show_teacher.html.erb | 2 +- spec/coffeescripts/models/QuizSpec.coffee | 4 ++++ spec/views/quizzes/quizzes/show.html.erb_spec.rb | 16 ++++++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/coffeescripts/models/Quiz.coffee b/app/coffeescripts/models/Quiz.coffee index 157bab31b1e..3767a143b20 100644 --- a/app/coffeescripts/models/Quiz.coffee +++ b/app/coffeescripts/models/Quiz.coffee @@ -65,10 +65,13 @@ define [ initPointsCount: -> pts = @get 'points_possible' text = '' - if pts && pts > 0 + if pts && pts > 0 && !@isUngradedSurvey() text = I18n.t('assignment_points_possible', 'pt', count: pts) @set 'possible_points_label', text + isUngradedSurvey: -> + @get('quiz_type') == "survey" + initAllDates: -> if (allDates = @get('all_dates'))? @set 'all_dates', new DateGroupCollection(allDates) diff --git a/app/helpers/quizzes_helper.rb b/app/helpers/quizzes_helper.rb index 9f015b087a5..746022790bb 100644 --- a/app/helpers/quizzes_helper.rb +++ b/app/helpers/quizzes_helper.rb @@ -672,4 +672,8 @@ module QuizzesHelper end end + def points_possible_display + @quiz.quiz_type == "survey" ? "" : @quiz.points_possible + end + end diff --git a/app/views/quizzes/quizzes/_quiz_show_teacher.html.erb b/app/views/quizzes/quizzes/_quiz_show_teacher.html.erb index 38e4d763e01..03649a8715d 100644 --- a/app/views/quizzes/quizzes/_quiz_show_teacher.html.erb +++ b/app/views/quizzes/quizzes/_quiz_show_teacher.html.erb @@ -18,7 +18,7 @@ <%= t(:points, "Points") %>
- <%= @quiz.points_possible %> + <%= points_possible_display %>
diff --git a/spec/coffeescripts/models/QuizSpec.coffee b/spec/coffeescripts/models/QuizSpec.coffee index f841207ef2e..828e0dbf17b 100644 --- a/spec/coffeescripts/models/QuizSpec.coffee +++ b/spec/coffeescripts/models/QuizSpec.coffee @@ -85,6 +85,10 @@ define [ @quiz = new Quiz(points_possible: 2) equal @quiz.get('possible_points_label'), "2 pts" + test "#initialize points possible to null if ungraded survey", -> + @quiz = new Quiz(points_possible: 5, quiz_type: "survey") + equal @quiz.get('possible_points_label'), "" + # Publishing test '#publish saves to the server', -> diff --git a/spec/views/quizzes/quizzes/show.html.erb_spec.rb b/spec/views/quizzes/quizzes/show.html.erb_spec.rb index fe4ac4ba1ea..14b1b8826dd 100644 --- a/spec/views/quizzes/quizzes/show.html.erb_spec.rb +++ b/spec/views/quizzes/quizzes/show.html.erb_spec.rb @@ -88,5 +88,21 @@ describe "/quizzes/quizzes/show" do expect(response).not_to have_tag ".unpublished_quiz_warning" end + it "should hide points possible for ungraded surveys" do + points = 5 + + course_with_teacher_logged_in(active_all: true) + @quiz = @course.quizzes.create!(quiz_type: "survey", points_possible: points) + + assigns[:quiz] = @quiz + view_context + render "quizzes/quizzes/show" + + doc = Nokogiri::HTML(response) + doc.css(".control-group .controls .value").each do |node| + expect(node.content).not_to include("#{points}") if node.parent.parent.content.include? "Points" + end + end + end