Skip to content

Commit 2eaba17

Browse files
author
Mark Ericksen
committed
disable speedgrader in courses with large_roster flag.
fixes CNVS-3111 test plan: * enable the 'large_roster' flag on a course and verify that, in that course, links to the speedgrader are hidden in the following places: - graded discussion topic gear menu; - graded discussion entry gear menu - quiz show page (right side bar); - assignment show page (right side bar); - gradebook1 assignment header dropdown; - gradebook1 grade cell popup; - gradebook2 assignment header dropdown; - gradebook2 grade cell popup; * also verify that attempting to navigate to the speedgrader directly via /courses/:id/gradebook path displays a message that the speedgrader is disabled for that course. Change-Id: Iab82bd7281208f6e2d3745bb3184c90068090535 Reviewed-on: https://gerrit.instructure.com/17710 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Eric Berry <ericb@instructure.com> Tested-by: Eric Berry <ericb@instructure.com> Reviewed-by: Joel Hough <joel@instructure.com> QA-Review: Myller de Araujo <myller@instructure.com>
1 parent e2cbbbd commit 2eaba17

21 files changed

Lines changed: 189 additions & 41 deletions

app/coffeescripts/SubmissionDetailsDialog.coffee

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ define [
1515

1616
class SubmissionDetailsDialog
1717
constructor: (@assignment, @student, @options) ->
18+
speedGraderUrl = if @options.speed_grader_enabled
19+
"#{@options.context_url}/gradebook/speed_grader?assignment_id=#{@assignment.id}#%7B%22student_id%22%3A#{@student.id}%7D"
20+
else
21+
null
22+
1823
@url = @options.change_grade_url.replace(":assignment", @assignment.id).replace(":submission", @student.id)
1924
@submission = $.extend {}, @student["assignment_#{@assignment.id}"],
2025
assignment: @assignment
21-
speedGraderUrl: "#{@options.context_url}/gradebook/speed_grader?assignment_id=#{@assignment.id}#%7B%22student_id%22%3A#{@student.id}%7D"
26+
speedGraderUrl: speedGraderUrl
2227
loading: true
2328
@dialog = $('<div class="use-css-transitions-for-show-hide" style="padding:0;"/>')
2429
@dialog.html(submissionDetailsDialog(@submission))

app/coffeescripts/gradebook2/GradebookHeaderMenu.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ define [
2121
templateLocals =
2222
assignmentUrl: "#{@gradebook.options.context_url}/assignments/#{@assignment.id}"
2323
speedGraderUrl: "#{@gradebook.options.context_url}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
24+
templateLocals.speedGraderUrl = null unless @gradebook.options.speed_grader_enabled
2425
@$menu = $(gradebookHeaderMenuTemplate(templateLocals)).insertAfter(@$trigger)
2526
@$trigger.kyleMenu(noButton:true)
2627
@$menu

app/controllers/discussion_topics_controller.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def edit
180180
def show
181181
parent_id = params[:parent_id]
182182
@topic = @context.all_discussion_topics.find(params[:id])
183+
@presenter = DiscussionTopicPresenter.new(@topic, @current_user)
183184
@assignment = if @topic.for_assignment?
184185
AssignmentOverrideApplicator.assignment_overridden_for(@topic.assignment, @current_user)
185186
else
@@ -244,8 +245,12 @@ def show
244245
:INITIAL_POST_REQUIRED => @initial_post_required,
245246
:THREADED => @topic.threaded?
246247
}
247-
if @topic.for_assignment? && @topic.assignment.grants_right?(@current_user, session, :grade)
248-
env_hash[:SPEEDGRADER_URL_TEMPLATE] = named_context_url(@topic.assignment.context, :speed_grader_context_gradebook_url, :assignment_id => @topic.assignment.id, :anchor => {:student_id => ":student_id"}.to_json)
248+
if @topic.for_assignment? &&
249+
@topic.assignment.grants_right?(@current_user, session, :grade) && @presenter.allows_speed_grader?
250+
env_hash[:SPEEDGRADER_URL_TEMPLATE] = named_context_url(@topic.assignment.context,
251+
:speed_grader_context_gradebook_url,
252+
:assignment_id => @topic.assignment.id,
253+
:anchor => {:student_id => ":student_id"}.to_json)
249254
end
250255
js_env :DISCUSSION => env_hash
251256

app/controllers/gradebook2_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def show
2424
:grading_standard => @context.grading_standard_enabled? && (@context.grading_standard.try(:data) || GradingStandard.default_grading_standard),
2525
:course_is_concluded => @context.completed?,
2626
:gradebook_is_editable => @gradebook_is_editable,
27+
:speed_grader_enabled => @context.allows_speed_grader?,
2728
}
2829

2930
end

app/controllers/gradebooks_controller.rb

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ def grade_summary
7474
)
7575
# pre-cache the assignment group for each assignment object
7676
@assignments.each { |a| a.assignment_group = @groups.find { |g| g.id == a.assignment_group_id } }
77-
all_submissions = if @context.large_roster?
78-
[]
79-
else
77+
all_submissions = if @context.allows_gradebook_uploads?
8078
# Yes, fetch *all* submissions for this course; otherwise the view will end up doing a query for each
8179
# assignment in order to calculate grade distributions
8280
@context.submissions.all(:select => "submissions.assignment_id, submissions.score, submissions.grade, submissions.quiz_submission_id")
81+
else
82+
[]
8383
end
8484

8585
@submissions_by_assignment = submissions_by_assignment(all_submissions)
@@ -200,7 +200,8 @@ def show
200200

