fix for using coffee when compiling js

coffee works a directory at a time, and the regex wasn't working for
plugins for just a directory

test plan:
 * npm install -g coffee-script@1.1.2
 * have a plugin with coffeescript
 * rake canvas:compile_assets (in a clean repo)
 * it should not fail

Change-Id: I5ca8030b9cdc572875169a0342dc09601fd2569b
Reviewed-on: https://gerrit.instructure.com/10095
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
set headers with the user id on every request

X-Canvas-User-Id and X-Canvas-Real-User-Id will now be set when someone is
logged in and when someone is masquerading. These could be useful for further
logging down the stack. We set the global id for sharded situations.

test plan:
 * Log in to canvas
 * Verify that your http requests include X-Canvas-User-Id in the response

Change-Id: Id8818b5280618956541c513f5a3763e2bd60e89d
Reviewed-on: https://gerrit.instructure.com/10050
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
changed css on a couple divs fixes #7905

test plan:

  1. go to discussions
  2. create a new discussion
  3. click more options
  4. click delay posting this message
  5. notice the until element display
     is in-line with the checkbox and
     string
  6. click on a date and make sure the alignment sticks

Change-Id: Iadb79b783751f6937a9a343f300f3422e94268e8
Reviewed-on: https://gerrit.instructure.com/10131
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
pending_review show as 'submitted' in event list; fixes #7840

submissions that are pending_review, which right now is just quiz submissions
with essay questions, were improperly being shown as 'not submitted' in the
coming-up events list on the dashboard and course home page. this correctly
marks them as submitted.

test-plan:
- create a quiz with an essay question and a due date in the next week
- as a student verify it shows in coming up as 'not submitted' on the dashboard
- take the quiz
- it should now show as 'submitted'
- make sure other events in the coming up list show correct states.

Change-Id: I3ad8d208f6b1d3a9366e68e869652c22ab2702d6
Reviewed-on: https://gerrit.instructure.com/9948
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
add referenced question banks to course copy

If a question bank outside of the course was referenced by
a quiz group the export for its quiz would fail. This fixes
that and tries to connect the group to the same bank on the
import step.

Test Plan:
 * Create a question bank on an account and one on a course
 * On a different course create a quiz that has two groups that point to each of those banks
 * Copy the course to a new one
 * The quiz groups should still point to their original banks

closes #8159

Change-Id: Idffb4e7c1ac3d00945d3544a9f0ace4ee241e45a
Reviewed-on: https://gerrit.instructure.com/10119
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
find_ids_in_ranges helper

like find_ids_in_batches, but returns a closed range of the ids,
instead of the actual ids so that whatever's iterating over the
table doesn't have to use a huge IN clause

test plan:
 * run the specs

Change-Id: Id22c197a6e4d80db49cc6ec99bb3e79e6fb69523
Reviewed-on: https://gerrit.instructure.com/10066
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
fix date adjustment on course copy

Test Plan:
 * Create a course with stuff with dates
 * Copy the course and set the date adjustment
 * Stuff in new course should have adjusted dates

closes #8162

Change-Id: I8d75f410a37b8cc4323001581e74c6a43c1979ab
Reviewed-on: https://gerrit.instructure.com/10156
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
don't make gradebook_history styles global

there is no need to as they only apply to the
gradebook history page

test plan:
* /courses/x/gradebook/history and make sure
  everything is still styled right

Change-Id: I69d194090ab5c7afa1fd597aefa78d7189f81889
Reviewed-on: https://gerrit.instructure.com/9873
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Joe Tanner <joe@instructure.com>
avoid page_views counts for users

count can be slow if there are a lot. also remove the "last" link
from api responses that skipped the count

test plan:
 * go to a user's page with less than 50 page views; they should show
   and it should not try to load more
 * go to a user's page with hundreds to thousands of page views; they
   should load on demand, and when you reach the bottom, it should
   stop trying to load more

Change-Id: I934cd7260232b78c33ae5fc1be5e49b2ea686614
Reviewed-on: https://gerrit.instructure.com/10135
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
capture the current shard for jobs

including batch jobs

test plan:
 * n/a without a sharding implementation

Change-Id: Id4e8b8a72e71a21e0862fda27059f57412a80a53
Reviewed-on: https://gerrit.instructure.com/10165
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Cody Cutrer <cody@instructure.com>
disable gradebook history page for large courses

refs #7855

test plan: set gradebook_history_submission_count_threshold to some
non-zero value, then visit the courses/X/gradebooks/history page for a
course with more than that number of submissions. You'll see this
message instead of the gradebook history, and none of the data will be
queried from AR.

