Skip to content

Commit

Permalink
show teacher and student todo items in calendar
Browse files Browse the repository at this point in the history
test plan:
 - have a user who is enrolled as a teacher in one course
   and a student in another
 - set up pages and ungraded discussions with todo dates in both
 - ensure the user can see
   1. published pages/discussions in the course in which she is a student
      (and these are not editable)
   2. all pages/discussions with todo dates in the course in which
      she is a teacher (and these can be moved/edited)

fixes ADMIN-1324

Change-Id: I9e37cb836a97e8cbf1bdaabcf24b9b08ccba38ee
Reviewed-on: https://gerrit.instructure.com/161516
Tested-by: Jenkins
Reviewed-by: Ed Schiebel <[email protected]>
QA-Review: Anju Reddy <[email protected]>
Product-Review: Jeremy Stanley <[email protected]>
  • Loading branch information
jstanley0 committed Aug 24, 2018
1 parent c952ead commit 294d831
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
18 changes: 14 additions & 4 deletions app/coffeescripts/calendar/EventDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import $ from 'jquery'
import _ from 'underscore'
import _ from 'lodash'
import fcUtil from '../util/fcUtil'
import commonEventFactory from '../calendar/commonEventFactory'
import 'jquery.ajaxJSON'
Expand Down Expand Up @@ -496,9 +496,19 @@ export default class EventDataSource {
]
if (ENV.STUDENT_PLANNER_ENABLED) {
eventDataSources.push(['/api/v1/planner_notes', params])
eventDataSources.push(['/api/v1/planner/items', _.extend({filter: 'ungraded_todo_items'}, params)])
} else if (ENV.PLANNER_ENABLED) {
eventDataSources.push(['/api/v1/planner/items', _.extend({filter: 'all_ungraded_todo_items'}, params)])
}
if (ENV.PLANNER_ENABLED) {
const [admin_contexts, student_contexts] = _.partition(params.context_codes, (cc) => (
ENV.CALENDAR.MANAGE_CONTEXTS.indexOf(cc) >= 0
))
if (student_contexts.length) {
const pparams = _.extend({filter: 'ungraded_todo_items'}, params, {context_codes: student_contexts})
eventDataSources.push(['/api/v1/planner/items', pparams])
}
if (admin_contexts.length) {
const pparams = _.extend({filter: 'all_ungraded_todo_items'}, params, {context_codes: admin_contexts})
eventDataSources.push(['/api/v1/planner/items', pparams])
}
}
return this.startFetch(eventDataSources, dataCB, doneCB, options)
}
Expand Down
16 changes: 16 additions & 0 deletions spec/selenium/calendar/calendar2_with_planner_notes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,20 @@
expect(discussion.reload).to be_deleted
end
end

context "with teacher and student enrollments" do
it "includes todo items from both" do
course1 = @course
course2 = course_with_student(user: @user, active_all: true).course
page1 = course1.wiki_pages.create!(title: 'Page1', todo_date: Date.today, workflow_state: 'unpublished')
page2 = course2.wiki_pages.create!(title: 'Page2', todo_date: Date.today, workflow_state: 'published')
user_session(@user)
get '/calendar2'
wait_for_ajax_requests
fj('.fc-title:contains("Page1")').click
expect(f('.event-details')).to contain_css('.edit_event_link')
fj('.fc-title:contains("Page2")').click
expect(f('.event-details')).not_to contain_css('.edit_event_link')
end
end
end

0 comments on commit 294d831

Please sign in to comment.