improve moodle 2 handling of missing file references

test plan:
* import the packages referenced in the ticket
* should not fail catastrophically

fixes #CNVS-13226

Change-Id: Ib66ec7c7d5eea3331349f069db6035e592ab84c4
Reviewed-on: https://gerrit.instructure.com/35448
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
fix issue with publishing a module not publishing quiz item correctly

this was fixed by changing two things.

1. all objects except quizzes are published by setting workflow_state to
   'published'. Quizzes differ in that it also needs to generate the question
   data and set the published at time. We have the Quiz#publish! method to do
   exactly this, but nobody uses it. So the code now just checks the workflow
   state and always triggers the correct code if someone changes it directly

2. Quizzes use 'available' instead of 'published' for the published workflow
   state. Content tags was checking for 'active' first and since quizzes
   responded to that method it was setting the state to active, which was
   messing things up. I switched the logic to check for responds_to :available
   first, so that quizzes get set correctly.

fixes CNVS-13003

test plan:
  - turn off draft state
  - as a teacher
    - create a new quiz with questions (leave unpublished)
    - create a new module (leave unpublished)
    - add the quiz to the module
    - publish the module
  - as a student
    - take the quiz
    - the questions should show up fine when taking the quiz

  - make sure that publish/unpublish of a quiz with DS continues to work
    as expected
  - mess around with any way you can think to publish the quiz via modules
    etc.

Change-Id: I734e2499d58891fda952b608a13e856d469ebca2
Reviewed-on: https://gerrit.instructure.com/35479
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
fix module unlocking via date

test plan:
 * create a module that unlocks in the future
 * wait until the module unlocks

 * as a student (not student view)
 * from the modules page, access the module
 - the module should be unlocked and accessible by the student

fixes CNVS-13292

Change-Id: I890289f5248faab52ae5291a7a0c197c6881bc48
Reviewed-on: https://gerrit.instructure.com/35477
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
force gradebook transition

this commit forces on the new, accessible, individual gradebook view and forces
of the old GB1

closes CNVS-12327

test plan:
- make sure that individual gradebook view is on and GB1 is off and that you
  can't change it from the UI as a teacher or site admin
- now run the following (to simulate not already having the flag set to on):

  FeatureFlag.where(feature: "screenreader_gradebook").destroy_all

- check again to make sure it is on and can't be turned off

Change-Id: I23cb476d051b4e7697de47432dbe4a408b9800ef
Reviewed-on: https://gerrit.instructure.com/35464
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cameron Matheson <cameron@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
treesame commit of origin/stable/2014-05-24

Treesame-Commit-Id: 1cc0e6006cbab4b5570691a2e2cf333d7af801e2
don't force MFA reconfig after successful CAS login when MFA is needed

fixes CNVS-13348

the problem was CAS login uses a GET, so we were taking the reconfig
path. so check more specifically for the reconfigure action

test plan:
 * configure MFA for an account
 * make sure you can log in, but *don't* remember the device for
   MFA purposes
 * configure CAS on the account
 * login with CAS
 * it should ask for your MFA code, not to reconfigure MFA

Change-Id: If955ee3ed48456c64c9732fa90c7fb911e1c402d
Reviewed-on: https://gerrit.instructure.com/35668
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
publish and unpublish with the api instead of changing workflow state directly

fixes CNVS-12975

test plan:
  - create a quiz with two questions (save but don't publish)
  - turn on fabulous quizzes
  - view the number of questions for the quiz on the ember quiz index page
  - it should show you the correct number
  - publish the quiz
  - refresh the page
  - it should continue to show you the correct number of questions

Change-Id: I47b3117a3346de62d167f0959c10b1ea620b8b2b
fix issue with republish quiz not working correctly pre-draft state

fixes CNVS-13391

test plan:
  - turn off draft state
  - as a teacher
    - create a new quiz
    - publish the quiz
    - make changes to the quiz questions
    - make sure the notification shows that you have unpublished changes
    - republish the quiz
    - the quiz changes should be published

  - make sure there are no regressions with CNVS-13003

  - make sure that publish/unpublish of a quiz with DS continues to work
    as expected
  - mess around with any way you can think to publish the quiz via modules
    etc.

Change-Id: I1365609f8c4fc10056de42a806a3629155e6643e
Reviewed-on: https://gerrit.instructure.com/35754
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
add sis_course_id to sections api attributes

fixes SIS-277

Change-Id: I06bfef5c18427b8db311ab433d5370fdb8c14bc5
Reviewed-on: https://gerrit.instructure.com/34955
Reviewed-by: Duane Johnson <duane@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Eric Adams <eadams@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
fix api sis id permissions

fixes CNVS-13433

test plan
 - you should not be able to see sis_id if you do
   not have permissions to
 - test for sections and courses

Change-Id: I983825e2bd2ea76a1c7300cee3be7859a5e4f5d4
Reviewed-on: https://gerrit.instructure.com/35898
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
source course copy validator permission

fixes: CNVS-13438

Changed the call to grants_rights? to grants_right? since there is only
one permission being checked.

Test Plan:

  - Setup a course where you do not have manage rights.
  - Try to copy the course and you should get an error:
    You are not allowed to copy the source course.
  - Give yourself manage rights to the course.
  - You should be able to copy the source course as normal.

Change-Id: Ib19757158f7a3e28df3b3e6e68ade8d08ea7dba0
Reviewed-on: https://gerrit.instructure.com/35896
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
treesame commit of origin/stable/2014-05-24

Treesame-Commit-Id: 937d87a01bfd8aed04e7e54b13620d359872f871
Merge pull request #10 from instructure/stable

merge stable
Merge pull request #11 from mayijun/stable

merge Stable to work branch