fix attachment migration for mysql, make it nicer for all dbs

* changes temp table usage to be more efficient (also, mysql doesn't let
  you ref the same temp table twice in a query)
* make it non-transactional to reduce locking
* break up the big update statements into batches of 1000

test plan:
* confirm the migration runs in mysql/postgres/sqlite, and the migration
  spec passes for all three as well

Change-Id: Ib15028fa49103230e2cb4957754d2ac19853f90c
Reviewed-on: https://gerrit.instructure.com/9802
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
avatars in SpeedGrader

Add an avatar in the top right of SpeedGrader to show
the currently visible student. Also add avatars for
submission comments made on the submission.

test plan:
- enable avatars on the account
- go to SpeedGrader for an assignment
- make sure student avatars appear correctly in the top left
- add a comment to the submission
- make sure your avatar appears correctly next to your comment

- disable avatars on the account
- go back to the same SpeedGrader view
- make sure no avatars appear

Change-Id: Iac0e2305f24340a984ff5546eed7e4789f8337b5
Reviewed-on: https://gerrit.instructure.com/9675
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
student view; closes #6995

allows course admins to view the course from a student perspective. this is
accessible from a button on the course/settings page. They should be able to
interact with the course as a student would, including submitting homework and
quizzes. Right now there is one student view student per course, so if the
course has multiple administrators, they will all share the same student view
student.

There are a few things that won't work in student view the way the
would for a normal student, most notably access to conversations is disabled.
Additionally, any publicly visible action that the teacher takes while in
student view will still be publicly visible -- for example if the teacher posts
a discussion topic/reply as the student view student, it will be visible to the
whole class.

test-plan:
- (the following should be tried both as a full teacher and as
  a section-limited course admin)
- set up a few assignments, quizzes, discussions, and module progressions in
  a course.
- enter student view from the coures settings page.
- work through the things you set up above.
- leave student view from the upper right corner of the page.
- as a teacher you should be able to grade the fake student so that they can
  continue to progress.
- the student should not show up in the course users list
- the student should not show up at the account level at all:
  * total user list
  * statistics

Change-Id: I886a4663777f3ef2bdae594349ff6da6981e14ed
Reviewed-on: https://gerrit.instructure.com/9484
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
scheduler: per-appointment participant limit

closes #7769

Test plan:
  - create an appointment group
  - open the appointment groups and edit one of its appointments
  - change the number of users allowed to attend the appointment
  - make sure that no more users can reserve the appointment than
    configured

Change-Id: I4365113d81d123bd8c3cdc24af8761cc6b9027a3
Reviewed-on: https://gerrit.instructure.com/9648
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
prevent intermittent selenium failures for conversation attachments

Change-Id: Ib6348f1aac572b4d9faceb00c5dbd1be4522d94b
Reviewed-on: https://gerrit.instructure.com/9818
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
fix disappearing appointment group events

fixes #7888

Test plan:
  - make an appointment group
  - reserve one of the appointments as a student
  - as the teacher, go to the month calendar view
  - edit the appointment group event
  - make sure the event doesn't disappear

Change-Id: I01574c7c343ff0681e13acd00773dc564814a437
Reviewed-on: https://gerrit.instructure.com/9661
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cameron Matheson <cameron@instructure.com>
gradebook2 header-column fixes

fixes #6873, #7286

Test plan:
  - open the gradebook in a course with an assignment that has a very
    long name
  - verify that the assignment name is truncated
  - verify the tooltips on the column headers are sensible

Change-Id: I2309f05e0426f5d855f9e385c13934a05efa6da1
Reviewed-on: https://gerrit.instructure.com/8791
Reviewed-by: Jake Sorce <jake@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
users API endpoint (for course settings) #7764

* merged Api::V1::Enrollment into Api::V1::User because of a circular
  dependency
* adding enrollments and email fields to #user_json
* adding associated_user_id, updated_at, and locked fields to
  #enrollment_json

/api/v1/courses/:course_id/users
test plan:
* create a course
* enroll a user twice in the course (e.g. a TA)
* call the api with 'enrollments' and 'email' in include[]
* verify that the user data includes an email and two enrollments

Change-Id: I2f09c72c0e60fb7d2cd5bc7b585834970ad7a7cf
Reviewed-on: https://gerrit.instructure.com/9607
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
show teacher's comments in rubric for students, fixes #7291

test plan:
- create an assignment and tie a grading rubric to it
- submit the assignment as a student
- grade the submission and add a comment to a couple of the fields in the rubric
- go back to the student and view "Submission Details"
- click on "Show Rubric"
- a comment bubble should show under the "Pts" column
- clicking on the bubble should show an un-editable popup with the comments

