version 1.60, 2002/02/15 22:16:04
|
version 1.70, 2003/04/08 02:42:55
|
Line 33 package Apache::response;
|
Line 33 package Apache::response;
|
use strict; |
use strict; |
|
|
BEGIN { |
BEGIN { |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','caparesponse','numericalresponse','formularesponse','stringresponse','radiobuttonresponse','optionresponse','imageresponse','essayresponse','dataresponse','externalresponse')); |
&Apache::lonxml::register('Apache::response',('responseparam','parameter','dataresponse')); |
} |
} |
|
|
sub start_response { |
sub start_response { |
Line 68 sub start_hintresponse {
|
Line 68 sub start_hintresponse {
|
|
|
sub end_hintresponse { |
sub end_hintresponse { |
pop @Apache::inputtags::response; |
pop @Apache::inputtags::response; |
%Apache::inputtags::params=@{pop(@Apache::inputtags::paramstack)}; |
if (defined($Apache::inputtags::paramstack[-1])) { |
|
%Apache::inputtags::params= |
|
@{ pop(@Apache::inputtags::paramstack) }; |
|
} |
return ''; |
return ''; |
} |
} |
|
|
Line 91 sub setrandomnumber {
|
Line 94 sub setrandomnumber {
|
$rndseed=$rndseed |
$rndseed=$rndseed |
+&Apache::lonnet::numval($Apache::inputtags::response['-1']); |
+&Apache::lonnet::numval($Apache::inputtags::response['-1']); |
} |
} |
srand($rndseed); |
&Math::Random::random_set_seed_from_phrase($rndseed); |
&Apache::lonxml::debug("randseed $rndseed"); |
&Apache::lonxml::debug("randseed $rndseed"); |
return ''; |
return ''; |
} |
} |
Line 172 sub check_for_previous {
|
Line 175 sub check_for_previous {
|
my ($curresponse,$partid,$id) = @_; |
my ($curresponse,$partid,$id) = @_; |
my %previous; |
my %previous; |
$previous{'used'} = 0; |
$previous{'used'} = 0; |
foreach my $key (reverse(sort(keys(%Apache::lonhomework::history)))) { |
foreach my $key (sort(keys(%Apache::lonhomework::history))) { |
if ($key =~ /resource\.$partid\.$id\.submission/) { |
if ($key =~ /resource\.$partid\.$id\.submission/) { |
&Apache::lonxml::debug("Trying $key"); |
&Apache::lonxml::debug("Trying $key"); |
my $pastresponse=$Apache::lonhomework::history{$key}; |
my $pastresponse=$Apache::lonhomework::history{$key}; |
Line 183 sub check_for_previous {
|
Line 186 sub check_for_previous {
|
$history=$1; |
$history=$1; |
$previous{'award'} = $Apache::lonhomework::history{"$history:resource.$partid.$id.awarddetail"}; |
$previous{'award'} = $Apache::lonhomework::history{"$history:resource.$partid.$id.awarddetail"}; |
$previous{'last'}='0'; |
$previous{'last'}='0'; |
|
push(@{ $previous{'version'} },$history); |
} else { |
} else { |
$previous{'award'} = $Apache::lonhomework::history{"resource.$partid.$id.awarddetail"}; |
$previous{'award'} = $Apache::lonhomework::history{"resource.$partid.$id.awarddetail"}; |
$previous{'last'}='1'; |
$previous{'last'}='1'; |
} |
} |
if (! $previous{'award'} ) { $previous{'award'} = 'UNKNOWN'; } |
if (! $previous{'award'} ) { $previous{'award'} = 'UNKNOWN'; } |
&Apache::lonxml::debug("got a match :$previous{'award'}:$previous{'used'}:"); |
&Apache::lonxml::debug("got a match :$previous{'award'}:$previous{'used'}:"); |
last; |
|
} |
} |
} |
} |
} |
} |
|
&Apache::lonhomework::showhash(%previous); |
return %previous; |
return %previous; |
} |
} |
|
|
Line 204 sub handle_previous {
|
Line 208 sub handle_previous {
|
} else { |
} else { |
push(@Apache::inputtags::previous,'PREVIOUSLY_USED'); |
push(@Apache::inputtags::previous,'PREVIOUSLY_USED'); |
} |
} |
|
push(@Apache::inputtags::previous_version,$$previous{'version'}); |
} |
} |
} |
} |
|
|
sub start_caparesponse { |
|
require Apache::caparesponse; |
|
import Apache::caparesponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
# print "\n<br />\nsimple caparesponse\n"; |
|
return &Apache::caparesponse::start_caparesponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_stringresponse { |
|
require Apache::caparesponse; |
|
import Apache::caparesponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::caparesponse::start_stringresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_formularesponse { |
|
require Apache::caparesponse; |
|
import Apache::caparesponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::caparesponse::start_formularesponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_numericalresponse { |
|
require Apache::caparesponse; |
|
import Apache::caparesponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::caparesponse::start_numericalresponse |
|
($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_radiobuttonresponse { |
|
require Apache::radiobuttonresponse; |
|
import Apache::radiobuttonresponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::radiobuttonresponse::start_radiobuttonresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_optionresponse { |
|
require Apache::optionresponse; |
|
import Apache::optionresponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::optionresponse::start_optionresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_imageresponse { |
|
require Apache::imageresponse; |
|
import Apache::imageresponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::imageresponse::start_imageresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_essayresponse { |
|
require Apache::essayresponse; |
|
import Apache::essayresponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::essayresponse::start_essayresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub start_externalresponse { |
|
require Apache::externalresponse; |
|
import Apache::externalresponse; |
|
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
|
return &Apache::externalresponse::start_externalresponse($target,$token,$tagstack,$parstack,$parser,$safeeval,$style); |
|
} |
|
|
|
sub view_or_modify { |
sub view_or_modify { |
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
my $myself=0; |
my $myself=0; |
Line 310 sub end_dataresponse {
|
Line 250 sub end_dataresponse {
|
my ($symb,$courseid,$domain,$name)=&Apache::lonxml::whichuser(); |
my ($symb,$courseid,$domain,$name)=&Apache::lonxml::whichuser(); |
my $allowed=&Apache::lonnet::allowed('mgr',$courseid); |
my $allowed=&Apache::lonnet::allowed('mgr',$courseid); |
if ($allowed) { |
if ($allowed) { |
&Apache::response::setup_params('datasubmission'); |
&Apache::response::setup_params('dataresponse'); |
my $partid = $Apache::inputtags::part; |
my $partid = $Apache::inputtags::part; |
my $id = $Apache::inputtags::response['-1']; |
my $id = $Apache::inputtags::response['-1']; |
my $response = $ENV{'form.HWVAL'.$id}; |
my $response = $ENV{'form.HWVAL_'.$id}; |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
if ( $response =~ /[^\s]/) { |
if ( $response =~ /[^\s]/) { |
$Apache::lonhomework::results{"resource.$partid.$id.$name"}= |
$Apache::lonhomework::results{"resource.$partid.$id.$name"}= |
Line 358 sub start_responseparam {
|
Line 298 sub start_responseparam {
|
$result = &Apache::edit::rebuild_tag($token); |
$result = &Apache::edit::rebuild_tag($token); |
$result.=&Apache::edit::handle_insert(); |
$result.=&Apache::edit::handle_insert(); |
} |
} |
} elsif ($target eq 'grade' || $target eq 'answer' || |
} elsif ($target eq 'grade' || $target eq 'answer' || $target eq 'web' || |
$target eq 'web' || $target eq 'tex') { |
$target eq 'tex' || $target eq 'analyze' ) { |
if ($ENV{'request.state'} eq 'construct') { |
if ($ENV{'request.state'} eq 'construct') { |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval); |
my $default = &Apache::lonxml::get_param('default',$parstack,$safeeval); |
my $default = &Apache::lonxml::get_param('default',$parstack,$safeeval); |
$Apache::inputtags::params{$name}=$default; |
if ($name) {$Apache::inputtags::params{$name}=$default;} |
} |
} |
} |
} |
return $result; |
return $result; |
Line 385 sub end_parameter {
|
Line 325 sub end_parameter {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub reset_params { |
|
%Apache::inputtags::params=(); |
|
} |
|
|
sub setup_params { |
sub setup_params { |
my ($tag) = @_; |
my ($tag) = @_; |
|
|
if ($ENV{'request.state'} eq 'construct') { return; } |
if ($ENV{'request.state'} eq 'construct') { return; } |
%Apache::inputtags::params=(); |
|
my %paramlist=(); |
my %paramlist=(); |
foreach my $key (keys(%Apache::lonnet::packagetab)) { |
foreach my $key (keys(%Apache::lonnet::packagetab)) { |
if ($key =~ /^$tag/) { |
if ($key =~ /^$tag/) { |
Line 451 sub answer_footer {
|
Line 394 sub answer_footer {
|
return $result; |
return $result; |
} |
} |
|
|
|
sub showallfoils { |
|
my $return=0; |
|
if (defined($ENV{'form.showallfoils'}) && |
|
$ENV{'request.state'} eq 'construct') { |
|
$return=1; |
|
} |
|
return $return; |
|
} |
|
|
|
sub getresponse { |
|
my ($temp)=@_; |
|
my $formparm='form.HWVAL_'.$Apache::inputtags::response['-1']; |
|
my $response; |
|
if (!defined($temp)) { |
|
$temp=1; |
|
} else { |
|
$formparm.=":$temp"; |
|
} |
|
my %let_to_num=('A'=>0,'B'=>1,'C'=>2,'D'=>3,'E'=>4,'F'=>5,'G'=>6,'H'=>7, |
|
'I'=>8,'J'=>9,'K'=>10,'L'=>11,'M'=>12,'N'=>13,'O'=>14, |
|
'P'=>15,'Q'=>16,'R'=>17,'S'=>18,'T'=>19,'U'=>20,'V'=>21, |
|
'W'=>22,'X'=>23,'Y'=>24,'Z'=>25); |
|
if ($ENV{'form.submitted'} eq 'scantron') { |
|
$response = $ENV{'scantron.'.($Apache::lonxml::counter+$temp-1). |
|
'.answer'}; |
|
$response = $let_to_num{$response}; |
|
} else { |
|
$response = $ENV{$formparm}; |
|
} |
|
return $response; |
|
} |
1; |
1; |
__END__ |
__END__ |
|
|