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>
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>
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>
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>
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>
Enrollment#sis_user_id without sis_source_id

refs CNVS-3610, CNVS-3653

test-plan:
 * enroll a user in a course without a sis_source_id
 * load the enrollment in a script/console
 * ask for enrollment.sis_user_id
 * it doesn't blow up

Change-Id: I8e526805181ad5351465af6eea362ca5478f9706
Reviewed-on: https://gerrit.instructure.com/17790
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
add french language translation

Test Plan:
  - French language should be an option, and updated

fixes CNVS-4029

Change-Id: I0f4d966c5b8985dec461e0af9650fb2e7fb6cc96
Reviewed-on: https://gerrit.instructure.com/17907
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
don't return from a proc

This worked in 1.8 but breaks in 1.9

test plan: create a delayed job that'll fail -- for instance
> User.find(X).send_later(:name)
> User.find(X).destroy!

Then run jobs, and the job should get inserted into failed_jobs
correctly.

Change-Id: Ie3a1f28cfaa7f1b1032b1c26dcee3330c30c0a5e
Reviewed-on: https://gerrit.instructure.com/17906
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
fix media preview thumbnails on file links

fixes CNVS-3973

test plan:
 * upload a video file to the files section of a course
 * give it time for kaltura to process it
 * edit a wiki page and use the wiki sidebar to insert that
   video
 * view the page.  a preview thumbnail should appear
   near the file link.   clicking it should play the video.

Change-Id: I515614ba01eed4db40a42b327a43767c9cfea2b8
Reviewed-on: https://gerrit.instructure.com/17971
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
skip kaltura assets with no url

Test Plan:
 * load a kaltura video with empty urls
 * if there are no valid ones it should say still converting
 * if there is just one missing, the player should use a valid one

Change-Id: If586ac446cdbf9c6e8b138d017dcd0fc6d81e20d
Reviewed-on: https://gerrit.instructure.com/17973
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
don't return invalid kaltura assets

This skips return both no urls and unknown types
also changed the cache key to clean up existing bad data

Change-Id: I59c665d0fffe4f53acf23e451ded5d44e0e657e3
Reviewed-on: https://gerrit.instructure.com/18009
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
prefer kaltura-converted assets over the original

there are two reasons why kaltura's processed assets
are preferable to the original:
 1. sometimes the user's uploaded one is in a non-streamable
    container ('mp4c', vs. the 'isom' kaltura uses),
    despite both being .mp4 files
 2. it's possible the original is too high a bitrate to
    stream effectively.  the old logic would prefer it
    nonetheless

test plan:
 - upload an mp4 in the 'mp4c' container format
 - ensure you can start watching it before it finishes
   downloading

fixes CNVS-4146

Change-Id: I6b2b9179b9e37b9a527938f81ace02c8dd6ac211
Reviewed-on: https://gerrit.instructure.com/18027
QA-Review: Clare Hetherington <clare@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
force media elements to use flash, and other bug fixes

 * default media to play using flash, fall back to html5 when flash is
   unavailable (like mobile)
 * fix stopping audio when minimizing media
 * fix audio in popup viewers (like speedgrader)

Test Plan
 * All properly converted videos/audio files should play

Change-Id: Id163caf71ffe3d6437076264700f4f3e218e89a0
Reviewed-on: https://gerrit.instructure.com/18021
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
fix ie9 media viewing

There were two problems:
  * IE9 cannot do $("<source type='blah'>").attr('type') for some
    reason, so now we're collecting the types separately.
  * IE9 has trouble with canPlayType(), so the HTML5 detection stuff
    in mejs was failing. This forces IE9 to just use the flash player.

Test plan:
 * Test that video and audio still works in all browsers.

Change-Id: Ia9f35e211f601424b244220edebf5d11a8c0bed2
Reviewed-on: https://gerrit.instructure.com/18034
QA-Review: Bryan Madsen <bryan@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
stick mail gem to version 2.4.4, even in ruby 1.9

v2.5.3 of the gem has a regex parsing error where it performs
negative lookahead on whitespace after the blank link that
separates the header from the body. This means that it will
misparse a message when the body starts with whitespace.

There is a fix on the master branch of the gem's repository, so
the next version of the gem should work. We should stick to
2.4.4 until we drop 1.8 support and the new gem has been
released.

fixes CNVS-4026

test plan:
 - bundle update and make sure bundler installs and uses
   version 2.4.4 of the mail gem

Change-Id: I4f3d2405e742a724e217fc803945e15c906f0f37
Reviewed-on: https://gerrit.instructure.com/17947
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
QA-Review: Zach Pendleton <zachp@instructure.com>
don't open a db transaction when storing page views to cassandra

This is pointless extra load and leaves idle transactions visible in db
monitoring.

closes CNVS-4132

test plan: with cassandra page views enabled, monitor the delayed job
that inserts into page views. verify it doesn't send any begin/commit
commands to the db.

Change-Id: I6efbcd7a68811b2d5bddfba3d84382d6f03fce31
Reviewed-on: https://gerrit.instructure.com/18001
Reviewed-by: Zach Wily <zach@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Hetherington <clare@instructure.com>
clean up Course#settings a bit, don't show hide_final_grades to students

refactor so that adding settings is less painful, and accessors are
automatic. change code to use accessors everywhere, and ensure settings
are handled by course import/export. also fix filter_attributes_for_user
call so that it correctly excludes hide_final_grades in api responses for
students

test plan:
1. toggle course settings (hide_final_grade / hide_distribution_graphs /
   allow_student_discussion_topics)
2. they should work as advertised

Change-Id: I152e2236099b1bc1a42730babef12ac9cc2f9733
Reviewed-on: https://gerrit.instructure.com/17534
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Joe Tanner <joe@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
course setting to prevent students from editing/deleting own posts

fixes CNVS-3178

test plan:
1. as a student, create a discussion topic and a reply
2. as a teacher, uncheck "Let students edit or delete their own discussion
   posts" on the course settings page.
3. as the student, confirm you cannot edit or delete the topic or reply
   that you created
4. as a teacher, recheck the box and save
5. on the discussion index page, confirm the setting is checked in the menu
6. disable it via the menu
7. repeat step 3

Change-Id: Ib7d6ba3604370241de1145aac8e23d35f78591c4
Reviewed-on: https://gerrit.instructure.com/17535
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Joe Tanner <joe@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>