version 1.69, 2002/11/07 15:12:23
|
version 1.77, 2003/02/23 20:31:51
|
Line 85 sub start_numericalresponse {
|
Line 85 sub start_numericalresponse {
|
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::tag_start($target,$token); |
$result.=&Apache::edit::text_arg('Answer:','answer',$token); |
$result.=&Apache::edit::text_arg('Answer:','answer',$token); |
if ($token->[1] eq 'numericalresponse') { |
if ($token->[1] eq 'numericalresponse') { |
$result.=&Apache::edit::text_arg('Unit:','unit',$token,5); |
$result.=&Apache::edit::text_arg('Unit:','unit',$token,5). |
$result.=&Apache::edit::text_arg('Format:','format',$token,4); |
&Apache::loncommon::help_open_topic('Physical_Units'); |
|
$result.=&Apache::edit::text_arg('Format:','format',$token,4). |
|
&Apache::loncommon::help_open_topic('Numerical_Response_Format'); |
} elsif ($token->[1] eq 'stringresponse') { |
} elsif ($token->[1] eq 'stringresponse') { |
$result.=&Apache::edit::select_arg('Type:','type', |
$result.=&Apache::edit::select_arg('Type:','type', |
['cs','ci','mc'],$token); |
[['cs','Case Sensitive'],['ci','Case Insensitive'], |
|
['mc','Case Insensitive, Any Order']],$token); |
} elsif ($token->[1] eq 'formularesponse') { |
} elsif ($token->[1] eq 'formularesponse') { |
$result.=&Apache::edit::text_arg('Sample Points:','samples',$token,40); |
$result.=&Apache::edit::text_arg('Sample Points:','samples',$token,40); |
} |
} |
Line 112 sub start_numericalresponse {
|
Line 115 sub start_numericalresponse {
|
} |
} |
} elsif ($target eq 'meta') { |
} elsif ($target eq 'meta') { |
$result=&Apache::response::meta_package_write('numericalresponse'); |
$result=&Apache::response::meta_package_write('numericalresponse'); |
|
} elsif ($target eq 'answer' || $target eq 'grade') { |
|
&Apache::response::reset_params(); |
} |
} |
return $result; |
return $result; |
} |
} |
Line 119 sub start_numericalresponse {
|
Line 124 sub start_numericalresponse {
|
sub end_numericalresponse { |
sub end_numericalresponse { |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; |
my $result = ''; |
my $result = ''; |
|
if (!$Apache::lonxml::default_homework_loaded) { |
|
&Apache::lonxml::default_homework_load($safeeval); |
|
} |
if ( $target eq 'grade' ) { |
if ( $target eq 'grade' ) { |
if ( defined $ENV{'form.submitted'}) { |
if ( defined $ENV{'form.submitted'}) { |
&Apache::response::setup_params($$tagstack[-1]); |
&Apache::response::setup_params($$tagstack[-1]); |
Line 169 sub end_numericalresponse {
|
Line 177 sub end_numericalresponse {
|
if ($target eq 'web') { |
if ($target eq 'web') { |
$result="<br />The correct answer is "; |
$result="<br />The correct answer is "; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result='\vskip 0 mm The correct answer is \\texttt{'; |
#$result='\vskip 0 mm The correct answer is \\texttt{'; |
} |
} |
for (my $i=0; $i <= $#answers; $i++) { |
for (my $i=0; $i <= $#answers; $i++) { |
my $answer=$answers[$i]; |
my $answer=$answers[$i]; |
Line 187 sub end_numericalresponse {
|
Line 195 sub end_numericalresponse {
|
&Apache::lonxml::debug("no format answer :$answer:"); |
&Apache::lonxml::debug("no format answer :$answer:"); |
$formatted="$answer,"; |
$formatted="$answer,"; |
} |
} |
if ($target eq 'tex') {$formatted=&Apache::lonxml::latex_special_symbols($formatted);} |
|
$result.=$formatted; |
if ($target eq 'tex') { |
} |
$formatted=''; |
|
#$formatted=&Apache::lonxml::latex_special_symbols($formatted); |
|
} |
|
$result.=$formatted; |
|
} |
chop $result; |
chop $result; |
if ($target eq 'web') { |
if ($target eq 'web') { |
$result.=" $unit.<br />"; |
$result.=" $unit.<br />"; |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
$result.=&Apache::lonxml::latex_special_symbols($unit); |
#$result.=&Apache::lonxml::latex_special_symbols($unit); |
$result.="}. \\vskip 0 mm "; |
#$result.="}. \\vskip 0 mm "; |
} |
} |
} |
} |
if ($Apache::lonhomework::type eq 'exam') { |
if ($Apache::lonhomework::type eq 'exam') { |
Line 222 sub end_numericalresponse {
|
Line 234 sub end_numericalresponse {
|
my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', |
my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', |
'Q','R','S','T','U','V','W','X','Y','Z'); |
'Q','R','S','T','U','V','W','X','Y','Z'); |
if ($target eq 'web') { |
if ($target eq 'web') { |
|
if ($$tagstack[-1] eq 'numericalresponse') { |
|
my $id=$Apache::inputtags::response[-1]; |
$result.= '<table border="1"><tr>'; |
$result.= '<table border="1"><tr>'; |
for ($ind=0;$ind<$number_of_bubbles;$ind++) { |
for ($ind=0;$ind<$number_of_bubbles;$ind++) { |
my $ans; |
my $ans; |
Line 240 sub end_numericalresponse {
|
Line 254 sub end_numericalresponse {
|
} |
} |
$ans = sprintf('%.'.$format,$bubbles_values[$ind]); |
$ans = sprintf('%.'.$format,$bubbles_values[$ind]); |
} |
} |
$result.='<td>'.$alphabet[$ind].': '.$ans.'</td>'; |
$result.='<td><input type="radio" name="HWVAL'.$id.'" value="'.$ans.'"><b>'.$alphabet[$ind].'</b>: '.$ans.'</td>'; |
} |
} |
$result.='</tr></table>'; |
$result.='</tr></table>'; |
|
} elsif ($$tagstack[-1] eq 'formularesponse') { |
|
$result.= '<br /><br /><font color="red"> Formula have to be entered here! </font><br /><br />'; |
|
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
my $max_val = 0; |
if ($$tagstack[-1] eq 'numericalresponse') { |
if ($formats[0]=~m/^(\d+)E([^\d]*)(\d*)$/) { |
my $max_val = 0; |
$max_val=$1+$2+4; |
if ($formats[0]=~m/^(\d+)E([^\d]*)(\d*)$/) { |
} else { |
$max_val=$1+$2+4; |
$max_val=4; |
} else { |
} |
$max_val=4; |
$max_val = int(0.9*$ENV{'form.textwidth'}/(($max_val+6)*2)); |
} |
my $celllength = 0.9*$ENV{'form.textwidth'}/$max_val-10; |
$max_val = int(0.9*$ENV{'form.textwidth'}/(($max_val+6)*2)); |
my @table_range = (); |
my $celllength = 0.9*$ENV{'form.textwidth'}/$max_val-10; |
my $number_of_tables = int($number_of_bubbles/$max_val); |
my @table_range = (); |
for (my $i=0;$i<$number_of_tables;$i++) {push @table_range,$max_val;} |
my $number_of_tables = int($number_of_bubbles/$max_val); |
if ($number_of_bubbles % $max_val != 0) { |
for (my $i=0;$i<$number_of_tables;$i++) {push @table_range,$max_val;} |
$number_of_tables++; |
if ($number_of_bubbles % $max_val != 0) { |
push @table_range,($number_of_bubbles % $max_val); |
$number_of_tables++; |
} |
push @table_range,($number_of_bubbles % $max_val); |
my $j=0; |
|
my $cou=0; |
|
$result.='\vskip -1 mm \noindent \begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]'; |
|
for (my $i=0;$i<$number_of_tables;$i++) { |
|
$result.='\vskip -1 mm \noindent \begin{tabular}{'; |
|
for ($ind=0;$ind<$table_range[$j];$ind++) { |
|
$result.='lp{'.$celllength.' mm}'; |
|
} |
} |
$result.='}'; |
my $j=0; |
for ($ind=$cou;$ind<$cou+$table_range[$j];$ind++) { |
my $cou=0; |
my $ans; |
$result.='\vskip -1 mm \noindent \begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]'; |
if ($formats[0] ne '') { |
for (my $i=0;$i<$number_of_tables;$i++) { |
$ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]); |
$result.='\vskip -1 mm \noindent \begin{tabular}{'; |
if ($ans =~ m/([0-9\.\-\+]+)E([0-9\-\+]+)/ ) { |
for ($ind=0;$ind<$table_range[$j];$ind++) { |
my $number = $1; |
$result.='lp{'.$celllength.' mm}'; |
my $power = $2; |
} |
$power=~s/^\+//; |
$result.='}'; |
$power=~s/^(-?)0+(\d+)//; |
for ($ind=$cou;$ind<$cou+$table_range[$j];$ind++) { |
$ans=$number.'$\times 10^{'.$1.$2.'}$'; #'stupidemacs |
my $ans; |
} |
if ($formats[0] ne '') { |
} else { |
$ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]); |
my $badans = $bubbles_values[$ind]; |
if ($ans =~ m/([0-9\.\-\+]+)E([0-9\-\+]+)/ ) { |
my $format = ''; |
my $number = $1; |
#What is the number? (integer,decimal,floating point) |
my $power = $2; |
if ($badans=~/^(\d*\.?\d*)(E|e)(\d*)$/) { |
$power=~s/^\+//; |
$format = 'e'.$2; |
$power=~s/^(-?)0+(\d+)//; |
} elsif ($badans=~/^(\d*)\.(\d*)$/) { |
$ans=$number.'$\times 10^{'.$1.$2.'}$'; #'stupidemacs |
$format = '4f'; |
} |
} elsif ($badans=~/^(\d*)$/) { |
} else { |
$format = 'd'; |
my $badans = $bubbles_values[$ind]; |
} |
my $format = ''; |
$ans = sprintf('%.'.$format,$bubbles_values[$ind]); |
#What is the number? (integer,decimal,floating point) |
if ($ans =~ m/([0-9\.\-\+]+)E([0-9\-\+]+)/ ) { |
if ($badans=~/^(\d*\.?\d*)(E|e)(\d*)$/) { |
my $number = $1; |
$format = 'e'.$2; |
my $power = $2; |
} elsif ($badans=~/^(\d*)\.(\d*)$/) { |
$power=~s/^\+//; |
$format = '4f'; |
$power=~s/^(-?)0+(\d+)//; |
} elsif ($badans=~/^(\d*)$/) { |
$ans=$number.'$\times 10^{'.$1.$2.'}$'; #'stupidemacs |
$format = 'd'; |
} |
} |
} |
$ans = sprintf('%.'.$format,$bubbles_values[$ind]); |
$result.='\hskip -3 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -2 mm & {\small '.$ans.'} '; |
if ($ans =~ m/([0-9\.\-\+]+)E([0-9\-\+]+)/ ) { |
if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';} |
my $number = $1; |
} |
my $power = $2; |
$cou += $table_range[$j]; |
$power=~s/^\+//; |
$j++; |
$power=~s/^(-?)0+(\d+)//; |
$result.='\\\\\end{tabular}\vskip 0 mm '; |
$ans=$number.'$\times 10^{'.$1.$2.'}$'; #'stupidemacs |
} |
} |
$result.='\end{enumerate}'; |
} |
&Apache::lonxml::increment_counter(); |
$result.='\hskip -3 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -2 mm & {\small '.$ans.'} '; |
|
if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';} |
|
} |
|
$cou += $table_range[$j]; |
|
$j++; |
|
$result.='\\\\\end{tabular}\vskip 0 mm '; |
|
} |
|
$result.='\end{enumerate}'; |
|
&Apache::lonxml::increment_counter(); |
|
} else { |
|
$result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}'; |
|
$result.= '\begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]\textit{Live blank on scoring form}\vskip 0 mm \end{enumerate}'; |
|
&Apache::lonxml::increment_counter(); |
|
} |
} |
} |
} |
} |
} elsif ($target eq 'edit') { |
} elsif ($target eq 'edit') { |
Line 353 sub end_numericalresponse {
|
Line 376 sub end_numericalresponse {
|
} |
} |
} |
} |
if ($target eq 'answer') { |
if ($target eq 'answer') { |
if ($high) { $ans.=' ['.$low.','.$high.'] '; } |
if ($high) { $ans.=' ['.$low.','.$high.']'; } |
if ($sighigh) { $ans.= "Sig <i>$siglow - $sighigh</i>"; } |
if ($sighigh) { $ans.= " Sig <i>$siglow - $sighigh</i>"; } |
$result.=&Apache::response::answer_part($$tagstack[-1],$ans); |
$result.=&Apache::response::answer_part($$tagstack[-1],$ans); |
} elsif ($target eq 'analyze') { |
} elsif ($target eq 'analyze') { |
push (@{ $Apache::lonhomework::analyze{"$part_id.answer"} }, |
push (@{ $Apache::lonhomework::analyze{"$part_id.answer"} }, |