optimize question bank importing

same idea as the quiz question import optimization - don't send a
huge list of strings to the database, and get a huge blob back, when
 we can exchange much less information to accomplish the same thing

test plan:
 * import a course with a question bank
 * it should work

Change-Id: I73d57cbbd600ac7c13618dc5b1dcfcef3bb92484
Reviewed-on: https://gerrit.instructure.com/23448
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
new conversations: middle truncate course name in drop-down

limit the length of the course name displayed in the course
dropdown to limit the width of the nested menu. truncating in
the middle because the most important parts of the course name
tend to come at the beginning and end.

fixes: CNVS-7442

test plan:
 - create and publish some courses with long names (> 25 chars).
 - make at least one course concluded, one a favorite, and one a
   non-favorite.
 - go to conversations beta and open the course drop down.
 - the courses with long names should be "middle-truncated"
   where the first 10 chars and the last 10 chars of the name
   are visible, separated by an ellipsis.
 - the long course names should be underlined to indicate they
   are "abbreviations."
 - hover over a truncated name, and the full name should appear
   as a tooltip.
 - screenreaders should still read the full course name when the
   truncated menu item gets focus (note there are some keyboard
   and accessibility issues noted below).
 - clicking on the truncated name should still activate the
   course filter.

known issues:
 - there are some issues with keyboard accessibility documented
   in CNVS-7619.

Change-Id: I4cd6f5e259c370bd51b671e8d39fe7df3ff0a26e
Reviewed-on: https://gerrit.instructure.com/23348
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <banderson@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
clarify oauth docs about deleted tokens

Change-Id: Ibbb161baed27ffdf0b1a17cdc18b7bcfcb8d2195
Reviewed-on: https://gerrit.instructure.com/23562
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
add model and javascript validations for accounts

fixes CNVS-3047

testing steps:
- create a new account
- edit the account and remove the "Account Name"
  try to save and verify an error displays
- edit the account name and make it longer than 255
  and verify it displays it is too long

Change-Id: I9437a16ea5f897a7ee214dcdb3b453599f99c1f7
Reviewed-on: https://gerrit.instructure.com/23465
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Marc LeGendre <marc@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
fix except(:includes) in a few places

Change-Id: I6ae9324a2833ea76de0445cc5666bf16ed80b037
Reviewed-on: https://gerrit.instructure.com/23587
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
always return discussion topic summary

fixes CNVS-6823

when a student who has not posted to a discussion topic
with the require_initial_post setting attempts to make an
api call to the show action, they can now see the topic
information instead of a "require_initial_post" message.

this commit only changes the behavior of the
discussion_topics_api_controller#show method. it does not
change the error behavior of the entries, view, and reply
to entry actions.

test plan:
  * create a discussion topic with require_inital_post set
    to true;
  * as a student in the topic's course, make a call to
    /api/v1/courses/:course_id/discussion_topics/:topic_id;
  * verify that topic information is returned.
  * verify that calls to the view and entries actions still
    return the string "require_inital_post" per the api
    documentation.

Change-Id: I816e7d1de57829e74ddf102a07856c3e65620aa8
Reviewed-on: https://gerrit.instructure.com/23541
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Product-Review: Zach Pendleton <zachp@instructure.com>
QA-Review: Zach Pendleton <zachp@instructure.com>
avoid doing very expensive assessment question queries

stupid includes on associations

test plan:
 * add a question bank to a course
 * copy the course, selecting specific content
 * it should work

Change-Id: I63ce0f95c644dbbee9331482892974b767c73527
Reviewed-on: https://gerrit.instructure.com/23519
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
add index on CommunicationChannel.confirmation_code

Change-Id: Id277db73d6964eebdfdd5d76c1d0c7d4f015bad6
Reviewed-on: https://gerrit.instructure.com/23524
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
add index on content_migrations.context_id

Change-Id: I6a2f65a3f316806aa69adf0c54411e1ab35d25ca
Reviewed-on: https://gerrit.instructure.com/23523
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
optimize CrocodocDocument.update_process_states

there is an index on process_states, but postgres can't use it cause
find_in_batches is ordering by id. so use the slave instead, which
allows (nay, forces) using a cursor, and no ordering, so postgres
can use it's index. (still do updates on the master)

Change-Id: I6f7a18f7ffa7a1a1971e4eb5195af890e2038fbd
Reviewed-on: https://gerrit.instructure.com/23593
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
spec: fix modal dialogs teacher_quizzes_spec

Change-Id: Ia1a96e7ec04a299e69a940f25d41bd812e8e1d61
Reviewed-on: https://gerrit.instructure.com/23602
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Kyle Rosenbaum <kyler@instructure.com>
Product-Review: Kyle Rosenbaum <kyler@instructure.com>
QA-Review: Kyle Rosenbaum <kyler@instructure.com>
Tested-by: Kyle Rosenbaum <kyler@instructure.com>
fix selective content with numerical migration ids

