assignments with no preview should show 'No Preview Available'

refs #7425

Marc L. pointed out that this wasn't working.

test plan:
- create a new assignment with paper submission
- give the assignment a score for a student in the speedgrader
- as the student verify that the submission details page shows
  'No Preview Available'

Change-Id: Ie29943589a1a50ca7a14a79d1e1d5e0556ece1f3
Reviewed-on: https://gerrit.instructure.com/10846
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
improve performance of terms page

it was doing a table scan on enrollments, so by adding a condition of
the root account, it can use an index

performance improvement is from 2 seconds to 50ms

test plan:
 * ensure user counts on terms page doesn't change

Change-Id: I98b25c97b34671537dd7254ec690ffc57bd4c512
Reviewed-on: https://gerrit.instructure.com/11046
Tested-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
properly escape discussion reply text with attachment; fixes #8509

when you submit an attachment with a discussion reply, we use a custom backbone
sync method in order to support multipart.  to do this we build a new form in
an iframe and insert it into the page, and values weren't getting escaped
properly when they were inserted into the new form.

test plan:
- in a new discussion, entry a reply that includes an apostrophe ', and angle
  brackets < and >. also attach a file to the reply.
- your message should come through in its entirety.

Change-Id: Iecb262f38819c184be4187891d7a30d17a8d80dd
Reviewed-on: https://gerrit.instructure.com/11050
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
return a new 640x thumbnail size for collection items

This extends Attachment with support for having multiple thumbnail sizes,
and allow specified sizes to be generated dynamically the first time
that they are requested.

test plan: create two collection items, one with an explicit image_url
and one without. Verify they both get images after the jobs run, and the
images are properly scaled.

Also verify that giving a non-image or invalid image_url ends up with a
nil image_url.

Change-Id: I4d1b1de681f2cddda0c81f1b340d32c3b5b0097b
Reviewed-on: https://gerrit.instructure.com/10822
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
slight pseudonym auth refactor

moved some code into the model for easier reuse (e.g. observer
co-enrollmenent needs to be able to auth as the observed user)

test plan:
1. run PseudonymSessionController specs
2. they should pass

Change-Id: If6cafc99235f270909d2dd17d1912b1a51bb11bc
Reviewed-on: https://gerrit.instructure.com/11079
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
pull embedly information on item creation

We store off the html preview snippet to return with the api response,
and we prefer the first image embedly returns over a page snapshot, if
no explicit image is given by the user.

test plan: configure embedly. create a collection item pointing to a
service embedly understands -- like a tweet or youtube video. verify the
html_preview is returned with the item once the job finishes running,
and that an appropriate image is pulled from the embedly data rather
than a snapshot capture of the page.

Change-Id: Ifd99053fa3c75833656b773eba6844da5994de9e
Reviewed-on: https://gerrit.instructure.com/10851
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
group activity stream endpoint in the api

test plan: hit api/v1/groups/X/activity_stream, verify you get back the
activity stream filtered to that group

Change-Id: I7c1a55f5340540d1c21818896e49a16a82acf135
Reviewed-on: https://gerrit.instructure.com/10925
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
add index on courses (sis_source_id)

test plan:
 * run specs

Change-Id: I16aaec14dc95a0d684d8c59f4dcd0df17b1cfbf5
Reviewed-on: https://gerrit.instructure.com/11038
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
add a DiscussionTopic to CollectionItems in the API

To allow commenting on CollectionItems, we are goign to leverage
DiscussionTopics. The topic will not be created until the first comment is
made, and is accessed via the normal DiscussionTopic API (using a special
endpoint).

This also adds a new "flat" DiscussionTopic type, which doesn't support any
nesting of replies.

test plan:
 * Create a collection and an item in that collection (via console or API)
 * Using the API, query the discussion topic for that item via the API
 * Using the APi, add a comment to that discussion topic
 * Using the API, fetch the discussion again and see that your comment appears

Change-Id: Ie7cc27a7bc1d7960040632015971e59f084d7e6f
Reviewed-on: https://gerrit.instructure.com/10960
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
refactor to not scope items by their collection in api urls

test plan: verify the new api endpoints work as the old ones, but don't
require the collection id in the path

