add custom_time_zone parameter to lti launches
test plan: * create a external tool with a custom field keys like: custom_time_zone=$Person.address.timezone custom_time_zone2=$Canvas.user.timezone custom_offset=$Canvas.user.timezone.offset * confirm that the tool launch parameters includes the custom keys substituted with the current set time zone or time zone offset (which derives from the user, or the root account) fixes #CNVS-6281 Change-Id: I9bf44f7ba10b2c7f68cae65496caba30ff601f15 Reviewed-on: https://gerrit.instructure.com/21621 QA-Review: Clare Strong <clare@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
parent
7a89817a25
commit
01b4192045
|
@ -65,6 +65,21 @@ class VariableSubstitutor
|
|||
@launch.tool.include_name? ? @launch.user.first_name : nil
|
||||
end
|
||||
|
||||
# $Person.address.timezone
|
||||
def sub_Person_address_timezone
|
||||
Time.zone || nil
|
||||
end
|
||||
|
||||
# $Canvas.user.timezone
|
||||
def sub_Canvas_user_timezone
|
||||
Time.zone || nil
|
||||
end
|
||||
|
||||
# $Canvas.user.timezone.offset
|
||||
def sub_Canvas_user_timezone_offset
|
||||
Time.zone ? Time.zone.formatted_offset : nil
|
||||
end
|
||||
|
||||
# returns the same LIS Role values as the default 'roles' parameter,
|
||||
# but for concluded enrollments
|
||||
# $Canvas.membership.concludedRoles
|
||||
|
|
|
@ -68,6 +68,38 @@ describe "External Tools" do
|
|||
doc.at_css('form#tool_form input#lis_outcome_service_url').should be_nil
|
||||
end
|
||||
|
||||
it "should include time zone in LTI paramaters if included in custom fields" do
|
||||
@tool.custom_fields = {
|
||||
"custom_time_zone" => "$Person.address.timezone",
|
||||
"custom_user_time_zone" => "$Canvas.user.timezone",
|
||||
"custom_user_offset" => "$Canvas.user.timezone.offset"
|
||||
}
|
||||
@tool.save!
|
||||
student_in_course(:course => @course, :active_all => true)
|
||||
user_session(@user)
|
||||
|
||||
account = @course.root_account
|
||||
account.default_time_zone = 'Alaska'
|
||||
account.save!
|
||||
|
||||
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
response.should be_success
|
||||
doc = Nokogiri::HTML.parse(response.body)
|
||||
doc.at_css('form#tool_form input#custom_time_zone')['value'].should == "(GMT-09:00) Alaska"
|
||||
doc.at_css('form#tool_form input#custom_user_time_zone')['value'].should == "(GMT-09:00) Alaska"
|
||||
doc.at_css('form#tool_form input#custom_user_offset')['value'].should == "-09:00"
|
||||
|
||||
@user.time_zone = "Hawaii"
|
||||
@user.save!
|
||||
|
||||
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
|
||||
response.should be_success
|
||||
doc = Nokogiri::HTML.parse(response.body)
|
||||
doc.at_css('form#tool_form input#custom_time_zone')['value'].should == "(GMT-10:00) Hawaii"
|
||||
doc.at_css('form#tool_form input#custom_user_time_zone')['value'].should == "(GMT-10:00) Hawaii"
|
||||
doc.at_css('form#tool_form input#custom_user_offset')['value'].should == "-10:00"
|
||||
end
|
||||
|
||||
it "should redirect if the tool can't be configured" do
|
||||
@tag.update_attribute(:url, "http://example.net")
|
||||
|
||||
|
|
Loading…
Reference in New Issue