don't store entire OAuth request token object in session

instead just store the token string and secret

test plan:
 * add a twitter account to your profile
 * add google docs to your profile
 * add a linked in account to your profile

Change-Id: I67c2dd9f8afe4af55ce37c1a10a4efc63609a2a6
Reviewed-on: https://gerrit.instructure.com/10612
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
selectively copy learning outcomes groups on course copy

Test Plan:
 * Create some learning outcomes with some in outcome groups
 * Copy the course, don't select "copy everything"
 * Select the learning outcomes to copy
 * Run the copy
 * The new course should have all the selected outcomes, including ones within groups

closes #8492

Change-Id: I70b428d4c83ec7f2b1b04878817fa0a7e1c78264
Reviewed-on: https://gerrit.instructure.com/10636
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
fix javascript check for submission file attachments; fixes #8086

the javascript check that prevents file upload submission without attachments
needed to be made aware of the possibility of using already uploaded files as
attachments, which are sent in a separate form field than files to be uploaded
with the submission.

test plan:
- create an assignment that allows file uploads
- as a student, upload a file directly to you files area (from profile ->
  files)
- when submitting an assignment, choose the option to use an already uploaded
  file
- it should successfully submit, and not give you an error that you must attach
  at least one file

Change-Id: I76273fe3aa2a6879667d6841d6049ffcf9a66f83
Reviewed-on: https://gerrit.instructure.com/10456
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
remove page views from the counts report

This will get added back in once page views are moved out of the
database.

test plan: visit an account statistics page, the two lines of page view
counts in last week/month will be gone. The CountsReport periodic job
should now not do the page view rollup queries.

Change-Id: Icb947a88ff6644d600a31593ff07050f964b8580
Reviewed-on: https://gerrit.instructure.com/10640
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
strip tags from HTML multiple-choice answers for stats fixes #8116

test plan:
 * create a quiz with multiple-choice or multiple-answers
   questions, using HTML formatting for the answers
 * as a student, take the quiz
 * as a teacher, look at the quiz statistics
   and verify that text under the bar graphs showing
   answer frequency is present
 * download the CSV statistics and make sure text is
   present there too

Change-Id: Ib7262c751bfc867d854e5707612ae323addb30c5
Reviewed-on: https://gerrit.instructure.com/10601
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
add delete communication channel api action. refs #8471.

test plan:
  * as an admin, attempt to delete another user's communication
    channel via the API and verify that call is successful and
    returns deleted communication channel object (meaning its
    workflow state is retired).
  * as a user, attempt to delete your own communication channel
    via the API and verify that the call is successful;
  * as a user, attempt to delete another user's communication
    channel via the API and verify that 401 is returned.

Change-Id: I636e8154a913710acada725fbf20ec7c306f8979
Reviewed-on: https://gerrit.instructure.com/10571
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
allow immediate module progression from quizzes

fixes #8356
refs #6245

Quiz scoring and module progession can interact in strange ways so that the
module progression link from the quiz page doesn't trigger the unlocking action
of the next module.  This was previously fixed for "within module" progression
links, but not "across module" progression links, which this commit addresses.

test plan:
- with caching and without delayed jobs
- create a module with a quiz as the last item
- make it so the module doesn't complete until a certain quiz score is reached
- make a second module that depends on the first being complete, with any
  content as the first module item
- work through the progression as a student - when you finish the quiz, make
  sure the 'Next Module' link at the bottom of the quiz summary page works.

Change-Id: I29ccbb28c2fe6c1d6facfc5757ac35f4f35ebb38
Reviewed-on: https://gerrit.instructure.com/10645
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
csv stats: deal with incomplete multiple-blanks submissions

don't trip over nil if a student fails to answer a fill-in-
multiple-blanks question.  fixes #8510

test plan:
 * create a quiz with a fill-in-multiple-blanks question
 * as a student, take the quiz, but don't submit an answer to the question
 * optionally, other students can take the quiz and submit the answer; the problem occurs if any student fails to answer the question
 * as a teacher, go to the quiz statistics page and click the "download CSV" button
 * confirm CSV is downloaded (no page error)

Change-Id: I3907d4b070feaf3038769bc8731df50366fe4fd2
Reviewed-on: https://gerrit.instructure.com/10650
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
Don't let browser cache user answers on quiz in text inputs. Fixes #8504

Add "autocomplete='off'" to quiz text inputs so browsers like Chrome and Firefox
don't store answers. The answer text remains between different users taking
a quiz on the same machine/browser.

Test Plan:
* Create a quiz with a single fill in the blank choice and a multi fill in the blank questions.
* As a student, take the quiz and give answers in the blanks.
* Log out as that student and then login as different user and take the same quiz.
* Using mouse double-click on the inputs for blanks or the down arrow key, no
  stored answers should appear.

Change-Id: I3b249537eec20820c815da4ee59892a286f92686
Reviewed-on: https://gerrit.instructure.com/10605
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Zach Pendleton <zachp@instructure.com>
Order user's PageView list as CSV with most recent first. Fixes #7474

 The CSV requested data was unordered but limited to 300. So CVS list did not
 always included expected data or in a predictable order. Added a named_scope
 and use it to give explicit ordering. In the process of working on this, I
 discovered that the "xml" link next to "csv" has no code backing it up and thus
 returns a blank page. Talked with Jon and determined to just delete the link.

 Test Plan:
 * enable page_views in settings (in order to see in UI)
   * ex: Setting.set('enable_page_views', 'db')
 * setup a user with page views that are not in chronological order
 * view the list at /accounts/?/users/?
 * html display version should be listed chronological order with most
   recent listed first (was correct before)
 * csv link downloads data and it should be in the same order
   and the same set of data.

 The easiest testing approach for CSV ordering is to review and run the
 new spec.

