version 1.31, 2001/12/04 15:17:56
|
version 1.34, 2002/01/07 18:03:57
|
Line 65 sub end_radiobuttonresponse {
|
Line 65 sub end_radiobuttonresponse {
|
if ($target eq 'edit') { $result=&Apache::edit::end_table(); } |
if ($target eq 'edit') { $result=&Apache::edit::end_table(); } |
&Apache::response::end_response; |
&Apache::response::end_response; |
pop @Apache::lonxml::namespace; |
pop @Apache::lonxml::namespace; |
|
&Apache::lonxml::deregister('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup')); |
return $result; |
return $result; |
} |
} |
|
|
Line 77 sub start_foilgroup {
|
Line 78 sub start_foilgroup {
|
} |
} |
|
|
sub storesurvey { |
sub storesurvey { |
if ( defined $ENV{'form.submitted'}) { |
if ( !defined($ENV{'form.submitted'})) { return ''; } |
my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; |
my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; |
&Apache::lonxml::debug("Here I am!:$response:"); |
&Apache::lonxml::debug("Here I am!:$response:"); |
if ( $response =~ /[0-9]+/) { |
if ( $response !~ /[0-9]+/) { return ''; } |
my $id = $Apache::inputtags::response['-1']; |
my $id = $Apache::inputtags::response['-1']; |
my @whichfoils=&whichfoils($max,$answer); |
my @whichfoils=@{ $Apache::response::foilgroup{'names'} }; |
my %responsehash; |
my %responsehash; |
$responsehash{$whichfoil[$reponse]}=$response; |
$responsehash{$whichfoils[$response]}=$response; |
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=&Apache::lonnet::hash2str(%responsehash); |
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=&Apache::lonnet::hash2str(%responsehash); |
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='SUBMITTED'; |
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='SUBMITTED'; |
&Apache::lonxml::debug("submitted a $response<br />\n"); |
&Apache::lonxml::debug("submitted a $response<br />\n"); |
} |
|
} |
|
return ''; |
return ''; |
} |
} |
|
|
|
sub grade_response { |
|
my ($max,$answer)=@_; |
|
if (!defined($ENV{'form.submitted'})) { return; } |
|
my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; |
|
if ( $response !~ /[0-9]+/) { return; } |
|
my $part=$Apache::inputtags::part; |
|
my $id = $Apache::inputtags::response['-1']; |
|
my @whichfoils=&whichfoils($max,$answer); |
|
my %responsehash; |
|
$responsehash{$whichfoils[$response]}=$response; |
|
my $responsestr=&Apache::lonnet::hash2str(%responsehash); |
|
my %previous=&Apache::response::check_for_previous($responsestr, |
|
$part,$id); |
|
$Apache::lonhomework::results{"resource.$part.$id.submission"}= |
|
$responsestr; |
|
&Apache::lonxml::debug("submitted a $response<br />\n"); |
|
my $ad; |
|
if ($response == $answer) { |
|
$ad='EXACT_ANS'; |
|
} else { |
|
$ad='INCORRECT'; |
|
} |
|
$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad; |
|
&Apache::response::handle_previous(\%previous,$ad); |
|
} |
|
|
sub end_foilgroup { |
sub end_foilgroup { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
|
Line 118 sub end_foilgroup {
|
Line 143 sub end_foilgroup {
|
} elsif ($target eq 'answer' ) { |
} elsif ($target eq 'answer' ) { |
$result=&displayanswers($max,$answer); |
$result=&displayanswers($max,$answer); |
} elsif ( $target eq 'grade') { |
} elsif ( $target eq 'grade') { |
if ( defined $ENV{'form.submitted'}) { |
&grade_response($max,$answer); |
my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']}; |
|
if ( $response =~ /[0-9]+/) { |
|
my $id = $Apache::inputtags::response['-1']; |
|
my @whichfoils=&whichfoils($max,$answer); |
|
my %responsehash; |
|
$responsehash{$whichfoil[$reponse]}=$response; |
|
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=&Apache::lonnet::hash2str(%responsehash); |
|
&Apache::lonxml::debug("submitted a $response<br />\n"); |
|
if ($response == $answer) { |
|
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='EXACT_ANS'; |
|
} else { |
|
$Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='INCORRECT'; |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 143 sub end_foilgroup {
|
Line 153 sub end_foilgroup {
|
sub getfoilcounts { |
sub getfoilcounts { |
my ($parstack,$safeeval)=@_; |
my ($parstack,$safeeval)=@_; |
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2'); |
my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2'); |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names; |
my $truecnt=0; |
my $truecnt=0; |
my $falsecnt=0; |
my $falsecnt=0; |
my $name; |
my $name; |
|
if ( $Apache::response::foilgroup{'names'} ) { |
|
@names= @{ $Apache::response::foilgroup{'names'} }; |
|
} |
foreach $name (@names) { |
foreach $name (@names) { |
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { |
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { |
$truecnt++; |
$truecnt++; |
Line 166 sub displayallfoils {
|
Line 178 sub displayallfoils {
|
my $id=$Apache::inputtags::response['-1']; |
my $id=$Apache::inputtags::response['-1']; |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; |
my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; |
|
my %lastresponse=&Apache::lonnet::str2hash($lastresponse); |
|
&Apache::lonhomework::showhash(%lastresponse); |
foreach my $name (@names) { |
foreach my $name (@names) { |
if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') { |
if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') { |
$result.="<br /><input type=\"radio\" name=\"HWVAL$Apache::inputtags::response['-1']\" value=\"$temp\" "; |
$result.="<br /><input type=\"radio\" name=\"HWVAL$Apache::inputtags::response['-1']\" value=\"$temp\" "; |
if ($lastresponse eq $temp) { $result .= 'checked="on"'; } |
if (defined($lastresponse{$name})) { $result .= 'checked="on"'; } |
$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</input>\n"; |
$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</input>\n"; |
$temp++; |
$temp++; |
} |
} |
Line 183 sub whichfoils {
|
Line 197 sub whichfoils {
|
my @truelist; |
my @truelist; |
my @falselist; |
my @falselist; |
|
|
my @names = @{ $Apache::response::foilgroup{'names'} }; |
my @names; |
|
if ( $Apache::response::foilgroup{'names'} ) { |
|
@names= @{ $Apache::response::foilgroup{'names'} }; |
|
} |
foreach my $name (@names) { |
foreach my $name (@names) { |
#result.="<br /><b>$name</b> is <i> $Apache::response::foilgroup{$name.'.value'} </i>"; |
#result.="<br /><b>$name</b> is <i> $Apache::response::foilgroup{$name.'.value'} </i>"; |
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { |
if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { |
Line 231 sub displayfoils {
|
Line 248 sub displayfoils {
|
my $id=$Apache::inputtags::response['-1']; |
my $id=$Apache::inputtags::response['-1']; |
my $part=$Apache::inputtags::part; |
my $part=$Apache::inputtags::part; |
my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; |
my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"}; |
|
my %lastresponse=&Apache::lonnet::str2hash($lastresponse); |
foreach my $name (@whichfoils) { |
foreach my $name (@whichfoils) { |
$result.="<br /><input type=\"radio\" name=\"HWVAL$Apache::inputtags::response['-1']\" value=\"$temp\" "; |
$result.="<br /><input type=\"radio\" name=\"HWVAL$Apache::inputtags::response['-1']\" value=\"$temp\" "; |
if ($lastresponse eq $temp) { $result .= 'checked="on"'; } |
if (defined($lastresponse{$name})) { $result .= 'checked="on"'; } |
$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</input>\n"; |
$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</input>\n"; |
$temp++; |
$temp++; |
} |
} |
Line 243 sub displayfoils {
|
Line 261 sub displayfoils {
|
|
|
sub displayanswers { |
sub displayanswers { |
my ($max,$answer)=@_; |
my ($max,$answer)=@_; |
my @names = @{ $Apache::response::foilgroup{'names'} }; |
|
my @whichopt = &whichfoils($max,$answer); |
my @whichopt = &whichfoils($max,$answer); |
my $result=&Apache::response::answer_header('radiobuttonresponse'); |
my $result=&Apache::response::answer_header('radiobuttonresponse'); |
foreach my $name (@whichopt) { |
foreach my $name (@whichopt) { |