speedgrader: always show group submission files

closes CNVS-9715

Some API consumers are uploading files intended for a group assignment
to a user's files endpoint instead of the group one.  This commit
allows a user's files to be associated with all submissions for an
assignment belonging to the same group.

NOTE: this does not allow users in the same group to steal each other's
files, only the owner of the file can submit it.

Test plan:
  1. create a group assignment
  2. upload a file to your user files area
  3. make a submission to the assignment with that file
  4. other users in that group should be able to view the file on their
     submission page
  5. try to submit the file from step 2 as another user in the group.
     this should fail

Change-Id: Ie949a5b71795fe0537305c57be94d48535605460
Reviewed-on: https://gerrit.instructure.com/27808
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cameron Matheson <cameron@instructure.com>
add aggregate parameter to outcome results rollup api

also replaces raw hashes in outcome result analytics with
structs to improve error detection and possibly support active
model serialization in the future.

fixes CNVS-10037

test plan:
 - check the outcome results api documentation for the new
   aggregate parameter.
 - call the outcome rollup api with the aggregate=course
   parameter.
 - verify the result in this case is one rollup that contains
   an accurate average of the user rollups for each outcome.

Change-Id: I635cf5e28f5de73e44b63ac6234971657728d035
Reviewed-on: https://gerrit.instructure.com/28103
Reviewed-by: Joel Hough <joel@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
QA-Review: Joel Hough <joel@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
add outcome gradebook feature

fixes CNVS-10196

test plan:
  * verify that no outcome gradebook tab or option appears
    on the gradebook2 page;
  * using feature flags, enable outcome gradebook;
  * verify that the gradebook2 page now displays a learning
    mastery tab;
  * verify that clicking the learning mastery tab displays
    the learning mastery gradebook;
  * verify that course outcomes with scores are displayed as
    columns and that students with results are displayed as
    rows;
  * in a course with sections, verify that filtering either
    the gradebook or outcome gradebook by section updates
    the filter of the other view (note: only the section
    dropdown will change in the outcome gradebook; no
    filtering will actually take place);
  * verify that toggling the mastery checkbox filters in
    the outcome gradebook will show/hide relevant cells in
    the table.

Change-Id: I9979f37ac42d9bc45f0dd9846dd7a92e45c25c09
Reviewed-on: https://gerrit.instructure.com/28014
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <banderson@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
display type of aligned items on outcome show page

fixes CNVS-7274

test plan:
  * create an outcome, associate it with a rubric, and use
    that rubric to grade an assignment;
  * navigate to the outcome's show page (e.g.
    /courses/x/outcomes/y);
  * verify that the assignment and rubric both display as
    aligned items and have assignment and rubric icons.

Change-Id: I85e448c6e276b0d5c466cf77aee3ca175a378b38
Reviewed-on: https://gerrit.instructure.com/28138
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
standardize due date format on discussions index

fixes CNVS-8727

test plan:
  * create a graded discussion with a due date;
  * navigate to the discussion index page and verify that
    the due date format is "Due Jan 1 at 11:59pm".

Change-Id: I00a38db24492c3250e999eb41368ca09a14db087
Reviewed-on: https://gerrit.instructure.com/28144
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <banderson@instructure.com>
Product-Review: Marc LeGendre <marc@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
discussions: handle keyboard shortcuts

fixes CNVS-5997

test plan:
  * open a discussion
  * verify that you can view shortcuts by pressing ? (or alt+shift+/)
  * verify that you can add a root entry by pressing n

  * focus a message
  * verify that you can edit it by pressing e
  * verify that you can delete it by pressing d
  * verify that you cannot edit or delete entries that you don't have
      permission to moderate
  * verify that you can reply to it by pressing r

  * verify that you can navigate through the entries with j and k
  * add more than ten replies to one entry and reload the page
  * verify that hidden replies are opened for navigation
  * verify that navigation order is correct for threaded and
      non-threaded discussions
  * verify that you can navigate through deleted items
      and newly added or edited items

  * verify that focus is maintained during these actions, including
      in rich editor launches
  * verify that these shortcuts work with a screenreader

Change-Id: I84bb061b9df30e3fb6006cd816b0b64e3da8c165
Reviewed-on: https://gerrit.instructure.com/27744
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
spec: comment out ember testing

Change-Id: Id2d5d4a69031ac4c718ccd7c9feca54560aa1347
Reviewed-on: https://gerrit.instructure.com/28212
Tested-by: Bryan Madsen <bryan@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
ignore scores for unpublished assignments

fixes CNVS-10244

test plan:
- create a new course with a teacher and student
- create two assignments, and publish them
- grade them both
- unpublish one of them
- look at all the places you can see grades, and make sure they all
  consistently show only the grades for the published assignment (the
  unpublished assignment should be completely ignored)
  * GB2 with and without 'treat ungraded as 0'
  * GB1 with and without 'incluce ungraded'
  * GB csv download
  * student grades summary page with and without what-if scores
  * /grades page as a student and as a teacher

Change-Id: I32aca28fe377e59cb2e0c6278b59eb74c87c73b4
Reviewed-on: https://gerrit.instructure.com/28047
Reviewed-by: Cameron Matheson <cameron@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
don't show unpublished assignments in recent_feedback

