Commit Graph

94 Commits

Author SHA1 Message Date
Simon Williams f74c14684b use a separate manage_assignments_edit flag when ff is on
refs FOO-2226
flag = granular_permissions_manage_assignments

I originally intended to keep the original manage_assignments permission
and use it when the flag was on for edit/manage specific permissions,
but this made labeling and documentation difficult, especially since our
rollout strategy for this flag is gradual rather than all at once. So
this commit shifts gears to create a separete granular edit flag and
only use the old permission when the flag is off.

test plan:
- labeling and documentation on the account permissions page should be
  clearer and make more sense
- everything should continue to work as before

Change-Id: I93e4cbe0daa319217e17007e3391f905f1a9d77d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273020
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: August Thornton <august@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2021-09-08 20:58:12 +00:00
Simon Williams 3a0276cde4 granularize adding and deleting assignments
closes FOO-2226
flag = granular_permissions_manage_assignments

Split manage_assignments_add and manage_assignments_delete off from the
main manage_assignments permission.

These permissions control more granularity for adding and deleting the
following types of content:
- Assignments
- Assignment Groups
- Quizzes
- Question Banks
- Questions within Question Banks
- Live Assessments

test plan:

[ with the flag off ]
- Smoke test creating, editing and deleting assignments, assignment
  groups, quizzes, and question banks.
- It should all work as before.

[ with the flag on ]
- Create roles that have only the add permission, only the manage
  permission, and only the delete permission.
- With those three roles, as well as with a role with all permission,
  try creating, editing, and deleting assignments, assignment groups,
  quizzes, and quesiton banks.
- It should make sense with the role.

Change-Id: I06505509e55e7ac6c3b5ef1c688ef1353e2045d8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/271290
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: August Thornton <august@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: August Thornton <august@instructure.com>
2021-08-18 22:39:15 +00:00
Eric Saupe edb78a6ced Add important dates checkbox to assignment overrides form
fixes LS-2307, LS-2308, LS-2309
flag=important_dates

test plan:
- Enable important dates site admin flag
- Create or find a C4E subject course
- Create an assignment
- Verify there is a checkbox for important dates under due date form
- Verify the checkbox is disabled if no due dates are set
- Verify the checkbox is enabled if a due date is set on any date
- Save the assignment and verify the checkbox is still checked
- Verify this behavior works in the other places this component is used.
 For example, quizzes, graded discussions, etc.

Change-Id: If2e806a8de764f467bf9ca086740260f2df015d1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/268061
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jackson Howe <jackson.howe@instructure.com>
QA-Review: Jackson Howe <jackson.howe@instructure.com>
Product-Review: Eric Saupe <eric.saupe@instructure.com>
2021-07-06 17:36:02 +00:00
Wagner Gonçalves 005e90871c part 3: change lookup_id and resource_link_id to UUID datatype
This is part 3 of changing the datatype from varchar to UUID of
lookup_id and resource_link_id from lti_resource_links.

We start to read from the new columns created lookup_uuid and
resource_link_uuid.

Adding a migration to remove the not-null constraint of lookup_id and
resource_link_id columns. As part 3.1 we'll stop writing into these
columns, we need to execute this postdeploy migration at this point.

refs INTEROP-6488
flag=none

test-plan:
* specs should pass;
* you should check if LTI is launching as expected, and if the custom
  params was expanded as expected in all records that were created in the
  part 1 and 2;
* you should be able to new persist custom params, for example you can
  use the RCE editor placement;
* you can follow the test-plan:
    * https://gerrit.instructure.com/c/canvas-lms/+/256029
    * https://gerrit.instructure.com/c/canvas-lms/+/254453

[fsc-timeout=30]

Change-Id: I401f53a82f4dbef66c45932eb2eed8727488313d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/258246
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
Product-Review: Wagner Goncalves <wagner.goncalves@instructure.com>
2021-02-11 18:02:20 +00:00
Cody Cutrer 81d0bbc465 add # frozen_string_literal: true for specs
Change-Id: Id508bec1817937b1c24c29f1db7221e09cb9c2ab
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251157
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:48:35 +00:00
Mark Neuburger 1d1994eff1 Add disable_timer_autosubmission to Quiz model
Test plan:

1. Ensure that the new migration has run.
    1. Because of 2 existing migrations with future dates, you may need
       to rollback 3 steps before you can run the new migration.
    2. Run `rake db:rollback STEP=3` followed by `rake db:migrate` in
       the web container.
