Commit Graph

65 Commits

Author SHA1 Message Date
Han Yan f9676125bb Qti import from Canvas to Quizzes.Next
refs QUIZ-4415

test plan:
- cr
- Quiz.Next CC import is not ready for test with only this patch
- regression on `Import Content`, to make sure:
  1) `Qti .zip file` import works
  2) `Common Catridge 1.x Package` import works

Change-Id: Iba2818a2b864020b6c59ef55e02f122b996e4c40
Reviewed-on: https://gerrit.instructure.com/149978
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: David Tan <dtan@instructure.com>
Product-Review: Han Yan <hyan@instructure.com>
2018-05-31 16:57:32 +00:00
Neil Gupta 517549ae3a disable SpeedGrader if all the moderated grader spots are taken
fixes GRADE-1060

test plan:
* Create a course in an account with AMM on
* Add one student
* Add 3 teachers to the course
* Create a moderated assignment with a grader count of 1 and make
  teacher 3 the final grader
* Masquerade as teacher 1 and grade the student in SpeedGrader
* Masquerade as teacher 2 and try to access speed grader for the
  moderated assignment. You should not be able to access SpeedGrader
* Masquerade as teacher 3 and grade the student in SpeedGrader.
  It should work

Change-Id: I1db39700d9ebe59c21129061caddae31d29606c9
Reviewed-on: https://gerrit.instructure.com/150485
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Keith T. Garner <kgarner@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-21 19:51:02 +00:00
Omar Khan 96e7f9187e Only include quiz question_types in api responses
The Quiz#question_types method is expensive for large quizzes. It's
currently called every time a quiz is serialized, even though we only
need the question_types attribute in API responses (I believe it's used
by the mobile app).

This commit moves the question_types attribute to a separate
QuizApiSerializer that is only used in API responses.

Fixes QO-356
Fixes QO-357

Test plan:

- Create several huge quizzes (tens of thousands of questions across
  multiple question groups)
- Open the quizzes list page
- Check that the page loads reasonably quickly

Change-Id: Id18a32fc47f20cd24cb178e972f49e8984bfe53e
Reviewed-on: https://gerrit.instructure.com/149829
Reviewed-by: James Williams  <jamesw@instructure.com>
Tested-by: Jenkins
QA-Review: David Tan <dtan@instructure.com>
Product-Review: Omar Khan <okhan@instructure.com>
2018-05-15 20:12:16 +00:00
Steve Kacsmark 3e42d24e36 return empty description for locked quizzes
closes QO-311

Test Plan:
- Create a quiz with an available date in the future.
- Attempt to access the quiz as a student via the API
- Verify the description key is an empty string in the returned JSON
- Attempt to access the quiz as a teacher via the API
- Verify the description key has the correct value in the returned JSON

Change-Id: I2c3fc840b1319f4f504c9e878357d3f501916e03
Reviewed-on: https://gerrit.instructure.com/142098
Tested-by: Jenkins
Reviewed-by: Mark Grant <mgrant@instructure.com>
QA-Review: David Tan <dtan@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
2018-03-06 15:54:53 +00:00
Marc Alan Phillips 953f6fbfd3 Add Results Services Endpoints
Create endpoints for the results service, using new api
namespace for controllers and serializers. Also introduce
the services directory in the root of the app folder.

closes PLAT-3007

Test Plan:
 - Create a line item and add some scores
 - Query for the results using the result endpoint
   - Should return a paginated list
 - Query for a result with a user_id in mind
        - Use both lti_user_id and user_id
        - Should return a single result object
          of the user
- Find a result by the id of the result

Change-Id: I5af4b679bcecfc0deef2876a897bc93d739057b6
Reviewed-on: https://gerrit.instructure.com/138870
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Marc Alan Phillips <mphillips@instructure.com>
QA-Review: Marc Alan Phillips <mphillips@instructure.com>
2018-02-21 22:24:24 +00:00
Marc Alan Phillips bbd453ad75 Add scores endpoint
closes PLAT-3008

Test Plan:
 - Create a line item (both assignment and nonassignment)
 - Create a user
 - For the assignment lineitem, the submission should be
   updated when FullyGraded or PendingManual is passed
   with a score. This should show in the gradebook
 - The nonassignment lineitem should not update the
   submission even if there are scores. These
   should only be found in the console

Change-Id: Ie8b65b475f00f364fb78f1d5fe4c1cdd84548472
Reviewed-on: https://gerrit.instructure.com/139469
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Marc Alan Phillips <mphillips@instructure.com>
QA-Review: Marc Alan Phillips <mphillips@instructure.com>
2018-02-15 22:51:19 +00:00
wdransfield e580e068ca Line Item Controller (sans index)
Closes PLAT-3004

Test Plan:
CREATE
- Attempt to create a new Line Item using the create
  endpont. Verify the following params are required:
    - scoreMaximum
    - label
- Verify a new line item is returned and properly serialized.
  example:
  {
    "id" : <line item show/update endpoint>
    "scoreMaximum" : 60,
    "label" : "Chapter 5 Test",
    "resourceId" : "quiz-231",
    "tag" : "grade"
  }
- Verify the create endpoint allows setting the
  following optional params:
    - resourceId
    - tag
    - ltiLinkId (Must be the `resource_link_id` of
      an Lti::ResourceLink. This resource link must
      already have one line item associated with it.)
- Verify a Line Item cannot be created for an Lti::ResourceLink
  that does not already have at least one Line Item associated
  with it already.
- Verify a Line Item may be created for an Lti::ResourceLink if
  it already has at least one Line Item associated with it.
