catch over quota error in content imports

changes an Exception to a StandardError so a content
migration import will be able to rescue them, and thus
not fail silently (and hang in a processing state), when
the destination quota is exceeded

test plan:
* create a course, set the storage quota to a low amount
* import a migration that includes attachments that
 it will exceed the quota size
* confirm that the import does not hang indefinitely

fixes #CNVS-3619

Change-Id: Icc4d7aeefd76006655f26f75df85e528073dcd08
Reviewed-on: https://gerrit.instructure.com/17584
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
spec fixes for group_categories_api

Change-Id: Ic849004d0cf93e1167253e704d6e439e5bb859e0
Reviewed-on: https://gerrit.instructure.com/17792
Reviewed-by: Nathan Mills <nathanm@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
make User#update_account_associations race-condition-safe

Change-Id: I803144def765f74455607d18e7143f321580fae6
Reviewed-on: https://gerrit.instructure.com/17815
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
this migration needs to be sync now

since a later migration will drop the table it works on

Change-Id: I37bd431b980a2e27622414fdbdc2c403efb086f8
Reviewed-on: https://gerrit.instructure.com/17818
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
Fix formatting issue with embedded youtube videos

This is a hotfix. Makes sure youtube videos
are being formatted correctly.

fixes CNVS-3947
Change-Id: I1556b21111c4eefc3dcc99de4b4b9db007a7e969
Reviewed-on: https://gerrit.instructure.com/17823
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
show gradebook2 for large_roster courses always

closes CNVS-3093

test plan:
1. visit a course grade book and click the button
  to go back to the old grade book
2. in script/console do:
      c = Course.find(<course_id>)
      c.large_roster = true
      c.save!
3. visit the course grade book page again
   - you should be sent to gradebook 2
   - there should be no button to go back to
     the old grade book

Change-Id: Ica16c57851597b571dcb8c06ed6621f9a2364666
Reviewed-on: https://gerrit.instructure.com/17626
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
QA-Review: Ryan Florence <ryanf@instructure.com>
don't check for auth token when recording quiz answer

test plan:
  - As a student, start taking a One Question at A Time Quiz with
    multiple questions.
  - Answer at least one question, and then open a new tab and log out,
    then log back in (in that same new tab that you opened).
  - Answer the question you are on in the first tab you opened, and hit the
    "next" button. Make sure you don't get a page error.

fixes CNVS-3498

Change-Id: Icaa89fd2be4cfbc8b7c17386f6762b051ce006d7
Reviewed-on: https://gerrit.instructure.com/17829
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
fix endless loop in grade calculators

Test plan:
  * make an assignment in an assignment_group with grade_dropping rules
    that has some stupid number of points possible (like
    100000000000000000000000000000000000000000000000000)
  * make sure the gradebook and api can both return grades for that
    course

Change-Id: I89ea9ce504392a0f2f95b412089e636629dff501
Reviewed-on: https://gerrit.instructure.com/17810
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
fix file path for clock icon path

closes CNVS-3961

test plan:
  - http://canvas/images/icon-clock.png should not 404
  - Main course page http://localhost:3000/courses/1 should only show
    single clock icon on Page History link
  - Quizzes should only show single clock icon on View Previous
    Attempts link

Change-Id: I16389ae7aa6c8de7103a6ec1411c30a053261d85
Reviewed-on: https://gerrit.instructure.com/17360
Reviewed-by: Cameron Matheson <cameron@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
respect people's gradebook preference in csv upload

fixes CNVS-1826

Test plan:
  after uploading gradebook csv, make sure you are redirected back to
  the gradebook you last visited

Change-Id: I2062548241da32885de277a3eb2926c92f9a0849
Reviewed-on: https://gerrit.instructure.com/17830
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Stanley Stuart <stanley@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
fix module display issue

test plan:
 - on each supported browser,
  - go to course module list page
  - make sure the dotted lines between module items are not broken
    when the indent/outdent/edit icons are hidden

Change-Id: I8f10c5ae33f5891e9712fbd8d63b222be04b1d6c
Reviewed-on: https://gerrit.instructure.com/17728
Reviewed-by: Mark Severson <markse@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
improve layout in conversations, update walkthrough.

fixes CNVS-3100

increase padding between user avatars and star/mark as
unread buttons in converastion list. also update image
and copy on third slide of conversations walkthrough to
reflect current functionality.

test plan:
  * send a conversations message to a user with an avatar
    (i.e. not the default avatar image);
  * verify that the recipient's avatar displays in the
    conversations list without touching the star or mark
    as read icons;
  * click the conversations help button (question mark icon
    above the new message  form) and click through to the
    third slide;
  * verify that the gear menu looks like the current gear
    menu and that the copy does not mention labeling
    messages.

Change-Id: I1ca5a1720aa31ecdd3f8fd0bbdcc20ebefd48776
Reviewed-on: https://gerrit.instructure.com/17749
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>
use a custom Marshal format for Time objects pre-1900 in ruby 1.9

Ruby 1.9 changed the Marshal format for Times and now raises an
exception for Time objects with a year < 1900. This extends _dump and
_load to handle these older Times.