2. Create a new Quiz in the Canvas UI.
3. In the Rails console, verify that the `disable_timer_autosubmission`
   value for this quiz is equal to false:
`Assignment.last.quiz.disable_timer_autosubmission`
4. Update the value to true:
   `Assignment.last.quiz.update_attribute(:disable_timer_autosubmission,
true)`
5. Verify that the value is now equal to `true` using the command in
   step 3.
6. A new Quiz attribute `timer_autosubmit_disabled?` is exposed that
   factors in the feature flag as well. Verify that this value returns
as expected with different combinations of the feature flag and
`disable_timer_autosubmission`.
    1. Read this flag in the Rails console with:
       `Assignment.last.quiz.timer_autosubmit_disabled?`

Refs PFS-15510
Refs PFS-15511
flag=timer_without_autosubmission

Change-Id: I4749bdd46dd06a425141636c41e0f30c0dfc88a9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/233860
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
Product-Review: Chad McGuire <cmcguire@instructure.com>
QA-Review: Petra Ashment <pashment@instructure.com>
2020-05-06 14:31:16 +00:00
Cody Cutrer a81944a73a rails 6: s/update_attributes/update/g
Change-Id: Ie137c1040260b363979160e1f0558883577ebebd
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/222510
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2020-01-09 20:56:35 +00:00
Han Yan ebbd9ebd63 a new endpoint to return both NQ and Old quiz json
(for N.Q mobile and N.Q Respondus)

closes QUIZ-6788

test plan:
- create old quizzes and new quizzes in Canvas
- /api/v1/course/:course_id/all_quizzes will return json for both
  old quizzes and new quizzes

Change-Id: I98c9a40b4075566a1945e3c46ef7b5dcb1c7dcac
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/218090
Tested-by: Jenkins
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
2019-12-16 19:36:38 +00:00
Han Yan 2706a2af1c align quiz migration behaviors with quiz duplication
closes QUIZ-6791

test plan:
- test the ps with quiz_lti patch
- make sure quiz migration works
  - quiz shell is created
  - quiz shell status is updated when quiz migration is done

Change-Id: Ia002ceb48ded582849301e3efd8631396d9ffe95
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/210548
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Kevin Dougherty <jdougherty@instructure.com>
2019-10-22 22:18:35 +00:00
Han Yan 6e65e2ef31 move N.Q to Quizzes Page
(flag=newquizzes_on_quiz_page)

- populate N.Q quizzes to assignment quizzes list
- display kebab menu based on quiz types (old quizze and new quizzes)
- items in kebab menu are functional

closes QUIZ-6790, QUIZ-6792, QUIZ-6789, QUIZ-6786

test plan:
- With the newquizzes_on_quiz_page flag disabled
  everything should behave like in production
- With the newquizzes_on_quiz_page flag enabled
  1) N.Q quizzes show up on Quizzes Page
  2) N.Q quiz shells have correct kebab menu
  3) each menu items (delete, duplicate) should work

Change-Id: Ie4a78bb0f0a69f4d6e248135d1c486f1ca0ffe7f
Reviewed-on: https://gerrit.instructure.com/209993
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Kevin Dougherty III <jdougherty@instructure.com>
2019-10-16 18:20:14 +00:00
Drake Harper 88e41e069a Add asset_name property to asset_accessed event type
Fixes PLAT-4718

Test Plan:
-create an event
-verify asset_name is in body of event

-create a context external tool
-verify asset name is not in body of event

Change-Id: I96d38dfc74b1888aae962e62ee06d025f83ff35b
Reviewed-on: https://gerrit.instructure.com/204268
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Oxana Jurosevic
2019-08-20 15:28:14 +00:00
cfurse 64e5d5c113 Add filename to the asset_accessed payload
Closes PLAT-3849

Test Plan:
- Trigger a live event by download a file from 1 of a few places including:
  1. Your account > Files
  2. Course > Files
- Verify an asset_accessed event is created and includes 2 new fields:
  (filename & display_name)

Change-Id: I9c0ca7c21b373250ed69c025da59d6057a598c87
Reviewed-on: https://gerrit.instructure.com/197857
Tested-by: Jenkins
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Oxana Jurosevic
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
2019-06-25 16:17:25 +00:00
wdransfield 1d7b8de179 Add LTI tool data to external tool asset accessed events
Closes PLAT-4442

