Add com.instructure.User.student_view variable expansion

At New Quizzes Item Analysis the submissions
with the student view should be excluded. For other LTI tools
it is a useful info that the tool is launched by a student
view `fake student`.

closes: QUIZ-12877
flag=none

test plan:
- have an LTI tool tha could be launched during test steps
- add `canvas_user_student_view=$com.instructure.User.student_view`
  as custom lti parameter

- launch tool with a student user
- ensure `custom_canvas_user_student_view` is false

- launch tool with an admin user
ensure `custom_canvas_user_student_view` is false

- launch tool with from a student view
- ensure `custom_canvas_user_student_view` is true

Change-Id: If86ac6452d01045fc85331aaaf42052a5319f512
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/334992
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Alexis Nast <alexis.nast@instructure.com>
Reviewed-by: Paul Gray <paul.gray@instructure.com>
QA-Review: Rajmund Csehil <rajmund.csehil@instructure.com>
This commit is contained in:
ferenc.marcso 2023-12-09 09:39:29 +01:00 committed by Ferenc Marcsó
parent 8b1b472a4d
commit c08de922e1
3 changed files with 44 additions and 0 deletions

View File

@ -250,6 +250,13 @@ Returns the host of the rich content service for the current region.
```
"rich-content-iad.inscloudgate.net"
```
## com.instructure.User.student_view
Returns true if the user is launching from student view.
**Availability**: *always*
**Launch Parameter**: *com_instructure_user_student_view*
```
## com.instructure.Observee.sisIds
returns all observee ids linked to this observer as an String separated by `,`.

View File

@ -317,6 +317,19 @@ module Lti
},
default_name: "com_instructure_rcs_app_host"
# Returns true if the User is from student view process
#
# @example
# ```
# "true"
# "false"
# ```
register_expansion "com.instructure.User.student_view",
[],
-> { @current_user.fake_student? || false },
USER_GUARD,
default_name: "com_instructure_user_student_view"
# Returns the RCS Service JWT for the current user
#
# @internal

View File

@ -1337,6 +1337,30 @@ module Lti
end
end
describe "$com.instructure.User.student_view" do
subject do
variable_expander.expand_variables!({ test: "$com.instructure.User.student_view" })[:test]
end
context "user is not logged in" do
let(:user) { nil }
it { is_expected.to eq "$com.instructure.User.student_view" }
end
context "user is generated by student view" do
before { allow_any_instance_of(User).to receive(:fake_student?).and_return(true) }
it { is_expected.to be true }
end
context "user is not from student view" do
before { allow_any_instance_of(User).to receive(:fake_student?).and_return(nil) }
it { is_expected.to be false }
end
end
describe "$com.instructure.instui_nav" do
subject do
variable_expander.expand_variables!({ test: "$com.instructure.instui_nav" })[:test]