Change-Id: I004b10548fdcaffa795cc497aba93cfdda2eac82
Reviewed-on: https://gerrit.instructure.com/10534
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Joe Tanner <joe@instructure.com>
Prevent quiz form from submitting on ENTER in input. Fixes #8293

 Prevent a quiz from being submitted (usually accidentally) whe the user
 hits their <ENTER> key while in a text input. This change just
 suppresses the submit action on quizzes when used in a text input.

  Test Plan:
 * Create a quiz with single and/or multiple fill-in-the-blank options
 * pressing <ENTER> while in those inputs should not submit the quiz
 * Leaving a question blank and pressing "Submit" should prompt
   to submit when blank.
 * With all questions filled in, clicking the "Submit" button or using
   <ENTER> while on the "Submit" button should submit
   without any warnings.

Change-Id: I6a6e321dfa2d6101c8e49d6af82852b7e41190bc
Reviewed-on: https://gerrit.instructure.com/10581
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Joe Tanner <joe@instructure.com>
prepare for foreign keys refs #6895

 * add the foreigner gem so plugins can begin adding foreign keys
   immediately
 * add an extension to do less locking when creating foreign keys
   on postgres 9.1+
 * fix a few pieces of code that either don't properly clean up
   foreign dependencies, or create objects in the wrong order
   to maintain referential integrity
 * change the specs to truncate all tables in a single command
   for postgres (to avoid referential integrity errors; also
   slightly faster)

test plan:
  * no user visible functionality should change

Change-Id: I185e478b99fbe598d408912053c34a064aa9c461
Reviewed-on: https://gerrit.instructure.com/10580
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
remove sizes from user content video tags in api responses

This makes it easier for api consumers to apply their own css styling.

test plan: embed a kaltura video in a user content, like a discussion
topic. Then get that data from the api, and verify the <video> tag
returned has no width or height.

Change-Id: I8f2029449e34734b3c2d4eb91aa00118326c680e
Reviewed-on: https://gerrit.instructure.com/10644
Reviewed-by: BJ Homer <bj@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
select for update in the postgresql job delete trigger

we think this will avoid a deadlock condition where an insert takes the
ShareRowExclusiveLock at the wrong moment and deadlocks us inside the
trigger.

test plan: not consistently reproducable without major postgresql
instrumentation. ensure that jobs with a strand function as normal
(running the specs is a good sanity check)

Change-Id: Ib8c8ba972fd3c51ff116776213c936b9d7a48785
Reviewed-on: https://gerrit.instructure.com/10663
Reviewed-by: Zach Wily <zach@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
optimize delayed job queue pops on psql

Use a db function with a SELECT .. FOR UPDATE clause to avoid lock
contention on the table. The makes popping off the queue a completely
serial process -- but that's what we want here.

note this also defines a maximum (lowest) priority on jobs of 1,000,000
which we didn't have before, any lower priority will now be ignored.
however, the lowest priority we use in the code is 20.

closes #8517

test plan: ensure delayed jobs still function as expected, including
when there are a very large number of jobs in the queue. test with at
least 100,000 jobs.

Change-Id: Ibf0b4ce1d54f9400d7e734f0736c702e67316b76
Reviewed-on: https://gerrit.instructure.com/10618
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
fix 'more options' url if clicked from sidebar, fixes #8335

test plan:

* go to calendar 2
* click the 'add event' in the cog menu of a course
  in the right sidebar
* click more options
* make sure that it takes you to
  /courses/x/calendar_events/new where x is the
  id of the course you clicked 'add event' for

Change-Id: Ieb9216b81c844d1b2bba3d5af666385e35f48777
Reviewed-on: https://gerrit.instructure.com/10462
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cameron Matheson <cameron@instructure.com>
collections models and api

This lays the groundwork for the new collections feature. See the API
documentation for details. There is still some pending tasks before this
is totally ready, see the development board.

test plan: no UI yet, but you can make api calls to add/edit/delete
collections, add/edit/delete items, and upvote items.

Change-Id: I8fa019d428d1aae3ac62b1f34ebe2ac3c77310be
Reviewed-on: https://gerrit.instructure.com/10465
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
make courses#workflow_state sis sticky fixes #8258

test plan:
 * import a course via SIS
 * publish and conclude the course via the UI
 * re-import the course via SIS (still 'active') status
 * the course should stay concluded

Change-Id: Ieba993d1aac65a3e0872edec5deda2731f70e165
Reviewed-on: https://gerrit.instructure.com/10422
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
unambiguify reference to package identifier class

This reference would fail if the PackageIdentifier class
hadn't been loaded already

fixes periodic course copy fails

Change-Id: Ic95bd83d93348eb5b4242652d0994563a2ba2783
Reviewed-on: https://gerrit.instructure.com/10677
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
fix truncate_all_tables for non-postgres

Change-Id: Ia706a09fb620967ffcdaf7349ce65ff8e7fc5076
Reviewed-on: https://gerrit.instructure.com/10682
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>