test plan:
* import the package referenced in the ticket with
'select content' checked
* select particular modules to import
* should import as expected

fixes #CNVS-7631

Change-Id: Ic3865a4c499e30ad544b1bab7d17001444a2ea88
Reviewed-on: https://gerrit.instructure.com/23497
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: August Thornton <august@instructure.com>
module sequence api

test plan:
 - consult the API documentation for the new Get Module Item Sequence
   endpoint, and also the Module Item Sequence return type
 - test retrieving the sequence information of a module item
   of each type
   - the ModuleItems for the prev, current, and next items
     in the sequence should be returned
   - any Modules referenced should also be returned
     (e.g., there should be three of them if you're testing
     on an item that is the only item in its module,
     and previous and next items in other modules exist)
 - verify that no more than 10 item sequences are returned
   when an item appears in modules more than 10 times
 - test as a student, ensuring that unpublished modules
   and unpublished module items are excluded from the results

fixes CNVS-7616

Change-Id: I75365dc3f169d35767525686815f9cd93e595bdb
Reviewed-on: https://gerrit.instructure.com/23578
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
add_recipients should exclude messages this user has not seen

with new conversations, not every conversation participant will
see every message. when a user adds a participant to a
conversation in the old interface, the new participant should
only see the messages that the user adding them has seen.

whether a user has seen a message is determined by whether they
have a conversation message participant, which were recently
changed to be soft deleted instead of hard deleted.

fixes CNVS-7653

test plan:
 - in the old interface, create a group conversation with at
   least 3 messages.
 - for one of the users, delete one of the messages using the
   old interface (this will be a soft delete).
 - hard delete another one of the messages using the console:
   u = User.find(<user id>)
   m = ConversationMessage.find(<message id>)
   c = u.conversations.where(conversation_id: <conversation id>)
   c.first.delete_messages(m)
 - refresh the old conversation interface. This user should only
   see one of the three messages now (one was soft deleted, and
   one was hard deleted).
 - using the old interface, add a new user to the group
   conversation.
 - switch to the new user's view of the conversation. they
   should see two messages in the conversation: the remaining
   message and the soft deleted message. the hard deleted
   message should not be visible.
 - otherwise, conversations should behave as they used to.

Change-Id: I5a8c9ff371c2b2877b08c1480261200e0d0b28a3
Reviewed-on: https://gerrit.instructure.com/23579
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Cam Theriault <cam@instructure.com>
Product-Review: Jon Willesen <jonw@instructure.com>
generate swagger json with other API docs

Generates public/doc/api/api.json when "rake doc:api" is called. Adds
arrays, formatting, proper names to arguments, param types.

Change-Id: I9a6367dcc8fced404f31835bbd6b216123d2b6ba
Reviewed-on: https://gerrit.instructure.com/23460
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Duane Johnson <duane@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
Tested-by: Duane Johnson <duane@instructure.com>
change pages to allow context-based draft state

test plan:
 - with draft state disabled and allow draft enabled for the account
   - account.settings[:enable_draft] = false
   - account.settings[:allow_draft] = true
 * enable draft state for the course
   - course.enable_draft = true
 * click on the 'Pages' tab in the course
   - the new pages UI should be shown
 * disable draft state for the course
   - course.enable_draft = false
 * click on the 'Pages' tab in the course
   - the legacy pages UI should be shown

Change-Id: If5d180e18451ec559d12b18784263b4ff92a754d
Reviewed-on: https://gerrit.instructure.com/23581
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
make slow migration postdeploy pt 2

Change-Id: Ie27a3de082b3868781dcbce817df870ba83b2522
Reviewed-on: https://gerrit.instructure.com/23621
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
fix date selector when using multiple override dates on a quiz/assignment

fixes CNVS-7684

test plan
- make sure that you have more than one section course in the settings
- create a quiz and add multiple due dates
- the date pickers should all continue to work correctly

Change-Id: Ic14ae50cbeea18dccc5ed6c47adc4aa5377bfa7b
Reviewed-on: https://gerrit.instructure.com/23609
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
preserve links to re-uploaded attachments in course copy

test plan:
* upload a file to a course
* create a wiki page with a link to the file
* delete the file
* re-upload the same file into the same location that
the old file was in
* note that the link in the wiki page is still functional

* copy the course
* the link in the new wiki page should still be functional

fixes #CNVS-7635

Change-Id: I534d33d62c2fb952fa1045f167287fca03609cbf
Reviewed-on: https://gerrit.instructure.com/23611
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
fix notifications migrations

notifications are unsharded, so the data only applies to the default
shard

Change-Id: I742e39c0ae131bc8ce37358285ae35a71e9d928f
Reviewed-on: https://gerrit.instructure.com/23610
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>