Answer for Part:'. + $Apache::inputtags::part. ' | '."\n"; + } + return $result; } -sub setup_params { - my ($tag) = @_; - - @Apache::inputtags::params=(); - my %paramlist=(); - foreach my $key (keys(%Apache::lonnet::packagetab)) { - if ($key =~ /^$tag/) { - my ($package,$name) = split(/&/,$key); - $paramlist{$name}=1; - } - } - foreach my $key (keys(%paramlist)) { - my $entry= 'resource.'.$Apache::inputtags::part; - if (defined($Apache::inputtags::response[-1])) { - $entry.='_'.$Apache::inputtags::response[-1]; +sub answer_part { + my ($type,$answer) = @_; + my $result; + if ($ENV{'form.answer_output_mode'} eq 'tex') { + $result = ' \verb|'.$answer.'|\\\\ \hline '; + } else { + $result = ''.$answer.' | '; } - $entry.='.'.$key; - &Apache::lonxml::debug("looking for $entry"); - my $value = &Apache::lonnet::EXT("$entry"); - &Apache::lonxml::debug("$key has value :$value:"); - if ($value eq 'con_lost' || $value =~ /^error:/) { - &Apache::lonxml::debug("using nothing"); - $Apache::inputtags::params{$key}=''; + return $result; +} + +sub answer_footer { + my ($type) = @_; + my $result; + if ($ENV{'form.answer_output_mode'} eq 'tex') { + $result = ' \end{tabular} \vskip 0 mm '; } else { - &Apache::lonxml::debug("using value"); - $Apache::inputtags::params{$key}=$value; + $result = '
Answer for Part:'. - $Apache::inputtags::part. ' | ||
---|---|---|
Answer for Part:'. - $Apache::inputtags::part. ' | '."\n"; - } - return $result; +sub showallfoils { + my $return=0; + if (defined($ENV{'form.showallfoils'}) && + $ENV{'request.state'} eq 'construct') { + $return=1; + } + return $return; } -sub answer_part { - my ($type,$answer) = @_; - my $result; - if ($type eq 'optionresponse') { - $result = ''.$answer.' | '; - } else { - $result = ''.$answer.' | '; - } - return $result; +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') { + my $part = $Apache::inputtags::part; + my $id = $Apache::inputtags::response[-1]; + $response = $ENV{'scantron.'.($Apache::lonxml::counter+$temp-1). + '.answer'}; + # save bubbled letter for later + $Apache::lonhomework::results{"resource.$part.$id.scantron"}.= + $response; + $response = $let_to_num{$response}; + } else { + $response = $ENV{$formparm}; + } + return $response; } -sub answer_footer { - my ($type) = @_; - my $result; - if ($type eq 'optionresponse') { - $result = '