Skip to content

Commit 2123950

Browse files
committed
show correct assignment course home for admin users
test plan: * create a course * set the course home page to the "Assignment List" * should be able to edit assignments on the front page as an admin (should not show the student view) closes #CNVS-23280 Change-Id: I9ddb5debe2b413f9865d5356c7cbb44f4a4f5128 Reviewed-on: https://gerrit.instructure.com/67813 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Clare Strong <clare@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
1 parent f4f3a95 commit 2123950

5 files changed

Lines changed: 30 additions & 42 deletions

File tree

app/coffeescripts/views/assignments/IndexView.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ define [
113113

114114
ensureContentStyle: ->
115115
# when loaded from homepage, need to change content style
116-
if window.location.href.indexOf('assignments') == -1
116+
if !@canManage() && window.location.href.indexOf('assignments') == -1
117117
$("#content").css("padding", "0em")
118118

119119
filterKeyBindings: =>

app/controllers/application_controller.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,30 @@ def set_js_wiki_data(opts = {})
19711971
js_env hash
19721972
end
19731973

1974+
def set_js_assignment_data
1975+
rights = [:manage_assignments, :manage_grades, :read_grades]
1976+
permissions = @context.rights_status(@current_user, *rights)
1977+
permissions[:manage] = permissions[:manage_assignments]
1978+
js_env({
1979+
:URLS => {
1980+
:new_assignment_url => new_polymorphic_url([@context, :assignment]),
1981+
:course_url => api_v1_course_url(@context),
1982+
:sort_url => reorder_course_assignment_groups_url(@context),
1983+
:assignment_sort_base_url => course_assignment_groups_url(@context),
1984+
:context_modules_url => api_v1_course_context_modules_path(@context),
1985+
:course_student_submissions_url => api_v1_course_student_submissions_url(@context)
1986+
},
1987+
:PERMISSIONS => permissions,
1988+
:DIFFERENTIATED_ASSIGNMENTS_ENABLED => @context.feature_enabled?(:differentiated_assignments),
1989+
:VALID_DATE_RANGE => CourseDateRange.new(@context),
1990+
:assignment_menu_tools => external_tools_display_hashes(:assignment_menu),
1991+
:discussion_topic_menu_tools => external_tools_display_hashes(:discussion_topic_menu),
1992+
:quiz_menu_tools => external_tools_display_hashes(:quiz_menu),
1993+
:current_user_has_been_observer_in_this_course => @context.user_has_been_observer?(@current_user),
1994+
:observed_student_ids => ObserverEnrollment.observed_student_ids(@context, @current_user)
1995+
})
1996+
end
1997+
19741998
def google_docs_connection
19751999
## @real_current_user first ensures that a masquerading user never sees the
19762000
## masqueradee's files, but in general you may want to block access to google

app/controllers/assignments_controller.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,7 @@ def index
4343
# It'd be nice to do this as an after_create, but it's not that simple
4444
# because of course import/copy.
4545
@context.require_assignment_group
46-
47-
rights = [:manage_assignments, :manage_grades, :read_grades]
48-
permissions = @context.rights_status(@current_user, *rights)
49-
permissions[:manage] = permissions[:manage_assignments]
50-
js_env({
51-
:URLS => {
52-
:new_assignment_url => new_polymorphic_url([@context, :assignment]),
53-
:course_url => api_v1_course_url(@context),
54-
:sort_url => reorder_course_assignment_groups_url,
55-
:assignment_sort_base_url => course_assignment_groups_url,
56-
:context_modules_url => api_v1_course_context_modules_path(@context),
57-
:course_student_submissions_url => api_v1_course_student_submissions_url(@context)
58-
},
59-
:PERMISSIONS => permissions,
60-
:DIFFERENTIATED_ASSIGNMENTS_ENABLED => @context.feature_enabled?(:differentiated_assignments),
61-
:VALID_DATE_RANGE => CourseDateRange.new(@context),
62-
:assignment_menu_tools => external_tools_display_hashes(:assignment_menu),
63-
:discussion_topic_menu_tools => external_tools_display_hashes(:discussion_topic_menu),
64-
:quiz_menu_tools => external_tools_display_hashes(:quiz_menu),
65-
:current_user_has_been_observer_in_this_course => @context.user_has_been_observer?(@current_user),
66-
:observed_student_ids => ObserverEnrollment.observed_student_ids(@context, @current_user)
67-
})
68-
46+
set_js_assignment_data # in application_controller.rb, because the assignments page can be shared with the course home
6947

7048
respond_to do |format|
7149
format.html do

app/controllers/courses_controller.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,8 @@ def show
15831583
@padless = true
15841584
when 'assignments'
15851585
add_crumb(t('#crumbs.assignments', "Assignments"))
1586-
set_urls_and_permissions_for_assignment_index
1586+
set_js_assignment_data
1587+
js_env(:COURSE_HOME => true)
15871588
get_sorted_assignments
15881589
when 'modules'
15891590
add_crumb(t('#crumbs.modules', "Modules"))
@@ -2333,22 +2334,6 @@ def changed_settings(changes, new_settings, old_settings=nil)
23332334
changes
23342335
end
23352336

2336-
def set_urls_and_permissions_for_assignment_index
2337-
permissions = {manage: false}
2338-
js_env({
2339-
:COURSE_HOME => true,
2340-
:URLS => {
2341-
:new_assignment_url => new_polymorphic_url([@context, :assignment]),
2342-
:course_url => api_v1_course_url(@context),
2343-
:context_modules_url => api_v1_course_context_modules_path(@context),
2344-
:course_student_submissions_url => api_v1_course_student_submissions_url(@context)
2345-
},
2346-
:PERMISSIONS => permissions,
2347-
:current_user_has_been_observer_in_this_course => @context.user_has_been_observer?(@current_user),
2348-
:observed_student_ids => ObserverEnrollment.observed_student_ids(@context, @current_user)
2349-
})
2350-
end
2351-
23522337
def ping
23532338
render json: {success: true}
23542339
end

app/views/courses/show.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
js_bundle :context_modules
129129
css_bundle :context_modules2
130130
when 'assignments'
131-
js_bundle :assignments
131+
js_bundle :assignment_index
132+
css_bundle :new_assignments
132133
when 'syllabus'
133134
js_bundle :syllabus
134135
css_bundle :tinymce

0 commit comments

Comments
 (0)