version 1.17.2.5, 2024/02/27 04:13:34
|
version 1.21, 2024/02/27 04:04:06
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# Utility functions for managing LON-CAPA LTI interactions |
# Utility functions for managing LON-CAPA LTI interactions |
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 34 use Digest::SHA;
|
Line 34 use Digest::SHA;
|
use Digest::MD5 qw(md5_hex); |
use Digest::MD5 qw(md5_hex); |
use Encode; |
use Encode; |
use UUID::Tiny ':std'; |
use UUID::Tiny ':std'; |
use LWP::UserAgent(); |
|
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
Line 55 use LONCAPA qw(:DEFAULT :match);
|
Line 54 use LONCAPA qw(:DEFAULT :match);
|
# When LON-CAPA is operating as a Consumer, nonce checking |
# When LON-CAPA is operating as a Consumer, nonce checking |
# occurs when a Tool Provider launched from an instance of |
# occurs when a Tool Provider launched from an instance of |
# an external tool in a LON-CAPA course makes a request to |
# an external tool in a LON-CAPA course makes a request to |
# (a) /adm/service/roster or (b) /adm/service/passback to, |
# (a) /adm/service/roster or (b) /adm/service/passback to, |
# respectively, retrieve a roster or store the grade for |
# respectively, retrieve a roster or store the grade for |
# the original launch by a specific user. |
# the original launch by a specific user. |
# |
# |
# When LON-CAPA is operating as a Provider, nonce checking |
# When LON-CAPA is operating as a Provider, nonce checking |
# occurs when a user in course context in another LMS (the |
# occurs when a user in course context in another LMS (the |
# Consumer) launches an external tool to access a LON-CAPA URL: |
# Consumer) launches an external tool to access a LON-CAPA URL: |
# /adm/lti/ with LON-CAPA symb, map, or deep-link ID appended. |
# /adm/lti/ with LON-CAPA symb, map, or deep-link ID appended. |
# |
# |
|
|
Line 359 sub verify_lis_item {
|
Line 358 sub verify_lis_item {
|
# LON-CAPA as LTI Consumer |
# LON-CAPA as LTI Consumer |
# |
# |
# Sign a request used to launch an instance of an external |
# Sign a request used to launch an instance of an external |
# tool in a LON-CAPA course, using the key and secret supplied |
# tool in a LON-CAPA course, using the key and secret supplied |
# by the Tool Provider. |
# by the Tool Provider. |
# |
# |
|
|
sub sign_params { |
sub sign_params { |
my ($url,$key,$secret,$paramsref,$sigmethod,$type,$callback,$post) = @_; |
my ($url,$key,$secret,$paramsref,$sigmethod,$type,$callback,$post) = @_; |
Line 693 sub get_roster {
|
Line 692 sub get_roster {
|
? join("&$name=", map {escape($_) } @{$hashref->{$_}}) |
? join("&$name=", map {escape($_) } @{$hashref->{$_}}) |
: &escape($hashref->{$_}) ); |
: &escape($hashref->{$_}) ); |
} keys(%{$hashref}))); |
} keys(%{$hashref}))); |
my $ua=new LWP::UserAgent; |
my $response = &LONCAPA::LWPReq::makerequest('',$request,'','',10); |
$ua->timeout(10); |
|
my $response=$ua->request($request); |
|
my $message=$response->status_line; |
my $message=$response->status_line; |
if (($response->is_success) && ($response->content ne '')) { |
if (($response->is_success) && ($response->content ne '')) { |
my %data = (); |
my %data = (); |
Line 845 END
|
Line 842 END
|
], |
], |
$gradexml, |
$gradexml, |
); |
); |
my $ua=new LWP::UserAgent; |
my $response = &LONCAPA::LWPReq::makerequest('',$request,'','',10); |
$ua->timeout(10); |
|
my $response=$ua->request($request); |
|
my $message=$response->status_line; |
my $message=$response->status_line; |
#FIXME Handle case where pass back of score to LTI Consumer failed. |
#FIXME Handle case where pass back of score to LTI Consumer failed. |
} |
} |
Line 873 sub setup_logout_callback {
|
Line 868 sub setup_logout_callback {
|
&Apache::lonnet::sign_lti($cdom,$cnum,$crstool,'lti','logout',$service_url,$idx, |
&Apache::lonnet::sign_lti($cdom,$cnum,$crstool,'lti','logout',$service_url,$idx, |
$keynum,\%ltiparams,\%info); |
$keynum,\%ltiparams,\%info); |
if (($status eq 'ok') && ($post ne '')) { |
if (($status eq 'ok') && ($post ne '')) { |
my $ua=new LWP::UserAgent; |
|
$ua->timeout(10); |
|
my $request=new HTTP::Request('POST',$service_url); |
my $request=new HTTP::Request('POST',$service_url); |
$request->content($post); |
$request->content($post); |
my $response=$ua->request($request); |
my $response = &LONCAPA::LWPReq::makerequest('',$request,'','',10); |
} |
} |
} |
} |
} |
} |
Line 887 sub setup_logout_callback {
|
Line 880 sub setup_logout_callback {
|
# |
# |
# LON-CAPA as LTI Provider |
# LON-CAPA as LTI Provider |
# |
# |
# Create a new user in LON-CAPA. If the domain's configuration |
# Create a new user in LON-CAPA. If the domain's configuration |
# includes rules for format of "official" usernames, those rules |
# includes rules for format of "official" usernames, those rules |
# will apply when determining if a user is to be created. In |
# will apply when determining if a user is to be created. In |
# additional if institutional user information is available that |
# additional if institutional user information is available that |
Line 1028 sub create_passwd {
|
Line 1021 sub create_passwd {
|
# in the Consumer, user privs will be added to the user's environment for |
# in the Consumer, user privs will be added to the user's environment for |
# the new role. |
# the new role. |
# |
# |
# If this is a self-enroll case, a Course Coordinator role will only be assigned |
# If this is a self-enroll case, a Course Coordinator role will only be assigned |
# if the current user is also the course owner. |
# if the current user is also the course owner. |
# |
# |
|
|
Line 1320 sub batchaddroster {
|
Line 1313 sub batchaddroster {
|
# |
# |
# Which LON-CAPA roles are assignable by the current user |
# Which LON-CAPA roles are assignable by the current user |
# and how LTI roles map to LON-CAPA roles (as defined in |
# and how LTI roles map to LON-CAPA roles (as defined in |
# the domain configuration for the specific Consumer) are |
# the domain configuration for the specific Consumer) are |
# factored in when compiling the list of available roles. |
# factored in when compiling the list of available roles. |
# |
# |
# Inputs: 3 |
# Inputs: 3 |