201201
# this can't happen in the slave block because this may trigger
202202
# writes in ContextModule
203-
js_env :assignment_groups => assignment_groups_json
203+
js_env :assignment_groups => assignment_groups_json,
204+
:speed_grader_enabled => @context.allows_speed_grader?
204205
set_gradebook_warnings(@groups, @just_assignments)
205206
if params[:view] == "simple"
206207
@headers = false
@@ -375,16 +376,25 @@ def submissions_zip_upload
375376
end
376377

377378
def speed_grader
378-
if authorized_action(@context, @current_user, [:manage_grades, :view_all_grades])
379-
@assignment = @context.assignments.active.find(params[:assignment_id])
380-
respond_to do |format|
381-
format.html {
382-
@headers = false
383-
@outer_frame = true
384-
log_asset_access("speed_grader:#{@context.asset_string}", "grades", "other")
385-
render :action => "speed_grader"
386-
}
387-
format.json { render :json => @assignment.speed_grader_json(@current_user, service_enabled?(:avatars)) }
379+
if !@context.allows_speed_grader?
380+
flash[:notice] = t(:speed_grader_disabled, 'SpeedGrader is disabled for this course')
381+
return redirect_to(course_gradebook_path(@context))
382+
end
383+
384+
return unless authorized_action(@context, @current_user, [:manage_grades, :view_all_grades])
385+
386+
@assignment = @context.assignments.active.find(params[:assignment_id])
387+
388+
respond_to do |format|
389+
format.html do
390+
@headers = false
391+
@outer_frame = true
392+
log_asset_access("speed_grader:#{@context.asset_string}", "grades", "other")
393+
render :action => "speed_grader"
394+
end
395+
396+
format.json do
397+
render :json => @assignment.speed_grader_json(@current_user, service_enabled?(:avatars))
388398
end
389399
end
390400
end

app/controllers/quizzes_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def new
6868

6969
def statistics
7070
if authorized_action(@quiz, @current_user, :read_statistics)
71-
if @context.large_roster?
71+
if !@context.allows_speed_grader?
7272
flash[:notice] = t "#application.notices.page_disabled_for_course", "That page has been disabled for this course"
7373
redirect_to named_context_url(@context, :context_quiz_url, @quiz)
7474
return

app/models/course.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,13 @@ def allows_gradebook_uploads?
10741074
!large_roster?
10751075
end
10761076

1077+
# Public: Determine if SpeedGrader is enabled for the Course.
1078+
#
1079+
# Returns a boolean.
1080+
def allows_speed_grader?
1081+
!large_roster?
1082+
end
1083+
10771084
def enrollment_allows(user, session, permission)
10781085
return false unless user && permission
10791086

app/presenters/discussion_topic_presenter.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,22 @@ def comments_disabled?
112112
topic.context.is_a?(Course) &&
113113
topic.context.settings[:lock_all_announcements]
114114
end
115+
116+
# Public: Determine if the discussion's context has a large roster flag set.
117+
#
118+
# Returns a boolean.
119+
def large_roster?
120+
if topic.context.respond_to?(:large_roster?)
121+
topic.context.large_roster?
122+
else
123+
topic.context.try(:context).try(:large_roster?)
124+
end
125+
end
126+
127+
# Public: Determine if SpeedGrader should be enabled for the Discussion Topic.
128+
#
129+
# Returns a boolean.
130+
def allows_speed_grader?
131+
!large_roster?
132+
end
115133
end

app/views/assignments/_grade_assignment.html.erb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
<% end %>
2020

2121
<ul class='page-action-list'>
22-
<li>
23-
<a target="_blank" href="<%= context_url(@context, :speed_grader_context_gradebook_url, :assignment_id => @assignment.id) %>">
24-
<i class="icon-speed-grader"></i> SpeedGrader&trade;
25-
</a>
26-
</li>
22+
<% if @context.allows_speed_grader? %>
23+
<li>
24+
<a target="_blank" href="<%= context_url(@context, :speed_grader_context_gradebook_url, :assignment_id => @assignment.id) %>">
25+
<i class="icon-speed-grader"></i> SpeedGrader&trade;
26+
</a>
27+
</li>
28+
<% end %>
2729

2830
<% if @current_student_submissions.present? %>
2931
<% if @assignment.submission_types && @assignment.submission_types.match(/(online_upload|online_text_entry|online_url)/)%>

app/views/discussion_topics/show.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<%
22
content_for :page_title, join_title( t(:topic, "Topic"), @topic.title)
33
%>
4-
<% @presenter = DiscussionTopicPresenter.new(@topic, @current_user) %>
54
<% content_for :auto_discovery do %>
65
<% if @context_enrollment %>
76
<%= auto_discovery_link_tag(:atom, feeds_topic_format_path(@topic.id, @context_enrollment.feed_code, :atom), {:title => t(:discussion_atom_feed_title, "Discussion Atom Feed")}) %>
@@ -91,7 +90,7 @@
9190
<li><a href="<%= context_url(@context, :context_discussion_topic_url, @topic.id) %>" data-method="delete" rel="nofollow" data-confirm="<%= t :confirm_delete_discussion, 'Are you sure you want to delete this discussion?' %>"><i class="icon-trash"></i> <%= t :delete, 'Delete' %></a></li>
9291
<% end %>
9392

94-
<% if @presenter.can_grade?(@current_user) %>
93+
<% if @presenter.can_grade?(@current_user) && @presenter.allows_speed_grader? %>
9594
<li><a href="<%= context_url(@topic.assignment.context,
9695
:speed_grader_context_gradebook_url,
9796
:assignment_id => @topic.assignment.id) %>">

0 commit comments

Comments
 (0)