fixes CNVS-10255

test plan:
- in a course with draft state enabled
- create an assignment, publish it, grade it
- it should show up for a student in 'recent feedback'
- unpublish it
- wait 15 minutes for the cache to expire
- it should no longer show up in 'recent feedback'

Change-Id: I074fb27edd0862827233167c17949b0fefd7cf85
Reviewed-on: https://gerrit.instructure.com/28059
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cameron Sutter <csutter@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
grades summary: toggles 'Show/Hide Details' button text

fixes CNVS-10253

test plan:
- on grades sumary page
- click 'show all details' button
- all details should expand
- button text should read 'hide all details'
- click 'hide all details' button
- all details should collapse
- button text should read 'show all details'

Change-Id: Iffade4195d520483995e6e0c7a8e0ab018c1bedd
Reviewed-on: https://gerrit.instructure.com/28137
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Liz Abinante <labinante@instructure.com>
fix equation editor when opening multiple times

test plan:
* using the rich text editor, use the equation editor
to insert an equation
* click again to insert another equation (should start
with a blank equation editor)
* should be able to insert another equation instead
of receiving an "undefined" message

fixes #CNVS-10242

Change-Id: I7d07a751a8e4fa454eec616d9fadeac01ad8e760
Reviewed-on: https://gerrit.instructure.com/28172
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Nathan Rogowski <nathan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
in API docs, remove space from "Custom Column" model

Test Plan:
- Custom Gradebook API docs should use "CustomColumn" to describe
  its model instead of "Custom Column".

Fixes SIS-123

Change-Id: I266733878803bda58ccc44fe26255f8518289469
Reviewed-on: https://gerrit.instructure.com/28121
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Reviewed-by: Duane Johnson <duane@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
spec: comment out fragile CustomList coffeescript specs

Change-Id: Ie9ec26bf9ff2ecc7629f6967d80e277873b652b6
Reviewed-on: https://gerrit.instructure.com/28218
Tested-by: Bryan Madsen <bryan@instructure.com>
Reviewed-by: Bryan Madsen <bryan@instructure.com>
QA-Review: Bryan Madsen <bryan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
hide unpublished assignments from students in old assignments interface

fixes CNVS-10252

test plan:
- create a course with draft state enabled
- create a mix of published and unpublished assignments
- as a student or teacher, go to the assignments tab in the top menu bar
- it should only show published assignments (even for teachers)
- now change your course homepage to be the assignment list
- it should show only published assignments for students
- it should show both published and unpublished for teachers
- finally, check that the course RSS feed contains only published assignments

Change-Id: Ib9494e76d178cba4b6c32722b0c33b1f8e11824c
Reviewed-on: https://gerrit.instructure.com/28055
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cameron Sutter <csutter@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
backport subqueries in array conditions from Rails 4 to Rails 3

we've already backported it to Rails 2

Change-Id: Ibe8ff2f5263f524f9b899966e350dfac8cb3ba29
Reviewed-on: https://gerrit.instructure.com/28001
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
fix simply_versioned version before_create callback for rails 3

Change-Id: Ide8ba029dbcde7ce4df4d3d874b1ffd4d146c32f
Reviewed-on: https://gerrit.instructure.com/28158
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
user_ids param on outcome result rollup endpoint

fixes CNVS-10040

test plan
- fetch outcome results using api, specifying some users from the
 context in the user_ids parameter
- ensure that only the specified users are returned, even if they
 don't have an outcome result
- fetch course aggregate results, specifying some users
- ensure that only the specified users' scores are used in the
 resulting average
- try to fetch outcome results using the api, specifying some users
 who are not in the context
- ensure that an error is returned
- fetch some outcomes using the api without the user_ids param
- ensure that results for all users are returned

Change-Id: I9e0e3fa37a7087a9808f3ab7c1859410620eab3d
Reviewed-on: https://gerrit.instructure.com/28149
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Product-Review: Joel Hough <joel@instructure.com>
filter outcome gradebook by section

fixes CNVS-10292

test plan:
  * enable outcome gradebook in a course with sections;
  * navigate to outcome gradebook, verify that you can
    filter results using the section dropdown in the right
    sidebar;
  * verify that filter changes in the gradebook are also
    propagated to the outcome gradebook.

Change-Id: I2c0bfb21b0376c48b5f8483ddd151df0d6f6d16f
Reviewed-on: https://gerrit.instructure.com/28203
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
change custom_gradebook_column permissions

these are the permissions required to view gradebook2

Test plans:
  Teachers/admins should still be able to edit/view custom gradebook
  columns for courses they can view the gradebook in. Students shouldn't
  be able to.

Change-Id: I6e4d79933e636a5274e353d8c611e0b4844642d0
Reviewed-on: https://gerrit.instructure.com/28141
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Cameron Matheson <cameron@instructure.com>
fix race condition creating quiz submissions

also do it shard-safely

Change-Id: If9d902c9f6db550df5e6d404952c51b5211f1155
Reviewed-on: https://gerrit.instructure.com/28244
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>