test plan: An easy test in the UI is to (with caching enabled) create an
enrollment term whose start or end date is before 1900, and restrict
student enrollments to that date. Then visit the dashboard and various
course pages as a student in the course, and verify you don't see page
errors.

Change-Id: I97925925e04bb3663efe9928810845c6c919adac
Reviewed-on: https://gerrit.instructure.com/17811
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
MessageableUser refactor with sharding

Separates, streamlines, and makes shard-aware all use cases of
User#messageable_users *other* than searching (call site in
SearchController#matching_participants).

Produces three new methods that take the bulk of that responsibility:

 * User#load_messageable_users -- given a set of users, filter out the
   ones that aren't messageable, and load any common contexts for those
   that are.

 * User#load_messageable_user -- as User#load_messageable_users, but for
   just one user.

 * User#messageable_users_in_context -- given a context (a course,
   section, or group), return the list of messageable users in that
   context.

refs CNVS-2519

remaining on CNVS-2519 is to tackle the search application of
User#messageable_user. mostly there, but reconciling pagination
with ranking by number of shared contexts is proving problematic, so I'm
going to separate that into another commit.

meanwhile, I've renamed User#messageable_users to
User#deprecated_search_messageable_users to discourage any accidental
new uses and left it otherwise untouched. searching for users on the
same shard should be unaffected. You can still locate messageable users
on other shards to insert into conversations by browsing the shared
contexts.

test-plan:
 * create user A in shard X
 * create user B in shard Y
 * for situations where A could message B if on the same shard:
   - setup the situation where the common tie is on shard X (e.g. course
     on shard X and both A and B in it). run exercises below
   - setup the situation where the common tie is on shard Y. run
     exercises.
   - if appropriate, setup the situation where the common tie is on
     shard Z. run exercises.
 * for each setup described above, login as A:
   - A should see the "message this user" button on B's profile
   - if the common tie is a course, section, or group, A should see B
     under that context when the context is selected in the recipient
     browser
   - if a conversation exists involving both A and B, when A loads the
     conversation they should see B tagged with the common contexts
 * regression test searching for messageable users from the same shard

Change-Id: Ibba5551f8afc2435fd14a2e827a400bf95eae76a
Reviewed-on: https://gerrit.instructure.com/17569
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
spec: removed unused constant

Change-Id: I4a2e3cd5ceb9a48bb9a4bf836265f5d58135764c
Reviewed-on: https://gerrit.instructure.com/17846
Reviewed-by: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
require login for course modules/assignments that use an external tool

closes #CNVS-3253

test plan:
- as a teacher go to Modules in a publicly available course
- add a module item and choose the "External Tool" type
- also add to the module an "External Tool" type assignment
- log out
- go back to the course's modules page (not logged in)
- click on the module item and assignment previously created,
  both should require logging in

Change-Id: I2064cc30f3d2ef85236f386337f73e44ee4ce520
Reviewed-on: https://gerrit.instructure.com/17656
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Joe Tanner <joe@instructure.com>
stop truncating discussion entry notification messages.

fixes CNVS-3949

when sending email notifications re: a new discussion entry,
include the whole entry instead of a truncated, 200
character version.

test plan:
  * create a new discussion post in a class with at least
    two users;
  * set the users' "discussion entry" notification policies
    to ASAP;
  * as user A, post a discussion entry to the previously
    created topic that is longer than 200 characters;
  * as a site admin, navigate to /users/:id/messages, where
    :id is the user ID of user B;
  * verify that user B has received a notification of user
    A's entry and that the notification contains the entire
    body of user A's entry (i.e. it has not been truncated).

Change-Id: I2b524ea5a36cf8e142522d8498e4aba80b8aa554
Reviewed-on: https://gerrit.instructure.com/17789
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>
checkbox spacing on new assignments edit page

Notes:
* Reduced spacing between 3 checkboxes that are shown by default
* Maintained spacing under "Restrict upload file types" when
  Submission Type: Online is chosen

fixes CNVS-3609

Change-Id: I82cb4d8b1db5ce2ac4411f79682d0a91c0cee223
Reviewed-on: https://gerrit.instructure.com/17490
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
refactored - removed unneccessary methods and references to 'MOOC'

test steps:
- create an assignment for a course
- in the database, update the course field 'large_roster' to false. this
  flags the course as not being a mooc
- go to the edit view of the assignment
- ensure that you have the ability to check 'This is a Group Assignment'
  and 'Require Peer Reviews'
- in the database, update the course field 'large_roster' to true.
  this flags the course as a mooc
- refresh the edit assignment view
- ensure that the group assignemnt and peer review options are no longer
  there

Change-Id: I4facf1621e21cc16a99d8b7158b95cb188d5cdfb
Reviewed-on: https://gerrit.instructure.com/17828
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
be nice when loading submissions for cached lateness

closes CNVS-3971

test plan:
- on an assignment with submissions, chance the due date to be before the
  submissions were created
- make sure they get marked as late

Change-Id: I2f51b06de5256b7fe2991628e9acfff49483edec
Reviewed-on: https://gerrit.instructure.com/17849
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>