Commit Graph

126 Commits

Author SHA1 Message Date
Duane Johnson 21de3036c0 remove 'the' from API doc generated nicknames
Auto-generated method names sometimes have 'the' in them. Remove 'the' to be consistent with the removal of articles 'a' and 'an'.

Test Plan:
- The following APIs should no longer have "the" in their
  nicknames (autogenerated JSON files):

  Accounts API:
    get_the_sub_accounts_of_account
    change_the_domains_for_account

  Assignments API:
    redirect_to_the_assignment_override_for_group
    redirect_to_the_assignment_override_for_section

  Discussion Topics API:
    get_the_full_topic_courses
    get_the_full_topic_groups
    get_the_full_topic_collection_items

  Groups API:
    list_the_groups_available_in_context_accounts
    list_the_groups_available_in_context_courses

  Quiz Statistics API:
    fetching_the_latest_quiz_statistics
    create_the_quiz_submission_start_quiz_taking_session
    complete_the_quiz_submission_turn_it_in

  Users API:
    list_the_activity_stream_self
    list_the_activity_stream_activity_stream
    list_the_todo_items

Fixes SIS-312

Change-Id: I6de521305605fe75b399889563f6d0b290cdf468
Reviewed-on: https://gerrit.instructure.com/35917
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ken Romney <kromney@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Eric Adams <eadams@instructure.com>
2014-06-06 21:34:48 +00:00
Ahmad Amireh cc1f4688fc Quiz Stats - Multiple Answers
Ports the generation of stats for that question type to the CQS gem.

Changes:

  - no longer exposing "user_ids"
  - can now identify students who skipped the question

Closes CNVS-13089

TEST PLAN
---- ----

  - create a quiz with multiple-answer question(s)
  - take it by a number of students and cover the following cases:
    - answer correctly by picking only the right choices
    - answer almost correctly by:
      1. picking only 1 right choice
      2. picking 1 right and 1 wrong choices
      3. picking everything
    - answer incorrectly by picking only the incorrect choice(s)
    - don't answer at all
  - get the stats from the API:
    - for "responses", "correct", and "partially_correct", verify they
      meet the specification in the docs
      - also for the "responses" field in each document in "answers"
    - verify that there is an answer document with "none" for an id with
      "responses" that reflect the number of students that skipped the
      question
  - visit ember quiz stats:
    - verify the "Attempts: X out of Y" should read the "responses"
      field out of the total quiz participant count
    - verify the donut chart reads the correct "correct" response ratio
    - verify there is a "No-Answer" bar
    - expand the question details:
      - verify that all the choices are displayed, and the correct
        choices are highlighted in GREEEN

Change-Id: Ibc08b6f521f9cae35dd16950c68c164d7e27d95d
Reviewed-on: https://gerrit.instructure.com/35736
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-06-05 09:12:19 +00:00
Ahmad Amireh 625f60ce97 Quiz Stats - Short Answer
Closes CNVS-13386

TEST PLAN
---- ----

  - similar to multiple-choice in https://gerrit.instructure.com/35734
    but with this question type with a few minor differences:
    - "correct" metric, see docs
    - "other"/"unknown" answer should be generated only if any student
      writes an answer that is not correct

Change-Id: I2d56afc0d9c1a3620d4de96059ebdadc56baecf9
Reviewed-on: https://gerrit.instructure.com/35735
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-06-05 09:12:07 +00:00
Ahmad Amireh 4503abaabf Quiz Stats - Multiple Choice & True/False
Changes:

  - no longer exposing user_ids
  - no longer exposing response_values
  - new metric: "responses" at the root-level

Closes CNVS-13385

TEST PLAN
---- ----

  - create a quiz with those question types
  - take the quiz by a number of students, choose different answers
  - get the stats from the API:
    [GET] /api/v1/courses/:course_id/quizzes/:quiz_id/statistics
    - verify you get the documented metrics and they have the proper
      values
  - verify the relevant sections in ember quiz stats is still functional

Change-Id: I470912060042405629812585ef6667693b1302a1
Reviewed-on: https://gerrit.instructure.com/35734
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-06-05 00:10:40 +00:00
Duane Johnson dfc3758aa9 remove asterisks from API doc generated methods
Method names generated for swagger could include asterisks, and
this would cause syntactically incorrect Ruby code to be generated
in Pandarus as a result.

