Commit Graph

21 Commits

Author SHA1 Message Date
David Wolever e1c9b8c658 Add the word 'paginated' to relevant API documentation.
fixes: GH-1119

Change-Id: I75992f23ff0f0d088983af0a4c931d1c2c09e3d5
Reviewed-on: https://gerrit.instructure.com/126253
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Bryan Petty <bpetty@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
2017-09-27 17:27:41 +00:00
Landon Wilkins e5ca22c923 da licença part 5
add consistent license headers to all source files
(ruby, coffeescript, javascript)

except for vendor files

Change-Id: If23fe3b449317df66cf4b0f52629d7fbe851e948
Reviewed-on: https://gerrit.instructure.com/110025
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-04-27 21:30:43 +00:00
Cody Cutrer 556f0b64bf rails 5: s/_filter/_action/g
fixes CNVS-34832

the arguments to these methods have not changed, just their names. and the
new methods became available in Rails 4, so we can start using them now

and prevent someone from doing old-style in the future

Change-Id: I61aa5512995dc8f25f3f7bd009a6cfa0a030e274
Reviewed-on: https://gerrit.instructure.com/101401
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-02-09 23:03:40 +00:00
James Williams a9fab4f4af remove strong_params
refs #CNVS-32574

Change-Id: I4e255b989f8ad3fc6ec2f2699d4950dc0e5a419a
Reviewed-on: https://gerrit.instructure.com/99483
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2017-01-13 12:49:15 +00:00
James Williams 6fc0f8c28b strong_params part all the rest
refs #CNVS-32574

Change-Id: If0a354295f9433fcf4dc2a776d93ae45833a44bd
Reviewed-on: https://gerrit.instructure.com/94683
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2017-01-10 18:19:55 +00:00
James Williams ba88661af9 rails 4.2: fix calls to Filters module
refs #CNVS-26056

Change-Id: Iccb8c2943927817c27a3e82106ab1844e683de98
Reviewed-on: https://gerrit.instructure.com/70558
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2016-01-19 20:24:02 +00:00
Ben Young c8530610ab update API doc required params - 9
- Poll choices
- Poll sessions
- Polls
- Quiz extensions
- Quiz question groups

Test plan:
- rake doc:api
- Verify the above doc pages for parameter accuracy

Refs SIS-403

Change-Id: Iefb2933061707390fa3b28428a5183ca214d5d87
Reviewed-on: https://gerrit.instructure.com/39313
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-08-26 16:14:19 +00:00
Josh Simpson dadb210455 add submission inclusion for students in polling
fixes CNVS-13826
This commit embeds a student's own submission into the poll sessions
endpoints.

Test plan
1. As a teacher, create a poll with choices and an opened session.
2. As a student, submit a submission to the poll session.
3. As the student, request the poll sessions GET show endpoint.
- The student's submission should be available in the "poll_submissions"
  field.

Other considerations are privacy: a student shouldn't be able to see
others' submissions (unless the poll session has public results).

Change-Id: I6050d5597fd44c0c0e9672b8e69a38022a3ea22d
Reviewed-on: https://gerrit.instructure.com/37078
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-06-30 21:44:14 +00:00
Josh Simpson 2f594ea5e3 add jsonapi pagination to polling and missing documentation
fixes CNVS-13534
This commit adds 2 things.  One is that, when it's requested via the
'Accept' request header with a value of 'application/vnd.api+json', it
will return jsonapi standard pagination.  The other is the addition of
of documentation for the 'results' attribute on poll sessions, and the
'total_results' attribute on polls.

Test plan
1. jsonapi pagination
- As a teacher, and using a header of Accept: application/vnd.api+json
  Test the following endpoints:
  - The polls index endpoint
  - The poll_choices index endpoint
  - The poll_sessions index endpoint
  - The poll_sessions opened endpoint
  - The poll_sessions closed endpoint
  - Each of these endpoints should return the same JSON response, but
    with the addition of a 'meta' attribute that has a 'pagination' key,
    with pagination information.

2. documentation
- The documentation for polls should now include a 'total_results'
  attribute, and the documentation for poll_sessions should include a
  'results' attribute.

