Commit Graph

106 Commits

Author SHA1 Message Date
Wagner Gonçalves 797058c228 Add custom variable Context.id.history
We're  adding a new custom variable substitution that returns a string
with a comma-separeted list of course ids in reverse chronological order
from which content has been copied related to the current course.

Requesting partners: (Aug2020: Cengage, Sep2020: Google)

closes INTEROP-6145
flag=none

test-plan:
* Have an LTI tool installed in your local Canvas at a course
level that uses the new custom variable.
* Ensure that your current user is enrolled in at least section
in the course the tool is installed in.
* Launch the tool and ensure that under the custom claims you see
the course ids variable expanded to a string that matches the ids where
the content of the current course was copied for.

Change-Id: Ie8fcabf4303f73cd647325a12b5f92974cdde511
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/250268
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
QA-Review: Mysti Lilla <mysti@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
2020-11-10 17:07:34 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
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:49:50 +00:00
Wagner Gonçalves f907d70909 Add custom variable com.instructure.Observee.sisIds
We're adding a custom variable substitution that returns a string of
observee's (students) SIS ids for the current user (observer), in the
context of the current course for LTI toll launches.

closes INTEROP-5940
flag=none

test-plan:
* Have an LTI tool installed in your local Canvas at a course
level that uses the new custom variable.
* Ensure that your current user is enrolled in at least section
in the course the tool is installed in.
* Launch the tool and ensure that under the custom claims you see
the observee ids variable expanded to an array that matches the
students your current user is linked in the current course.

Change-Id: Ib9d019411b991646633a4c3b7bc33ac159635379
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249646
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2020-10-14 19:23:15 +00:00
Ryan Hawkins 9049e62a35 Add custom variable com.instructure.User.sectionNames
In response to a partner request, added a custom variable substitution
that returns an array of section names for the current user, in the
context of the current course for LTI tool launches.
Note that because of the way enrollment information is stored, if a
user launches a tool and is enrolled in
multiple sections in a course (which is common for teachers), then there is
no way to determine which specific section the launch occurred in.

test-plan:
* Have an LTI tool installed in your local Canvas at a course
level that uses the new custom variable.
* Ensure that your current user is enrolled in at least section
in the course the tool is installed in.
* Launch the tool and ensure that under the custom claims you see
the sectionNames variable expanded to an array that matches the
section(s) your current user is enrolled in in the current course.
* Ideally, you should test with a user in one section and in multiple
sections in the current course.

closes INTEROP-4701

flag=none

Change-Id: I58793a3e21d046f965af3983e5361b5a303416c1
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/244645
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Mysti Lilla <mysti@instructure.com>
2020-08-19 17:17:59 +00:00
Ryan Hawkins d72c3c34a1 Use LTI 1.3 lti_id for observees custom field
Previously, when any LTI tool, regardless of version, used the
custom field `com.instructure.User.observees`, a comma separated
list that contained the LTI 1.1 lti_user_id of all the students
the current user was observing in the current context was returned.
Now, if the tool being launched uses LTI 1.3, that list now
uses the lti_id of the students the current user is observing
in the current context instead.

fixes INTEROP-5991

flag = none

test-plan:
* Have an LTI 1.3 and 1.1 tool installed, both of which use the
  `com.instructure.User.observees` custom field.
* Have a user with an observer in the current context (typically
  a course)
* As the observer, launch both tools.
* For the LTI 1.3 tool, verify that the list of students the
  observer is observing matches the students' lti_id's.
* For the LTI 1.1 tool, verify that the list of students the
  observer is observing matches the students' lti_user_ids.
  This can be verified (and is calculated) using
  Lti::Asset.opaque_identifier_for(<your_user>)

Change-Id: I59117f567d1c0548f9e38eaba9cc2f097d59adb7
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/243314
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2020-08-04 02:41:04 +00:00
Han Yan ac18b746bc add an lti launch variable to indicate rldb status
flag=none

closes QUIZ-7736