Test Plan:
- method names generated by "rake api:doc" should not include "*",
  e.g. "resolve_path_courses_full_path" used to have be called
  "resolve_path_courses_*full_path" and should no longer be so.

Fixes SIS-307

Change-Id: I0c618bb9f1589721675766c4d307ff21c816c2fc
Reviewed-on: https://gerrit.instructure.com/35792
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Eric Adams <eadams@instructure.com>
Product-Review: Eric Adams <eadams@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
2014-06-04 20:07:45 +00:00
Ahmad Amireh 741a6e0036 Ember Quiz Stats [+Backend] - Numerical
Adds numerical question support to CanvasQuizStatistics and the renderer
in the Ember quiz statistics (subclass of ShortAnswer question).

Closes CNVS-13087, CNVS-13086

TEST PLAN
---- ----

  - create a quiz with a numerical question:
    - mix and match between the answer types: exact, exact with margin,
      and range answers
  - take the quiz by a number of students, we need to score like this to
    cover the possible cases:
    - a correct answer
    - a missing answer
    - an incorrect/out-of-range answer
  - hitting the stats api should return the documented metrics in the
    output of "question_statistics":
    /api/v1/courses/:course_id/quizzes/:quiz_id/statistics [GET]
  - visiting ember quizzes should now render the numerical stats which
    is similar to short answer (fill in the blank) and multiple answers:
    - make sure the "Other" and "No Answer" answers and bars show up
  - verify the API docs are updated

Change-Id: I0c9ec0dbc7c729410241177b6ed43b0cd4dad143
Reviewed-on: https://gerrit.instructure.com/35431
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-27 22:16:58 +00:00
Ahmad Amireh 33e6711c9a Quiz Stats - Matching
Adds support for Matching question statistics. Similar to FIMB and
Mulitple Dropdowns in the output.

Closes CNVS-13088

TEST PLAN
---- ----

Similar to https://gerrit.instructure.com/#/c/35101/ but with Matching
questions instead of FIMB.

Change-Id: Iaa5da1631503a8750b9673d7cb6064a296a8aa55
Reviewed-on: https://gerrit.instructure.com/35331
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-05-27 16:39:05 +00:00
Eric Adams b2e4471709 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>
2014-05-22 23:49:05 +00:00
Eric Adams 28eb7d9e60 swagger-ui redesign
fixes SIS-273

Change-Id: Ia19b08580f83002c90ebdce22ba55775c35a69a5
Reviewed-on: https://gerrit.instructure.com/34683
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Duane Johnson <duane@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
2014-05-22 21:41:13 +00:00
Ahmad Amireh ddcffe00ef Quiz Stats - File Upload & Formula
Add support for generating stats for File Upload and Formula questions.
Similar to Essay metrics but adjusted to calculate properly.

Closes CNVS-13169

TEST PLAN
---- ----

  - create a quiz with those question types
  - take the quiz:
    - answer both question types by at least one student, but leave it
      unanswered by another so we can test the "responses" metric
  - test the stats:
    GET /api/v1/courses/:course_id/quizzes/:quiz_id/statistics
    - the "responses" metric should count the number of students who
      provided an answer
    - the "graded" metric should read the number of students whose
      answers you've graded so far
    - the "full_credit" one should read 0 until you grade it and give
      them a score higher than, or equal to, the maximum points possible
    - "point_distribution" is similar to that of Essays; it is an array
      of objects that track every score you gave the students and the
      number of students who received those scores
  - grade the scores and re-test to verify the metrics update correctly
  - verify that the API documentation is updated to include those
    question types

PS: the "responses" field will read "the number of students who uploaded
a file" for File Upload, and "the number of students who wrote any
answer" for Formula.

Change-Id: I890eafe018e000eef88de782bd7e86b5259df5d5
Reviewed-on: https://gerrit.instructure.com/35112
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:29 +00:00
Ahmad Amireh 32801bd45d Quiz Stats - Multiple Dropdowns
Closes CNVS-13161

TEST PLAN
---- ----
  - create a quiz with multiple-dropdown questions
  - take the quiz by a number of students and type in different answers
  - make an API request to stats:
    GET /api/v1/courses/:course_id/quizzes/:quiz_id/statistics
    - verify you get the documented metrics and they have the proper
      values
  - visit the ember quizzes page and verify that:
    - the charts are still working

