version 1.383, 2024/02/21 19:50:21
|
version 1.384, 2024/11/21 07:26:01
|
Line 1978 sub convert_for_js {
|
Line 1978 sub convert_for_js {
|
|
|
sub do_ltipassback { |
sub do_ltipassback { |
if (@Apache::lonhomework::ltipassback) { |
if (@Apache::lonhomework::ltipassback) { |
|
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
|
my $ip = &Apache::lonnet::get_host_ip($lonhost); |
foreach my $item (@Apache::lonhomework::ltipassback) { |
foreach my $item (@Apache::lonhomework::ltipassback) { |
if (ref($item) eq 'HASH') { |
if (ref($item) eq 'HASH') { |
if ((ref($item->{'lti'}) eq 'HASH') && ($item->{'cid'} =~ /^($match_domain)_($match_courseid)$/)) { |
if ((ref($item->{'lti'}) eq 'HASH') && ($item->{'cid'} =~ /^($match_domain)_($match_courseid)$/)) { |
Line 1988 sub do_ltipassback {
|
Line 1990 sub do_ltipassback {
|
my $id = $item->{'pbid'}; |
my $id = $item->{'pbid'}; |
my $url = $item->{'pburl'}; |
my $url = $item->{'pburl'}; |
my $type = $item->{'pbtype'}; |
my $type = $item->{'pbtype'}; |
my $scope = $item->{'scope'}; |
my $pbscope = $item->{'pbscope'}; |
my $map = $item->{'pbmap'}; |
my $map = $item->{'pbmap'}; |
my $symb = $item->{'pbsymb'}; |
my $symb = $item->{'pbsymb'}; |
my $uname = $item->{'uname'}; |
my $uname = $item->{'uname'}; |
my $udom = $item->{'udom'}; |
my $udom = $item->{'udom'}; |
|
my $uhome = $item->{'uhome'}; |
my $keynum = $item->{'lti'}->{'cipher'}; |
my $keynum = $item->{'lti'}->{'cipher'}; |
my $crsdef = $item->{'crsdef'}; |
my $crsdef = $item->{'crsdef'}; |
my $scoretype = $item->{'format'}; |
my $scoretype = $item->{'format'}; |
|
my $scope = $item->{'scope'}; |
|
my $clientip = $item->{'clientip'}; |
my ($total,$possible); |
my ($total,$possible); |
if ($scope eq 'resource') { |
if ($pbscope eq 'resource') { |
$total = $item->{'total'}; |
$total = $item->{'total'}; |
$possible = $item->{'possible'}; |
$possible = $item->{'possible'}; |
} elsif (($scope eq 'map') || ($scope eq 'nonrec')) { |
} else { |
($total,$possible) = &get_lti_score($uname,$udom,$map,$scope); |
if (($pbscope eq 'map') || ($pbscope eq 'nonrec')) { |
} elsif ($scope eq 'course') { |
($total,$possible) = &get_lti_score($uname,$udom,$map,$pbscope); |
($total,$possible) = &get_lti_score($uname,$udom); |
} elsif ($pbscope eq 'course') { |
|
($total,$possible) = &get_lti_score($uname,$udom); |
|
} |
|
$item->{'total'} = $total; |
|
$item->{'possible'} = $possible; |
} |
} |
if (($id ne '') && ($url ne '') && ($possible)) { |
if (($id ne '') && ($url ne '') && ($possible)) { |
&LONCAPA::ltiutils::send_grade($cdom,$cnum,$crsdef,$type,$ltinum,$keynum,$id,$url,$scoretype,$sigmethod,$msgformat,$total,$possible); |
my ($sent,$score,$code,$result) = |
|
&LONCAPA::ltiutils::send_grade($cdom,$cnum,$crsdef,$type,$ltinum,$keynum,$id, |
|
$url,$scoretype,$sigmethod,$msgformat,$total,$possible); |
|
$item->{'score'} = $score; |
|
my ($linkprotector,$linkuri,$no_passback,$appname); |
|
if ($item->{'linkprot'}) { |
|
($linkprotector,$linkuri) = split(/:/,$item->{'linkprot'}); |
|
} |
|
if ($sent) { |
|
if ($code == 200) { |
|
if ($item->{'linkprot'}) { |
|
my $key = join("\0",($linkuri,$linkprotector,$scope)); |
|
my $namespace = $cdom.'_'.$cnum.'_lp_passback'; |
|
my $store = { |
|
'score' => $score, |
|
'ip' => $ip, |
|
'host' => $Apache::lonnet::perlvar{'lonHostID'}, |
|
'protector' => $linkprotector, |
|
'deeplink' => $linkuri, |
|
'scope' => $scope, |
|
'url' => $url, |
|
'id' => $id, |
|
'clientip' => $clientip, |
|
'whodoneit' => $env{'user.name'}.':'.$env{'user.domain'}, |
|
}; |
|
my $value=''; |
|
foreach my $key (keys(%{$store})) { |
|
$value.=&escape($key).'='.&Apache::lonnet::freeze_escape($store->{$key}).'&'; |
|
} |
|
$value=~s/\&$//; |
|
&Apache::lonnet::courselog(&escape($linkuri).':'.$uname.':'.$udom.':EXPORT:'.$value); |
|
&Apache::lonnet::cstore({'score' => $score},$key,$namespace,$udom,$uname,'',$ip,1); |
|
} |
|
} else { |
|
if ($item->{'linkprot'}) { |
|
$no_passback = "Passback response was $code ($result)."; |
|
} |
|
} |
|
} else { |
|
if ($item->{'linkprot'}) { |
|
$no_passback = 'No passback of scores.'; |
|
} |
|
} |
|
if ($no_passback) { |
|
if ($item->{'linkprot'}) { |
|
my ($ltinum,$ltitype) = ($linkprotector =~ /^(\d+)(c|d)$/); |
|
if ($ltitype eq 'c') { |
|
my %lti = &Apache::lonnet::get_course_lti($cnum,$cdom,'provider'); |
|
if (ref($lti{$ltinum}) eq 'HASH') { |
|
$appname = $lti{$ltinum}{'name'}; |
|
} |
|
} elsif ($ltitype eq 'd') { |
|
my %lti = &Apache::lonnet::get_domain_lti($cdom,'linkprot'); |
|
if (ref($lti{$ltinum}) eq 'HASH') { |
|
$appname = $lti{$ltinum}{'name'}; |
|
} |
|
} |
|
$no_passback .= " LTI launcher $linkprotector ($appname) for $linkuri (${cdom}_${cnum})"; |
|
&Apache::lonnet::logthis($no_passback." for $uname:$udom"); |
|
&Apache::lonnet::log($udom,$uname,$uhome,"$no_passback score=$score total=$total poss=$possible"); |
|
&Apache::lonnet::put('linkprot_passback_pending',$item,$cdom,$cnum); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 2016 sub do_ltipassback {
|
Line 2087 sub do_ltipassback {
|
} |
} |
|
|
sub get_lti_score { |
sub get_lti_score { |
my ($uname,$udom,$mapurl,$scope) = @_; |
my ($uname,$udom,$mapurl,$pbscope) = @_; |
my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom); |
my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom); |
if (ref($navmap)) { |
if (ref($navmap)) { |
my $iterator; |
my $iterator; |
Line 2025 sub get_lti_score {
|
Line 2096 sub get_lti_score {
|
my $firstres = $map->map_start(); |
my $firstres = $map->map_start(); |
my $finishres = $map->map_finish(); |
my $finishres = $map->map_finish(); |
my $recursive = 1; |
my $recursive = 1; |
if ($scope eq 'nonrec') { |
if ($pbscope eq 'nonrec') { |
$recursive = 0; |
$recursive = 0; |
} |
} |
$iterator = $navmap->getIterator($firstres,$finishres,undef,$recursive); |
$iterator = $navmap->getIterator($firstres,$finishres,undef,$recursive); |