don't include all_dates in assignment api with too many overrides
test plan: * in the rails console, configure the override threshold with Setting.set('assignment_all_dates_too_many_threshold', '5') * an assignment more than 5 overrides should not return the 'all_dates' value in the api, but rather 'all_dates_count' * on the assignment index page, an assignment with more than 5 overrides should still list "Multiple Dates" but no longer shows a tooltip closes #CNVS-32277 Change-Id: I99df5ae0f482c745f00a2d4c9dcedbc8042f007c Reviewed-on: https://gerrit.instructure.com/91478 Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> Reviewed-by: Matt Berns <mberns@instructure.com> QA-Review: Heath Hales <hhales@instructure.com> Product-Review: McCall Smith <mcsmith@instructure.com>
This commit is contained in:
parent
ba3fad0155
commit
8a1d2ebc18
|
@ -280,8 +280,12 @@ define [
|
|||
lock_at: @get("lock_at")
|
||||
|
||||
multipleDueDates: =>
|
||||
dateGroups = @get("all_dates")
|
||||
dateGroups && dateGroups.length > 1
|
||||
count = @get("all_dates_count")
|
||||
if count && count > 1
|
||||
true
|
||||
else
|
||||
dateGroups = @get("all_dates")
|
||||
dateGroups && dateGroups.length > 1
|
||||
|
||||
hasDueDate: =>
|
||||
!@isPage()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{{#if multipleDueDates}}
|
||||
<strong>{{#t "available"}}Available{{/t}}</strong>
|
||||
|
||||
{{#if allDates}}
|
||||
<a title class="vdd_tooltip_link"
|
||||
aria-labelledby="vdd_tooltip_{{selector}}"
|
||||
data-tooltip-selector="#vdd_tooltip_{{selector}}"
|
||||
|
@ -25,6 +26,9 @@
|
|||
{{/each}}
|
||||
</dl>
|
||||
</div>
|
||||
{{else}}
|
||||
{{#t "multiple_dates"}}Multiple Dates{{/t}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<span class="default-dates">
|
||||
{{#with defaultDates}}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{{#if multipleDueDates}}
|
||||
<strong>{{#t "due"}}Due{{/t}}</strong>
|
||||
|
||||
{{#if allDates}}
|
||||
<a title class="vdd_tooltip_link"
|
||||
aria-labelledby="vdd_tooltip_{{selector}}"
|
||||
data-tooltip-selector="#vdd_tooltip_{{selector}}"
|
||||
|
@ -25,7 +26,9 @@
|
|||
{{/each}}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{else}}
|
||||
{{#t "multiple_dates"}}Multiple Dates{{/t}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if singleSectionDueDate}}
|
||||
<strong>{{#t "due_date"}}Due{{/t}}</strong>
|
||||
|
|
|
@ -211,7 +211,13 @@ module Api::V1::Assignment
|
|||
end
|
||||
|
||||
if opts[:include_all_dates] && assignment.assignment_overrides
|
||||
hash['all_dates'] = assignment.dates_hash_visible_to(user)
|
||||
override_count = assignment.assignment_overrides.loaded? ?
|
||||
assignment.assignment_overrides.select(&:active?).count : assignment.assignment_overrides.active.count
|
||||
if override_count < Setting.get('assignment_all_dates_too_many_threshold', '25').to_i
|
||||
hash['all_dates'] = assignment.dates_hash_visible_to(user)
|
||||
else
|
||||
hash['all_dates_count'] = override_count
|
||||
end
|
||||
end
|
||||
|
||||
if opts[:include_module_ids]
|
||||
|
|
|
@ -673,6 +673,35 @@ describe AssignmentsApiController, :include_lti_spec_helpers, type: :request do
|
|||
expect(assign['all_dates']).not_to be_nil
|
||||
end
|
||||
|
||||
it "doesn't include all_dates if there are too many" do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
s1 = student_in_course(:course => @course, :active_all => true).user
|
||||
s2 = student_in_course(:course => @course, :active_all => true).user
|
||||
|
||||
a = @course.assignments.create!(:title => "all_date_test", :submission_types => "online_url", :only_visible_to_overrides => true)
|
||||
o1 = assignment_override_model(:assignment => a)
|
||||
os1 = o1.assignment_override_students.create!(:user => s1)
|
||||
|
||||
Setting.set('assignment_all_dates_too_many_threshold', '2')
|
||||
|
||||
@user = @teacher
|
||||
json = api_call(:get,
|
||||
"/api/v1/courses/#{@course.id}/assignments.json",
|
||||
{ :controller => 'assignments_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s},
|
||||
:include => ['all_dates'])
|
||||
expect(json.first['all_dates'].count).to eq 1
|
||||
|
||||
o2 = assignment_override_model(:assignment => a)
|
||||
os2 = o2.assignment_override_students.create!(:user => s2)
|
||||
|
||||
json = api_call(:get,
|
||||
"/api/v1/courses/#{@course.id}/assignments.json",
|
||||
{ :controller => 'assignments_api', :action => 'index', :format => 'json', :course_id => @course.id.to_s},
|
||||
:include => ['all_dates'])
|
||||
expect(json.first['all_dates']).to be_nil
|
||||
expect(json.first['all_dates_count']).to eq 2
|
||||
end
|
||||
|
||||
|
||||
it "returns due dates as they apply to the user" do
|
||||
course_with_student(active_all: true)
|
||||
|
|
Loading…
Reference in New Issue