Change-Id: I37ef48f22c3c16170034b6dd887b40ff20da4af5
Reviewed-on: https://gerrit.instructure.com/35104
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-05-21 16:37:11 +00:00
Ahmad Amireh 2e00d94732 Quiz Stats - FIMB
Support for FIMB question statistics in the CanvasQuizStatistics gem.

Closes CNVS-13160

TEST PLAN
---- ----

  - create a quiz with FIMB questions
  - take the quiz by a number of students and type in different answers
  - make an API request to stats:
    GET /api/v1/courses/:course_id/quizzes/:quiz_id/statistics
    - verify you get the documented metrics and they have the proper
      values
  - visit the ember quizzes page and verify that:
    - the charts are still working

Change-Id: I2d82c708614c41e222aa24d65de64555d8056a9a
Reviewed-on: https://gerrit.instructure.com/35101
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-05-21 16:36:58 +00:00
Cody Cutrer 4777aac2df Merge pull request #445 from sfu/feature-sis-user-names
Add full & sortable name fields to SIS User Import

Change-Id: Ib8617572802ca69913b422d22301299ab75c211f
Reviewed-on: https://gerrit.instructure.com/34548
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-05-13 14:26:23 -06:00
Cody Cutrer c6090faa0a allow enrolling users via sis from another root account
fixes CNVS-12963

test plan:
 * set up a trust from account A to account B
 * enable sis imports for account A and account B
 * add a user to account B with an SIS ID
 * add a course to account A with an SIS ID
 * do an sis import to account A for enrollments as user
   that is an admin in both account A and account B;
   specify the course from account A as the target,
   the user from account B, and add another column
   root_account with account B's domain
 * it should succeed, and enroll the user from account B
 * unenroll the user manually
 * do the import as a user that's an admin in account A,
   but not account B - it should fail citing permissions
 * remove the trust link from A to B
 * do the import as the user that's an admin in both;
   it should fail citing no usable login

Change-Id: Ie5b7b71bfe563da9c49d3aa2321586994634ccb5
Reviewed-on: https://gerrit.instructure.com/32133
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-05-13 17:19:48 +00:00
Ahmad Amireh 555e7b0e18 Quiz Stats [Backend] - Gem & Essays
Refactoring the generation of quiz question statistics into its own gem.
This patch adds support for Essay question statistics.

Closes CNVS-12725

TEST PLAN
---- ----

  - create a quiz with an essay question
  - perform an API request to retrieve the quiz statistics
  - ensure that the following metrics are generated and correct:
    - "graded": number of students whose answers have been graded by the
      teacher
    - "full_credit": number of students who received a full score
    - "point_distribution": a list of scores and the number of students
      who received them (so if 2 students got graded for 3 points, it
      should have a key of 2 and a value of 3), un-graded submissions
      should be keyed under null
    - "responses": number of students who answered the question
      (wrote anything)
    - "user_ids": IDs of those students
  - documentation for QuizStatistics -> Essay should be updated with the
    new stats

> Other things to test

  - verify that the old statistics page still renders:
    /courses/:course_id/quizzes/:quiz_id/statistics
  - verify that you can still generate both student and item analysis
    CSV reports

API endpoint for quiz stats:

  /api/v1/courses/:courseid/quizzes/:quiz_id/statistics [GET]

Change-Id: Ib15434ff4cef89ac211c1f4602d1ee609ef48ec4
Reviewed-on: https://gerrit.instructure.com/33990
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-05-12 15:02:45 +00:00
Andrew Leung ab78550748 Add full & sortable name fields to SIS User Import
Both fields are optional. If absent, the user's name and sortable_name
will be set in the same manner as before.

The full_name field takes precedence over first_name and last_name. The
sortable_name field takes precedence over the inferred value.
2014-05-02 14:09:26 -07:00
Cody Cutrer 9b703545fb Merge pull request #438 from sfu/feature-sis-user-short_name
Add display name field to SIS User Import
2014-04-25 16:48:13 -06:00
Eric Adams a363981fd4 init base for swagger-ui canvas-api docs
fixes SIS-181
fixes SIS-188