- Verify that creating a Line Item _without_ specifying an
  `ltiLinkId` creates a line item and a new assignment specified
  with the line item. The new assignment should have the following:
    - context: context of the new line item
    - name: label of the new line item
    - point_possible: the score maximum of the new line item
    - submission_types: none

UPDATE
- Verify the following attributes may be updated:
  - scoreMaximum
  - label
  - resourceId
  - tag
- Verify that the ltiLinkId may not be updated
- Verify that updating the Line Item label also
  updates the assignment title in the following cases:
    - when the line item has no associate Lti::ResourceLink
    - when the Lti::ResourceLink associated with the Line Item
      only has one line item (the one being updated)
- Verify the update response is properly serialized (see
  example in CREATE).

SHOW
- Verify the show endpoint allows retrieving the Line Item.
- Verify the endpoint responds with 404 if the Line Item
  does not exist.
- Verify the endpoint responds with a 404 if the Line Item
  exists but is in a different course than the one specified
  as a parameter.

DESTROY
- Verify the endpoint responds with 404s in the same instances
  as the show endpoint.
- Verify the endpoint does not allow destroying a Line Item
  when it is the first line item created chronologically
  for its associate Lti::ResourceLink
- Verify the endpoint allows destroying line items.

Change-Id: Iaf26e6addd1e3fe38c5fb76db33fed41a069e7c9
Reviewed-on: https://gerrit.instructure.com/138831
Tested-by: Jenkins
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2018-02-06 17:34:58 +00:00
James Williams bec2efbf5c add 'anonymous_submissions' attribute to quiz api json
test plan:
* set up a survey quiz with
"Keep submissions anonymous" checked
* the quizzes API (/api/v1/courses/X/quizzes/Y)
 should return a "anonymous_submissions" attribute

closes #CNVS-39992

Change-Id: Ia9ca4f64120f2c38d74a759f88b58c660ec13cff
Reviewed-on: https://gerrit.instructure.com/129842
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2017-10-17 19:56:26 +00:00
Jayce Higgins 715a36d243 Remove session from quiz permission grants
Fixes: CNVS-36218

Test-Plan:
  - As a teacher
    - You should be able to create a quiz
    - You should be able to update a quiz
    - You should be able to publish a quiz
  - As a student
    - You should be able to take a quiz

Change-Id: Ia43094399fffabf01e15c1f06cde3433f2ba2f45
Reviewed-on: https://gerrit.instructure.com/125835
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Jayce Higgins <jhiggins@instructure.com>
2017-09-20 21:14:14 +00:00
Cody Cutrer 3f6eb9ec9f spec: mocha => rspec-mocks for serializers
Change-Id: Iea402e15dbc6199faa16df331f4d760e0724eafb
Reviewed-on: https://gerrit.instructure.com/120562
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-07-26 19:29:27 +00:00
Landon Wilkins e1d42ddc24 da licença part 59
add consistent license headers to all source files

Change-Id: I218bf2aef012547d39092cf2b3589c9fdaff3d0f
Reviewed-on: https://gerrit.instructure.com/110310
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-05-01 21:11:16 +00:00
Derek Bender 1c53ab3d72 add late_policy controller/serializer
closes CNVS-36146

test plan:
- hit the following api endpoint (id is the course id):
  - /api/v1/courses/:id/late_policy
  with the following verbs:
  - GET (show)
  - POST (create)
  - PATCH (update)
  the following valid params for LatePolicy are available:
  - missing_submission_deduction_enabled
  - missing_submission_deduction
  - late_submission_deduction_enabled
  - late_submisison_deduction
  - late_submission_interval
  - late_submission_minimum_percent_enabled
  - late_submission_minimum_percent
  example set of valid params:
  - missing_submission_deduction_enabled: false
  - late_submission_deduction_enabled: true
  - late_submisison_deduction: '1'
  - late_submission_interval: 'hour'
  - late_submission_minimum_percent_enabled: true
  - late_submission_minimum_percent: '10'
  example set of invalid params:
  - late_submisison_deduction: '-1'
  the user must be a user with manage_grades permissions such as a
  teacher enrolled in the course, otherwise the json response will have
  an unauthorized message
- refer to the api docs for late_policy for more details

Change-Id: I9e3b2704680cf4b1f9b789deb1dccb2a1ccaa5d5
Reviewed-on: https://gerrit.instructure.com/108989
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
QA-Review: Keith T. Garner <kgarner@instructure.com>
2017-04-26 19:09:55 +00:00
Cody Cutrer 6beba043bc fix some ruby 2.4 deprecations
the thread_safe gem has deprecations too, but they'll require Rails 5.1
until they're fixed (when both activesupport and tzinfo no longer
depend on it)

Change-Id: Ic53839d911ba8ed4d463d17f9dd7207673510f3a
Reviewed-on: https://gerrit.instructure.com/100499
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-01-25 21:53:37 +00:00
Simon Williams ece65b5a89 spec: rename the `user` helper to `user_factory`
closes CNVS-34042

test plan: specs should pass

Change-Id: I20709a69f0cb28fb55eba18ca81f89f4d7673b56
Reviewed-on: https://gerrit.instructure.com/98426
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2016-12-27 20:25:25 +00:00
Jon Jensen f55776d146 spec: fix spec that fails the first run on most builds
also prevent session stubbing in before(:once) blocks and remove lots
of unnecessary stubbing

note that while session stubbing is also unnecessary in controller/api
specs (just need @user to be set), delaying removal of thay to another
commit (we might want tweak it to actually use session stubbing or
something otherwise explicit and less magical than @user)

