cross shard dashboards

two major pieces:
 * use context_type/context_id instead of context_code for
   three relations so that sharding extensions will
   automatically work
 * deserialize stream item data as actual AR objects instead
   of OpenObject (for similar reasons)

test plan:
 * run the predeploy migration, but not the postdeploy one
 * view your dashboard on a shard other than your home shard;
   it should be identical to your home shard
 * view courses that you are enrolled in with the same id but on
   different shards. the activity stream should have the correct
   data for the course in that shard, for both courses (i.e.
   no mixing of data from the two shards)
 * do actions that generate new stream items, and verify the new
   items appear correctly for the above two steps
 * run the postdeploy migration, wait for the job to finish, then
   repeat the test plan

Change-Id: I8d5fcadb8d971acf7388a12e9151a3e927751f44
Reviewed-on: https://gerrit.instructure.com/15462
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
restore attach link after posting a discussion reply.

fixes #11979

when posting a reply w/ an attachment to a discussion, future
replies to that post were missing the attach link. this commit
restores the attach link on posting.

test plan:
  * create a discussion;
  * create a reply to the discussion that has an attachment;
  * without refreshing the page, attempt to reply again to the
    same discussion post and verify that the attach link is
    present.

Change-Id: I2e9c0a169f7fcf7a982242ca9a78dfef78301562
Reviewed-on: https://gerrit.instructure.com/15661
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Willesen <jonw@instructure.com>
Reviewed-by: Marc LeGendre <marc@instructure.com>
refs #8395 expanded page views

force a page_view record when
submitting an assignment
and when updating an assignment
description

force a page_view when
starting a new discussion
or when replying to a discussion

force a page_view when updating
a wiki page and when joining
a conference and when starting
a collaboration

start tracking http methods for
page views

don't link through to urls
for page views if they aren't 'get'
methods

pull some of the page_view logging
down into the asset_user_access
object and simplify it so
that the application controller is
more readable and the scoring incrementing
is easier to understand

TEST PLAN:
  1) login as a student
  2) turn in an assignment submission
  3) take a quiz
  4) update an assignment description
  5) start a discussion and reply to it
  6) login as an admin and confirm through
     analytics and through the detailed
     page view listing that all these
     actions counted as participations
     (and that the ones that are not
      'get' methods can't be clicked through
      from the student accound details page)

Change-Id: I2dfe4df41e8b006e6a0c0d8a1f914ecd7fb62477
Reviewed-on: https://gerrit.instructure.com/15428
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Prevent malicious zip uploads

refs #11857

don't allow zip files with more than
100000 files to get attached

don't allow zip files that add enough
data (with a minimum file size of 512)
to go over the context quota

also refactor unzip_attachment.rb a
bit as long as we're in there because
it's a bit dense and monolithic.  There
is still much that could be done there,
but it's not one enormous method anymore.

TEST PLAN:
  1) login as any user with permissions
  to upload files.

  2) attempt to upload a zip archive with
  more than the configured max number of
  files inside of it (currently 100,000)

  3) you should get an error preventing
  this action from occuring and no
  new attachments should have been made
  to that context

  4) navigate to some context where the
  attachment quota is known.

  5) attempt to upload a zip archive to
  that context with enough size to exceed
  that quota.

  6) you should get an error preventing
  any of the new attachments from being
  attached to that context.

Change-Id: I35ce673e96fb98728cb36cfd27538fd802a249f2
Reviewed-on: https://gerrit.instructure.com/15671
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Clare Hetherington <clare@instructure.com>
Icon font replacement for course Settings section

To test:

Go to a course, click on Settings, click thru each tab

Change-Id: I4411e3a795c08f4c03a75fa40f61a64610423309
Reviewed-on: https://gerrit.instructure.com/15438
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Icon replacement for Account > Settings

To test: Open managed account from main dropdown and go thru each menu option on left

Notes:

Did not do icon replacement for "Account Permissions" section as it is heavily CSS sprite-based

Account > Settings > Announcements -- icon font replacement is possible here, but need small dev help

Change-Id: I1b0e52b338eb04a118230fbc2b563ddbf74ea3c1
Reviewed-on: https://gerrit.instructure.com/15569
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Icon font replacement for ePortfolios

To test:

- Create and edit an ePortfolio

- Comment on an ePortfolio page

Change-Id: I324fabf0d5b5ae081da59db7e0d79605feaecc34
Reviewed-on: https://gerrit.instructure.com/15635
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
fix needs grading count trigger for mysql. fixes gh-245

test plan:
 * use mysql
 * accept a course invitation

Change-Id: I8307c2d5925f85dd3be7c4aded6fa822518be3b2
Reviewed-on: https://gerrit.instructure.com/15716
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
display and allow editing of overrides in calendar2.

fixes #11754, #11756

assignment override dates now display on teacher, TA,
and course designer calendars. an assignment appears
once for each override, and overrides can be edited
via drag/drop or by clicking them and then opening the
'edit' form.

assignment overrides are distinguished from default
assignments by the inclusion of their title in
parentheses after the assignment name, e.g. "Assignment
Name (Section Name)".

test plan:
  * verify that assignment overrides appear on a teacher's
    calendar along with assignment and are displayed like
    assignments;
  * as a teacher or admin, attempt to drag and drop an
    overridden date and verify that it updates successfully;
  * ensure that there are no drag/drop regressions
    with assignments;
  * as a teacher or admin, verify that clicking an override
    and selecting the 'edit' link displays a form with only
    the date of the override displayed;
  * verify that the original assignment event form still
    includes an editable title field.