Test Plan:
- Launch an external tool that has a url, domain, and name
- Verify these fields are included in the asset accessed
  event that is sent
- Verify other asset accessed event bodies remain unchanged

Change-Id: Ia728a784b01cc640a8619fa05ca01acae2e918b7
Reviewed-on: https://gerrit.instructure.com/197694
Tested-by: Jenkins
Reviewed-by: Drake Harper <dharper@instructure.com>
Reviewed-by: Clint Furse <cfurse@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2019-06-18 16:11:20 +00:00
Drake Harper fbdfc2c859 Use past lti id if present
fixes PLAT-4481

Test Plan:
-Create 3 courses
-Create 2 users
-Enroll user 1 in courses 1 and 2
-Merge users
-Enroll user 2 in course 3
-Check to see user ids are different

Change-Id: I9da709285f8fdbaab238f1f1c8ceb127a748de11
Reviewed-on: https://gerrit.instructure.com/193535
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2019-05-15 17:05:13 +00:00
wdransfield 219bb96d45 Send lti_id in serialized AGS result
Closes PLAT-4158

Test Plan:
Use the index and show endpoint of the result service to
verify the result contains the lti_id of the user rather
than the Canvas id.

Change-Id: I0ab8fc2d8b3923a6a11d2a88f3a6cea127a94f0b
Reviewed-on: https://gerrit.instructure.com/178486
Tested-by: Jenkins
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2019-01-18 18:29:46 +00:00
Marc Phillips ed6dffe18c Fix ags service bugs
refs PLAT-4082

Test Plan:
 - Run through creation of lineitems, retrieving them, making
   scores, and retrieving results. They should all work now.

Change-Id: I2b045ddcfd11092509a51af2cd2b0d43819e709f
Reviewed-on: https://gerrit.instructure.com/177115
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
2019-01-08 21:41:25 +00:00
Marc Phillips f2f369c768 Fixup ags to work with spec and original design
closes PLAT-4030

Test Plan:
 - AGS should work with test tool
  - install the test tool and make an assignment
    out of it
  - use the tool to return a line item and scores
    and results and such
  - also, from teh tool, create a new line item
    and do the results and scores and such

Change-Id: I4f1a6bab561e10d38158748626cf94ec61d8916f
Reviewed-on: https://gerrit.instructure.com/174095
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Tested-by: Jenkins
Product-Review: Marc Phillips <mphillips@instructure.com>
2018-12-11 21:21:30 +00:00
Marc Phillips 8ff32e568a Constrain AGS to resourcelink lookups
closes PLAT-4008

test plan:
 - regression on the ags service

Change-Id: If1754abb3bdbc4640addbf76db60e6d31ce85842
Reviewed-on: https://gerrit.instructure.com/173326
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
2018-11-30 16:02:55 +00:00
wdransfield ae2c958676 Fix first-time render issues with LTI keys
Fixes PLAT-3924

Test Plan:
- Create a new LTI key
- Without refreshing the page verify the following:
  * toggling the "on/off" switch works
  * the global id of the key is displayed
  * the key's secret is available

Change-Id: I1cde9db31ecf8315a7814633d398364acea0a45f
Reviewed-on: https://gerrit.instructure.com/170184
Tested-by: Jenkins
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
2018-10-30 21:50:35 +00:00
Dan McCallum 9b44f895f7 Consolidate NRPS `message` serialization rules
- Previously custom param rules were in `MembershipsProvider`
  and claim group rules were in `NamesAndRolesSerializer`. Now
  they're all in the latter.
  - Also moved `privacy_level` enforcement into
  `NamesAndRolesSerializer` since that involves rendering of
  one special custom param and all custom param config had
  been moved into that class. This obviated the need for
  `UserDecorator`, which is now completely removed.
  - Simplified LTI message matchers significantly by accepting
  an `opts` hash. So now we're back to just two top-level
  code paths through those matchers... one for groups and one
  for courses. Previously each of those had an alternate path
  for `rlid` matching rules.

References LTIA-41

Test Plan:

  - This is purely a technical refactoring. No behavioral difference
  should be observable.
  - To guard against regressions, repeat selections from:
    - LTIA-41 tests to verify correct rendering of custom params when
    the `rlid` query param is present
    - LTIA-13/19 tests to verify correct enforcement of tool
    `privacy_level`
    - LTIA-24/34 tests to verify correct rendering of the
    `lis_person_sourcedid` field.