Change-Id: Iea1792c960ad32090bc4644febc87e1d3651f550
Reviewed-on: https://gerrit.instructure.com/96791
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Tested-by: Jenkins
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2016-12-06 00:07:13 +00:00
James Williams 8539a6b44b allow course admins without manage rights to preview quizzes
test plan:
* create a custom teacher role with "Manage assignments/quizzes"
 disabled
* a teacher with that role should be able to see and preview
 a quiz

closes #CNVS-30574

Change-Id: Ib036b2f352c63c63fc4454e08d80d21f34415ce0
Reviewed-on: https://gerrit.instructure.com/86119
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2016-08-02 12:47:16 +00:00
Matthew Berns b559308012 include quiz access code in api response if user can manage
fixes CNVS-29728

test plan:
- create a user in a role that has permission to manage,
  but not edit grades
- create a quiz with an access code
- as the user, observe the access code can be seen in the ui
- as the user, observe the access code is included in the api
  response
- as a student (or any other user that lacks either grading
  or management permissions), the access code should still
  not appear in either the ui or the api response

Change-Id: I70e87d2f5ad975fc7776f54388c8339d7cbf521a
Reviewed-on: https://gerrit.instructure.com/82916
Reviewed-by: Ryan Taylor <rtaylor@instructure.com>
Tested-by: Jenkins
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Jason Sparks <jsparks@instructure.com>
2016-06-20 16:56:34 +00:00
James Williams 0777cba946 remove differentiated assignments feature checks
test plan:
* basic regression test of assignment overrides

closes #CNVS-27549

Change-Id: Ie463848b3831087efb3f9ec762dca6264055ee76
Reviewed-on: https://gerrit.instructure.com/73139
Tested-by: Jenkins
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2016-03-07 18:44:46 +00:00
Cody Cutrer e1529eb1ae switch a few things to use account_chain
instead of assuming [self, Account.site_admin]

refs CNVS-26291, CNVS-26292

Change-Id: I8c20a3e29f5af91d04e380794f21705706fd96a8
Reviewed-on: https://gerrit.instructure.com/69841
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2016-01-18 17:51:42 +00:00
Cody Tanner afd4fce104 adds ability to filter quiz statistics by section
closes PFS-2226
Tests:
1. Create a course with two or more sections
2. Create a Quiz with submissions.
3. with student A submit a submission to the quiz in the first section
4. With Student B submit a submittion to the quiz in the second section
5. As a teacher navigate to the quiz statistics section and view the
results
6. By default all submission will show, once you select a section only
that sections results will show.
Change-Id: Ifd32bbfb67068008f008b8323a10b9ea18a67468
Reviewed-on: https://gerrit.instructure.com/58962
Tested-by: Jenkins
Reviewed-by: Ryan Taylor <rtaylor@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Jason Sparks <jsparks@instructure.com>
2015-09-23 23:54:28 +00:00
James Williams c63f0b946c improve module item file selector performance
test plan:
* selecting files as module items should still work
 as before (but loading from API should be more performant
on back-end)

refs #CNVS-20049

Change-Id: Icb4114651c1fc614192217aabcd699d20988f537
Reviewed-on: https://gerrit.instructure.com/56705
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Reviewed-by: Dan Minkevitch <dan@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
2015-06-23 12:46:07 +00:00
Michael Nomitch 2dc7f65f1d add verifiers to user quiz rich content
fixes CNVS-17525

test plan:
  - make a quiz with an embedded image and canvas
    links (from the right side bar) inserted into
    the description, a question, and a potential
    answer to the question
  - request quiz data via the api
    (api/v1/courses/:course_id/quizzes/:quiz_id)
    (api/v1/courses/:course_id/quizzes/:quiz_id/questions)
  - note that the links to content now have
    values for "data-api-endpoint" and
    "data-api-returntype"

Change-Id: I9ca545cdcd82e171ac95aa3ec05e06fbae235495
Reviewed-on: https://gerrit.instructure.com/54726
Tested-by: Jenkins
Reviewed-by: Brian Finney <bfinney@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Hilary Scharton <hilary@instructure.com>
2015-05-29 23:51:20 +00:00
Ryan Taylor 221b15d7fa Creates quiz attribute "has_access_code" for mobile API
Now quizzes report if they have an access code in the API.

Closes CNVS-20233

Test Plan:
  - Visit api/v1/courses/1/quizzes
  - Confirm each quiz shows "has_access_code" accurately
  - ["with", "without"].map do |word|
    - Create a quiz #{word} an access code
    - Check the api/v1/courses/1/quizzes/:id endpoint to see if
      has_access_code is correct

Change-Id: I825af0a42ef722a03f5d4ee7a7065c6bb187dd1c
Reviewed-on: https://gerrit.instructure.com/54372
Tested-by: Jenkins
Reviewed-by: Cameron Sutter <csutter@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Ryan Taylor <rtaylor@instructure.com>
2015-05-19 15:44:12 +00:00
Ryan Taylor 0bfe1c1cea Adds question_types to quiz API responses
Necessary for mobile quiz selection

Closes CNVS-19613

Test Plan:
  - Confirm that quiz API endpoints return question_types array,
    containing unique quiz question types.

Change-Id: If1a51bb101fc6a346872c7d5952cb68d32e85397
Reviewed-on: https://gerrit.instructure.com/52217
Reviewed-by: Brian Finney <bfinney@instructure.com>
Tested-by: Jenkins
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Ryan Taylor <rtaylor@instructure.com>
2015-04-20 16:04:42 +00:00
Ahmad Amireh 45260fa4b9 QLA - Table view / answer matrix
A table view that lists all the answers to all questions with lots of
options. The view is restricted to Support SiteAdmins only.