Change-Id: I2a16b4d32b3b2a4f2023628b24f9accaecbffcc1
Reviewed-on: https://gerrit.instructure.com/36216
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-06-11 16:33:55 +00:00
Josh Simpson 53920a96ce add explicit poll choice ordering and poll_session deletion
fixes CNVS-13521,CNVS-13489
This commit adds 3 things.  One is a fix for deleting a poll_session when
there are poll_submissions created already for the poll_session. The
second is the addition of a new attribute on poll_choices called
'position'.
The 'position' attribute specifies the order a poll choice should be
returned in. The third is the visibility of poll sessions to students:
as long as a student is enrolled in the course (and course section, if
it exists on the poll session) associated with the poll session, they
can access it, whether or not it's open or closed.

Test plans
1. Deleting a poll session
As a teacher
- Create a poll and related poll session
- Open the poll session for submissions
As a student
- Create a submission for the newly created poll session
As a teacher
- You should be able to delete the poll session

2. Position ordering attribute
As a teacher
- Create a poll
- Create poll choices, passing along the 'position' attribute to specify
  ordering (try to mix these up, e.g. create a poll choice with a
  position
  of 2, then a poll choice with an position of 4, then a poll choice with
  an position of 3, then a poll choice with an position of 1)
- Retrieve the poll choices for the poll with the poll choices index
  endpoint
- The poll should be returned in the order they were specified using the
  'position' attribute

3. Poll session visibility to students
As a teacher
- Create a poll
- Create an associated poll session with a valid course
As a student enrolled in the given course
- You should be able to view the poll session whether or not it's open
  or closed.
As a student not enrolled in the given course
- You should not be able to view the poll session, whether or not it's
  open or closed.

Change-Id: Ifabd64540d843c83f3a22fb6668c4fcac8f728b0
Reviewed-on: https://gerrit.instructure.com/36087
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Bryan Madsen <bryan@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-06-11 00:48:16 +00:00
Josh Simpson 608b0896e2 improve polling performance
fixes CNVS-13440
this commit addresses bad polling performance, particularly in
poll_sessions. It also removes a foreign key constraint on the
poll_sessions poll_id, that would introduce sharding issues.

Test plan
- Test the following attributes on particular models to insure that
  they're still correct:
  - Poll#total_results should accurately return the aggregate results for all of
    the poll_sessions that belong to the poll
  - PollSession#results should accurately return the results of all poll
    submissions submitted for the particular poll session

Change-Id: Ic0d4aaeb77c735fa4ba6c5f73dfbf84d8e6ac615
Reviewed-on: https://gerrit.instructure.com/35860
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-06-10 19:53:31 +00:00
Josh Simpson 38917d0c32 expose poll_choice#is_correct to students when available
fixes CNVS-13474
This commit exposes the is_correct attribute on poll_choices when a
student has submitted their answer to the latest poll_session, and that
poll_session has been closed.

Test plan
- As a teacher, create a poll, relevant poll choices, and a poll session
- Publish the poll session
- As a student, at this point is_correct should not be viewable on poll
  choices
- As a student, submit a poll submission
- As a student, at this point is_correct should not be viewable on poll
  choices
- As a teacher, close the poll session
- As a student, at this point is_correct should be viewable on poll
  choices

Change-Id: I20a8bb534affe5e1a23c1dddbb727043535dd23d
Reviewed-on: https://gerrit.instructure.com/36031
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Trevor deHaan <tdehaan@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-06-06 22:41:04 +00:00
Josh Simpson 824cbe580d fix polling api 500 errors
fixes CNVS-13434
This commit addresses several 500 errors the polling api was emitting in
various circumstances.

Test plan
- Create a poll session with an invalid course section id
  - The API should return a 404 and JSON response of 'resource not found'

- Create a poll session with a blank has_public_results attribute
  - The poll session should be created with a 'false' has_public_results
    attribute

- Update a poll session with a new course_id and valid course_section id
  - The poll session should be updated successfully

- Create a poll submission with no poll_choice_id supplied.
  - The API should return a 404 and JSON response of 'resource not found'

- Create a poll submission who has made a submission for a different
  session on the same poll
  - The poll submission should be created successfully

