version 1.385, 2024/12/03 23:20:59
|
version 1.386, 2024/12/09 02:46:01
|
Line 2001 sub do_ltipassback {
|
Line 2001 sub do_ltipassback {
|
my $scoretype = $item->{'format'}; |
my $scoretype = $item->{'format'}; |
my $scope = $item->{'scope'}; |
my $scope = $item->{'scope'}; |
my $clientip = $item->{'clientip'}; |
my $clientip = $item->{'clientip'}; |
my ($total,$possible); |
my ($total,$possible,%total_by_symb,%possible_by_symb); |
if ($pbscope eq 'resource') { |
if ((exists($item->{'total_s'})) && (ref($item->{'total_s'}) eq 'HASH')) { |
|
%total_by_symb = %{$item->{'total_s'}}; |
|
if ($pbscope eq 'resource') { |
|
if (exists($total_by_symb{$symb})) { |
|
$total = $total_by_symb{$symb}; |
|
} else { |
|
$total = $item->{'total'}; |
|
} |
|
} |
|
} elsif ($pbscope eq 'resource') { |
$total = $item->{'total'}; |
$total = $item->{'total'}; |
|
} |
|
if ((exists($item->{'possible_s'})) && (ref($item->{'possible_s'}) eq 'HASH')) { |
|
%possible_by_symb = %{$item->{'possible_s'}}; |
|
if ($pbscope eq 'resource') { |
|
if (exists($possible_by_symb{$symb})) { |
|
$possible = $possible_by_symb{$symb}; |
|
} else { |
|
$possible = $item->{'possible'}; |
|
} |
|
} |
|
} elsif ($pbscope eq 'resource') { |
$possible = $item->{'possible'}; |
$possible = $item->{'possible'}; |
} else { |
} |
if (($pbscope eq 'map') || ($pbscope eq 'nonrec')) { |
if (($pbscope eq 'map') || ($pbscope eq 'nonrec')) { |
|
if ((keys(%total_by_symb)) && (keys(%possible_by_symb))) { |
|
($total,$possible) = |
|
&get_lti_score($uname,$udom,$map,$pbscope,\%total_by_symb,\%possible_by_symb); |
|
} else { |
($total,$possible) = &get_lti_score($uname,$udom,$map,$pbscope); |
($total,$possible) = &get_lti_score($uname,$udom,$map,$pbscope); |
} elsif ($pbscope eq 'course') { |
|
($total,$possible) = &get_lti_score($uname,$udom); |
|
} |
} |
$item->{'total'} = $total; |
} elsif ($pbscope eq 'course') { |
$item->{'possible'} = $possible; |
($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)) { |
my ($sent,$score,$code,$result) = |
my ($sent,$score,$code,$result) = |
&LONCAPA::ltiutils::send_grade($cdom,$cnum,$crsdef,$type,$ltinum,$keynum,$id, |
&LONCAPA::ltiutils::send_grade($cdom,$cnum,$crsdef,$type,$ltinum,$keynum,$id, |
$url,$scoretype,$sigmethod,$msgformat,$total,$possible); |
$url,$scoretype,$sigmethod,$msgformat,$total,$possible); |
$item->{'score'} = $score; |
$item->{'score'} = $score; |
Line 2087 sub do_ltipassback {
|
Line 2111 sub do_ltipassback {
|
} |
} |
|
|
sub get_lti_score { |
sub get_lti_score { |
my ($uname,$udom,$mapurl,$pbscope) = @_; |
my ($uname,$udom,$mapurl,$pbscope,$totals,$possibles) = @_; |
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 2107 sub get_lti_score {
|
Line 2131 sub get_lti_score {
|
my $depth = 1; |
my $depth = 1; |
my $total = 0; |
my $total = 0; |
my $possible = 0; |
my $possible = 0; |
|
my (%totals_by_symb,%possibles_by_symb); |
|
if (ref($totals) eq 'HASH') { |
|
%totals_by_symb = %{$totals}; |
|
} |
|
if (ref($possibles) eq 'HASH') { |
|
%possibles_by_symb = %{$possibles}; |
|
} |
$iterator->next(); # ignore first BEGIN_MAP |
$iterator->next(); # ignore first BEGIN_MAP |
my $curRes = $iterator->next(); |
my $curRes = $iterator->next(); |
while ( $depth > 0 ) { |
while ( $depth > 0 ) { |
if ($curRes == $iterator->BEGIN_MAP()) {$depth++;} |
if ($curRes == $iterator->BEGIN_MAP()) {$depth++;} |
if ($curRes == $iterator->END_MAP()) { $depth--; } |
if ($curRes == $iterator->END_MAP()) { $depth--; } |
if (ref($curRes) && $curRes->is_gradable() && !$curRes->randomout) { |
if (ref($curRes) && $curRes->is_gradable() && !$curRes->randomout) { |
my $parts = $curRes->parts(); |
my $currsymb = $curRes->symb(); |
foreach my $part (@{$parts}) { |
if (($currsymb) && (exists($totals_by_symb{$currsymb})) && |
next if ($curRes->solved($part) eq 'excused'); |
(exists($possibles_by_symb{$currsymb}))) { |
$total += $curRes->weight($part) * $curRes->awarded($part); |
$total += $totals_by_symb{$currsymb}; |
$possible += $curRes->weight($part); |
$possible += $possibles_by_symb{$currsymb}; |
|
} else { |
|
my $parts = $curRes->parts(); |
|
foreach my $part (@{$parts}) { |
|
next if ($curRes->solved($part) eq 'excused'); |
|
$total += $curRes->weight($part) * $curRes->awarded($part); |
|
$possible += $curRes->weight($part); |
|
} |
} |
} |
} |
} |
$curRes = $iterator->next(); |
$curRes = $iterator->next(); |