Change-Id: I7375376e832abbbea1240323874c624eb8dd40e0
Reviewed-on: https://gerrit.instructure.com/30668
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Eric Adams <eadams@instructure.com>
Reviewed-by: Duane Johnson <duane@instructure.com>
2014-04-25 15:49:02 +00:00
Duane Johnson 85e9fb5fb5 Fix CalendarEvent API docs
API docs must reference doc models in the same file, otherwise
they will be ignored by swagger codegen.

Test Plan:
- CalendarLink doc model should move from Calendar API doc page
  to Course API doc page.
- Calendar API doc page should show that CalendarEvent is returned
  by the get and list API calls.

Fixes SIS-247

Change-Id: Ic25e46462958388932b941dbaf8102258c1b1fb3
Reviewed-on: https://gerrit.instructure.com/33786
Reviewed-by: Eric Adams <eadams@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
2014-04-25 15:47:37 +00:00
Andrew Leung 7c229153b0 Update CSV documentation to include short_name 2014-04-24 14:03:51 -07: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
Michael Ziwisky 7e45a710b9 add option to force re-login for oauth, fixes CAT-68
test plan:
- login to canvas
- do an oauth login from an external app, or with a manual GET request
  according to Step 1 of the "Web Application Flow" at
  https://canvas.instructure.com/doc/api/file.oauth.html,
  and make sure you include the query param force_login=1
- verify that canvas sends you to /login
- verify that without the param force_login=1, canvas still sends you
  directly to /login/oauth2/confirm

Change-Id: I49cd43cc48edf46f192221f5cf8707ee00e0bd8a
Reviewed-on: https://gerrit.instructure.com/32988
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeff Belser <jbelser@instructure.com>
Reviewed-by: Nick Houle <nhoule@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Marc LeGendre <marc@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
2014-04-09 23:00:54 +00:00
Michael Ziwisky 1ae3c0fe4f add option to logout on oauth token deletion, fixes CAT-67
test plan:
- do an oauth login, perhaps by using some external app, or by following
  the guide at https://canvas.instructure.com/doc/api/file.oauth.html
- end the oauth session with param expire_sessions=1, i.e.
    DELETE <canvas>/login/oauth2/token?expire_sessions=1
- do another oauth login, and notice that you're asked for your
  credentials.  i.e., your canvas session was destroyed.  that's a good
  thing.

Change-Id: I765d8f62dfcd133bc652b484c26c7bb1fc86e24a
Reviewed-on: https://gerrit.instructure.com/32866
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Marc LeGendre <marc@instructure.com>
QA-Review: Marc LeGendre <marc@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-04-07 19:33:09 +00:00
Phil McGachey e57aa50832 Remove duplicate nicknames in generated Swagger documentation
As outlined in Issue 398, the current Swagger documentation constains
a handful of instances where multiple API operations have the same
nicknames. This occurs when multiple routes with the same third path
segment resolve to a single method.

This change fixes the issue by calculating a unique nickname for each
route, and ensuring that duplicate routes are only documented once.

Change-Id: I95a95880378fe5c5b6bf988ac484aef3bec41ee5
Reviewed-on: https://gerrit.instructure.com/32230
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Reviewed-by: Duane Johnson <duane@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
2014-04-03 20:12:14 +00:00
Ahmad Amireh 8d7a11e132 Update API docs to include namespaced Quizzes
Closes CNVS-12019

Test plan:

  - generate the API docs using `bundle exec rake doc:api`
  - verify that all the quiz APIs are included in the docs
  - verify that the appendices are functional (in the QuizSubmissions
    API for example)

Change-Id: I80c6a10c13777d0b88fe96a8114f25b9a2a6f007
Reviewed-on: https://gerrit.instructure.com/32490
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Derek DeVries <ddevries@instructure.com>
2014-03-28 18:35:29 +00:00
Cody Cutrer ed11cc48c0 fix formatting of special ids in api docs
Change-Id: I49499d4dadde3d83ed7b545317723ebad1eae6fd
Reviewed-on: https://gerrit.instructure.com/30101
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2014-02-13 19:39:38 +00:00
Cody Cutrer cd3b797d58 support special api ids for terms
also, document all special ids

Change-Id: Ife484c02343f8b109eecb3e3b2b4a408f48895b3
Reviewed-on: https://gerrit.instructure.com/30008
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-02-12 22:10:03 +00:00
Rob Orton 0e5480c023 converting @object notation to @model part 11/11
converting for:
tabs controller
wiki pages controller