Closes CNVS-17165

Backend/API Changes:

  - QuizSubmissionEvents#index is now paginated

  - Added a new account-level permission :view_quiz_answer_audits to
    control the visiblity of the answer matrix. You can test this on the
    quiz using "quiz.grants_right?(user, :view_answer_audits)"

Client app changes:

  - Fixed a race issue when loading environment-specific config;
    sometimes would cause the tests to fail because the test suite would
    run before the test config was loaded

  - Moved the decoration of QUESTION_ANSWERED events to a separate
    module and now it is done only once at fetch-time, instead of once
    per render

  - Simplified a lot of book-keeping that was done in the Events store
    by using query & URL parameters

  - A global loading indicator prop "isLoading" which is managed by the
    root route in routes/app.jsx - if you want to create a nicer loading
    indicator, this would be the place to edit

  - Moved all "devDependencies" into "dependencies" in package.json so
    now we can just do "npm shrinkwrap" without any flags to generate
    the shrinkwrap.

  - grunt watch task is now smart enough to pick up the current app
    we're working on. Doing `grunt server:events` will watch all the
    files in /apps/events and run the test suite only for that app. :)

Doc changes:

  - Defined a new JSDuck tag @seed that allows us to inspect React
    components in real-time in the docs! Every @seed tag you define will
    accept a JSON construct (or a file that contains JSON) and will
    inject that into the rendered component, so you can show off
    different states and usages in the documentation itself.

