Give calendar event API assignment results sane default ordering.

Fixes #CNVS-1989

NOTE: This is not a perfect solution as that would require
examining all overrides and sorting before paginating. This
solution gives a more sane default order rather than just
natural DB order.

Testing Notes:
============
* assignments should now be returned by the base assignment's
  due_at.

Change-Id: I9db720bf2e24d6e2d4cd0956689223a5e9b6c654
Reviewed-on: https://gerrit.instructure.com/17536
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
fix conversation scoping for masquerading site admins.

previously, :for_masquerading_user scope was restricting
site admins that didn't have become_user permissions on
the site admin account. this commit unrestricts all users
in the site admin account.

test plan:
  * create a user in the site admin account that does not
    have :become_user permission in that account;
  * as that user, masquerade as a user in another account
    and navigate to their inbox;
  * verify that their messages display.

Change-Id: Id6f9357af2f2885c6307156a49e98f66db230276
Reviewed-on: https://gerrit.instructure.com/17332
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
link to course users page on course statistics students tab

change the link for each student on the course statistics
students tab, to link to the course specific user page,
not the institutional user page

also change the permissions so that teachers
cannot visit that page by default

test plan:
* create a course with a teacher and student
* login as a student into the course (so you'll
 show up in the list of recently logged-in users)

* as a teacher:
 * go to course settings -> course statistics page
  -> students tab
 * the link on the users name should go to the
 course users page (e.g. "/courses/:course_id/users/:id")
 as opposed to the root users page ("/users/:id")
 * also, try, as a teacher to visit the root users page
 ("/users/:id") for the student, confirm that you cannot visit it
 with default teacher permissions

closes #CNVS-2964

Change-Id: I629448cc42de860ad3be4dfa7ff5fd32818f4fdd
Reviewed-on: https://gerrit.instructure.com/17438
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
make gradebook.csv less slow

fixes CNVS-3606

Test plan:
  * download some gradebook csv in a large class
  * experience euphoria and surprise as your gradebook csv is quickly
    delivered

Change-Id: I44e5fe14d73993d669eb6600072d6e2d125ad3cc
Reviewed-on: https://gerrit.instructure.com/17593
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
gb1: don't call assignment_json in slave block

fixes CNVS-3765

assignment_json may write to the db when module progression is
configured

Change-Id: If0f807dc390ab1ab6fd46c4de62a65195e133b18
Reviewed-on: https://gerrit.instructure.com/17624
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
optionally lock all course announcements.

fixes CNVS-3116

add course setting to default all its announcements to
'locked.' this setting is managed from the course settings
page.

test plan:
  * edit a course from its settings page and check the
    'Disable comments on announcements' checkbox;
  * create a new announcement in the course and verify
    that it is automatically locked;
  * uncheck the 'Disable comments on announcements'
    checkbox, create an announcement, and verify that it is
    unlocked.

Change-Id: If535abbbb0849284c8a6dfc2e6a6d42861796777
Reviewed-on: https://gerrit.instructure.com/17436
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
QA-Review: Zach Pendleton <zachp@instructure.com>
Tested-by: Zach Pendleton <zachp@instructure.com>
gradebook history api

fixes #CNVS-2802

This provides a reimplementation of 
the functionality in 'lib/submission_list.rb'.
That lib file has been used to produce
a grade book history page, but it loads
the entire history of the course at once,
which is untenable.  This take all the same data,
and provides it through a paginated
API endpoint.  Using this API, a rich front
end will be possible to create in order to replace
the current large grade book history page, 
one that makes API calls to reveal data further d
own the tree as it is requested.  This is an 
unusual API endpoint in that it does not present 
data as it is in the database, there is a series 
of transformations that the submission data is
put through to arrive at a versioned history
where each node contains within itself some
contextual knowledge of the flow of the
submission progress (each version knows
what the grade of the version before it was, 
and what the grade is today, for example).

TEST PLAN:
This is a new API endpoint and does not
yet get used by any front end code yet.
It can be played with by performing some
valid API queries against the following paths:

/courses/:course_id/gradebook_history/days
/courses/:course_id/gradebook_history/:date 
^ date is like "2013-01-31" ^
/courses/:course_id/gradebook_history/:date/graders/:grader_id/assignments/:assignment_id/submissions
(yes, that last one is huge, but it does follow
the nested structure described by the original
grade book history page).

The user that is selected for testing needs to 
have the "manage_grades"
permission on the referenced course.  API
documentation is available on the controller class
app/controllers/gradebook_history_api_controller.rb

Change-Id: I18e0b4b967d6c20ad47b86e98adbc15b87276098
Reviewed-on: https://gerrit.instructure.com/17366
QA-Review: Clare Hetherington <clare@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
refactor assignment show/edit to use backbone

change and clean up the assignment show and edit pages to use new code
standards and to follow the style guide.  separates the logic for viewing and
editing an assignment and moves editing into a backbone model.o

closes CNVS-930

test plan:
- make sure you can still view and edit existing assignments.
- make sure all fields in the assignment form work (enable turnitin and
  assignment freezing for a comprehensive test)
