version 1.22, 2021/08/07 01:32:12
|
version 1.22.2.3, 2023/07/05 18:42:48
|
Line 96 sub handler {
|
Line 96 sub handler {
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; |
my ($idx,$is_tool,%toolhash,%toolsettings); |
my ($idx,$crstool,$is_tool,%toolhash,%toolsettings); |
|
|
if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") { |
if ($r->uri eq "/adm/$cdom/$cnum/$marker/$exttool") { |
%toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); |
%toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); |
if ($toolsettings{'id'}) { |
if ($toolsettings{'id'}) { |
$idx = $toolsettings{'id'}; |
my %ltitools; |
my %ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); |
if ($toolsettings{'id'} =~ /^c(\d+)$/) { |
|
$idx = $1; |
|
$crstool = 1; |
|
%ltitools = &Apache::lonnet::get_course_lti($cnum,$cdom,'consumer'); |
|
} else { |
|
$idx = $toolsettings{'id'}; |
|
%ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); |
|
} |
if (ref($ltitools{$idx}) eq 'HASH') { |
if (ref($ltitools{$idx}) eq 'HASH') { |
%toolhash = %{$ltitools{$idx}}; |
%toolhash = %{$ltitools{$idx}}; |
$toolhash{'display'} = { |
$toolhash{'display'} = { |
Line 204 sub handler {
|
Line 211 sub handler {
|
} |
} |
} |
} |
my $submittext = &mt('Launch [_1]',$toolhash{'title'}); |
my $submittext = &mt('Launch [_1]',$toolhash{'title'}); |
if (($toolhash{'key'} ne '') && ($toolhash{'secret'} ne '') && |
if (($toolhash{'url'} ne '') && ($launchok)) { |
($toolhash{'url'} ne '') && ($launchok)) { |
|
my %lti = <i_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash); |
my %lti = <i_params($r,$cnum,$cdom,$idx,$submittext,\%toolhash); |
my $url = $toolhash{'url'}; |
my $url = $toolhash{'url'}; |
if ($toolhash{'crsappend'} ne '') { |
if ($toolhash{'crsappend'} ne '') { |
$url .= $toolhash{'crsappend'}; |
$url .= $toolhash{'crsappend'}; |
} |
} |
$r->print(&launch_html($url,$toolhash{'key'},$toolhash{'secret'}, |
my %info = ( |
$toolhash{'sigmethod'},$submittext,\%lti)); |
method => $toolhash{'sigmethod'}, |
|
); |
|
$r->print(&launch_html($cdom,$cnum,$crstool,$url,$idx, |
|
$toolhash{'cipher'},$submittext,\%lti,\%info)); |
} else { |
} else { |
$r->print('<div>'.&mt('External Tool Unavailable').'</div>'); |
$r->print('<div class="LC_warning">'.&mt('External Tool Unavailable').'</div>'); |
} |
} |
} |
} |
return OK; |
return OK; |
Line 275 sub lti_params {
|
Line 284 sub lti_params {
|
$ltirole = 'Learner'; |
$ltirole = 'Learner'; |
} |
} |
my @possdigest; |
my @possdigest; |
my $digest_user = &Encode::decode_utf8($uname.':'.$udom); |
my $digest_user = &Encode::decode('UTF-8',$uname.':'.$udom); |
$digest_user = &Digest::SHA::sha1_hex($digest_user); |
$digest_user = &Digest::SHA::sha1_hex($digest_user); |
push(@possdigest,$digest_user); |
push(@possdigest,$digest_user); |
if ($env{'course.'.$env{'request.course.id'}.'.languages'} ne '') { |
if ($env{'course.'.$env{'request.course.id'}.'.languages'} ne '') { |
Line 298 sub lti_params {
|
Line 307 sub lti_params {
|
my ($title,$digest_symb); |
my ($title,$digest_symb); |
my ($symb) = &Apache::lonnet::whichuser(); |
my ($symb) = &Apache::lonnet::whichuser(); |
if ($symb) { |
if ($symb) { |
$digest_symb = &Encode::decode_utf8($symb); |
$digest_symb = &Encode::decode('UTF-8',$symb); |
$digest_symb = &Digest::SHA::sha1_hex($digest_symb); |
$digest_symb = &Digest::SHA::sha1_hex($digest_symb); |
push(@possdigest,$digest_symb); |
push(@possdigest,$digest_symb); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
my $navmap = Apache::lonnavmaps::navmap->new(); |
Line 427 sub lti_params {
|
Line 436 sub lti_params {
|
} |
} |
} |
} |
foreach my $key (keys(%ltiparams)) { |
foreach my $key (keys(%ltiparams)) { |
$ltiparams{$key} = &Encode::decode_utf8($ltiparams{$key}); |
$ltiparams{$key} = &Encode::decode('UTF-8',$ltiparams{$key}); |
} |
} |
$ltiparams{'basiclti_submit'} = $submittext; |
$ltiparams{'basiclti_submit'} = $submittext; |
return %ltiparams; |
return %ltiparams; |
} |
} |
|
|
sub launch_html { |
sub launch_html { |
my ($url,$key,$secret,$sigmethod,$submittext,$paramsref) = @_; |
my ($cdom,$cnum,$crstool,$url,$idx,$keynum,$submittext,$paramsref,$inforef) = @_; |
my $hashref = &LONCAPA::ltiutils::sign_params($url,$key,$secret,$paramsref,$sigmethod); |
my ($status,$hashref) = |
|
&Apache::lonnet::sign_lti($cdom,$cnum,$crstool,'tools','launch',$url,$idx,$keynum, |
|
$paramsref,$inforef); |
|
unless ($status eq 'ok') { |
|
return '<div class="LC_warning">'.&mt('External Tool Unavailable').'</div>'; |
|
} |
my $action = &HTML::Entities::encode($url,'<>&"'); |
my $action = &HTML::Entities::encode($url,'<>&"'); |
my $form = <<"END"; |
my $form = <<"END"; |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |