add new variable substitutions - term and cousre start date
fixes PLAT-832 test plan: Add the custom field CourseStartDate=$Canvas.course.startAt to an external app make sure the value of CourseStartDate resolves to the start date of the class (if a start date is set) Add the custom field TermStart=$Canvas.term.startAt to an external app make sure the value of TermStart resovles to the start date of the term (if a start date is set) Change-Id: Ie205497a544bdeabd72ca1f37981dcd343f34ed1 Reviewed-on: https://gerrit.instructure.com/52726 Reviewed-by: Brad Horrocks <bhorrocks@instructure.com> Reviewed-by: Nathan Mills <nathanm@instructure.com> Tested-by: Jenkins QA-Review: August Thornton <august@instructure.com> Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
parent
4a8a1fa2b1
commit
28195523f8
|
@ -37,6 +37,8 @@ module Lti
|
|||
end
|
||||
|
||||
COURSE_GUARD = -> { @context.is_a? Course }
|
||||
TERM_START_DATE_GUARD = -> { @context.is_a?(Course) && @context.enrollment_term &&
|
||||
@context.enrollment_term.start_at }
|
||||
USER_GUARD = -> { @current_user }
|
||||
PSEUDONYM_GUARD = -> { sis_pseudonym }
|
||||
ENROLLMENT_GUARD = -> { @current_user && @context.is_a?(Course) }
|
||||
|
@ -46,7 +48,6 @@ module Lti
|
|||
USAGE_RIGHTS_GUARD = -> { @attachment && @attachment.usage_rights}
|
||||
MEDIA_OBJECT_ID_GUARD = -> {@attachment && (@attachment.media_object || @attachment.media_entry_id )}
|
||||
|
||||
|
||||
def initialize(root_account, context, controller, opts = {})
|
||||
@root_account = root_account
|
||||
@context = context
|
||||
|
@ -119,6 +120,14 @@ module Lti
|
|||
-> { @context.sis_source_id },
|
||||
COURSE_GUARD
|
||||
|
||||
register_expansion 'Canvas.course.startAt', [],
|
||||
-> { @context.start_at },
|
||||
COURSE_GUARD
|
||||
|
||||
register_expansion 'Canvas.term.startAt', [],
|
||||
-> { @context.enrollment_term.start_at },
|
||||
TERM_START_DATE_GUARD
|
||||
|
||||
register_expansion 'CourseSection.sourcedId', [],
|
||||
-> { @context.sis_source_id },
|
||||
COURSE_GUARD
|
||||
|
@ -187,7 +196,6 @@ module Lti
|
|||
register_expansion 'Canvas.xuser.allRoles', [],
|
||||
-> { lti_helper.all_roles }
|
||||
|
||||
|
||||
# Substitutions for the primary pseudonym for the user for the account
|
||||
# This should hold all the SIS information for the user
|
||||
# This may not be the pseudonym the user is actually gingged in with
|
||||
|
@ -242,7 +250,6 @@ module Lti
|
|||
-> { @content_tag.id },
|
||||
CONTENT_TAG_GUARD
|
||||
|
||||
|
||||
register_expansion 'Canvas.assignment.id', [],
|
||||
-> { @assignment.id },
|
||||
ASSIGNMENT_GUARD
|
||||
|
|
|
@ -235,6 +235,35 @@ module Lti
|
|||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq '5a,6b'
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.course.startAt' do
|
||||
course.start_at = '2015-04-21 17:01:36'
|
||||
course.save!
|
||||
exp_hash = {test: '$Canvas.course.startAt'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq '2015-04-21 17:01:36'
|
||||
end
|
||||
|
||||
it 'has a functioning guard for $Canvas.term.startAt when term.start_at is not set' do
|
||||
term = course.enrollment_term
|
||||
exp_hash = {test: '$Canvas.term.startAt'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
|
||||
unless term && term.start_at
|
||||
expect(exp_hash[:test]).to eq '$Canvas.term.startAt'
|
||||
end
|
||||
end
|
||||
|
||||
it 'has substitution for $Canvas.term.startAt when term.start_at is set' do
|
||||
course.enrollment_term ||= EnrollmentTerm.new
|
||||
term = course.enrollment_term
|
||||
|
||||
term.start_at = '2015-05-21 17:01:36'
|
||||
term.save
|
||||
exp_hash = {test: '$Canvas.term.startAt'}
|
||||
subject.expand_variables!(exp_hash)
|
||||
expect(exp_hash[:test]).to eq '2015-05-21 17:01:36'
|
||||
end
|
||||
end
|
||||
|
||||
context 'context is a course with an assignment' do
|
||||
|
@ -261,8 +290,6 @@ module Lti
|
|||
expect(exp_hash[:test]).to eq 10
|
||||
end
|
||||
|
||||
|
||||
|
||||
it 'has substitution for $Canvas.assignment.unlockAt' do
|
||||
assignment.stubs(:unlock_at).returns(right_now.to_s)
|
||||
exp_hash = {test: '$Canvas.assignment.unlockAt'}
|
||||
|
|
Loading…
Reference in New Issue