Change-Id: Iad9de6fd6087e7638bf26abe623bd30760e7f16a
Reviewed-on: https://gerrit.instructure.com/9740
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
properly handle selective external migration imports

The selective imports mostly worked before, but if a
given section was completely unchecked the previous
code would import it anyway. This fixes that and makes all
the decision code in one place and easy to test.

Test Plan:
 * Import a content package and only choose certain items
 * Only the items you chose should be imported

closes #5528

Change-Id: Ia6c0c1f5f9a44497053733101140cc74d6239129
Reviewed-on: https://gerrit.instructure.com/9799
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
fix cancel typos refs #7949

Change-Id: If8d9c75a9ac31b87474aa21cfdae77ef40513eb0
Reviewed-on: https://gerrit.instructure.com/9798
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
remove invalid spanish translation key

in the new discussions we changed a key that used to have an interpolated value
to one that no longer has one.  Since the spanish translation lags a bit, this
causes an error until the new translation is done.

test-plan:
- in a course that has a dashboard entry about a graded discussion topic
- switch course locale to spanish
- make sure the dashboard loads

Change-Id: Ia41fe4b40ec08ad5de78005e4b3a42d007c2c036
Reviewed-on: https://gerrit.instructure.com/9837
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
spec: fix bad course import spec

we were relying on the order and array of courses got sent to the page

Change-Id: I10b4d0c6a173758f13a2b37ace059e4453fcd0d6
Reviewed-on: https://gerrit.instructure.com/9841
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
clean up temporary tables in migrations

since an external connection pool might be in use, and it would mess
up future migrations

test plan:
 * create two new shards through pgbouncer in the same database in
   quick succession

Change-Id: I2bf582a543a48f9df83888feda54818211931a34
Reviewed-on: https://gerrit.instructure.com/9842
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
fix conversation merge issue, fixes #7801

fix an issue where private conversations were improperly merged when
merging user accounts (only a problem when it was being merged into an
existing conversation on the target user). this would cause page errors
due to orphaned conversation_participants.

includes a data migration to fix affected conversations.

test plan:
1. on the old code, create three users (A, B, C)
2. start a private conversation between A and B
3. start a private conversation between A and C
4. merge user B into user C
5. confirm that users A and C get a page error when going to conversations
6. upgrade the code and run the migration
7. confirm that conversations load and the merged conversation appears
   correctly
8. on the new code, create three more users, repeat steps 2-4, and confirm
   that conversations load and the merged conversation appears correctly

Change-Id: I50785764ae4376a38824ffa099ff678686ec5023
Reviewed-on: https://gerrit.instructure.com/9847
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
latest spin.js, fixes conversations UI glitches

fixes:
1. missing spinner bars in when loading the messages pane
2. random viewport flickers (old spin.js used 3d transforms by default)

test plan:
1. check various places where we use disableWhileLoading (conversations,
   calendar2, gradebook2, etc.)
2. ensure that the spinner shows up and looks good while things are
   loading

Change-Id: Ia18881a2d8983c92b4f587fd99f836e5d9225a22
Reviewed-on: https://gerrit.instructure.com/9827
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
fix caching of default account in forked selenium specs

test plan:
 * run all specs in spec/selenium/content_migrations_spec.rb serially

Change-Id: Ic23b718b296a8a205eed654a77c37723a8111329
Reviewed-on: https://gerrit.instructure.com/9851
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
spec: fix intermittent jobs spec failures

Change-Id: Ib882130c345987d9ca6e33137c035db02c2ddbd0
Reviewed-on: https://gerrit.instructure.com/9850
Reviewed-by: Bryan Madsen <bryan@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
redirect to the correct domain when logging in where they shouldn't

refs #7167

test plan:
 * create a user in a non-default account
 * log in on the default account
 * you should get redirected to the correct account to log in again
 * it should have a scary warning at the bottom
 * the username should be pre-filled
 * after logging in, the scary warning should be gone

Change-Id: I1b69c0f14624bace22b9b5f71e08c698a839f71d
Reviewed-on: https://gerrit.instructure.com/9772
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Cody Cutrer <cody@instructure.com>
remove modal backdrop from media upload window.

fixes #8015

test plan:
  * enable kaltura;
  * create a quiz with an essay question;
  * click the media button in the rich text editor and
    verify that the media window appears, but that no
    backdrop accompanies it.

Change-Id: I08e59c9650d37f9959f4932cea90c4fdaa2260fa
Reviewed-on: https://gerrit.instructure.com/9815
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>