- make sure submitting an assignment as a student still works
- make sure downloading and uploading submissions as a teacher still works
- make sure adding a new assignment group, group category, grading standard,
  and rubric still work
- make sure the show page renders correctly for both a student and a teacher.

Change-Id: I9ca6c5d56eb386d35a62f6b816a03ebebda662d4
Reviewed-on: https://gerrit.instructure.com/16823
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Stanley Stuart <stanley@instructure.com>
add varied due date functionality to the assignments edit page

closes CNVS-747

test plan:
  - go to the assignments edit page
  - you should be able to create new assignment overrides as a teacher
  - you should be able to update existing assignment overrides as a
    teacher
  - make sure you are able to delete assignment overrides
  - make sure that using the "add due date" button, you cannot add more
    overrides than the number of the sections of the course + 1 (the +1
    is for the due date representing everyone else.
  - make sure that you can not remove the last override when hitting the
    remove buttons to the right of overrides when you have more than one
    override.
  - make sure the remove button disappears when you only have one
    override, and reappears when you add an override.
  - ensure the dates you enter on this page propogate to the assignments
    show page and other areas of Canvas.

Change-Id: I974924797d9d4783c7f6ae93a25c356112fc0f54
Reviewed-on: https://gerrit.instructure.com/17342
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
CollectionView and SearchView updates

- fixed issue where items weren't being inserted
  because they couldn't find the sibling element
  in CollectionView
- typos in View.coffee
- abort old requests in SearchView
- doc formatting changes

Change-Id: I0851d994338c8b5050865354b4e4bf4c3ffb1a45
Reviewed-on: https://gerrit.instructure.com/17618
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Ryan Florence <ryanf@instructure.com>
added better css selectors to links

Change-Id: Ib26fe17d3dba3823e740043e41e4857aa5ffdc3a
Reviewed-on: https://gerrit.instructure.com/17648
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
QA-Review: Jake Sorce <jake@instructure.com>
add course and account level large_roster settings, fixes #CNVS-3773

there is no ui for this (yet)

test plan: N/A

Change-Id: Ifed7192dc23b7e92681bd03bc68ad16ace509205
Reviewed-on: https://gerrit.instructure.com/17614
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
jenkins build and rerun summary

Change-Id: I6f24cf17204006290c5e1108510bbe011bdd3305
Reviewed-on: https://gerrit.instructure.com/17405
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jake Sorce <jake@instructure.com>
QA-Review: Jake Sorce <jake@instructure.com>
don't log an ErrorReport for 450 Recipient address rejected

This isn't an actionable error. Though at some point it'd be nice to
display a message to the user if their emails are consistently failing.

Change-Id: Ia760214c355976592373404b03a41d9ff64034e7
Reviewed-on: https://gerrit.instructure.com/16566
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
allow edits of a discussion that has replies.

fixes CNVS-2987

previously, editing a discussion topic with replies of its
own would result in a circular JSON structure that would
result in the edit failing to persist.

test plan:
  * create a threaded discussion topic;
  * as a student or teacher (user A), reply to the original
    topic;
  * as a different user (user B), reply to the user A's
    response;
  * as user A, reload the page and attempt to edit your
    reply; verify that it saves without throwing a
    javascript error;
  * reload the page to verify that the edit was persisted;

Change-Id: I28795a65d4d19cbdb22c990e4630a570eddc66b0
Reviewed-on: https://gerrit.instructure.com/17606
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Eric Berry <ericb@instructure.com>
Tested-by: Eric Berry <ericb@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
fix account page course search autocomplete

fixes a javascript error on the course search box
on the account show page (e.g. "/accounts/1")

test plan:
* go to the account page for an account with
 at least one course
* type in the first few characters of the name
 of a course in the account
* confirm that a box for the course pops up
* confirm that clicking on the box takes you
 to the courses page

fixes #CNVS-1577

Change-Id: Iec2c589d8b02993adb7bf79840e9b900ab853be3
Reviewed-on: https://gerrit.instructure.com/17608
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
add option to include term info in course json for api

test plan:
* make an api request for a course, supplying
 "term" as an "include" option
* confirm that the response includes the
 tern name and id of the course

fixes #CNVS-3204

Change-Id: I1694736b35dc398e3f730b9365332d4ea23c93df
Reviewed-on: https://gerrit.instructure.com/17612
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
limit facebook user searching to pertinent shards

closes CNVS-3834

test plan:
 * facebook app should still work

Change-Id: Ifd892a0b00afa173ec1d9d1f973955c3fbb806a1
Reviewed-on: https://gerrit.instructure.com/17662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
allow specifying shards for HasManyAssociation#with_each_shard

this stub doesn't do anything with them, but specific sharding
implementations can use them, and the signature should allow that.

Change-Id: I11a27e52e1e98e7aa77818dcf5a00d829bdaef41
Reviewed-on: https://gerrit.instructure.com/17578
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jacob Fugal <jacob@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Enrollment#sis_user_id convenience method

Change-Id: Ib37e4ce1d494b5489490c9d582793447188ebf16
Reviewed-on: https://gerrit.instructure.com/17528
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>