From 4f8c00c73d12df2e593c622268fe132e92f8df53 Mon Sep 17 00:00:00 2001 From: James Williams Date: Mon, 19 Oct 2015 08:26:22 -0600 Subject: [PATCH] fix "Download Submissions" in gradebook in concluded courses test plan: * create a course with file upload submissions * upload a student submission * soft or hard-conclude the course * the "Download Submissions" dropdown under the assignment in the gradebook should work as before * should also be able to download from the assignment page closes #CNVS-11107 Change-Id: Ie187733bd1f638945e0a4d268db0d7cad53b99ba Reviewed-on: https://gerrit.instructure.com/65330 Tested-by: Jenkins Reviewed-by: Jeremy Stanley QA-Review: Clare Strong Product-Review: James Williams --- .../gradebook2/GradebookHeaderMenu.coffee | 2 +- app/controllers/assignments_controller.rb | 6 ++- app/controllers/submissions_controller.rb | 13 +++--- .../assignmentHeaderDropdownOptions.jsx | 2 +- .../assignments/_assignment_sidebar.html.erb | 2 +- .../assignments/_grade_assignment.html.erb | 46 ++++++++++--------- ...assignmentHeaderDropdownOptionsSpec.coffee | 2 +- 7 files changed, 38 insertions(+), 35 deletions(-) diff --git a/app/coffeescripts/gradebook2/GradebookHeaderMenu.coffee b/app/coffeescripts/gradebook2/GradebookHeaderMenu.coffee index 5e4f9b02d7e..b1cfcbeab1d 100644 --- a/app/coffeescripts/gradebook2/GradebookHeaderMenu.coffee +++ b/app/coffeescripts/gradebook2/GradebookHeaderMenu.coffee @@ -54,7 +54,7 @@ define [ setDefaultGrade: @allSubmissionsLoaded curveGrades: @allSubmissionsLoaded && @assignment.grading_type != 'pass_fail' && @assignment.points_possible downloadSubmissions: "#{@assignment.submission_types}".match(/(online_upload|online_text_entry|online_url)/) && @assignment.has_submitted_submissions - reuploadSubmissions: @assignment.submissions_downloads > 0 + reuploadSubmissions: @gradebook.options.gradebook_is_editable && @assignment.submissions_downloads > 0 } ) .popup('open') diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index 4eb1916d743..31c1b5d262b 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -140,8 +140,10 @@ class AssignmentsController < ApplicationController :EXTERNAL_TOOLS => external_tools_json(@external_tools, @context, @current_user, session) }) - if @assignment.grants_right?(@current_user, session, :grade) - visible_student_ids = @context.enrollments_visible_to(@current_user).pluck(:user_id) + @can_view_grades = @context.grants_right?(@current_user, session, :view_all_grades) + @can_grade = @assignment.grants_right?(@current_user, session, :grade) + if @can_view_grades || @can_grade + visible_student_ids = @context.enrollments_visible_to(@current_user, :include_priors => true).pluck(:user_id) @current_student_submissions = @assignment.submissions.where("submissions.submission_type IS NOT NULL").where(:user_id => visible_student_ids).to_a end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 3aa3cd26724..8606e781c7a 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -93,13 +93,12 @@ class SubmissionsController < ApplicationController def index @assignment = @context.assignments.active.find(params[:assignment_id]) - if authorized_action(@assignment, @current_user, :grade) - if params[:zip] - generate_submission_zip(@assignment, @context) - else - respond_to do |format| - format.html { redirect_to named_context_url(@context, :context_assignment_url, @assignment.id) } - end + return render_unauthorized_action unless @assignment.user_can_read_grades?(@current_user, session) + if params[:zip] + generate_submission_zip(@assignment, @context) + else + respond_to do |format| + format.html { redirect_to named_context_url(@context, :context_assignment_url, @assignment.id) } end end end diff --git a/app/jsx/gradebook/grid/components/dropdown_components/assignmentHeaderDropdownOptions.jsx b/app/jsx/gradebook/grid/components/dropdown_components/assignmentHeaderDropdownOptions.jsx index bd41d86d718..67b49122777 100644 --- a/app/jsx/gradebook/grid/components/dropdown_components/assignmentHeaderDropdownOptions.jsx +++ b/app/jsx/gradebook/grid/components/dropdown_components/assignmentHeaderDropdownOptions.jsx @@ -36,7 +36,7 @@ define([ dropdownOptions.push(downloadSubmissionsOption); } - if (assignment.submissions_downloads > 0 ) { + if (GradebookConstants.gradebook_is_editable &&assignment.submissions_downloads > 0 ) { reuploadSubmissionsOption = { title: I18n.t('Re-Upload Submissions'), action: 'reuploadSubmissions' }; dropdownOptions.push(reuploadSubmissionsOption); } diff --git a/app/views/assignments/_assignment_sidebar.html.erb b/app/views/assignments/_assignment_sidebar.html.erb index abdbbcf7627..e33a6814e9e 100644 --- a/app/views/assignments/_assignment_sidebar.html.erb +++ b/app/views/assignments/_assignment_sidebar.html.erb @@ -1,5 +1,5 @@