Change-Id: If07e3886eeb069379b01282686133517446f9f4b
Reviewed-on: https://gerrit.instructure.com/169495
Tested-by: Jenkins
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Bill Smith <bsmith@instructure.com>
2018-10-26 21:43:47 +00:00
Dan McCallum 75fdd13da6 Render simplified launch params into NRPS v2 responses
- Output a smaller version of a LTI 1.3 launch payload for
  each NRPS v2 member when the NRPS request includes a `rlid`
  query parameter.
  - Most claims and custom params from the launch payload are
  excluded either because:
    - They describe the context and would thus be redundant, or
    - They pose performance problems (N+1 queries, usually), or
    - They are absent from the spec example, e.g.
    `https://purl.imsglobal.org/spec/lti/claim/version`, or
    - They require additional development and thus need to be
    handled as a separate task.
  - See `memberships_provider.rb` ~line 68 for list of
  custom params supported in this commit. (More coming later.)
  - Vast majority of the patch has to do with tests against
  `JwtMessage`, which was modified to allow claims to be turned
  on/off via a new white/blacklist mechanism in `AppUtil`.
  - Custom param white/blacklisting is handled directly in
  `VariableExpander` to satisfy the LTI rule that unsupported
  params should just be echoed as-is. This (instead of keeping
  all the white/blacklist support in `JwtMessage` ensures
  consistent behavior w/r/t `VariableExpander`'s more sophisticated
  features, specifically its suport for expanding variables embedded
  into larger strings.

Closes LTIA-40

Test Plan

  - Configure a LTI 1.3/Advantage tool with the supported set of
  custom params listed in `memberships_provider.rb` starting ~line 68.
  If using the POST
  `/api/lti/accounts/:account_id/developer_keys/tool_configuration`
  API, this is done by setting
  `tool_configuration.settings.custom_fields` to a JSON object where
  keys are the param name to be rendered into LTI payloads and values
  are the $-prefixed custom param names themselves. Include several
  nonsense entries as well as unsupported entries e.g.:

  ```
  // ... snip ...
  "tool_configuration": {
    "settings": {
      // ... snip ...
      "custom_fields": {
        "person_name_full": "$Person.name.full",
        "person_name_display": "$Person.name.display",
        "person_name_family": "$Person.name.family",
        "person_name_given": "$Person.name.given",
        "canvas_user_isrootaccountadmin": "$Canvas.user.isRootAccountAdmin"
        "unsupported_param_1": "$unsupported.param.1",
        "unsupported_param_2": "$unsupported.param.2"
      }
      // ... snip ...
    }
    // ... snip ...
  }
  // ... snip ...
  ```
  - Place this tool into a course, ensure the course has several active
  members.
  - Launch the tool in order to observe the course context's LTI
  identifier. Use that identifier as the value of the NRPS `rlid`
  parameter, e.g. a GET to:
  `/api/lti/courses/1/names_and_roles?rlid=4dde05e8ca1973bcca9bffc13e1548820eee93a3`
  - Each `members` array element in the response should have a
  `message` array with a single element being the simplified
  representation of a LTI 1.3 launch payload, were that user to launch
  the context referenced by `rlid`.
  - The `message` entry should have two top level claims:
    - `"https://purl.imsglobal.org/spec/lti/claim/message_type": "LtiResourceLinkRequest"`
    - `"https://purl.imsglobal.org/spec/lti/claim/custom": <object>`
  - The `custom` claim should include an entry for each `custom_fields`
  key/value pair configured above, with supported entries being
  correctly expanded and nonsense and unsupported entries being echoed
  as-is.
  - Repeat for a group context in the same course (still using the
  course's LTI ID as the `rlid` value). Results should be the same,
  though scoped to group membership.

Change-Id: If2591c62c494756d65774e3115abeca19935c988
Reviewed-on: https://gerrit.instructure.com/169090
Tested-by: Jenkins
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Bill Smith <bsmith@instructure.com>
2018-10-26 21:41:16 +00:00
Dan McCallum e73f9275f3 Add lis_person_sourcedid field to NRPS v2 responses
- Effectively adds rendering of the `$Person.sourcedId` custom param
  to NRPS v2 responses.
  - Required changes to user preloading logic to allow preloading of
  pseudonyms even if the current user is not an admin.
  - Now memoizes context, enrollment, and user 'decorator' instances,
  as well as per-member mapped LTI roles.
  - Copy/paste in serialization tests and matchers caused problems
  during implementation so those have been DRYed out.
  - Some example groups also renamed to remove single quotes which made
  them difficult to run in isolation.

Closes LTIA-34

Test Plan:

  - Assign a SIS ID to one or more users actively enrolled in a
  Course and Group visible to a LTI 1.3 Tool.
  - Verify, for both Course and Group contexts, that the NRPS
  memberships describing those SIS ID'd users include those SIS
  IDs in the `lis_person_sourcedid` field.

Change-Id: I6316f45fe7aa476c5ccd884fa0236dc684241e3b
Reviewed-on: https://gerrit.instructure.com/167720
Tested-by: Jenkins
QA-Review: Samuel Barney <sbarney@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
2018-10-16 20:44:35 +00:00
Dan McCallum 9b89b6de75 Change NRPS response Content-Type and context nesting
- Two changes to NRPS response generation to match latest spec:
    1. Content-Type changed to
    `application/vnd.ims.lti-nrps.v2.membershipcontainer+json`
    2. `context` fields moved out of `members` elemens and up
    to top-level fields.

Closes LTIA-33

Test Plan:

  - Set up Tool, Course, and Group as usual for NRPS testing.
  - Verify NRPS responses for both Course and Group reflect the
  new Content-Type
  - Verify NRPS responses for both Course and Group describe the
  LTI context with a top-level `context` field rather than per-
  member fields.

Change-Id: I198501708a1ec044f2e422cf58d034f51cb685a4
Reviewed-on: https://gerrit.instructure.com/167710
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Samuel Barney <sbarney@instructure.com>
Tested-by: Jenkins
Tested-by: Marc Phillips <mphillips@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2018-10-16 19:26:04 +00:00
Dan McCallum a30b8db9db Respect Tool privacy level in NRPS v2 responses
- Mimic LTI 1.3 'launch' user attribute release policies in NRPS v2
  responses.
  - Here are the NRPS `member` fields allowed by each Tool privacy
  level (exclusive of `status`, `roles`, and `user_id`, which are always
  included):
    - 'public': `name`, `picture`, `given_name`, `family_name`, `email`
    - 'name_only': `name`, `given_name`, `family_name`
    - 'email_only': `email`
    - 'anonymous': <none>

Closes LTIA-29

Test Plan:

  - Place a 1.3-enabled LTI tool into a `Course` with at least one
  active enrollment. Point the LTI tool at the IMS LTI 1.3/Advantage
  Reference Implementation (RI)
  - Using the Rails console, direct db query, or External Tools API,
  verify that the tool's privacy level is 'public'.
  - Launch the RI and click the 'Request Names and Roles' button.
  - Verify that user attribute fields listed above for the 'public'
  privacy level appear in the NRPS v2 response.
  - For each of the remaining privacy levels, using the Rails console,
  direct db query, or External Tools API, modify the tool's privacy
  level to that value, relaunch the RI, re-request NRPS v2 memberships
  and verify the user attributes are correctly limited.
  - Repeat the above for a `Group` in the same `Course`. NB the RI
  cannot be used for this. Instead use direct API invocation. Because
  this involves signing a request with a RSA private key, this is
  easiest to accomplish via the Postman collection provided out of band
  for LTIA-27.

Change-Id: I103b8529c592da050fa2fa91018bec125ab8739f
Reviewed-on: https://gerrit.instructure.com/167343
Tested-by: Jenkins
QA-Review: Samuel Barney <sbarney@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2018-10-16 16:33:42 +00:00
Dan McCallum 2da7dd4d4d Rename NRPS v2 `*Finder`s classes to `*Provider`s
- Also renames containing namespace
  - Also renames containing directory from `helpers` to `providers`

Closes LTIA-30

Test Plan:

  - Purely technical change, so tests just need to check for
  regressions:
    1. All automated specs still pass
    2. Round-trip smoke tests still pass:
      2.1. Launch IMS RI from a `Course` with a LTI 1.3/Advantage-
      enabled tool. Verify NRPS v2 callback still returns memberships.
      2.2. Same for a `Group` in that course, except that the
      NRPS v2 callback needs to be performed manually. See Postman-
      based approach in commit log for LTIA-27

Change-Id: Ic4d899cbeaa077d1fa4ee65e0267468c9776d340
Reviewed-on: https://gerrit.instructure.com/167251
Tested-by: Jenkins
QA-Review: Samuel Barney <sbarney@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
2018-10-16 16:32:41 +00:00
Dan McCallum e947caf2b9 Combine User's Course Enrollments to single NRPS Membership
- Previously a User with multiple active Enrollments in the
  requested Course would be represented with a NRPS v2 `member`
  array element per _Enrollment_. That diverged from legacy
  NRPS ('membership service') behavior, which emitted a NRPS
  member per _User_. The legacy behavior is probably what a Tool
  expects. So now Course Enrollments are grouped by User for
  purposes of NRPS v2 response modeling.
  - Resulted in a rather large patch since we could no longer
  filter and page directly on Enrollments. Need to hit
  Users instead. This is much closer to the legacy NRPS approach,
  but this new implementation avoids the N+1 query patterns
  in the original.
  - And since Course and Group handling are no so much different,
  the utility of the shared base `MembershipsFinder` class is
  greatly reduced, as is its size.

Closes LTIA-9

Test Plan:

  * Add a given User to a Course in multiple roles.
  * Accept at least two such Enrollments for that User.
  * Verify that each of the User's active Enrollments in that Course
  are represented by a single NRPS v2 `members` array element, with the
  `roles` array containing a canonical LTI/LIS role URN for each
  Course enrollment.
  * Verify no regressions to NRPS v2 Course Context membership
  pagination behavior.
  * Verify no regressions to NRPS v2 Group Context membership listing
  and/or pagination behavior.

Change-Id: Id0639302672e67189c83a5586e369d87385b5015
Reviewed-on: https://gerrit.instructure.com/166004
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
Tested-by: Jenkins
QA-Review: Pedro Fajardo <pfajardo@instructure.com>
2018-10-01 20:53:17 +00:00
Dan McCallum cca82a4654 Add LTI NRPS v2 Course and Group membership list API
- No-frills support for LTI Advantage Names and Roles Provisioning
  Service version 2. I.e. no query param support, no pagination.
  - Similar to other LTI Adv services, this API is disabled in prod
  env due to incompleteness, esp lack of authN/authZ.
  - URL scheme: `/api/lti/[courses|groups]/:context_id/names_and_roles`

  Closes LTIA-11

  Test Plan
    * Create course with several participating (i.e. invite-accepted)
    and pending enrollments. Add several of those enrolled users to
    one or more groups in that course.
    * Ensure participating enrollments are spread across all base roles
    and several custom roles.
    * GET `/api/lti/[courses|groups]/:context_id/names_and_roles` for
    the course and group, respectively.
    * Verify all participating users returned with correct attribute
    mappings, all non-participating users not returned.
    * See LTIA-11 for additional attribute mapping details, esp
    role mappings.
    * Create another course with no enrollments and an empty group.
    * Verify GET `/api/lti/[courses|groups]/:context_id/names_and_roles`
    returns 200 with an empty `members` array for the course and group,
    respectively.
    * Verify GET `/api/lti/[courses|groups]/:context_id/names_and_roles`
    for non-existent contexts returns 404.

Change-Id: Ib8d174a3d583435423ce41f2488c80ae6d66cb72
Reviewed-on: https://gerrit.instructure.com/165275
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
Tested-by: Jenkins
QA-Review: Pedro Fajardo <pfajardo@instructure.com>
2018-10-01 19:50:21 +00:00
James Williams 77e35d5650 skip permissions for quizzes on planner index
Change-Id: I73cfb0bc9201a4089914ca2b8f0070c78d6ee641
Reviewed-on: https://gerrit.instructure.com/162174
Tested-by: Jenkins
Reviewed-by: Mysti Sadler <mysti@instructure.com>
Reviewed-by: Dan Minkevitch <dan@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-08-28 12:28:52 +00:00
Cody Cutrer 6d82a64c24 moar preloads
refs CORE-1541

Change-Id: I51967c0eebcd4dc6f9282dd9e8b3934dafb62aca
Reviewed-on: https://gerrit.instructure.com/160315
Reviewed-by: Rob Orton <rob@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-08-10 17:28:38 +00:00
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