Contributed by github.com/mcgachey

Fixes SIS-146

Currently, some API objects are documented using the @object tag, and
others are documented using @model. The @model tag is preferred because
it provides more information in the machine-readable Swagger documents
generated by the API documentation build step. For example, the @object
notation does not give a way to specify that a model property contains
an instance of another type. This complete information is necessary in
order to build an SDK generator.

This change converts the @object notations into @model, adding missing
type information and correcting inaccurate data (for example, dates were
typed as "string" in the existing JSON documentation). Embedded types are
also separated out so that their format can also be documented - this
information was previously lost.

The change also makes two minor fixes to the HTML and JSON documentation
generators. The HTML generator is fixed so that a missing documentation
string is ignored rather than being shown as an empty comment, and the
JSON generator is modified so that the Model-level documentation and
required attributes are properly provided.

Note that the JSON generated here is not fully-complient to the Swagger
format. Swagger does not support a Map structure, but the Canvas API
uses (semi-)arbitrary key/value dictionaries in a few places. In those
instances the properties are typed as "map", but this is not a part of the
Swagger spec. Any cleaner alternative approaches here would be welcome.

Change-Id: I465e20b9ba04e02de554db09050a4efce6c0d6c2
Reviewed-on: https://gerrit.instructure.com/30005
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2014-02-12 15:55:10 +00:00
Ahmad Amireh 20a3562779 Quiz Submission Questions API - Update
This patch provides support for answering Quiz Questions via the API.

closes CNVS-9844, CNVS-10225

TEST PLAN
---- ----

Testing this will be a bit rough because there are many variations and
validations to cover. I'll spare the validations that are covered by
specs from the test plan.

Create a quiz with a question of *each* type except "Text" and "File
Upload". There's a script that creates a quiz with its questions
automatically for you if you don't want to keep doing this manually. See
references.

> Answering Questions

Now you need to answer each question via the API. Most of them vary in
formats, but they are fully specified in the API documentation page
(along with examples). See DOCUMENTATION for more info.

> Flagging Questions

Flagging, and unflagging, a question is the same regardless of its type,
see the "EXAMPLE REQUESTS" section.

> Access Validations

