version 1.433, 2007/08/22 18:27:03
|
version 1.434, 2007/08/24 00:32:00
|
Line 45 use LONCAPA;
|
Line 45 use LONCAPA;
|
|
|
use POSIX qw(floor); |
use POSIX qw(floor); |
|
|
my %perm=(); |
my %perm; |
|
|
# ----- These first few routines are general use routines.---- |
# ----- These first few routines are general use routines.---- |
# |
# |
Line 194 sub showResourceInfo {
|
Line 194 sub showResourceInfo {
|
return $result,$responseType,$hdgrade,$partlist,$handgrade; |
return $result,$responseType,$hdgrade,$partlist,$handgrade; |
} |
} |
|
|
|
sub reset_caches { |
|
&reset_analyze_cache(); |
|
&reset_perm(); |
|
} |
|
|
sub get_order { |
{ |
my ($partid,$respid,$symb,$uname,$udom)=@_; |
my %analyze_cache; |
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
|
$url=&Apache::lonnet::clutter($url); |
sub reset_analyze_cache { |
my $subresult=&Apache::lonnet::ssi($url, |
undef(%analyze_cache); |
('grade_target' => 'analyze'), |
} |
('grade_domain' => $udom), |
|
('grade_symb' => $symb), |
sub get_analyze { |
('grade_courseid' => |
my ($symb,$uname,$udom)=@_; |
$env{'request.course.id'}), |
my $key = "$symb\0$uname\0$udom"; |
('grade_username' => $uname)); |
return $analyze_cache{$key} if (exists($analyze_cache{$key})); |
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2); |
|
my %analyze=&Apache::lonnet::str2hash($subresult); |
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb); |
return ($analyze{"$partid.$respid.shown"}); |
$url=&Apache::lonnet::clutter($url); |
|
my $subresult=&Apache::lonnet::ssi($url, |
|
('grade_target' => 'analyze'), |
|
('grade_domain' => $udom), |
|
('grade_symb' => $symb), |
|
('grade_courseid' => |
|
$env{'request.course.id'}), |
|
('grade_username' => $uname)); |
|
(undef,$subresult)=split(/_HASH_REF__/,$subresult,2); |
|
my %analyze=&Apache::lonnet::str2hash($subresult); |
|
return $analyze_cache{$key} = \%analyze; |
|
} |
|
|
|
sub get_order { |
|
my ($partid,$respid,$symb,$uname,$udom)=@_; |
|
my $analyze = &get_analyze($symb,$uname,$udom); |
|
return $analyze->{"$partid.$respid.shown"}; |
|
} |
|
|
|
sub get_radiobutton_correct_foil { |
|
my ($partid,$respid,$symb,$uname,$udom)=@_; |
|
my $analyze = &get_analyze($symb,$uname,$udom); |
|
foreach my $foil (@{&get_order($partid,$respid,$symb,$uname,$udom)}) { |
|
if ($analyze->{"$partid.$respid.foil.value.$foil"} eq 'true') { |
|
return $foil; |
|
} |
|
} |
|
} |
} |
} |
|
|
#--- Clean response type for display |
#--- Clean response type for display |
#--- Currently filters option/rank/radiobutton/match/essay/Task |
#--- Currently filters option/rank/radiobutton/match/essay/Task |
# response types only. |
# response types only. |
Line 258 sub cleanRecord {
|
Line 290 sub cleanRecord {
|
} elsif ($response eq 'radiobutton') { |
} elsif ($response eq 'radiobutton') { |
my %answer=&Apache::lonnet::str2hash($answer); |
my %answer=&Apache::lonnet::str2hash($answer); |
my ($toprow,$bottomrow); |
my ($toprow,$bottomrow); |
my $correct=($order->[0])+1; |
my $correct = |
for (my $i=1;$i<=$#$order;$i++) { |
&get_radiobutton_correct_foil($partid,$respid,$symb,$uname,$udom); |
my $foil=$order->[$i]; |
foreach my $foil (@$order) { |
if (exists($answer{$foil})) { |
if (exists($answer{$foil})) { |
if ($i == $correct) { |
if ($foil eq $correct) { |
$toprow.='<td><b>true</b></td>'; |
$toprow.='<td><b>true</b></td>'; |
} else { |
} else { |
$toprow.='<td><i>true</i></td>'; |
$toprow.='<td><i>true</i></td>'; |
Line 1665 sub build_section_inputs {
|
Line 1697 sub build_section_inputs {
|
$section_inputs .= '<input type="hidden" name="section" value="all" />'."\n"; |
$section_inputs .= '<input type="hidden" name="section" value="all" />'."\n"; |
} else { |
} else { |
my @sections = &Apache::loncommon::get_env_multiple('form.section'); |
my @sections = &Apache::loncommon::get_env_multiple('form.section'); |
foreach my $section(@sections) { |
foreach my $section (@sections) { |
$section_inputs .= '<input type="hidden" name="section" value="'.$section.'" />'."\n"; |
$section_inputs .= '<input type="hidden" name="section" value="'.$section.'" />'."\n"; |
} |
} |
} |
} |
Line 7515 ENDHEADER
|
Line 7547 ENDHEADER
|
sub handler { |
sub handler { |
my $request=$_[0]; |
my $request=$_[0]; |
|
|
&reset_perm(); |
&reset_caches(); |
if ($env{'browser.mathml'}) { |
if ($env{'browser.mathml'}) { |
&Apache::loncommon::content_type($request,'text/xml'); |
&Apache::loncommon::content_type($request,'text/xml'); |
} else { |
} else { |
Line 7628 sub handler {
|
Line 7660 sub handler {
|
} |
} |
} |
} |
$request->print(&Apache::loncommon::end_page()); |
$request->print(&Apache::loncommon::end_page()); |
|
&reset_caches(); |
return ''; |
return ''; |
} |
} |
|
|