Change-Id: I86add3fdb0366fba87881feffa1be881d3ce8b3a
Reviewed-on: https://gerrit.instructure.com/10176
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
fix day substitutions when copying courses

Test Plan:
 * copy a course and do a day sub
 * it should work

closes #8162

Change-Id: Id20bbc7d4e2c008aa9f16b0a66b70f28efaec9f1
Reviewed-on: https://gerrit.instructure.com/10181
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
change the quiz export file extension

Test Plan:
 * Export quizzes for a course
 * The extensions should be .zip

closes #8248

Change-Id: I2a4b909c846ecd3690e34dcddf06e0dacc556cd5
Reviewed-on: https://gerrit.instructure.com/10171
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
update ruby-saml-mod to 0.1.8; fixes #8091

this update includes the following changes:
- make request ids always start with a letter to be xml compliant
- support multiple assertion_consumer_service_url

Change-Id: I82ad3e8344215a6ef4b49837e13f01dd0fdccade
Reviewed-on: https://gerrit.instructure.com/10237
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Bryan Madsen <bryan@instructure.com>
limit quizzes to 1000 questions, increase key limit. fixes #8172

changes quiz editing UI such that you can't exceed 1000 questions. quizzes
that already have over 1000 questions can still be edited, but new
questions cannot be added. this limit covers both regular questions as
well as question groups (e.g. "pick 20 of the following questions"). the
changes only affect the quiz UI and have no impact on question banks, or
on quizzes or banks created/updated via import.

also doubles the Rack::Utils.key_space_limit to 128 KB so that (most)
existing large quizzes can be taken successfully. this sets a rough upper
bound of ~1500 questions for a quiz.

test plan:
1. on the old code, create a quiz with > 1000 questions (easiest via
   question groups)
2. on the new code, confirm that you can edit and remove existing
   questions on the quiz.
3. confirm that you cannot add any questions (either standalone or via
   groups) until the total is below 1000 again
4. take a quiz with 1000 questions
5. confirm that you can submit the quiz without getting a 500 error

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

Conflicts:

	spec/selenium/quizzes_spec.rb
update last completed quiz sub. when manually scoring; fixes #7916

a teacher can manually override the score on a quiz, and we try to keep things
in sync by writing this score back to the quiz submission. however, the quiz
submission might currently be in progress (or the latest attempt might be
abandoned) in which case syncing back can fail or do the wrong thing. So we
needed to make sure that we synced back to the correct version.

test-plan:
- take a quiz, complete it, then start it again and leave the page without
  completing it.
- as a teacher, score this quiz, and reload the page; the score should stick
- make sure scoring an essay question quiz from the quiz submission page still
  works.

Change-Id: Id2c919199a12ea8b0636959142efc649d5daf738
Reviewed-on: https://gerrit.instructure.com/10177
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
grant read permission to teachers of date-concluded, unpublished course

fixes #7484, and also allows teachers to view the content of these
date-concluded, unpublished courses, which they couldn't before.

test plan: as a teacher who is *not* also an admin, visit a course that
was never published, but is now "soft" concluded because the term it's in is
concluded. verify that you can view course content, and copy the course
content into another course.

Change-Id: I8af6213e8f2ecf0ffc758acee0080e6ffbf9b9dc
Reviewed-on: https://gerrit.instructure.com/10163
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
fix copying root-level course files and media object references

File in the root folder of a course we being copied into
and extra folder called "course files" in the destination
course. And media object references linking to non-existant
.flv files in the course when copied.

Test Plan:
 * Create some files in the root of a course
 * Create a media comment on a wiki page or the course syllabus
 * Copy the course
 * The files should be in the root in the new course and the media comment should work

closes #8299

Change-Id: I505007d195c962eb249975f7e6d4afc9733fb59e
Reviewed-on: https://gerrit.instructure.com/10254
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
don't alter media object links when copying course

Test Plan:
 * Copy a course that has media objects
 * The videos should still work

closes #8299

Change-Id: Ia6cb107d138e0cbf78f71ee9d33ade85c7b9c333
Reviewed-on: https://gerrit.instructure.com/10272
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
copy all the rubrics when copying a course

Only the rubrics created directly in a course were being
copied. This commit copies ones through rubric_associations
to get everything.

Test Plan:
 * Create a course with some rubrics
 * Make an assignment use a rubric associated with another course
 * Copy the course
 * The new course should have all the necessary rubrics

closes #8266

Change-Id: Ib1e1b6c0cc053d53182c0825fe871eb8429ab734
Reviewed-on: https://gerrit.instructure.com/10266
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>