Here are some generic, non-question based validations to verify. You
should NOT be able to answer a question if:

  - the quiz submission has been turned in
  - the quiz submission is overdue
  - the Access Code for the quiz is invalid
  - the IP filter of the Quiz prohibits you from taking the quiz
  - the quiz submission :validation_token is incorrectly specified (ie,
    other students shouldn't be able to answer your questions)
  - you don't specify the latest :attempt, so if the Quiz has multiple
    attempts, and this is your 2nd take, you specify an :attempt of 1,
    3, or anything but 2 should fail
  - NEW: turn quiz into an OQAAT quiz with the "Can't go back" flag on;
    the API should not reject all requests to modify any of the
    questions with a 501 error saying that type of quizzes is not
    supported yet (support will come in CNVS-10224)

> Grading

Also, when you're done answering the questions, take a look at the
grades and make sure everything gets graded just like it does when using
the UI directly.

> Verifying results in the browser

While taking a quiz in the canvas UI, the scripts perform backups in the
background that would overwrite any changes you do via the API. If you
want to verify the changes you make via the API from the UI, you must
append "?backup=false" to the take quiz page URL, something like this:

http://localhost:3000/courses/1/quizzes/1/take?backup=false

Setting that flag will (for now) disable the backup behaviour and should
make things tick.

EXAMPLE REQUESTS
------- --------

Don't forget to set the 'Content-Type' header to 'application/json'!

> Answering a Multiple-Choice question

[PUT] /api/v1/quiz_submissions/:quiz_submission_id/questions/:id

{
  "attempt": 1,
  "validation_token": "1babd0...",
  "answer": 10
}

> Flagging a question

[PUT] /api/v1/quiz_submissions/:quiz_submission_id/questions/:id/flag

{
  "attempt": 1,
  "validation_token": "1babd0..."
}

> Unflagging a question

[PUT] /api/v1/quiz_submissions/:quiz_submission_id/questions/:id/unflag

{
  "attempt": 1,
  "validation_token": "1babd0..."
}

DOCUMENTATION
-------------

Run `bundle exec rake doc:api` and check out the Quiz Submission
Questions page. There's an Appendix that contains example requests for
each question type, as well as the errors produced by each handler.

LINKS
-----

  - bootstrap script:
    https://gist.github.com/amireh/e7e8f835ffbf1d053e4c
  - direct link to the API documentation page:
    http://canvas.docs.kodoware.com/quiz_submission_questions.html

Change-Id: I9a958323ece8854bc21a24c2affd8dc3972e46d5
Reviewed-on: https://gerrit.instructure.com/27206
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-01-23 17:49:36 +00:00
Ahmad Amireh 34e58a7354 Quiz Submissions API - Update
This patch ports the ability for teachers to manually grade questions
and add comments on student answers in a quiz submission.

fixes CNVS-8981

TEST PLAN
---- ----

Create a quiz with like two questions, take it as a student and turn it
in.

Endpoint: [PUT]
/api/v1/courses/:course_id/quizzes/:quiz_id/submissions/:id

  1. Modify fudge points (Appendix A) with values like -2.5, 2.5 and:
    a. verify that the score gets adjusted by the fudge amount
    b. verify that the returned "fudge_points" in the output is adjusted
  2. Modify a question score (Appendix B) and:
    a. verify that the total score is adjusted by the correct amount
    b. verify that no other question scores were affected
    c. verify that no comments were affected
  3. Modify a question comment (Appendix C) and:
    a. verify that the total score is not affected
    b. verify that no comments were affected

Tip: to verify stuff like single question scores and comments, just go
to the quiz history page in the web UI and keep refreshing after
sending API requests.

Tip: to get a list of all the question ids, perform a GET request to:
  /api/v1/courses/:course_id/quizzes/:quiz_id/questions

Validations that should hold:

  1. [403] if you're not a teacher
  2. [400] if you specify an invalid attempt
  3. [400] if you specify an attempt that is in progress (not turned in)
  4. [400] if you pass in a funny score, like an array ([ 'hehe' ]) or a
     Hash ({ hello: 'World' })

EXAMPLE REQUESTS
------- --------

Appendix A: Modifying fudge points

{
  "quiz_submissions": [{
    "attempt": 1,
    "fudge_points": VALUE
  }]
}

Appendix B: Modifying a question score

{
  "quiz_submissions": [{
    "attempt": 1,
    "questions": {
      "QUESTION_ID": {
        "score": VALUE
      }
    }
  }]
}

Appendix C: Modifying a question comment

{
  "quiz_submissions": [{
    "attempt": 1,
    "questions": {
      "QUESTION_ID": {
        "comment": "HEHEHEHH"
      }
    }
  }]
}

Change-Id: Id290d4e9f9cb9abcaa00eae857f4b0b7bd06e2ff
Reviewed-on: https://gerrit.instructure.com/28268
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Myller de Araujo <myller@instructure.com>
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
Product-Review: Ahmad Amireh <ahmad@instructure.com>
2014-01-14 08:30:39 +00:00
Duane Johnson 07bba1e551 Generate unique swagger methods per Rails route for APIs
When auto-generating the JSON that is used to describe our API for
swagger, our code previously did not take into account controller
methods that have multiple routes. For example, the Submissions API
can request either 'courses' or 'sections', each of which is part of
the URL (path).

This patch adds a way to differentiate the submissions API methods.
Since these are the only methods that need it, the solution takes a
shortcut to uniqueness by using the 'courses' or 'sections' route
segment, known in advance to be the 3rd segment.

In future, we could make this more intelligent by using an algorithm
to find the shortest segments that make the method name unique.

Test Plan:
- the JSON output (e.g. public/doc/api/submissions.json) should have
  unique nicknames for the section or course variant of an API. e.g.
  the "List assignment submissions" API should have both a
  "list_assignment_submissions_courses" nickname and a
  "list_assignment_submissions_sections" nickname.

Fixes SIS-115

Change-Id: I7f3d093e4e3cc99f5f7cb93310756421708dc6f3
Reviewed-on: https://gerrit.instructure.com/28080
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Eric Adams <eadams@instructure.com>
Product-Review: Eric Adams <eadams@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
2014-01-13 22:54:03 +00:00
James Williams 9725c540ec fix api doc generation for rails 3
Change-Id: I15b7323e36eeee5b8104bf0c5eae7d37d87c5db1
Reviewed-on: https://gerrit.instructure.com/27031
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2013-12-11 19:58:50 +00:00
Cody Cutrer f838d142f4 allow oauth clients to provide a purpose to the oauth flow
refs CNVS-5794

test plan:
 * go through the oauth flow, adding purpose=something to the first
   step
 * at the end, when you view the access token in your user profile,
   it should show the purpose you put in

Change-Id: I3f7f55df5540931ef5844c7f265dc720af153372
Reviewed-on: https://gerrit.instructure.com/26249
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2013-11-16 20:26:36 +00:00
Duane Johnson b88a1ab92c change swagger reference to relative from absolute
Code generation does not work with absolute URLs since swagger-
codegen appends the 'path' value directly on to the base. Change
to relative fixes the issue.

Change-Id: I93474ca603cc9675c5d7a4eb3dd9fce654c0959f
Reviewed-on: https://gerrit.instructure.com/24477
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
2013-11-15 21:29:39 +00:00
Brad Humphrey 6fe9daca43 fixes improperly formatted external tool documentation
also modified the documentation for external tool configurations
to clarify how "environment" settings work

Test plan:

 - verify that underscores are displaying instead of italicizing content

Change-Id: Ie62d11018becdc9a5281f3d25907827814d3fb7d
Reviewed-on: https://gerrit.instructure.com/25191
Reviewed-by: Brad Humphrey <brad@instructure.com>
Product-Review: Brad Humphrey <brad@instructure.com>
QA-Review: Brad Humphrey <brad@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2013-10-31 20:43:09 +00:00
Rob Orton 6ff1a38ac8 document the time the signature is good for
test plan
- the time should show up at doc/api/file.file_uploads.html

Change-Id: I54eec0e6276d46a960878563a0505ddba7152251
Reviewed-on: https://gerrit.instructure.com/25616
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
QA-Review: Bracken Mosbacker <bracken@instructure.com>
2013-10-29 20:21:04 +00:00
Duane Johnson 8563caf03b fix swagger argument parser and add specs
Argument parser was not detecting optional/required args properly.
Added specs, improved parsing success rate.

Change-Id: Id101ab92cdba32c95a91488c9fab1a912b0b6a0f
Reviewed-on: https://gerrit.instructure.com/24560
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brandon Broschinsky <brandonbr@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
2013-09-30 20:13:41 +00:00
Cody Cutrer 2c9cefe6a5 update API documentation on usage of SIS IDs
refs CNVS-7814

Change-Id: I492b6b0f3bce2f328a85c642394b5aa2fe1ad0f8
Reviewed-on: https://gerrit.instructure.com/24519
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-09-20 16:56:11 +00:00
Duane Johnson e6aadc704b swagger: handle 'array' return types in API docs
Our generated json did not handle array data types for @return tags.
This adds support, for example, for '@return [User]'

Change-Id: I3f9bee95c49fc737d07b220b99c9083d28d0ffde
Reviewed-on: https://gerrit.instructure.com/24500
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
2013-09-19 14:51:04 +00:00
Brian Palmer c263e2b22b fix links to static api doc files
test plan: links to the files api documentation, such as in
submissions#upload_file , should work correctly

Change-Id: I936a597b5a9e40bae06c753e036ca36aa1538cfd
Reviewed-on: https://gerrit.instructure.com/24279
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
2013-09-16 18:49:46 +00:00
Duane Johnson a633e14fc1 add @model description for User datatype in user API
Replaces the @object User example description. Add :model to tags that
are shown to describe objects in the API docs. Uses model info to
reproduce the expected @object style API documentation.

Change-Id: I12ffca98aeef72851cd331794fa8268d14812315
Reviewed-on: https://gerrit.instructure.com/23967
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
Tested-by: Duane Johnson <duane@instructure.com>
Reviewed-by: Duane Johnson <duane@instructure.com>
QA-Review: Adam Phillipps <adam@instructure.com>
2013-09-06 21:51:29 +00:00
Duane Johnson 3ee943278b update API docs generated for swagger
- Explicitly describe path parameters (e.g. "id", "account_id") so
  that swagger will autogenerate the correct code.
- Use :resources which is already grouped, rather than :object, which
  is not.
- Guess type information from current sample @object models
- Accept @model in API docs as a better alternative to @object.
  @model descriptions use the JSON-schema draft 4 specification,
  which is what Swagger uses.

  See https://github.com/wordnik/swagger-core/wiki/Datatypes

- Add some swagger json generator specs
- Fix SubmissionsController's "Submission" object

Change-Id: I71befe1d2cea039fd996124e7de9cab2e639e191
Reviewed-on: https://gerrit.instructure.com/23831
Reviewed-by: Brian Palmer <brianp@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
2013-09-05 19:55:40 +00:00
Duane Johnson dfff4041c7 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>
2013-08-22 21:11:50 +00:00
Simon Williams b2e44eb237 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>
2013-08-22 17:14:02 +00:00
Duane Johnson ee70c75174 generate an api.json file from 'yard' API docs
Add 'swagger' API metadata generator from Yard. This metadata
can be used to generate a Canvas API wrapper library, or to benefit
from the swagger doc ecosystem.

See https://github.com/wordnik/swagger-core/wiki

Test Plan:
- Call 'rake doc:api API_YML=1' from the command line
- Check that api.yml file is created in current directory

fixes CNVS-7311

Change-Id: I9c5f756192794e5ea767c4db745a777cd63c3942
Reviewed-on: https://gerrit.instructure.com/23079
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Nathan Mills <nathanm@instructure.com>
Product-Review: Duane Johnson <duane@instructure.com>
QA-Review: Duane Johnson <duane@instructure.com>
2013-08-16 21:45:35 +00:00
Mark Severson 3603934770 change api pagination to include the current page link
test plan:
 * exercise paginated api endpoints (including the search endpoint)
 - ensure the link headers now include current (for the current page)

refs CNVS-7508

Change-Id: Id271c3a05b726de9ce619bd0100af84db199d4f1
Reviewed-on: https://gerrit.instructure.com/23365
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Hannah Bottalla <hannah@instructure.com>
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-08-16 19:13:25 +00:00
Rob Orton 83acc5b7c8 add note in api documentation about 64 bit ids
closes CNVS-7220

test plan
- should have "All ids in canvas are 64 bit integers"

Change-Id: I45ed55f85233c48aee38194695fc04c6e73ab623
Reviewed-on: https://gerrit.instructure.com/22803
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2013-08-01 19:56:37 +00:00
Jacob Fugal 38604a1368 define canvas-style compound API documents
documentation on the server side, and adaptation of Backbone.Collection
to handle this style of document on the UI side.

refs CNVS-390, refs CNVS-6069

Change-Id: Ice854695df66efb13545aa7ae47b39e7ad673c60
Reviewed-on: https://gerrit.instructure.com/22145
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2013-07-17 02:48:45 +00:00
Brian Palmer d2bbc3e0be integrate fake_rails3_routes
This allows us to upgrade our routes file to rails 3 syntax while still
staying compatible with rails 2.3

refs CNVS-5146

test plan:

This affects literally every URL in Canvas, but shouldn't introduce any
new behavior. The automated integration and selenium tests still pass,
which is a good smoke test. Other than that, it's really just making
sure that routes are generated and recognized as before (regression
testing).

Change-Id: I443d006e3fcb5a0a0f8d6db46a8873a498ae7fd4
Reviewed-on: https://gerrit.instructure.com/21729
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
2013-06-26 21:22:20 +00:00
Jeremy Stanley 1cd3580615 add data-api-endpoint for quiz / quiz list links
test plan:
 - have a course with a quiz
 - in rich content (like a wiki page), use the wiki sidebar
   to insert a link to the quiz list and a link to the quiz
 - retrieve the wiki page via the pages API
 - the quiz list link should have added attributes
   * data-api-returntype="[Quiz]" (with brackets)
   * data-api-endpoint: valid API link to the quiz index
 - the quiz link should have added attributes
   * data-api-returntype="Quiz"
   * data-api-endpoint: valid API link to the quiz
 - the API documentation should mention "Quiz" in the list
   of supported data-api-returntype values, found in the
   "Basics" section under "API Endpoint Attributes"

fixes CNVS-6115

Change-Id: If405f6779f1b3f3719503a9987cceaf29a508ed8
Reviewed-on: https://gerrit.instructure.com/21080
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
2013-06-04 20:34:24 +00:00