Change-Id: I435067488914b2d1a3e48e2df5eda835228759c2
Reviewed-on: https://gerrit.instructure.com/35936
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Reviewed-by: Jason Madsen <jmadsen@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-06-05 01:21:00 +00:00
Josh Simpson a49ba0748c add user_id to poll serializer
fixes CNVS-13360
This commit adds the user_id to the poll json response, only for
teachers.

Test plan
- As a teacher, create a poll
- Request that poll via the poll#show endpoint
- It should have a 'user_id' field with the id of the creator
- As a student, request the same poll via the poll#show endpoint (the
  student won't be able to view it without a published poll session)
- The student should not see the 'user_id' field.

Change-Id: Ib0b09d779f3486edaa38a870d20211268be819d3
Reviewed-on: https://gerrit.instructure.com/35693
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-30 22:46:02 +00:00
Josh Simpson 184d524040 add opened/closed endpoints for poll sessions
fixes CNVS-13262
This commit changes the external semantics for API users.  Instead of
'publish' and 'close', the two states of poll sessions are now 'open'
and 'close'.  This is reflected in the endpoints.

This commit also adds two endpoints for students: one to see all available
poll sessions (based on their enrollments) that are published, and
another to see all available poll sessions (based on their enrollments)
that are closed.

Test plan
- Create a poll, and multiple poll sessions for the poll that correspond
  to different courses.
- Publish the sessions
- As a student enrolled in one of the courses, the /published endpoint
  should return the poll session corresponding to the course they're
  enrolled in.
- The student should not see the sessions that correspond to the courses
  they're not enrolled in.
  - The student should not see any of the sessions via the /closed
    endpoint
- Close all sessions.
- The /published endpoint should not return any of the sessions.
- The /closed endpoint should return all sessions that correspond to
  course(s) the student is enrolled in.

Change-Id: Ib2743c123a2323c59d923264498f65cb60163405
Reviewed-on: https://gerrit.instructure.com/35503
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-29 19:57:40 +00:00
Josh Simpson a3a1205e2d embed poll submissions into poll session
fixes CNVS-13275, CNVS-13297
This commit embeds all submissions when a particular poll session is
requested by authorized users (the creator/teacher of the poll and
relevant poll session.).  It also deletes all submissions and sessions
that belong to a poll when that poll is deleted.

Test plan
Submission embedding
- Create a poll and related poll session
- Create multiple submissions for the poll as students
- As a teacher, you should be able to see the related submissions
  when requesting the poll session via the API

Poll session/submission deletion
- Create a poll and two poll sessions, with two submissions per session
- Delete the poll via the api, it should be deleted successfully

Change-Id: I335f92eb97be095a2ddf6bc730954ed8a14220ef
Reviewed-on: https://gerrit.instructure.com/35456
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Derek DeVries <ddevries@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-28 22:21:41 +00:00
Josh Simpson 705fdb7bef transition the polling api to the jsonapi standard
fixes CNVS-13271
this commit changes the formatting of the JSON returned by the polling
endpoints to conform to the adopted jsonapi standard. It also adds a
'created_at' field to the poll and poll_session endpoints

Test plan
- All polling endpoints should adhere to the jsonapi standard (nested
  under a collection, e.g. all returned JSON items will be contained under
  a pluralized root, polls will be under a 'polls' key, poll choices
  will be under a 'poll_choices' key, even for a single resource)

- There are no 'meta' or 'links' attributes to worry about yet

- The poll and poll_session endpoints should return a 'created_at'
  field.  This is viewable by both students and teachers

Change-Id: Ie0fd49a2c699fba5d8257ee1e8dbb062c81662cb
Reviewed-on: https://gerrit.instructure.com/35388
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ahmad Amireh <ahmad@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-28 16:47:30 +00:00
Josh Simpson 0b7d6d1f5f fix poll session visibility after it's closed
fixes CNVS-13261
poll sessions are not visible to their creators via the #show action
after they've been closed. This commit fixes that issue.

Test plan
1. Create a poll with poll choices via the API
2. Create a poll session via the API
3. Publish then close the poll session via the API
- the session should be viewable by its creator
- the session should not be viewable by students