test plan:
- create a n.q quiz
- go to account > settings > Apps, and find "Quizzes 2" tool
- edit the tool, and add a new Custom Fields as
  custom_canvas_assignment_ldb_enabled=Canvas.assignment.lockdownEnabled
- launch as a teacher, in browser dev tool, find quiz lti launch page,
  and custom_canvas_assignment_ldb_enabled is false
- launch as a student, custom_canvas_assignment_ldb_enabled is false
- configure a N.Q assignment to be LDB auto-launch
   assignment.settings =
     {"lockdown_browser"=>{"require_lockdown_browser"=>true}
   assignment.save!
- repeat teacher and student launch, and see
  custom_canvas_assignment_ldb_enabled should be true

Change-Id: Ie4e48ff6745d72c8e204c8ae060dcab9d3869b68
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242368
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Han Yan <hyan@instructure.com>
2020-07-10 22:06:03 +00:00
wdransfield 0982b0e23c Add com.instructure.User.observees variable expansion
Closes PLAT-5744
flag=none

Test Plan
- Install an LTI tool (LTI version does not matter)
  The new tool should have the following custom
  variable in it's course_navigation config:
  `$com.instructure.User.observees`
- Navigate to a course that contains several students
  and an observer who is linked to more than one
  student
- Act as the observer and launch the tool
- Verify the new variable is expanded to a comma-
  separated list of LTI IDs that identify the
  users the observer can observe

Change-Id: I14d4db655f0732b40da2508af7d149124e4f5bea
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/237058
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Evan Battaglia <ebattaglia@instructure.com>
QA-Review: Evan Battaglia <ebattaglia@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2020-05-14 00:52:40 +00:00
Rob Orton 46e3574900 used script to update LTI documentation
looks like the last commit added some info to the file manually and so
when the script is run it will show that file has changed. Updated the
date to be something more real for documentation when related to start
date

Change-Id: I3dc7af0f80ba4daa7f09ffdcd6fcaaa67d91af09
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/225697
Reviewed-by: Evan Battaglia <ebattaglia@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2020-02-05 23:37:08 +00:00
Evan Battaglia 6e68700f0c add $Canvas.course.endAt LTI variable substitution
closes PLAT-5288
flag=none

Test plan:
* create a course with an end_at date
* set up a tool with the "$Canvas.course.endAt" LTI variable
  substitution
* launch the tool and look at the LTI parameters in dev tools
  and see that the variable is set correctly
* remove the end_at date, relaunch the tool, check that the variable
  is now an emptry string

Change-Id: Ifba70ebd6cb9fe8d39da1d24fb6ae69e97902828
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/223702
Reviewed-by: Marc Phillips <mphillips@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
2020-01-20 18:49:30 +00:00
James Williams b462789a10 query for modules and assignment groups in variable expansion
test plan:
* with the commons favorites flag turned on,
 the modules index placement and assignment index placement
 should send the same launch parameters as before
 (but not send all the module/group data in the iframe url)

flag=commons_favorites
closes #LA-389

Change-Id: I133ef62c7542c3e6ab236f459e5bd22ef759eb3b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/221293
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-12-18 22:19:42 +00:00
James Williams 61b0ebaf7b prefer array for available_canvas_resources variable
test plan:
* launching a tool with the
 module_index_menu and assignment_index_menu placements
 should return an array of hashes for the
 com_instructure_course_available_canvas_resources
 variable, as described in the documentation

refs #LA-75

Change-Id: I2c81ca611a60dfdc67d62823b35319353c4d846d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/218693
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-11-27 13:09:19 +00:00
James Williams ba7f83d080 encode available_canvas_resources variable as JSON
test plan:
* testing with the new index placement tools
 on the assignments/modules page should send
 the available canvas resources encoded
 as a JSON string so the oauth signature works

Change-Id: I329c819a17ca70b84a5d165964246af6e635dacb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/218523
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-11-25 20:27:16 +00:00
James Williams 6990a780e4 add module_index_menu LTI placement
test plan:
* configure a tool with an module_index_menu placement
 (similar to the wiki_index_menu type)
* enable the "Import Commons Favorites" feature
* should launch the tool though a cog dropdown
 in the header of the modules page into a tray
* closing the tray after a message has been posted
 should cause the modules page to refresh

flag=commons_favorites
closes #LA-71 #LA-72

Change-Id: I4ab15bf71da574482b107cbbba295cb4557f4fa8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/217828
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jenkins
Reviewed-by: Carl Kibler <ckibler@instructure.com>
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-11-20 13:35:24 +00:00
wdransfield 4f6b22b87e Add LTI expansion for user pronouns
Closes PLAT-5143

Test Plan:

- Install an LTI tool that uses the new
  $com.instructure.Person.pronouns variable
  expansion
- Do an LTI launch and verify the post parameter
  contains the current user's pronouns

Change-Id: I03ae80e0c6a3fe6a7ada5ce87da8cf8a97299964
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/217430
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jenkins
Product-Review: Weston Dransfield <wdransfield@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Reviewed-by: Evan Battaglia <ebattaglia@instructure.com>
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Evan Battaglia <ebattaglia@instructure.com>
2019-11-18 22:43:37 +00:00
Carl Kibler ed71122c85 send parameters to wiki_index_menu LTI launch
closes ADMIN-2891
flag=none

test plan:
 - Set up new LTI Tool to accept the 4 custom parameters
 - On Pages index, trigger LTI from kabob menu
 - See the 4 new parameters are correctly sent to LTI

Change-Id: Ib3a17d2d9a5d6c5117671061a00365ca86a57d4f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/213879
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Carl Kibler <ckibler@instructure.com>
2019-10-28 20:01:49 +00:00
Simon Williams d4a3346cea bump yard to 0.9.20
https://github.com/lsegal/yard/blob/master/CHANGELOG.md

yard 0.9.6 added functionality which parses code blocks and tries to
auto link constants to their respective yard documentation. this means
that code blocks with invalid constants cause issues, which is why we
need to properly quote strings in our code blocks.

Change-Id: I0814ebb2658935f8bd3d528515acfdb5041d1e0f
Reviewed-on: https://gerrit.instructure.com/212925
Tested-by: Jenkins
Reviewed-by: Cameron Matheson <cameron@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2019-10-14 15:12:49 +00:00
Rob Orton 57616667df make variable expander for grade_passback_setting
fixes CORE-3215

test plan
 - have a course with grade_passback_setting
 - use gradePassbackSetting variable in lti tool
 - it should return the setting

Change-Id: I0f598c8563d9f9d40e1d1f49c483a93bbde364a0
Reviewed-on: https://gerrit.instructure.com/205841
Tested-by: Jenkins
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-08-21 19:57:54 +00:00
James Williams 6a40ee3a00 add variable expansion for hide_distribution_graphs
test plan:
* the expansion "Canvas.course.hideDistributionGraphs"
 should correspond to the course checkbox
 "Hide grade distribution graphs from students"

refs #PLYT-1826

Change-Id: I6172441ac0dfdc4a59396bade794bbfbbf74e893
Reviewed-on: https://gerrit.instructure.com/197368
Tested-by: Jenkins
QA-Review: Nathan Mills <nathanm@instructure.com>
Product-Review: Nathan Mills <nathanm@instructure.com>
Reviewed-by: Nathan Mills <nathanm@instructure.com>
2019-06-13 15:19:31 +00:00
James Williams bb6bd0aeac add permissions variable expansion
also keeps it undocumented for now

test plan:
* test an lti launch in a course using a variable
 in the format:

 $Canvas.membership.permissions<permission1,permission2,..>

 with a comma-separated list in between the brackets
 corresponding to course-level permissions
 (see doc/api/roles.html#method.role_overrides.show), e.g.

 $Canvas.membership.permissions<read_forum,moderate_forum>

 these are the list of permissions to check
 when the variable is expanded it should substitute it with a
 comma-separated list of permissions filtered to those
 that the user has been granted within the course

closes #PLYT-1796

Change-Id: I1c039e04318fcfe8ca5ee450e608bd3fb2affe6b
Reviewed-on: https://gerrit.instructure.com/194797
Tested-by: Jenkins
QA-Review: Nathan Mills <nathanm@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
Reviewed-by: Nathan Mills <nathanm@instructure.com>
Reviewed-by: Marc Phillips <mphillips@instructure.com>
2019-06-12 12:13:28 +00:00
James Williams b0c770470d add variable substitution for section restriction
test plan:
* set up a tool with the "$Canvas.course.sectionRestricted"
 LTI variable substitution
* it should correspond to whether the user was enrolled
 with "Can interact with users in their section only" checked

closes #PLYT-2349

Change-Id: I567a57927f0e5ec1b2dd34529262257f7dc9b527
Reviewed-on: https://gerrit.instructure.com/196878
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: Nathan Mills <nathanm@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-06-10 16:35:12 +00:00
Marc Phillips 273889d6f3 Remove N+1 on NRPS calls
Variable Expansion for sis_ids was causing an n+1 because
the lookup for the pseudonym didn't take into account if
the pseudonyms were preloaded.

Because of this, several other expansions would have produced
n+1s, so all known n+1 scenarios have been fixed.

fixes PLAT-4241

Test Plan:
 tests pass

Change-Id: Ib39068e8e5f1e17a0963443148438b1d16287526
Reviewed-on: https://gerrit.instructure.com/195731
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Marc Phillips <mphillips@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
2019-05-30 19:04:14 +00:00
Rob Orton 128a4cb3cc use sis_pseudonym from enrollment if there is one
fixes CORE-2926

test plan
 - specs should pass

Change-Id: I0b349bc44aecffbcede7093b0689e686c49fe0bb
Reviewed-on: https://gerrit.instructure.com/192886
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2019-05-14 15:18:40 +00:00
Rob Orton 003ed64763 use the sis_id tied to enrollments for lit2 launch
refs CORE-2850

test plan
 - have a user with a sis enrolled course
 - have a second sis_id for the user
 - it should return the sis for enrollment on
   lti_launch

Change-Id: I3de963944465e7e49b768e898762362e1c463c7f
Reviewed-on: https://gerrit.instructure.com/191080
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: Nathan Mills <nathanm@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2019-04-26 21:17:53 +00:00
Rob Orton e5291c04db rename user_past_lti_ids to user_past_lti_id
Change-Id: If7801aa4af6e39af0f885eba78e354ec7096db29
Reviewed-on: https://gerrit.instructure.com/189636
Tested-by: Jenkins
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2019-04-17 19:11:29 +00:00
Rob Orton c4de231b0e support past lti ids for users
when a user_a is merged into user_b, user_a is
deleted, but the enrollments lti_tools still point
to the old lti_id, so this allows us to store them
and serve them as the lti_id when a user is merged

fixes CORE-2565

test plan
 - merge a user that uses an lti tool in a course
 - the lti_id should not change for that course

Change-Id: Iac70957ed1fcb08111745a91d0c2e402dfad3002
Reviewed-on: https://gerrit.instructure.com/181905
Tested-by: Jenkins
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2019-03-28 22:03:07 +00:00
James Williams 0962ef21f4 use sispseudonym to find lti sis_email
closes #PLAT-4274

Change-Id: I44770570d052dcc2eec995c2c85c64c3a3060bae
Reviewed-on: https://gerrit.instructure.com/185168
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2019-03-18 16:17:55 +00:00
Marc Phillips bdcd348962 Revert "Fix global_navigation showing context roles"
This reverts commit aa23d87dc9.

Change-Id: I171bb684b04874b80fc491023cbeb7484997ae7a
Reviewed-on: https://gerrit.instructure.com/185021
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-03-12 22:07:09 +00:00
Marc Phillips aa23d87dc9 Fix global_navigation showing context roles
closes PLAT-4115

Test Plan:
 - Install a tool with a global_navigation or user_navigation
   placement
 - launch the tool from these locations and note that they
   don't pass the context roles of the use

Change-Id: I9810fc9745d26e5623a67f66988dbb97b25c606b
Reviewed-on: https://gerrit.instructure.com/182351
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Weston Dransfield <wdransfield@instructure.com>
Product-Review: Marc Phillips <mphillips@instructure.com>
Tested-by: Jenkins
2019-02-28 20:17:01 +00:00
wdransfield 61d200a3e7 Use ext_roles for roles claim in LTI 1.3 launches
Closes PlAT-4110

Test Plan:
- Do an LTI 1.3 launch
- Verify the roles claim contains the `ext_roles`
  from LTI 1 rather than the `roles`.

Change-Id: I9d20a33b6a2f8997353f4198de880a80df43ed8c
Reviewed-on: https://gerrit.instructure.com/177280
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-10 22:23:43 +00:00
Dan McCallum f89d9ee839 Share LTI 1.3 role map between NRPS and launch
- For the `$Membership.role` and `$com.Instructure.membership.roles`
  custom params, calculate role URNs using
  `LIS_V2_LTI_ADVANTAGE_ROLE_MAP` for 1.3 tools, else
  `LIS_V2_ROLE_MAP`.
  - This way the `https://purl.imsglobal.org/spec/lti/claim/roles`
  launch claim matches up with the NRPS `roles` field _except_ that
  NRPS `roles` doesn't include system nor institution roles
  (N+1 issues).
  - Really the only meaningful difference is the TA role URN, where
  `LIS_V2_LTI_ADVANTAGE_ROLE_MAP` corrects a typo in the
  `LIS_V2_ROLE_MAP`. See `SubstitutionsHelper` line ~61 for all the
  differences.
  - Since the contents of `LIS_V2_LTI_ADVANTAGE_ROLE_MAP` changed
  to include additional roles to support launches but which should not
  be used as NRPS role filters, `MembershipsProvider.lis_roles` also
  needed to change to filter those roles out. So took the opportunity
  to rename that method to `queryable_roles` to avoid confusion with
  `GroupMembershipDecorator.lti_roles` and
  `CourseEnrollmentsDecorator.lti_roles` methods that perform the
  mapping in the _opposite_ direction.

Closes LTIA-42

Test Plan

  - Place a 1.3 tool in a `Course` with several active members, at
  least one of which is in a TA role.
  - Ensure the tool's configuration includes mappings for the
  `$Membership.role` and `$com.Instructure.membership.roles` custom
  params.
  - Launch the tool for several members and verify correct contents
  of:
    - `https://purl.imsglobal.org/spec/lti/claim/roles`
    - `https://purl.imsglobal.org/spec/lti/claim/custom['com_instructure_membership_roles']`
    - `https://purl.imsglobal.org/spec/lti/claim/custom['membership_role']`
  In particular, the first two should match and for a TA all three
  should include
  `http://purl.imsglobal.org/vocab/lis/v2/membership/Instructor#TeachingAssistant`
  (capital 'I').
  - Invoke NRPS for this tool and `Course`. For each `member`, the
  `roles` field should match the first two launch fields listed
  above _except_ that system and institution roles are _not_ listed.
  The `com_instructure_membership_roles` and `membership_role` custom
  params should render unexpanded, i.e. literally as
  `$com.Instructure.membership.roles` and `$Membership.role`.

Change-Id: I315220edd0b5500934ede9a82047cc0206fbd8f5
Reviewed-on: https://gerrit.instructure.com/169626
Tested-by: Jenkins
Reviewed-by: Marc Phillips <mphillips@instructure.com>
QA-Review: Bill Smith <bsmith@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2018-10-26 21:44:19 +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
Jared Crystal 8528c3bb00 add sortable_name as variable expansion
refs AMS-1444

test plan:
 - sortable name is available to LTI tools as a
   variable expansion

Change-Id: I21b94845a34ff668caa37619de2d5eede4fd0099
Reviewed-on: https://gerrit.instructure.com/167591
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: Jared Crystal <jcrystal@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2018-10-19 16:52:33 +00:00
James Williams 1a82392bf3 fix group lti variables with non-group assignments
closes #PLAT-3681

Change-Id: I0d55e46e52a592d83b005fb4fda5b4c8bd3fd148
Reviewed-on: https://gerrit.instructure.com/163056
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
2018-09-04 17:14:09 +00:00
wdransfield d99d409780 Add anonymous grading substitution
Closes PLAT-2222

Test Plan:
- Create an assignment with anonymous_grading set to
  true.
- Launch a tool that uses the new
  'com.instructure.Assignment.anonymous_grading'
  substitution in a context of the assignment.
- Verify the parameter value is 'true'
- Set the anonymous_grading attribute of the
  assignment to false.
- Launch the tool again and verify the parameter
  value is 'false'

Change-Id: I8de86dd166a4bbae68b63aef08b0e4dc6dc9fbbf
Reviewed-on: https://gerrit.instructure.com/160935
Reviewed-by: Han Ngo <hngo@instructure.com>
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: Nathan Mills <nathanm@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2018-08-16 15:40:27 +00:00
wdransfield 0f14bf4d93 Add LTI 1.3 Launch Path
Closes PLAT-3629

Test Plan:
- Install an LTI 1 tool in a course
- Modify the tool via the Rails console:
  `tool.settings['use_1_3'] = true; tool.save!`
- Add the tool to a module item
- Launch the tool and verify a JWT is sent as the 'id_token'
- Verify the JWT contains all required LTI 1.3 claims (minus
  security claims).
- Verify all claim data is accurate
- Verify the JWT contains all extensions Canvas sends
  from the same placement in LTI 1.1
- Verify custom variables are sent and expanded
- Create an External Tool assignment with the same tool
- View the assignment and verify a JWT is sent as the
  'id_token'
- Verify the JWT contains all required LTI 1.3 claims (minus
  the security claims).
- Verify the JWT contains all extension Canvas sends in LTI 1
  (ext_ LTI 1 params) as extension claims.

Note: For now the id_token is signed with a placeholder secret.

Change-Id: I7df3d150055bb30010bb509e4d40dde82a406631
Reviewed-on: https://gerrit.instructure.com/158907
Tested-by: Jenkins
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
Product-Review: Marc Alan Phillips <mphillips@instructure.com>
QA-Review: Marc Alan Phillips <mphillips@instructure.com>
2018-08-08 16:43:58 +00:00
wdransfield edb63589e9 Add com.instructure.Course.groupIds varaible expansion
Closes PLAT-3106

Test Plan:
- Create several groups in a course.
- Install a tool that uses the new $com.instructure.Course.groupIds
  variable expansion.
- Launch the tool from the coures nave and verify the
  param value is a list of Canvas ids for each group in the course.
- Launch the tool from an assignment and verify the same thing.
- Verify groups that are soft deleted are not included.

Change-Id: I36cc73525361c54505c5f0d4c4df57a549c97718
Reviewed-on: https://gerrit.instructure.com/140804
Tested-by: Jenkins
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2018-03-01 17:45:35 +00:00
Nathan Mills bde75c653d update ext_roles documentation
fixes PLAT-3154

test plan:
the updated documentation should make it clear how the
ext_roles and Canvas.xuser.allRoles variable expansion work.

Change-Id: I6482bf6c6b4e19cd61f36db0b9d34cf2ea94b978
Reviewed-on: https://gerrit.instructure.com/141781
Tested-by: Jenkins
Reviewed-by: Marc Alan Phillips <mphillips@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Karl Lloyd <karl@instructure.com>
2018-02-26 20:02:01 +00:00
wdransfield 6b465dd804 Fix last N+1 for adding originality_data to submission_history
Closes: GRADE-861

Test Plan
- Verify there are no N+1 queries when loading speedgrader
  caused by originality reports
- Verify there are no N+1 queries when loading gradebook
  caused by originality reports
- Verify originality reports are copied to all submissions
  in a group when they are created or updated in a group
  assignment.
- Verify online upload originality reports are displayed
  correctly in speedgrader, gradebook, student grade page,
  and submission details page.
- Verify originality reports display properly in gradebook
  and speed grader when there are multiple submissions
  and each has a different originality report.
- Verify the "resubmit to plagiarism tool" button still
  appears in speedgrader.
- Verify originality reports for group assignments are displayed
  correctly.
- Verify text entry originality reports are displayed correctly.
- Verify originality report launches work correctly from speedgrader
  and gradebook.

Change-Id: I459bbf0a165bb131d58fc153feb0dce3d0bf07af
Reviewed-on: https://gerrit.instructure.com/141321
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2018-02-22 17:01:41 +00:00
wdransfield bc20165672 Update membership expansion documentation
Refs CNVS-41279

Test Plan:
Verify the new documentation is clear that
Canvas.xuser.allRoles does not scope roles
to the launch context.

Verify that the Canvas.membership.roles
expansion now has a default name
(not required to address this issue,
just more convenient for the TP).

Change-Id: I182b2dbd51e47063b959c4568f9d1880d044d7ae
Reviewed-on: https://gerrit.instructure.com/140784
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2018-02-13 21:45:55 +00:00
wdransfield 9dfbb56af1 Add group id variable substitution
Closes PLAT-3036

Test Plan:
- Create an assignment that uses a plagiarism tool and is a group
  assignment. The tool should use both new variable expansions.
- Verify all originality report launches show the correct
  group id and name for the current user.

Change-Id: Id2908ff649e4e931f6a76992871ebebe7558d88b
Reviewed-on: https://gerrit.instructure.com/139504
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-09 20:20:24 +00:00
Rob Orton b5de0458d9 dots and new lines
test plan
 - specs should pass

Change-Id: Iafc7c9b8ca64f32568e658b600e19c2e6f9045ca
Reviewed-on: https://gerrit.instructure.com/138026
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
2018-01-17 16:56:26 +00:00
Andrew Butterfield f9d1e029a0 Revert previousCourseId variable substitution change
fixes PLAT-2961

Reverts d3d4cc58e0 but also adds
functionality with new variable expansion

Test plan:
* Ensure $Canvas.course.previousContextIds works as it did before
* Ensure $Canvas.course.previousContextIds.recursive works the way the
  new changed intended

Change-Id: I737c2bdca2936e092fb6a929adb009cdc79b89d5
Reviewed-on: https://gerrit.instructure.com/136245
Tested-by: Jenkins
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: August Thornton <august@instructure.com>
Product-Review: Andrew Butterfield <abutterfield@instructure.com>
2017-12-21 17:37:05 +00:00
wdransfield a8b009c77d Remove attachment dependancy for originality reports
Closes PLAT-2953

Test Plan:
- Create an assignment associated with a plag tool
  that uses the `text entry` submission option
- As a student submit to the assignment
- With the tool attempt to request the submission
  via the LTI API and verify the submission
  is received
- With the tool attempt to create an originality report
  for the submission _without_ specifying an attachment
  id (since there is no attachment for the assignment)
- Verify the report is created and is visible in the
  following locations:
    * Speedgrader
    * gradebook
    * student grades page
  Note that for parity it does not need to be visible in the
  submission details page.
- Attempt to edit the the report via each of the 3 update endpoints
  (let me know if you don't know what 3 those are) and verify
  update works. When testing these first create other originality
  reports for other assignemnts in the course to verify the correct
  originality report is updated.
- Verify that clicking on originality reports from each part of the UI
  initiates an LTI launch to the tool
- Verify that the entire plagiarism platform flow still works for
  file upload assignments

Change-Id: I318f605dace31c92ae3954f26ec2aefa3e8ad90e
Reviewed-on: https://gerrit.instructure.com/135409
Tested-by: Jenkins
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Weston Dransfield <wdransfield@instructure.com>
2017-12-19 18:06:18 +00:00
Marc Alan Phillips 08b1df3440 Enable Person.name.display as an option
Allows for lti launch where you can expand the display name of
a user in lti tools for use.

closes PLAT-2776

Test Plan:
 - Create an lti config that uses Person.name.display
 - Do an lti launch and verify that the expanded value as a param
 - For LTI 2, create a tool proxy that includes the Personl.name.display
  capability
 - Repeat step 2

Change-Id: I7f919bb9af2bb1efb42d8a3bd76cfb3b69378152
Reviewed-on: https://gerrit.instructure.com/134518
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Marc Alan Phillips <mphillips@instructure.com>
2017-12-04 21:07:03 +00:00
Andrew Gardener 7a4b4d82b8
Add term name to tools variable substitutions
test plan:
* add a new custom field, `term_name=$Canvas.term.name`, to an external tool
* open launch link to external tool
* verify that `custom_term_name` was part of the launch request and is correct
2017-11-22 13:03:32 -08:00
Ryan Shaw cc49521daa Fix link & brand-primary color HC & ie11
Closes: CNVS-38498 CORE-25 CORE-338

test plan:
* turn on high contrast
* using ie11, make sure that all the links and things that should
  be the brand-primary color look right. (Dark, not light, blue)
* make sure they also look good in edge 15 and chrome with HC on.

Change-Id: I83cb35aa40c774bcd8e4c0a1a18b8cb0875e9a0c
Reviewed-on: https://gerrit.instructure.com/129911
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2017-11-02 17:36:22 +00:00
wdransfield c0f7738cea Add text editor contents and selection variable expansions
Closes PLAT-2792

Test Plan:
- Install a tool that uses the new
  'com.instructure.Editor.contents' and
  'com.instructure.Editor.selection' varaiable
  expansions in a content item launch.
- Navigate to a page that uses the RCE
- Enter some content in the editor and highlight
  a portion of that content.
- Do a launch and verify the complete contents of the
  editor is sent as com.instructure.Editor.contents and
  the selected content is sent as com.instructure.Editor.selection.

Change-Id: Id2b3104b6324aa62d9ae3025b593de367eb5d6a3
Reviewed-on: https://gerrit.instructure.com/129005
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Product-Review: Karl Lloyd <karl@instructure.com>
2017-10-16 20:10:02 +00:00
Jeff Belser 9a78c89799 variable substitution for brand config JSON
refs PLAT-2840

Test plan:
  1. Install an LTI tool with the variable substitution:
     `com.instructure.brandConfigJSON`
  2. Ensure that it appears on launch as the brand config JSON
  3. Ensure it is well documented within variable expander writeup
  4. Tests pass

Change-Id: I4bfa7db8e89fa0f0ae2b0a81a610b97e556d69e9
Reviewed-on: https://gerrit.instructure.com/128374
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins
Product-Review: Jeff Belser <jbelser@instructure.com>
2017-10-13 22:25:55 +00:00
Andrew Butterfield d29aaaf6a1 Add Lti Link model for LTI 2 launches
refs PLAT-2724

Test plan:
* Regression test plagiarism platform

Change-Id: I98fd4efc5f259bd73747337d07a7e2ec2508dbb0
Reviewed-on: https://gerrit.instructure.com/122906
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Nathan Mills <nathanm@instructure.com>
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Andrew Butterfield <abutterfield@instructure.com>
2017-10-02 22:32:18 +00:00
Andrew Butterfield 6b3e3389a9 Add LTI variable substitutions for brand config urls
fixes PLAT-2840

Test plan:
* Install a tool with the following variable substitutions
  com.instructure.brandConfigJSON.url
  com.instructure.brandConfigJS.url
* Ensure that they are subtituted on launch
* Ensure that the variable expander documentation includes these
  substitutions

Change-Id: I0c0287b8b4bd029c9dd0619a5f08d8a3b9306c02
Reviewed-on: https://gerrit.instructure.com/126806
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
Reviewed-by: Weston Dransfield <wdransfield@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Andrew Butterfield <abutterfield@instructure.com>
2017-09-27 18:04:44 +00:00