version 1.6, 2018/03/23 01:01:47
|
version 1.12, 2018/05/14 20:10:15
|
Line 43 sub handler {
|
Line 43 sub handler {
|
my $r = shift; |
my $r = shift; |
my $requri = $r->uri; |
my $requri = $r->uri; |
# |
# |
|
# Check for existing session, and temporarily delete any form items |
|
# in %env, if session exists |
|
# |
|
my %savedform; |
|
my $handle = &Apache::lonnet::check_for_valid_session($r); |
|
if ($handle ne '') { |
|
foreach my $key (sort(keys(%env))) { |
|
if ($key =~ /^form\.(.+)$/) { |
|
$savedform{$1} = $env{$key}; |
|
delete($env{$key}); |
|
} |
|
} |
|
} |
|
# |
# Retrieve data POSTed by LTI Consumer on launch |
# Retrieve data POSTed by LTI Consumer on launch |
# |
# |
&Apache::lonacc::get_posted_cgi($r); |
&Apache::lonacc::get_posted_cgi($r); |
Line 52 sub handler {
|
Line 66 sub handler {
|
$params->{$1} = $env{$key}; |
$params->{$1} = $env{$key}; |
} |
} |
} |
} |
|
# |
|
# Check for existing session, and restored temporarily |
|
# deleted form items to %env, if session exists. |
|
# |
|
if ($handle ne '') { |
|
if (keys(%savedform)) { |
|
foreach my $key (sort(keys(%savedform))) { |
|
$env{'form.'.$key} = $savedform{$key}; |
|
} |
|
} |
|
} |
|
|
unless (keys(%{$params})) { |
unless (keys(%{$params})) { |
&invalid_request($r,1); |
&invalid_request($r,1); |
Line 140 sub handler {
|
Line 165 sub handler {
|
# Order is: |
# Order is: |
# |
# |
# (a) from custom_coursedomain item in POSTed data |
# (a) from custom_coursedomain item in POSTed data |
# (b) from tail of requested URL (after /adm/lti) if it has format of a symb |
# (b) from tail of requested URL (after /adm/lti/) if it has format of a symb |
# (c) from tail of requested URL (after /adm/lti) if it has format of a map |
# (c) from tail of requested URL (after /adm/lti) if it has format of a map |
# (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID |
# (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID |
# (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/\w+ |
# (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/\w+ |
Line 182 sub handler {
|
Line 207 sub handler {
|
$symb = $tail; |
$symb = $tail; |
$symb =~ s{^/+}{}; |
$symb =~ s{^/+}{}; |
} |
} |
|
} elsif ($tail =~ m{^/res/(?:$match_domain)/(?:$match_username)/.+\.(?:sequence|page)(|___\d+___.+)$}) { |
|
if ($1 eq '') { |
|
$mapurl = $tail; |
|
} else { |
|
$symb = $tail; |
|
$symb =~ s{^/+}{}; |
|
} |
} elsif ($tail =~ m{^/($match_domain)/($match_courseid)$}) { |
} elsif ($tail =~ m{^/($match_domain)/($match_courseid)$}) { |
($urlcdom,$urlcnum) = ($1,$2); |
($urlcdom,$urlcnum) = ($1,$2); |
if (($cdom ne '') && ($cdom ne $urlcdom)) { |
if (($cdom ne '') && ($cdom ne $urlcdom)) { |
Line 262 sub handler {
|
Line 294 sub handler {
|
$protocol = 'https'; |
$protocol = 'https'; |
} |
} |
|
|
|
if (exists($params->{'oauth_callback'})) { |
|
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0A; |
|
} else { |
|
$Net::OAuth::PROTOCOL_VERSION = Net::OAuth::PROTOCOL_VERSION_1_0; |
|
} |
|
|
my ($itemid,$consumer_key,$secret); |
my ($itemid,$consumer_key,$secret); |
$consumer_key = $params->{'oauth_consumer_key'}; |
$consumer_key = $params->{'oauth_consumer_key'}; |
if (ref($lti_by_key{$consumer_key}) eq 'ARRAY') { |
if (ref($lti_by_key{$consumer_key}) eq 'ARRAY') { |
Line 329 sub handler {
|
Line 367 sub handler {
|
# |
# |
# (a) from course mapping (if the link between Consumer "course" and |
# (a) from course mapping (if the link between Consumer "course" and |
# Provider "course" has been established previously). |
# Provider "course" has been established previously). |
# (b) from tail of requested URL (after /adm/lti) if it has format of a symb |
# (b) from tail of requested URL (after /adm/lti/) if it has format of a symb |
# (c) from tail of requested URL (after /adm/lti) if it has format of a map |
# (c) from tail of requested URL (after /adm/lti) if it has format of a map |
# (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID |
# (d) from tail of requested URL (after /adm/lti) if it has format /domain/courseID |
# (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/\w+ |
# (e) from tail of requested URL (after /adm/lti) if it has format /tiny/domain/\w+ |
Line 400 sub handler {
|
Line 438 sub handler {
|
my @lcroleorder = ('cc','in','ta','ep','st'); |
my @lcroleorder = ('cc','in','ta','ep','st'); |
my @ltiroleorder = ('Instructor','TeachingAssistant','Mentor','Learner'); |
my @ltiroleorder = ('Instructor','TeachingAssistant','Mentor','Learner'); |
if ($params->{'roles'} =~ /,/) { |
if ($params->{'roles'} =~ /,/) { |
my @possltiroles = split(/\s*,\s*/,$params->{'role'}); |
my @possltiroles = split(/\s*,\s*/,$params->{'roles'}); |
foreach my $ltirole (@ltiroleorder) { |
foreach my $ltirole (@ltiroleorder) { |
if (grep(/^\Q$ltirole\E$/,@possltiroles)) { |
if (grep(/^\Q$ltirole\E$/,@possltiroles)) { |
push(@ltiroles,$ltirole); |
push(@ltiroles,$ltirole); |
Line 484 sub handler {
|
Line 522 sub handler {
|
} |
} |
if ($lcauth eq '') { |
if ($lcauth eq '') { |
$lcauth = $lti{$itemid}{'lcauth'}; |
$lcauth = $lti{$itemid}{'lcauth'}; |
$lcauthparm = $lti{$itemid}{'lcauthparm'}; |
if ($lcauth eq 'internal') { |
|
$lcauthparm = &create_passwd(); |
|
} else { |
|
$lcauthparm = $lti{$itemid}{'lcauthparm'}; |
|
} |
} |
} |
} else { |
} else { |
&invalid_request($r,12); |
&invalid_request($r,12); |
Line 542 sub handler {
|
Line 584 sub handler {
|
if (($ltiroles[0] eq 'Instructor') && ($lcroles[0] eq 'cc') && ($lti{$itemid}{'mapcrs'}) && |
if (($ltiroles[0] eq 'Instructor') && ($lcroles[0] eq 'cc') && ($lti{$itemid}{'mapcrs'}) && |
($lti{$itemid}{'makecrs'})) { |
($lti{$itemid}{'makecrs'})) { |
unless (&Apache::lonnet::usertools_access($uname,$udom,'lti','reload','requestcourses')) { |
unless (&Apache::lonnet::usertools_access($uname,$udom,'lti','reload','requestcourses')) { |
&Apache::lonnet::put('environment',{ 'requestcourses.lti' => 1, },$udom,$uname); |
&Apache::lonnet::put('environment',{ 'requestcourses.lti' => 'autolimit=', },$udom,$uname); |
} |
} |
} |
} |
} else { |
} else { |
Line 811 sub lti_session {
|
Line 853 sub lti_session {
|
&Apache::lonauth::success($r,$uname,$udom,$uhome,'noredirect'); |
&Apache::lonauth::success($r,$uname,$udom,$uhome,'noredirect'); |
if ($symb) { |
if ($symb) { |
$env{'form.symb'} = $symb; |
$env{'form.symb'} = $symb; |
|
$env{'request.lti.uri'} = $symb; |
} else { |
} else { |
if ($mapurl) { |
if ($mapurl) { |
$env{'form.origurl'} = $mapurl; |
$env{'form.origurl'} = $mapurl; |
|
$env{'request.lti.uri'} = $mapurl; |
} elsif ($tail =~ m{^\Q/tiny/$cdom/\E\w+$}) { |
} elsif ($tail =~ m{^\Q/tiny/$cdom/\E\w+$}) { |
$env{'form.origurl'} = $tail; |
$env{'form.origurl'} = $tail; |
|
$env{'request.lti.uri'} = $tail; |
|
} elsif ($tail eq "/$cdom/$cnum") { |
|
$env{'form.origurl'} = '/adm/navmaps'; |
|
$env{'request.lti.uri'} = $tail; |
} else { |
} else { |
unless ($tail eq '/adm/roles') { |
unless ($tail eq '/adm/roles') { |
$env{'form.origurl'} = '/adm/navmaps'; |
$env{'form.origurl'} = '/adm/navmaps'; |
Line 850 sub lti_session {
|
Line 898 sub lti_session {
|
$env{'request.lti.rosterurl'} = $params->{'ext_ims_lis_memberships_url'}; |
$env{'request.lti.rosterurl'} = $params->{'ext_ims_lis_memberships_url'}; |
} |
} |
} |
} |
$env{'request.lti.login'} = 1; |
$env{'request.lti.login'} = $itemid; |
|
if ($params->{'launch_presentation_document_target'}) { |
|
$env{'request.lti.target'} = $params->{'launch_presentation_document_target'}; |
|
} |
foreach my $key (%{$params}) { |
foreach my $key (%{$params}) { |
delete($env{'form.'.$key}); |
delete($env{'form.'.$key}); |
} |
} |
Line 871 sub lti_session {
|
Line 922 sub lti_session {
|
'domain' => $udom, |
'domain' => $udom, |
'username' => $uname, |
'username' => $uname, |
'server' => $lonhost, |
'server' => $lonhost, |
'lti.login' => 1, |
'lti.login' => $itemid, |
|
'lti.uri' => $tail, |
); |
); |
if ($role) { |
if ($role) { |
$info{'role'} = $role; |
$info{'role'} = $role; |
Line 903 sub lti_session {
|
Line 955 sub lti_session {
|
$info{'lti.rosterurl'} = $params->{'ext_ims_lis_memberships_url'}; |
$info{'lti.rosterurl'} = $params->{'ext_ims_lis_memberships_url'}; |
} |
} |
} |
} |
|
if ($params->{'launch_presentation_document_target'}) { |
|
$info{'lti.target'} = $params->{'launch_presentation_document_target'}; |
|
} |
|
|
unless ($info{'symb'}) { |
unless ($info{'symb'}) { |
if ($mapurl) { |
if ($mapurl) { |
$info{'origurl'} = $mapurl; |
$info{'origurl'} = $mapurl; |
Line 934 sub invalid_request {
|
Line 990 sub invalid_request {
|
} |
} |
&Apache::lonlocal::get_language_handle($r); |
&Apache::lonlocal::get_language_handle($r); |
$r->print( |
$r->print( |
&Apache::loncommon::start_page('Invalid LTI call'). |
&Apache::loncommon::start_page('Invalid LTI call','',{ 'only_body' => 1,}). |
&mt('Invalid LTI call [_1]',$num). |
&mt('Invalid LTI call [_1]',$num). |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
|
|
|
sub create_passwd { |
|
my $passwd = ''; |
|
my @letts = ("a".."z"); |
|
for (my $i=0; $i<8; $i++) { |
|
my $lettnum = int(rand(2)); |
|
my $item = ''; |
|
if ($lettnum) { |
|
$item = $letts[int(rand(26))]; |
|
my $uppercase = int(rand(2)); |
|
if ($uppercase) { |
|
$item =~ tr/a-z/A-Z/; |
|
} |
|
} else { |
|
$item = int(rand(10)); |
|
} |
|
$passwd .= $item; |
|
} |
|
return ($passwd); |
|
} |
|
|
1; |
1; |