Change-Id: I5b03241b539d8abe32d48907c260a01c53fb6b01
Reviewed-on: https://gerrit.instructure.com/35366
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Stanley Stuart <stanley@instructure.com>
Reviewed-by: Stanley Stuart <stanley@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-23 14:49:16 +00:00
Josh Simpson 5fb5464891 add polling session and submission apis
fixes CNVS-12474, CNVS-12477, CNVS-12478
this commit fleshes out the API endpoints for polling sessions and
submissions, and solidifies the other polling endpoints.

Test plan
- Full tests on the following endpoints:
  - Polls are the basic data model of the polling app.  They can take a
    question attribute and a description attribute. They are only
    creatable and modifiable by teachers.

    - GET /api/v1/polls (index action)
    - POST /api/v1/polls (create action)
    - GET /api/v1/polls/:id (show action)
    - PUT /api/v1/polls/:id (update action)
    - DELETE /api/v1/polls/:id (destroy action)

  - Poll choices belong to polls. They consist of the particular answers
    a submitter can choose when participating in a poll session.  They
    have attributes of text (the answer text), their associated poll,
    and an 'is_correct' boolean attribute.  The 'is_correct' attribute
    show not be accessible by students.  Poll choices are only creatable
    and modifiable by the creator of the poll.

    - GET /api/v1/polls/:poll_id/poll_choices (index action)
    - POST /api/v1/polls/:poll_id/poll_choices (create action)
    - GET /api/v1/polls/:poll_id/poll_choices/:id (show action)
    - PUT /api/v1/polls/:poll_id/poll_choices/:id (update action)
    - DELETE /api/v1/polls/:poll_id/poll_choices/:id (destroy action)

  - Poll sessions are for publishing a poll so that it can accept
    submissions.  They should only be createable / modifiable by
    teachers. Only students that are enrolled in the associated course
    of the poll session should be allowed to view them.
    The show action of a poll session acts differently for a teacher.
    They are able to see the results of the voting that has taken place
    by students since the session was published.

    - GET /api/v1/polls/:poll_id/poll_sessions (index action)
    - POST /api/v1/polls/:poll_id/poll_sessions (create action)
    - GET /api/v1/polls/:poll_id/poll_sessions/:id (show action)
    - PUT /api/v1/polls/:poll_id/poll_sessions/:id (update action)
    - DELETE /api/v1/polls/:poll_id/poll_sessions/:id (destroy action)
    - GET /api/v1/polls/:poll_id/poll_sessions/:id/publish (publish action)
    - GET /api/v1/polls/:poll_id/poll_sessions/:id/close (close action)

  - Poll submissions are for submitting an answer for a particular poll
    session.  A student should only be allowed to submit a poll choice
    for a session they're able to view, and they can only submit one
    poll choice per poll session.

    - GET /api/v1/polls/:poll_id/poll_sessions/:poll_session_id/poll_submissions/:id (show action)
    - POST /api/v1/polls/:poll_id/poll_sessions/:poll_session_id/poll_submissions (create action)

Change-Id: Ifcfd72ec30597e37fc54c687fb7d61a644d7348c
Reviewed-on: https://gerrit.instructure.com/34605
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-22 20:49:40 +00:00
Josh Simpson 854bae635b fix yard documentation for polling controllers
fixes CNVS-12913
YARD documentation needs to be above the explicit class it's referencing
and documenting.

Change-Id: I9e143c1f5300cad4abaa04f21c76820e8a0f6913
Reviewed-on: https://gerrit.instructure.com/34478
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-07 19:41:06 +00:00
Josh Simpson 4e903f5fd1 add basic polling api
refs CNVS-12469
closes CNVS-12471,CNVS-12472,CNVS-12473
This commit adds basic CRUD API operations for polling.

Test plan
- Check the create/show/update/deletion API endpoints for both polls
and poll_choices

- Check access controls (students shouldn't be allowed to
  create/delete/update polls or poll choices, nor see the 'is_correct'
  attribute on poll_choices)

Change-Id: I05504bac9cce30382311b3beb6df826e6a30b77f
Reviewed-on: https://gerrit.instructure.com/33956
Reviewed-by: Derek DeVries <ddevries@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Josh Simpson <jsimpson@instructure.com>
2014-05-05 20:30:43 +00:00