TEST PLAN
---- ----

  - create a large quiz with a lot of questions and multiple attempts
  - take it a few times, do many things like answering questions,
    tabbing out and back in, flagging/unflagging questions, etc.
  - go to the log view
    + make sure you enable the new permission for your user from the
      "Manage Permissions" page in the SiteAdmin settings
    + verify you see the "View Table" button
    + click it, and verify the table works as expected
  - go back to the Stream View
  - click on a question link
    + in the question page, verify that the answers are rendered in a
      friendly version (e.g, MultipleChoice answers are shown as radio
      buttons, with the student's answer selected)
    + hop to other questions/types and verify the same thing

Change-Id: I0529b08becbf7dead86c959254faab55761db8df
Reviewed-on: https://gerrit.instructure.com/45883
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-12-19 22:11:56 +00:00
James Williams 2c69f3966b remove non-draft-state everything
test plan:
* basic regression test on assignments, discussion topics
 gradebook, and modules (mostly make sure the basic
 index/show/edit views aren't broken)

closes #CNVS-15563

Change-Id: I3411bfb7645b3c4bf8a4663e3e052b4402f899ba
Reviewed-on: https://gerrit.instructure.com/43609
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com>
2014-12-10 17:57:18 +00:00
Ahmad Amireh fd6da9e2f8 Quiz API - "only after last attempt" in show correct answers
Closes CNVS-16905

TEST PLAN
---- ----

  - create a quiz with multiple attempts allowed (>1) and check the
    option to Show Correct Answers
  - use the API to update the new parameter
    "show_correct_answers_last_attempt" with a value of `true`
    + verify the setting is accepted
  - disable multiple attempts
    + if you make the API request again, the setting should be ignored
  - re-enable multiple attempts, but disable "show correct answers"
    + if you make the API request again, the setting should be ignored

...

  - check the Quizzes API docs, the new parameter should be documented
    in both the Quiz Object synopsis and the "Create a quiz" endpoint
    docs

Change-Id: I1a059c07c44cd7905e491996f20ec4fab4f083fc
Reviewed-on: https://gerrit.instructure.com/44676
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Finney <bfinney@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-11-26 18:17:32 +00:00
Ahmad Amireh 7b74b9887d Quiz stats cleanup
Removed a couple of fields we're not using from the API and adjusted the
docs. Also added reminders for things to drop once new stats replaces
the legacy version.

Closes CNVS-16519, CNVS-13387

TEST PLAN
---- ----

  - generate the API docs, `bundle exec rake doc:api`
  - check out the quiz stats docs, it should no longer be marked in beta
  - two fields were dropped from the API: "user_ids" and
    "logged_out_users" in the "submission_statistics" set
  - turn on the new stats feature flag and visit the stats page, verify
    it loads fine

Change-Id: I16603d4f67fc334ebb994ec6e9363bdb94002e64
Reviewed-on: https://gerrit.instructure.com/44674
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Finney <bfinney@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-11-24 18:08:19 +00:00
Ahmad Amireh 26d7cb06c3 Quiz Reports API - force regeneration
Extends the quiz reports API with the ability to re-trigger failed CSV
generation jobs, and to abort them completely. The UI is extended to
utilize those new APIs.

Closes CNVS-16525

TEST PLAN
---- ----

  - create a quiz with a file upload question
  - take the quiz by a student and upload a file, then submit
  - turn on new stats and go to new stats page
  - click the "Student Analysis" report generator button and verify that
    the CSV file is generated and you get prompted to save it

Now... we break the student's submission by removing the attachment and
then the student analysis will start failing to generate.

Launch a rails console and perform the following command:

[ 'Quizzes::QuizSubmission', 'Quizzes::QuizStatistics' ].each do |type|
  Attachment.where({ context_type: type }).last.destroy!
end

  - reload the stats page
    + the "Student Analysis" button should now read that it had never
      been generated, that's right because we just removed the CSV file
      attachment using the console
    + try generating the report again
      - verify that it blows up
    + you should now see a notification as in the screencast
      - clicking the "retry" link should retry generating the report
        (which will fail again)
      - clicking the "cancel" link should remove the notification
      - clicking "Dismiss" should dismiss the notification, but if you
        reload the page, it's still there

Change-Id: I467a9030c3ef94d685ec20b31dd533e530e24758
Reviewed-on: https://gerrit.instructure.com/43862
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-11-12 22:49:38 +00:00
Cody Cutrer 19f44adc18 rspec 3-ify spec/serializers
refs CNVS-16239

Change-Id: Ib2b8647b1da7e2dfb7a742ceaa70f3b12c87deec
Reviewed-on: https://gerrit.instructure.com/42671
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Braden Anderson <braden@instructure.com>
Product-Review: Braden Anderson <braden@instructure.com>
QA-Review: Braden Anderson <braden@instructure.com>
2014-10-14 14:17:16 +00:00
Derek DeVries 152d1c26a7 clean up quizzes specs to pass with draft state on
fixes CNVS-16041

test plan:
  - passes jenkins!

Change-Id: Id8afcac08b4baa5e01de43a6a379165f39ec4206
Reviewed-on: https://gerrit.instructure.com/42253
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Taylor <rtaylor@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
QA-Review: Derek DeVries <ddevries@instructure.com>
2014-10-09 21:50:01 +00:00
Ahmad Amireh 1c03e40aae quiz index optimizations
Closes CNVS-15109, CNVS-15173

CHANGES
-------

  - "auto-grading" of due submissions that was previously done
    synchronously in the index action is now done in a DJ
  - when viewing the index page, you don't get to see due/available
    dates on load, instead the dates are fetched on the client-side and
    load progressively
  - new API endpoint for retrieving assignment overrides for a bunch of
    quizzes at [GET] /courses/:course_id/quizzes/assignment_overrides
  - we now cache the user's quiz permissions
  - Canvas AMS API serializer now accepts a new option, see docs
  - QuizSerializer behavior changed radically:
    - "takeable", "submitted_students", "unsubmitted_students"  disabled
    - all associations disabled including the submission, assignment
      group, and any student participants
    - it can now utilize preloaded permissions

Rationale behind disabling things in the serializer is that these were
exclusive for the "show" action, so the next step forwards is to
allow the serializer to recognize different "modes" for output (e.g, for
index and one for show) and tailor the associations/fields accordingly.
Using "#filter" right now isn't cutting it, because assocs get loaded
anyway.

REFACTORING
-----------

  - broke down index into three actions for visibility:
    1. default, Draft-State version
    2. legacy non-DS version that's not reachable in the UI, kept around
       until we upgrade the tests
    3. ember version
  - legacy non-DS ERB code goes into its own file
  - moved code that used to grade due submissions inside index to
    SubmissionGrader in preparation to remove it from there entirely
  - cleaned up internal docs for the Canvas AMS api serializer

TEST PLAN
---- ----

  - create ~30 quizzes
    + make one of them have many questions
    + make a good number of submissions (i tested with 420 and 20
students)
  - create multiple sections
    + specify date overrides for certain sections, and have at least one
      student enrolled in that section
  - as a teacher and/or an observer, go to quizzes index
    + verify the page renders fine
    + verify that you see "loading indicators" in the due/available
      field which get replaced with actual dates when they're loaded
    + verify it's faster than the version in master (should be at least
      60% faster)
  - as a student in the general section, go to quizzes index
    + verify the page renders
    + verify you see the same loading behavior for dates as in teacher
      view
  - as a student in one of the section with overrides, go to index:
    + verify you see the overridden date

Change-Id: I741d89625da1b858148baa95e881fcc75c1802e5
Reviewed-on: https://gerrit.instructure.com/40350
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-09-05 14:20:38 +00:00
Cameron Sutter 79f45f569d DA - quiz edit page
fixes CNVS-9766

test plan:
 * turn on the Differentiated Assignments feature flag
 * from the quiz edit page
  - add a due date for some of the sections, but not all
  - save (update quiz)
  > the only_visible_to_overrides flag on the quiz should be true
  > edit the quiz again and there should not be an
    empty due date row for 'Everyone else'
  - add a due date for all the sections
  - update the quiz
  > the only_visible_to_overrides flag should not be there
  - edit the quiz so that there are only due dates
    for some sections but not all
 * on the normal quiz show page and
 * on the new Quiz Statistics show page
  > there should not be a row in the due date area
    for 'Everyone else'
 - turn off the DA flag and make sure the quiz show page works
   with the 'New Quiz Stats page' flag and without it
 - make sure the edit page works with the DA flag off as well

Change-Id: Ifb090a195ff3283d963df12ae7a9eb503f32ee86
Reviewed-on: https://gerrit.instructure.com/34085
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Product-Review: Cameron Sutter <csutter@instructure.com>
2014-07-23 14:41:24 +00:00
Cody Cutrer b51d0898cd adheres_to_policy improvements
refs CNVS-11425

 * be more strict about the DSL
 * store policies so that we can avoid linear searches for
   an applicable condition block

Change-Id: I68f6414b396e1cb16d744d0719cdd6aa86085784
Reviewed-on: https://gerrit.instructure.com/36222
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-06-24 15:32:00 +00:00
Ahmad Amireh 4964865302 Quiz Stats - Whitelist exposed question data
Changes:

  - drops unused attributes from the api output, the only things we
    expose now are question id, type, text, and position (for sorting)
  - drops logic in ember that is no longer necessary
  - stringifies IDs in the serializer output

Closes CNVS-13388

TEST PLAN
---- ----

  - BEFORE YOU CHECK THIS OUT:
    - create a quiz with all question types
    - hit the stats API and save the JSON output in some text file
  - now check this patch out:
    - use the same quiz, hit the stats api
    - verify that each question document in "question_statistics" has
      the following fields beside the metrics:
      "id", "question_type", "question_name", and "position"
    - verify that MChoice/TF questions still contain the "item analysis"
      report data (like point_biserials, etc.)
    - check out the ember quiz stats and make sure everything is OK

Note: i found a small tool that can help you see the differences in the
API output if you push the old JSON and the new one into it: try it out
maybe it will make things easier: http://tlrobinson.net/

Note 2: the docs are really out-of-date now and need to be adjusted.
There is CNVS-13387 for that.

Change-Id: I2d2e8c4dcb0e406378b50cd63f5aba14efe8c2ef
Reviewed-on: https://gerrit.instructure.com/35739
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-06-05 09:12:33 +00:00
Jason Madsen c66ab5ce78 fix quiz moderate refresh with no submissions
closes CNVS-13241

fix error where quiz moderate refresh button fails when no existing quiz
submissions listed.

test plan:
  - create and publish a quiz
  - don't have any submissions on it
  - visit quiz moderate as instructor
  - hit the refresh icon in top right of moderate table
    - no errors should happen
  - as student, take and submit quiz
  - as instructor hit the refresh icon once quiz is submitted
    - student row in table should be updated

Change-Id: Ifeb97a4b4094ea50ec38c529c721aa5f7467b693
Reviewed-on: https://gerrit.instructure.com/35342
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-05-22 22:47:53 +00:00
Stanley Stuart 5712fbe5cb add a preview quiz button to ember quizzes page
Test plan:
  - As a teacher, you should be able to preview a quiz on fabulous
    quizzes.

closes CNVS-12442

Change-Id: Iec3aa3735b47e4b71d3a92d7f0b479bc3bd3c475
Reviewed-on: https://gerrit.instructure.com/35206
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2014-05-22 22:05:25 +00:00
Derek DeVries efa361db59 add student extension dialogs on new ember quiz moderate page
fixes CNVS-12449

test plan:
  - as a teacher
  - enable fabulous quizzes
  - enroll a few students in the course

  - there is a new quizzes api attribute called 'quiz_extensions_url'
  - check out the jsonapi quizzes api to make sure this attribute only shows
    up for teachers (and not students)

  - create a quiz with no time limit and unlimited attempts
    - visit the quiz moderate page
    - click the "edit" icon for a student
    - the modal dialog should only allow you to "manually unlock"

  - create a quiz with a time limit
    - visit the quiz moderate page
    - click the "edit" icon for a student
    - the modal dialog should only allow you to "manually unlock"
    - the modal dialog should only allow you to add "extra time"

  - create a quiz with a limited number of attempts (1 or more)
    - visit the quiz moderate page
    - click the "edit" icon for a student
    - the modal dialog should only allow you to "manually unlock"
    - the modal dialog should only allow you to add "extra attempts"

  - create a quiz with both a time limit and a limited number of attempts
    - visit the quiz moderate page
    - click the "edit" icon for a student
    - the modal dialog should only allow you to "manually unlock"
    - the modal dialog should only allow you to add "extra attempts"
    - the modal dialog should only allow you to add "extra time"
    - change the settings for extra attempts, extra time, and manually unlock
    - hit submit
    - it should save these new settings if you reopen the dialog
    - it should show the extra minutes allowed on the attempt under the username
    - it should add the extra attempts to the 'attempts left' column value

Change-Id: I0e10942ff7a3a80cec200468216ba0641decee2c
Reviewed-on: https://gerrit.instructure.com/35089
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-05-22 19:45:34 +00:00
Ahmad Amireh 076e541cdb Ember Quiz Stats - File Upload & Formula
Render question statistics for those question types similar to Essay.
File Upload should include a link to download all submissions too.

QuizSerializer was updated to include the submission ZIP download URL.

Closes CNVS-12988

TEST PLAN
---- ----

  - using your data set from https://gerrit.instructure.com/#/c/35112/
    - verify that the score chart renders with the student scores
    - verify that you get a link to Download All Files for FUpload
      questions
    - verify that the "Attempts: x out of Y" reads correctly based on
      the "responses" field and the total participant count,
      respectively
    - tooltips and chart interactivity like that for Essay

Change-Id: I4a77631491b169106e2eb677b21c1f30f3ca9440
Reviewed-on: https://gerrit.instructure.com/35113
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-05-22 15:56:45 +00:00
Derek DeVries 1343e2379c add api for quiz submission extensions
quiz submissions can have their time limit or number of attempts extended.
we can extend both existing quiz submissions, and also those that don't exist
yet. adding this functionality to the existing quiz submissions api would
muddle up responsibilities. So instead we post all extensions to a the
quiz extensions api which is specifically meant for adding extensions to a
submission whether it has been started yet or not.

Also add 'manually_unlocked' to the quiz submissions api. this field lets us
know if a student can take a quiz after it has been locked for everyone else.

fixes CNVS-13165

test plan
  - There is a new attribute added to quiz_submissions objects in the api
    called 'manually_unlocked'. This attribute will now show up when returning
    results back from
    - GET /api/v1/courses/:course_id/quizzes/:quiz_id/submissions (index)
    - GET /api/v1/courses/:course_id/quizzes/:quiz_id/submissions/:id (show)

  - There is a new endpoint to create quiz extensions. This should work to
    create quiz extensions for users that both have existing quiz submissions
    started, and users who have not yet started a quiz:
    - POST /api/v1/courses/:course_id/quizzes/:quiz_id/extensions (create)
  - Check Permissions on the new quiz extension endpoint. Only teachers should
    be able to extend the quizzes.
  - Check that all the documentation looks okay for quiz extensions.

Change-Id: Ie23113c1f30e139a1e376475fb35a2cf3ce0212c
Reviewed-on: https://gerrit.instructure.com/35111
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-05-21 21:30:15 +00:00
Stanley Stuart e115ae8ad8 ember quizzes: take quiz button
Adds the "Take Quiz" button from the old quiz show page to ember
quizzes.

Test Plan:
  - As a teacher
    - You should pretty much always be able to take the quiz if it is
      published.
    - You should not see the Take Quiz button if the quiz is not
      published.
  - As a student:
    - You should be able to see the Take Quiz button only if the quiz
      is published.
    - You should be able to see the Take Quiz button if you have not
      taken the quiz.
    - You should be able to see the Take Quiz button if you have
      completed the quiz and you have enough remaining attempts left.
      If you have 0 attempts left on a quiz, you should not see the button.
    - If the quiz has unlimited attempts, you should always be able to
      see the Take Quiz button. It should say "Resume the Quiz/Survey"
      if you are in the process of taking the quiz.

fixes CNVS-12436

Change-Id: Ib6c3d2aa2637563a84bc6be4ae12561205c7ed2b
Reviewed-on: https://gerrit.instructure.com/34944
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2014-05-20 23:56:09 +00:00
Jon Jensen e7582b1a40 spec: slight global speedup
change how we default to UTC for tests. this way we:
1. don't create Account.default if a given spec doesn't need it
   (explicitly or otherwise)
2. don't do an unnecessary Account#update_attributes before every spec

test plan:
specs, duh

Change-Id: Icd425b0e2b27bbfa6c95b713ae69c5fa36e14c14
Reviewed-on: https://gerrit.instructure.com/35069
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2014-05-19 22:12:09 +00:00
Stanley Stuart 52217621a7 move quiz_submissions to student_quiz_submissions
test plan:
  - Query the quizzes api using JSONAPI header.
  - You should not see "student_quiz_submissions" if you are a student,
    but should if you are a teacher.
  - You should see "quiz_submission" with the id of your quiz submission
    if you have one, otherwise it should be null.
  - Ember quizzes show should still work

closes CNVS-13031

Change-Id: I5935af55ad09cf04d2bd76ee5b40b2d252b1675d
Reviewed-on: https://gerrit.instructure.com/34722
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2014-05-19 19:40:18 +00:00
Liz Abinante e04a49235e AssignmentOverrides refactor
fixes CNVS-10793
fixes CNVS-12360

test plan
=========
- assignment overrides should still work
- general regression of assignment#new, #edit, quizzes#new, #edit, discussions#new, #edit
- check API end points for above overrides

Change-Id: I211ad888ac14d7e863ab67bfcb27d56a85e62aac
Reviewed-on: https://gerrit.instructure.com/29980
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Liz Abinante <labinante@instructure.com>
2014-05-16 21:12:45 +00:00
Derek DeVries 0ecec1a16c don't show the 'everyone' assignment date if all sections have overrides
fixes CNVS-13002

test plan:
  - as a teacher
    - create a quiz with assignment overrides for every section
    - enable fabulous quizzes
    - visit the quiz
    - make sure that it doesn't show an extra date for "Everyone"

  - as a teacher
    - check the courses/{id}/quizzes/{id} jsonapi end point
    - there should be a new 'section_count' attribute

  - as a student
    - check the courses/{id}/quizzes/{id} jsonapi end point
    - there should *NOT* be a 'section_count' attribute

Change-Id: I1cf33be890c76df07d73cfa278dcbc550abf1090
Reviewed-on: https://gerrit.instructure.com/34791
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>
2014-05-13 19:41:33 +00:00
Stanley Stuart b6cbbdc0cd add a private API endpoint for getting quiz submission HTML
Test plan:
  - As a teacher and student, the quiz show page should show the quiz
    show page as usual with submission results at the bottom.

closes CNVS-12452

Change-Id: I5844c9594a769dd1d5204db9a7e841e23b789382
Reviewed-on: https://gerrit.instructure.com/33509
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2014-04-18 22:13:52 +00:00
Stanley Stuart 94f3b1bd15 add submitted/unsubmitted quiz users endpoint to quizzes api
Test plan:
  - As a teacher, create a quiz.
  - Visit the quizzes API using JSONAPI headers. For that quiz,
    "submitted_students" should be null. You should get a URL back to
    the "unsubmitted_students" endpoint, which you can query and find
    the unsubmitted students.
  - As a student submit the quiz. As a different student, don't submit
    the quiz.
  - As a teacher, visit the quiz show endpoint for that quiz again. You
    should have "submitted_students" and "unsubmitted_students" under
    the "links" hash. Query these APIs using those URLs. The students
    returned from the link that looks like "?submitted=true"
  - As a student, you should not see "submitted_students" or
   "unsubmitted_students" under the "links" hash when querying
   the show API in JSONAPI format
  - In non-jsonapi format as any user, you should not see
   "unsubmitted_students" or "submitted_students"

closes CNVS-11687

Change-Id: I7094dfc37b0dde501e5a2c1f12ade983cd2a150a
Reviewed-on: https://gerrit.instructure.com/31223
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-04-18 21:04:23 +00:00
Ahmad Amireh ad2cf2b43e QuizStatistics API
Closes CNVS-8989

CHANGES
-------

  - ItemAnalysis can now be generated to a Hash as well as CSV

TEST PLAN
---- ----

  - create a quiz with a number of questions (true/false and
    multiple-choice a must-have)
  - take the quiz by 2-3 students
  - perform an API request as described below and verify that you get a
    statistics object that matches the API docs
  - do it once in legacy JSON format, e.g:
    "Accept: application/json"
  - do it once in JSON-API format, e.g:
    "Accept: application/vnd.api+json"
  - read the API docs and report any mistakes or stuff that's not clear,
    the stuff is written in the QuizStatistics module

Endpoint: [GET] /api/v1/courses/:course_id/quizzes/:quiz_id/statistics

Change-Id: I1588e1cdc8955b890c739df4c730507dad7118d1
Reviewed-on: https://gerrit.instructure.com/31141
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-04-16 15:01:24 +00:00
Ahmad Amireh e95305fb7c Quiz Reports API - Index
An endpoint for retrieving all quiz reports for a given quiz.

Closes CNVS-12172

CHANGES
-------

The biggest effort in this patch was to normalize the way QuizReport
objects are interfaced with, and the generation of their CSV attachments
in particular:

  - Quiz#current_statistics_for() now ALWAYS returns a persisted object
    while still considering the freshness of the stats
  - Quiz#statistics_csv() is no longer responsible for testing whether
    the attachment should be generated or not, but instead ensures
    that the CSV will be generated ASAP
  - QuizStatistics#generate_csv() now guards against generating multiple
    attachments
  - QuizStatistics#generate_csv_in_background() now guards against
    queueing multiple generation jobs (by testing the status of the
    Progress object)

QuizReport API changes:

  - new property: "generatable"
  - new property: "readable_type"
  - new property: "url"
  - now accepts JSON-API format for all endpoints:
    - JSON-API allows you to embed file and progress objects directly in
      the QuizReport document, just pass ?include=file,progress

Quizzes API changes:

  - new property (JSON): "quiz_reports_url"
  - new property (JSON-API): "links.quiz_reports"

Some AMS changes:

  - added support for accepting side-loading requests from controllers
    by passing an :includes array to the serializer initializer
  - added support for embedding objects in root, using `embed: :object
    and embed_in_root: true` for has_one associations
  - also, in that same scenario, AMS's default behavior is to wrap
    single objects (has_one) in an array, which didn't work for me, so I
    added a new option called "wrap_in_array" which you can set to false
    when defining the association to override this behavior

Other changes:

  - covered the front-end/javascript that utilizes the reports and
    allows teachers to generate them
  - QuizReport in the front-end no longer relies on magical course_id
    exposed in window.ENV, but instead uses its URL to construct the
    generation URL (see QuizReport#baseURL)
  - Attachment now has a shallow-AMSerializer that proxies to the legacy
    one in lib/api/v1 which allows us to at least side-load them
  - Progress now has an AMS
  - QuizReport legacy serializer in lib/api/v1 removed entirely,
    replaced by the new AMS one

TEST PLAN
---- ----

Endpoint: [GET] /api/v1/courses/:course_id/quizzes/:quiz_id/reports

  - as a teacher, make a request to the endpoint above:
    - it should return a set of two quiz report objects
  - add a parameter "includes_all_versions=true" to the query parameters
    and verify that the "student_analysis" report in the returned set
    now reflects the new value (the reports have a field called
    "includes_all_versions" which should be true in this case, false
    otherwise)
  - as a student, make the request and verify that it rejects you

Endpoint: [GET] /api/v1/courses/:course_id/quizzes/:quiz_id/reports/:id

  - turn on JSON-API mode
  - as a teacher:
    - don't generate the report from the UI yet
    - make the request, and verify that you get only the report
    - generate
    - repeat the request, verify that you still get only the report
    - add a ?include=file query parameter
      - you should read the file document now
    - add a ?include=progress query parameter
      - you should read the progress document now
  - turn off JSON-API mode
  - as a teacher:
    - make the request, and verify you get the "progress_url" field and
      that the file document is embedded automatically without having to
      specify the ?include= parameter

Front-end testing:

  - go to the statistics page
  - generate all reports:
    - verify that the progress bar updates
    - verify that you can download them
    - verify that auto-download occurs unless you refresh the page
      before the report is generated
  - toggle on the "Count All Attempts" button and repeat the above:
    - verify that Item Analysis is not generatable anymore since it's
      not affected by that parameter

Please note that "item_analysis" reports will always have
"includes_all_versions" as true.

Change-Id: I0dc6d5108cbcef78b2fa17ba0476f470d33d402d
Reviewed-on: https://gerrit.instructure.com/32731
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-04-15 19:22:02 +00:00
Stanley Stuart a7213e5c76 restore quiz submission loading in quiz serializer
This reverts changes from 8018ce8374.

Instead of using `present?` on has_many associations for
Canvas::APISerializer, use `empty?` so that we don't overload the
database or app memory with large queries for big data sets.

Test Plan:
  - Create a quiz.
  - In your console, run:
    quiz = Quizzes::Quiz.find(your_quiz_id)
    10_000.times { quiz.quiz_submissions.create! }
  - Get a cup or two of coffee and wait for that to finish.
  - You should be able to load the quiz show page for that quiz.
  - Making an API for that request as the teacher should not time out.

closes CNVS-12098

Change-Id: Ib14bc30583f521bd91a3de115218a33fb3bd73c4
Reviewed-on: https://gerrit.instructure.com/32553
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
2014-03-31 17:45:06 +00:00