Change-Id: I3f18d4414a64022a72aaf73f611d4878bc3e61f6
Reviewed-on: https://gerrit.instructure.com/15442
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
optimize the page views cassandra migrator

refs #11772

The previous strategy didn't perform as hoped, so we've switched to the
(account_id, created_at) index. This required storing a separate
progress state per account_id so we can migrate one account at a time.

At the same time I decided to switch from newest-first going backwards
to oldest-first going forwards. This will make it easier to do the
entire migration while still on db page views, then switch to cassandra
page views, then do a 2nd migration just to move over the small # of
page views created in the interim.

test plan: generate some db page views in multiple accounts. then switch
configuration to cassandra page views. run rake
db:migrate_pageviews_to_cassandra and the existing db page views should
now be in cassandra, including showing up in the user's page view
history.

Change-Id: Ic748376032a4305a0537f398670fb37ee17b071c
Reviewed-on: https://gerrit.instructure.com/15489
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
don't use antialiased font rendering

we had put in this css rule to render text antialiased
but it actually makes things less readable.

test plan: load a page, make sure text is readable

Change-Id: I4bc2ac5eb4d88564fb20719a1d119b37fbfc6e5e
Reviewed-on: https://gerrit.instructure.com/15689
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Chris Hart <chris@12spokes.com>
properly merge redis.yml settings in to redis session store settings

fixes gh-247

test plan:
 * set up a redis store on a non-standard port, IP, or database
 * configure it in redis.yml
 * configure session_store.yml to use redis_session_store, but
   not any other options
 * start up the server; sessions should properly be stored in
   the redis instance configured in redis.yml

Change-Id: I2a6518d07e8571840ab74c014dcd8ae06eef5369
Reviewed-on: https://gerrit.instructure.com/15684
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
dashboard: missed one icon in backwards compatibility

fixes #11925

test plan:
- create an account level announcement with the "group of people" icon
- make sure the dashboard loads

Change-Id: I40ac9b191a73167fab85e7019a304fe841ec0cfa
Reviewed-on: https://gerrit.instructure.com/15507
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cam Theriault <cam@instructure.com>
Reviewed-by: Ryan Florence <ryanf@instructure.com>
spec: fix unsorted compare

Change-Id: I6ba60cd1bfa5b0b27cc0fc0e39fab5bfac709340
Reviewed-on: https://gerrit.instructure.com/15473
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
migrate account membership types to new role engine

test plan:
* migrate and confirm that the csv in
 account.membership_types is now split into
 Role objects with base_role_type of
 'AccountMembership'
* also, roleoverrides that aren't referenced
 in membership_types are assumed to have been deleted
 so confirm that a Role is still made
 but it is 'inactive'

Change-Id: Ic96c0ecdfd70e5678f74467686a9c9f385e53725
Reviewed-on: https://gerrit.instructure.com/15712
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
add the ability to take quizzes one question at a time

fixes #11781

This commit also adds the ability for quiz creators to restrict students
to only submit their answers for a question once, preventing them from
returning to a question they have already answered.

test plan:
- create a normal quiz, a 1-question at a time quiz, and a quiz that locks
  answered questions
- as a student, take each of these quizzes, making sure they work as expected
- make sure to use the next/previous buttons, the sidebar links, and try
  submitting in the middle of a quiz vs at the end of a quiz
- try to get back to a previous question on a locks answers quiz, make sure
  there is no way to do this.
- normal quizzes should function as you would expect.

Change-Id: Icb7efc646a51549269e3a4ead2c7f34b00e94103
Reviewed-on: https://gerrit.instructure.com/15292
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Stanley Stuart <stanley+gerrit@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Dave Donahue <dave@12spokes.com>
make other APIs deal with course roles

fixes #11938

test plan:
 - generate the documentation

 - for CoursesController#index "List your courses"
  - enroll a user in two different courses, using a base
    enrollment type in one course (e.g., TA) and a
    derived custom enrollment type in the other
    (e.g., AwesomeTA; use the Add Role API to generate it).
  - publish the courses, accept the enrollments, etc.
  - as the created user,
   - GET /api/v1/courses and make sure both courses show.
     Also make sure (here and below) that the custom role
     shows up in the results, i.e.
     'enrollments' => [{'type' => 'ta', 'role' => 'AwesomeTA'}]
   - GET /api/v1/courses?enrollment_type=ta and make sure
     both courses show.
   - GET /api/v1/courses?enrollment_role=TaEnrollment
     and make sure only one course is returned.
   - GET /api/v1/courses?enrollment_role=AwesomeTA
     and make sure the other course is returned.

 - for CoursesController#users "List users"
  - enroll multiple users in the same course with
    a base and a derived enrollment type
    (kind of the opposite of the previous)
  - As an admin,
   - GET /api/v1/courses/:course_id/users and make sure
     both users are returned.
   - GET /api/v1/courses/:course_id/users?enrollment_type=ta
     and make sure both users are returned.
   - GET /api/v1/courses/:course_id/users?enrollment_role=TaEnrollment
     and make sure only the plain TA is returned
   - GET /api/v1/courses/:course_id/users?enrollment_role=AwesomeTA
     and make sure only the awesome TA is returned
   - GET /api/v1/courses/:course_id/users?enrollment_role[]=TaEnrollment&enrollment_role[]=AwesomeTA
     and make sure both users are returned.

 - for EnrollmentsApiController#index "List enrollments",
   exercise the 'role' parameter, using all three contexts
   (course, section, and user), testing cases like those
   outlined above
   - also make sure enrollment['role'] shows the custom role
     type in the returned JSON

Change-Id: Icefe662538c2fc6df19f7a6fe82e8009a3bd25e3
Reviewed-on: https://gerrit.instructure.com/15598
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>