Change-Id: I36e2b761cfd47a01d04d58c12821cf78652563e0
Reviewed-on: https://gerrit.instructure.com/11091
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
use the user global_id in the active user redis stat set

test plan: you'll need access to the redis console to check the
active_users: keys and verify the user ids are global ids now

Change-Id: Ia046170714cd99d033a97a915c24a95eb79aca67
Reviewed-on: https://gerrit.instructure.com/11080
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
optionally return current and final grades in enrollments api.

refs #8803

test plan:
  * create a course with student enrollments and assignments;
  * grade some of the assignments;
  * make an api call to /api/v1/courses/:course_id/enrollments;
  * verify that the two fields are displayed correctly in the
    [:grades] hash of the returned student enrollments;
  * verify that the [:grades] hash is absent on non-student
    enrollments.

Change-Id: I2b71218ee8b18a3a072209add23e30768287151e
Reviewed-on: https://gerrit.instructure.com/11075
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
fix race condition in psql jobs popping optimization

Because a volatile function gets its own mvcc view of the data, the
subselect could end up finding and locking a row that doesn't exist for
the outer select, ending up with a row that's locked but not being
worked on.

We've switched gears to return the actual job row from the function,
removing the need for the subselect.

test plan: this race condition is rare, and impossible to reproduce
without dozens of jobs processes hitting the queue, along with many
processes inserting jobs. a regressing test is worthwhile though, making
sure delayed jobs function normally.

Change-Id: I49a8eb062d4e8ceee12283510d62c0ce0087c13c
Reviewed-on: https://gerrit.instructure.com/11069
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ben Chobot <bench@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
spec: cleaned up submissions_spec

Change-Id: Ib798b7f56ce92614003acc109cc159a1f68edb3a
Reviewed-on: https://gerrit.instructure.com/11109
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
lower priority on media object processing

Change-Id: I30383fb69218bb5d20687de2ad117ed3bc1620c0
Reviewed-on: https://gerrit.instructure.com/10669
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
add collections to groups (backend + api); closes #8670

groups are now a valid context for collections. as a group moderator, you are
allowed to do anything (create/update/delete) with any collection or item in
the group. as a group member, you are not allowed to create/update/delete
collections, but you are allowed to post to them, and edit/delete posts you
have made.

test plan:
- nothing visible, but try making calls through the api. make sure the above
  permissions are accurately represented
- make sure the api doc additions are coherent

Change-Id: Ic259c6bdf1988420438a8258bf585671f972cd32
Reviewed-on: https://gerrit.instructure.com/10848
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
pass conversion settings hash into assessment qti parser

The assessment converter didn't know what type flavor of
QTI was being processed so it couldn't correctly adjust
the points possible for QTI from WebCT. The test for this
would have caught this break but it didn't have an assertion

Test Plan:
 * Import a QTI package from a WebCT course
 * The questions in the quiz should have the expected points possible

closes #8143

Change-Id: Iee65fd86fa4aeef5f65354ee4fb29fcfd051a666
Reviewed-on: https://gerrit.instructure.com/11119
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
return collection item created_at and user_id in api

add the time that the item was posted and the user id of the person who posted
it to the collection item api response.

test plan:
- query the api for a collection item, and make sure these two fields are
  returned

Change-Id: I3ac4b5b3212d380b947f236c69d47507517997df
Reviewed-on: https://gerrit.instructure.com/11128
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
scheduler: allow sub_context selection on multiple contexts

fixes #8508, refs #7561

test plan:
  * create or edit a new appointment group
  * add course(s) or sections from some courses

Change-Id: I8813f312fe5a36ca83ed9dce9c66cbab761d463e
Reviewed-on: https://gerrit.instructure.com/10703
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
copy missed course settings on course copy

The settings for the course grading scheme, hiding the
final grade, and the storage quota weren't being copied.

Test Plan:
 * On course settings increase file storage limit, set a course grading scheme, and select option to hide totals in student grades summary
 * Copy course, make sure option to copy settings is selected
 * On new course, check that all properties are set

closes #8541

Change-Id: I3cb9b84b425412412e04eddf8a8a8448970e9d5b
Reviewed-on: https://gerrit.instructure.com/11078
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>