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>
This commit is contained in:
Evan Battaglia 2020-01-17 10:19:00 -07:00
parent da2915bca5
commit 6e68700f0c
3 changed files with 26 additions and 0 deletions

View File

@ -513,6 +513,15 @@ returns the current course start date.
```
2018-01-15 00:00:00 -0700
```
## Canvas.course.endAt
returns the current course end date.
**Availability**: *when launched in a course*
```
2019-05-10 00:00:00 -0600
```
## Canvas.course.workflowState
returns the current course workflow state. Workflow states of "claimed" or "created"
indicate an unpublished course.

View File

@ -518,6 +518,15 @@ module Lti
-> { @context.start_at },
COURSE_GUARD
# returns the current course end date.
# @example
# ```
# 2018-01-15 00:00:00 -0700
# ```
register_expansion 'Canvas.course.endAt', [],
-> { @context.end_at },
COURSE_GUARD
# returns the current course workflow state. Workflow states of "claimed" or "created"
# indicate an unpublished course.
# @example

View File

@ -1106,6 +1106,14 @@ module Lti
expect(exp_hash[:test]).to eq '2015-05-21 17:01:36'
end
it 'has substitution for $Canvas.course.endAt' do
course.conclude_at = '2019-04-21 17:01:36'
course.save!
exp_hash = {test: '$Canvas.course.endAt'}
variable_expander.expand_variables!(exp_hash)
expect(exp_hash[:test]).to eq '2019-04-21 17:01:36'
end
it 'has a functioning guard for $Canvas.term.name when term.name is not set' do
term = course.enrollment_term
exp_hash = {test: '$Canvas.term.name'}