version 1.75, 2002/12/02 17:06:09
|
version 1.76, 2003/01/13 21:22:00
|
Line 193 sub end_numericalresponse {
|
Line 193 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') { |
if ($target eq 'tex') { |
$formatted=''; |
$formatted=''; |
#$formatted=&Apache::lonxml::latex_special_symbols($formatted); |
#$formatted=&Apache::lonxml::latex_special_symbols($formatted); |
Line 231 sub end_numericalresponse {
|
Line 232 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]; |
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++) { |
Line 253 sub end_numericalresponse {
|
Line 255 sub end_numericalresponse {
|
$result.='<td><input type="radio" name="HWVAL'.$id.'" value="'.$ans.'"><b>'.$alphabet[$ind].'</b>: '.$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') { |