Annotation of loncom/homework/caparesponse/caparesponse.pm, revision 1.190
1.3 albertel 1: # The LearningOnline Network with CAPA
2: # caparesponse definition
1.47 albertel 3: #
1.190 ! albertel 4: # $Id: caparesponse.pm,v 1.1 2006/06/12 13:51:13 bisitz Exp $
1.47 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.3 albertel 28:
29: package Apache::caparesponse;
30: use strict;
1.4 albertel 31: use capa;
1.190 ! albertel 32: use Safe::Hole;
! 33: use Apache::lonmaxima();
1.129 www 34: use Apache::lonlocal;
1.166 albertel 35: use Apache::lonnet;
1.3 albertel 36:
1.50 harris41 37: BEGIN {
1.190 ! albertel 38: &Apache::lonxml::register('Apache::caparesponse',('caparesponse','numericalresponse','stringresponse','formularesponse','mathresponse'));
1.3 albertel 39: }
40:
1.181 albertel 41: my %answer;
42: my $cur_name;
43: sub start_answer {
44: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
45: my $result;
46: $cur_name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
47: if ($cur_name =~ /^\s*$/) { $cur_name = $Apache::lonxml::curdepth; }
48: my $type = &Apache::lonxml::get_param('type',$parstack,$safeeval);
49: if (!defined($type) && $tagstack->[-2] eq 'answergroup') {
50: $type = &Apache::lonxml::get_param('type',$parstack,$safeeval,-2);
51: }
52: if (!defined($type)) { $type = 'ordered' };
53: $answer{$cur_name}= { 'type' => $type,
54: 'answers' => [] };
55: return $result;
56: }
57:
58: sub end_answer {
59: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
60: my $result;
61: undef($cur_name);
62: return $result;
63: }
64:
65: sub start_answergroup {
66: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
67: my $result;
68: my $id = $Apache::inputtags::response[-1];
69: my $dis = &Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval);
70: if (defined($dis)) { $Apache::inputtags::answertxt{$id}=$dis; }
71: return $result;
72: }
73:
74: sub end_answergroup {
75: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
76: my $result;
77: return $result;
78: }
79:
80: sub start_value {
1.182 albertel 81: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.181 albertel 82: my $result;
83: if ( $target eq 'web' || $target eq 'tex' ||
84: $target eq 'grade' || $target eq 'webgrade' ||
85: $target eq 'answer' || $target eq 'analyze' ) {
1.182 albertel 86: my $bodytext = &Apache::lonxml::get_all_text("/value",$parser,$style);
1.181 albertel 87: $bodytext = &Apache::run::evaluate($bodytext,$safeeval,
88: $$parstack[-1]);
89: push(@{ $answer{$cur_name}{'answers'} },$bodytext);
90: }
91: return $result;
92: }
93:
94: sub end_value {
95: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
96: my $result;
97: return $result;
98: }
99:
100: sub start_array {
1.182 albertel 101: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.181 albertel 102: my $result;
103: if ( $target eq 'web' || $target eq 'tex' ||
104: $target eq 'grade' || $target eq 'webgrade' ||
105: $target eq 'answer' || $target eq 'analyze' ) {
1.182 albertel 106: my $bodytext = &Apache::lonxml::get_all_text("/array",$parser,$style);
1.181 albertel 107: my @values = &Apache::run::evaluate($bodytext,$safeeval,
108: $$parstack[-1]);
109: push(@{ $answer{$cur_name}{'answers'} },@values);
110: }
111: return $result;
112: }
113:
114: sub end_array {
115: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
116: my $result;
117: return $result;
118: }
119:
120: sub start_unit {
121: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
122: my $result;
123: return $result;
124: }
125:
126: sub end_unit {
127: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
128: my $result;
129: return $result;
130: }
131:
1.89 albertel 132: sub start_numericalresponse {
133: my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.181 albertel 134: &Apache::lonxml::register('Apache::caparesponse',('answer','answergroup','value','array','unit'));
1.89 albertel 135: my $id = &Apache::response::start_response($parstack,$safeeval);
136: my $result;
1.181 albertel 137: undef(%answer);
138: undef(%{$safeeval->varglob('LONCAPA::CAPAresponse_args')});
1.89 albertel 139: if ($target eq 'edit') {
140: $result.=&Apache::edit::tag_start($target,$token);
141: $result.=&Apache::edit::text_arg('Answer:','answer',$token);
142: if ($token->[1] eq 'numericalresponse') {
1.122 albertel 143: $result.=&Apache::edit::text_arg('Incorrect Answers:','incorrect',
1.149 www 144: $token).
145: &Apache::loncommon::help_open_topic('numerical_wrong_answers');
1.89 albertel 146: $result.=&Apache::edit::text_arg('Unit:','unit',$token,5).
147: &Apache::loncommon::help_open_topic('Physical_Units');
148: $result.=&Apache::edit::text_arg('Format:','format',$token,4).
149: &Apache::loncommon::help_open_topic('Numerical_Response_Format');
150: } elsif ($token->[1] eq 'formularesponse') {
151: $result.=&Apache::edit::text_arg('Sample Points:','samples',
152: $token,40).
153: &Apache::loncommon::help_open_topic('Formula_Response_Sampling');
154: }
155: $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
156: } elsif ($target eq 'modified') {
157: my $constructtag;
158: if ($token->[1] eq 'numericalresponse') {
159: $constructtag=&Apache::edit::get_new_args($token,$parstack,
160: $safeeval,'answer',
1.156 albertel 161: 'incorrect','unit',
1.117 albertel 162: 'format');
1.89 albertel 163: } elsif ($token->[1] eq 'formularesponse') {
164: $constructtag=&Apache::edit::get_new_args($token,$parstack,
165: $safeeval,'answer',
166: 'samples');
167: }
168: if ($constructtag) {
169: $result = &Apache::edit::rebuild_tag($token);
170: $result.=&Apache::edit::handle_insert();
1.22 albertel 171: }
1.89 albertel 172: } elsif ($target eq 'meta') {
173: $result=&Apache::response::meta_package_write('numericalresponse');
174: } elsif ($target eq 'answer' || $target eq 'grade') {
175: &Apache::response::reset_params();
1.96 albertel 176: } elsif ($target eq 'web') {
177: my $partid = $Apache::inputtags::part;
178: my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');
179: &Apache::lonxml::debug("Got unit $hideunit for $partid $id");
180: #no way to enter units, with radio buttons
181: if (lc($hideunit) eq "yes") {
182: my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
183: $safeeval);
184: if ($unit =~ /\S/) { $result.=" (in $unit) "; }
185: }
1.146 albertel 186: if ( &Apache::response::show_answer() ) {
187: my $answertxt;
188: my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,
189: $safeeval);
190: my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,
191: $safeeval);
192: my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
193: $safeeval);
194: for (my $i=0; $i <= $#answers; $i++) {
195: my $answer=$answers[$i];
1.186 albertel 196: if ( scalar(@$tagstack)
197: && $tagstack->[-1] ne 'numericalresponse') {
198: $answertxt.=$answer.',';
1.146 albertel 199: } else {
1.186 albertel 200: my $format;
201: if ($#formats > 0) {
202: $format=$formats[$i];
203: } else {
204: $format=$formats[0];
205: }
206: if ($unit=~/\$/) { $format="\$".$format; $unit=~s/\$//g; }
207: if ($unit=~/\,/) { $format="\,".$format; $unit=~s/\,//g; }
208: my $formatted=&format_number($answer,$format,$target,
209: $safeeval);
210: $answertxt.=$formatted.',';
1.146 albertel 211: }
212: }
213: chop $answertxt;
214: if ($target eq 'web') {
1.148 albertel 215: $answertxt.=" $unit ";
1.146 albertel 216: }
217: $Apache::inputtags::answertxt{$id}=$answertxt;
218: }
1.16 albertel 219: }
1.89 albertel 220: return $result;
1.21 albertel 221: }
222:
1.167 albertel 223: sub check_submission {
1.171 albertel 224: my ($response,$partid,$id,$tag,$parstack,$safeeval,$ignore_sig)=@_;
1.167 albertel 225: my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
226: $$args_ref{'response'}=$response;
227: my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');
228:
229: foreach my $arg ('type','tol','sig','format','unit','calc',
230: 'samples') {
231: $$args_ref{$arg}=
232: &Apache::lonxml::get_param($arg,$parstack,$safeeval);
233: }
234: foreach my $key (keys(%Apache::inputtags::params)) {
235: $$args_ref{$key}=$Apache::inputtags::params{$key};
236: }
237:
238: #no way to enter units, with radio buttons
239: if ($Apache::lonhomework::type eq 'exam' ||
240: lc($hideunit) eq "yes") {
241: delete($$args_ref{'unit'});
242: }
243: #sig fig don't make much sense either
244: if (($Apache::lonhomework::type eq 'exam' ||
1.171 albertel 245: &Apache::response::submitted('scantron') ||
246: $ignore_sig) &&
1.167 albertel 247: $tag eq 'numericalresponse') {
248: delete($$args_ref{'sig'});
249: }
250:
251: if ($tag eq 'formularesponse') {
252: $$args_ref{'type'}='fml';
1.190 ! albertel 253: } elsif ($tag eq 'mathresponse') {
! 254: $$args_ref{'type'}='math';
1.167 albertel 255: } elsif ($tag eq 'numericalresponse') {
256: $$args_ref{'type'}='float';
257: }
258: my @answer=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
259: &Apache::lonxml::debug('answer is'.join(':',@answer));
1.181 albertel 260: if (@answer && defined($answer[0])) {
261: $answer{'INTERNAL'}= {'type' => 'ordered',
262: 'answers' => \@answer };
263: }
264: #FIXME would be nice if we could save name so we know who graded him
265: #correct
266: my (%results,@final_awards,@final_msgs,@names);
267: foreach my $name (keys(%answer)) {
268: &Apache::lonxml::debug(" doing $name with ".join(':',@{ $answer{$name}{'answers'} }));
269: @{$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=@{ $answer{$name}{'answers'} };
270: my ($result,@msgs) =
271: &Apache::run::run("&caparesponse_check_list()",$safeeval);
272: &Apache::lonxml::debug('msgs are '.join(':',@msgs));
273: my ($awards)=split(/:/,$result);
274: my @awards= split(/,/,$awards);
275: my ($ad, $msg) = &Apache::inputtags::finalizeawards(\@awards,\@msgs);
276: $results{$name}= [$ad,$msg];
277: push(@final_awards,$ad);
278: push(@final_msgs,$msg);
279: push(@names,$name);
280: }
281: my ($ad, $msg, $name) = &Apache::inputtags::finalizeawards(\@final_awards,
282: \@final_msgs,
283: \@names,1);
284: return($ad,$msg);
1.167 albertel 285: }
286:
1.89 albertel 287: sub end_numericalresponse {
288: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.90 albertel 289: my $increment=1;
1.89 albertel 290: my $result = '';
291: if (!$Apache::lonxml::default_homework_loaded) {
292: &Apache::lonxml::default_homework_load($safeeval);
1.34 albertel 293: }
1.167 albertel 294: my $partid = $Apache::inputtags::part;
295: my $id = $Apache::inputtags::response[-1];
1.125 albertel 296: my $tag;
1.190 ! albertel 297: my $safehole = new Safe::Hole;
1.168 albertel 298: $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
1.190 ! albertel 299: $safehole->wrap(\&Apache::lonmaxima::maxima_check,$safeeval,'&maxima_check');
! 300:
1.125 albertel 301: if (scalar(@$tagstack)) { $tag=$$tagstack[-1]; }
1.162 albertel 302: if ( $target eq 'grade' && &Apache::response::submitted() ) {
1.140 albertel 303: &Apache::response::setup_params($tag,$safeeval);
1.95 albertel 304: if ($Apache::lonhomework::type eq 'exam' &&
1.190 ! albertel 305: (($tag eq 'formularesponse') || ($tag eq 'mathresponse'))) {
1.95 albertel 306: $increment=&Apache::response::scored_response($partid,$id);
307: } else {
308: my $response = &Apache::response::getresponse();
309: if ( $response =~ /[^\s]/) {
310: my %previous = &Apache::response::check_for_previous($response,$partid,$id);
311: &Apache::lonxml::debug("submitted a $response<br>\n");
312: &Apache::lonxml::debug($$parstack[-1] . "\n<br>");
313:
1.162 albertel 314: if ( &Apache::response::submitted('scantron')) {
1.184 albertel 315: my ($values,$display)=&make_numerical_bubbles($partid,$id,
316: $target,$parstack,$safeeval);
1.158 albertel 317: $response=$values->[$response];
1.95 albertel 318: }
1.115 albertel 319: $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
1.181 albertel 320: my ($ad,$msg)=&check_submission($response,$partid,$id,
321: $tag,$parstack,$safeeval);
1.167 albertel 322:
1.142 albertel 323: &Apache::lonxml::debug('ad is'.$ad);
324: if ($ad eq 'SIG_FAIL') {
325: my ($sig_u,$sig_l)=
326: &get_sigrange($Apache::inputtags::params{'sig'});
327: $msg=join(':',$msg,$sig_l,$sig_u);
328: &Apache::lonxml::debug("sigs bad $sig_u $sig_l ".
329: $Apache::inputtags::params{'sig'});
330: }
1.95 albertel 331: &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");
1.163 albertel 332: if ($Apache::lonhomework::type eq 'survey' &&
333: ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
334: $ad eq 'EXACT_ANS')) {
335: $ad='SUBMITTED';
336: }
1.95 albertel 337: &Apache::response::handle_previous(\%previous,$ad);
338: $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
1.142 albertel 339: $Apache::lonhomework::results{"resource.$partid.$id.awardmsg"}=$msg;
1.95 albertel 340: $result='';
1.90 albertel 341: }
1.89 albertel 342: }
343: } elsif ($target eq 'web' || $target eq 'tex') {
1.90 albertel 344: my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,
345: $safeeval);
1.89 albertel 346: my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
347: my $status = $Apache::inputtags::status['-1'];
348: if ($Apache::lonhomework::type eq 'exam') {
1.184 albertel 349: my ($bubble_values,$bubble_display)=
350: &make_numerical_bubbles($partid,$id,$target,$parstack,
351: $safeeval);
352: my $number_of_bubbles = scalar(@{ $bubble_values });
1.89 albertel 353: my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
354: $safeeval);
355: my @alphabet=('A'..'Z');
356: if ($target eq 'web') {
1.125 albertel 357: if ($tag eq 'numericalresponse') {
1.89 albertel 358: if ($unit=~/\S/) {$result.=' (in '.$unit.')<br /><br />';}
359: $result.= '<table border="1"><tr>';
1.116 albertel 360: my $previous=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.$id.submission"};
1.90 albertel 361: for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
1.116 albertel 362: my $checked='';
1.158 albertel 363: if ($previous eq $bubble_values->[$ind]) {
1.116 albertel 364: $checked=" checked='on' ";
365: }
1.90 albertel 366: $result.='<td><input type="radio" name="HWVAL_'.$id.
1.158 albertel 367: '" value="'.$bubble_values->[$ind].'" '.$checked
1.116 albertel 368: .' /><b>'.$alphabet[$ind].'</b>: '.
1.158 albertel 369: $bubble_display->[$ind].'</td>';
1.89 albertel 370: }
371: $result.='</tr></table>';
372: }
373: } elsif ($target eq 'tex') {
1.107 sakharuk 374: if ((defined $unit) and ($unit=~/\S/) and ($Apache::lonhomework::type eq 'exam')) {
1.89 albertel 375: $result.=' \textit{(in} \verb|'.$unit.'|\textit{)} ';
376: }
1.125 albertel 377: if ($tag eq 'numericalresponse') {
1.90 albertel 378: my ($celllength,$number_of_tables,@table_range)=
1.159 albertel 379: &get_table_sizes($number_of_bubbles,$bubble_display);
1.89 albertel 380: my $j=0;
381: my $cou=0;
382: $result.='\vskip -1 mm \noindent \begin{enumerate}\item[\textbf{'.$Apache::lonxml::counter.'}.]';
383: for (my $i=0;$i<$number_of_tables;$i++) {
1.144 sakharuk 384: $result.='\vskip -1 mm \noindent \setlength{\tabcolsep}{2 mm}\begin{tabular}{';
1.90 albertel 385: for (my $ind=0;$ind<$table_range[$j];$ind++) {
1.128 sakharuk 386: $result.='p{3 mm}p{'.$celllength.' mm}';
1.89 albertel 387: }
388: $result.='}';
1.90 albertel 389: for (my $ind=$cou;$ind<$cou+$table_range[$j];$ind++) {
1.159 albertel 390: $result.='\hskip -4 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$ & \hskip -3 mm {\small '.$bubble_display->[$ind].'} ';
1.89 albertel 391: if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';}
392: }
393: $cou += $table_range[$j];
394: $j++;
395: $result.='\\\\\end{tabular}\vskip 0 mm ';
396: }
397: $result.='\end{enumerate}';
398: } else {
1.188 albertel 399: $increment = &Apache::response::repetition();
1.89 albertel 400: }
401: }
402: }
403: } elsif ($target eq 'edit') {
404: $result.='</td></tr>'.&Apache::edit::end_table;
405: } elsif ($target eq 'answer' || $target eq 'analyze') {
1.167 albertel 406: my $part_id="$partid.$id";
1.89 albertel 407: if ($target eq 'analyze') {
408: push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
1.125 albertel 409: $Apache::lonhomework::analyze{"$part_id.type"} = $tag;
1.117 albertel 410: my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,$safeeval);
1.161 albertel 411: if ($#incorrect eq 0) { @incorrect=(split(/,/,$incorrect[0])); }
1.117 albertel 412: push (@{ $Apache::lonhomework::analyze{"$part_id.incorrect"} }, @incorrect);
1.154 albertel 413: &Apache::response::check_if_computed($token,$parstack,
414: $safeeval,'answer');
1.89 albertel 415: }
1.125 albertel 416: if (scalar(@$tagstack)) {
1.140 albertel 417: &Apache::response::setup_params($tag,$safeeval);
1.125 albertel 418: }
1.89 albertel 419: my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
1.58 sakharuk 420: my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval);
421: my $unit=&Apache::lonxml::get_param_var('unit',$parstack,$safeeval);
1.89 albertel 422: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval);
423:
424: if ($target eq 'answer') {
1.125 albertel 425: $result.=&Apache::response::answer_header($tag);
1.185 albertel 426: if ($tag eq 'numericalresponse'
427: && $Apache::lonhomework::type eq 'exam') {
1.184 albertel 428: my ($bubble_values,undef,$correct) = &make_numerical_bubbles($partid,
429: $id,$target,$parstack,$safeeval);
430: $result.=&Apache::response::answer_part($tag,$correct);
431: }
1.89 albertel 432: }
1.176 albertel 433: my ($sigline,$tolline);
1.89 albertel 434: for(my $i=0;$i<=$#answers;$i++) {
435: my $ans=$answers[$i];
1.90 albertel 436: my $fmt=$formats[0];
437: if (@formats && $#formats) {$fmt=$formats[$i];}
1.89 albertel 438: my ($high,$low);
439: if ($Apache::inputtags::params{'tol'}) {
440: ($high,$low)=&get_tolrange($ans,$Apache::inputtags::params{'tol'});
441: }
442: my ($sighigh,$siglow);
443: if ($Apache::inputtags::params{'sig'}) {
444: ($sighigh,$siglow)=&get_sigrange($Apache::inputtags::params{'sig'});
445: }
1.125 albertel 446: if ($fmt && $tag eq 'numericalresponse') {
1.112 albertel 447: $fmt=~s/e/E/g;
1.156 albertel 448: if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; }
449: if ($unit=~/\,/) { $fmt="\,".$fmt; $unit=~s/\,//g; }
1.153 albertel 450: $ans = &format_number($ans,$fmt,$target,$safeeval);
1.155 albertel 451: #if ($high) {
452: # $high=&format_number($high,$fmt,$target,$safeeval);
453: # $low =&format_number($low,$fmt,$target,$safeeval);
454: #}
1.60 sakharuk 455: }
1.89 albertel 456: if ($target eq 'answer') {
1.176 albertel 457: if ($high && $tag eq 'numericalresponse') {
458: $ans.=' ['.$low.','.$high.']';
459: $tolline .= "[$low, $high]";
460: }
1.145 albertel 461: if (defined($sighigh) && $tag eq 'numericalresponse') {
1.166 albertel 462: if ($env{'form.answer_output_mode'} eq 'tex') {
1.106 sakharuk 463: $ans.= " Sig $siglow - $sighigh";
1.98 sakharuk 464: } else {
1.101 albertel 465: $ans.= " Sig <i>$siglow - $sighigh</i>";
1.176 albertel 466: $sigline .= "[$siglow, $sighigh]";
1.98 sakharuk 467: }
468: }
1.125 albertel 469: $result.=&Apache::response::answer_part($tag,$ans);
1.89 albertel 470: } elsif ($target eq 'analyze') {
471: push (@{ $Apache::lonhomework::analyze{"$part_id.answer"} }, $ans);
472: if ($high) {
473: push (@{ $Apache::lonhomework::analyze{"$part_id.ans_high"} }, $high);
474: push (@{ $Apache::lonhomework::analyze{"$part_id.ans_low"} }, $low);
1.58 sakharuk 475: }
1.165 albertel 476: if ($fmt) {
477: push (@{ $Apache::lonhomework::analyze{"$part_id.format"} }, $fmt);
478: }
1.79 sakharuk 479: }
1.176 albertel 480: }
481:
482: my @fmt_ans;
483: for(my $i=0;$i<=$#answers;$i++) {
484: my $ans=$answers[$i];
485: my $fmt=$formats[0];
486: if (@formats && $#formats) {$fmt=$formats[$i];}
487: if ($fmt && $tag eq 'numericalresponse') {
488: $fmt=~s/e/E/g;
489: if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; }
490: if ($unit=~/\,/) { $fmt="\,".$fmt; $unit=~s/\,//g; }
491: $ans = &format_number($ans,$fmt,$target,$safeeval);
1.177 albertel 492: if ($fmt=~/\$/ && $unit!~/\$/) { $ans=~s/\$//; }
1.176 albertel 493: }
494: push(@fmt_ans,$ans);
495: }
496: my $response=join(', ',@fmt_ans);
497: my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.
498: $id.'.turnoffunit');
499: if ($unit ne '' &&
500: ! ($Apache::lonhomework::type eq 'exam' ||
501: lc($hideunit) eq "yes") ) {
502: my $cleanunit=$unit;
503: $cleanunit=~s/\$\,//g;
504: $response.=" $cleanunit";
505: }
506:
1.181 albertel 507: my ($ad,$msg)=&check_submission($response,$partid,$id,$tag,
508: $parstack,$safeeval);
1.176 albertel 509: if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
510: my $error;
511: if ($tag eq 'formularesponse') {
1.183 albertel 512: $error=&mt('Computer\'s answer is incorrect ("[_1]").',$response);
1.176 albertel 513: } else {
514: # answer failed check if it is sig figs that is failing
1.181 albertel 515: my ($ad,$msg)=&check_submission($response,$partid,$id,
516: $tag,$parstack,
517: $safeeval,1);
1.176 albertel 518: if ($sigline ne '') {
519: $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] or significant figures [_3] need to be adjusted.',$response,$tolline,$sigline);
1.171 albertel 520: } else {
1.180 albertel 521: $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] needs to be adjusted.',$response,$tolline);
1.171 albertel 522: }
1.167 albertel 523: }
1.176 albertel 524: if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
525: &Apache::lonxml::error($error);
526: } else {
527: &Apache::lonxml::warning($error);
528: }
1.36 albertel 529: }
1.176 albertel 530:
1.102 albertel 531: if (defined($unit) and ($unit ne '') and
1.125 albertel 532: $tag eq 'numericalresponse') {
1.89 albertel 533: if ($target eq 'answer') {
1.166 albertel 534: if ($env{'form.answer_output_mode'} eq 'tex') {
1.125 albertel 535: $result.=&Apache::response::answer_part($tag,
1.106 sakharuk 536: " Unit: $unit ");
1.98 sakharuk 537: } else {
1.125 albertel 538: $result.=&Apache::response::answer_part($tag,
1.98 sakharuk 539: "Unit: <b>$unit</b>");
540: }
1.89 albertel 541: } elsif ($target eq 'analyze') {
1.103 albertel 542: push (@{ $Apache::lonhomework::analyze{"$part_id.unit"} }, $unit);
1.89 albertel 543: }
544: }
1.125 albertel 545: if ($tag eq 'formularesponse' && $target eq 'answer') {
1.89 albertel 546: my $samples=&Apache::lonxml::get_param('samples',$parstack,$safeeval);
1.125 albertel 547: $result.=&Apache::response::answer_part($tag,$samples);
1.89 albertel 548: }
549: if ($target eq 'answer') {
1.125 albertel 550: $result.=&Apache::response::answer_footer($tag);
1.89 albertel 551: }
1.69 sakharuk 552: }
1.121 sakharuk 553: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
1.90 albertel 554: $target eq 'tex' || $target eq 'analyze') {
555: &Apache::lonxml::increment_counter($increment);
556: }
1.89 albertel 557: &Apache::response::end_response;
558: return $result;
1.90 albertel 559: }
560:
561: sub get_table_sizes {
1.128 sakharuk 562: my ($number_of_bubbles,$rbubble_values)=@_;
563: my $scale=2; #mm for one digit
564: my $cell_width=0;
565: foreach my $member (@$rbubble_values) {
566: my $cell_width_real=0;
1.160 albertel 567: if ($member=~/(\+|-)?(\d*)\.?(\d*)\s*\$?\\times\s*10\^{(\+|-)?(\d+)}\$?/) {
1.138 sakharuk 568: $cell_width_real=(length($2)+length($3)+length($5)+7)*$scale;
569: } elsif ($member=~/(\d*)\.?(\d*)(E|e)(\+|-)?(\d*)/) {
1.128 sakharuk 570: $cell_width_real=(length($1)+length($2)+length($5)+9)*$scale;
1.138 sakharuk 571: } elsif ($member=~/(\d*)\.(\d*)/) {
1.132 sakharuk 572: $cell_width_real=(length($1)+length($2)+3)*$scale;
1.128 sakharuk 573: } else {
1.138 sakharuk 574: $cell_width_real=(length($member)+1)*$scale*0.9;
1.128 sakharuk 575: }
576: if ($cell_width_real>$cell_width) {$cell_width=$cell_width_real;}
1.90 albertel 577: }
1.132 sakharuk 578: $cell_width+=8;
1.130 sakharuk 579: my $textwidth;
1.166 albertel 580: if ($env{'form.textwidth'} ne '') {
581: $env{'form.textwidth'}=~/(\d*)\.?(\d*)/;
1.132 sakharuk 582: $textwidth=$1.'.'.$2;
1.130 sakharuk 583: } else {
1.166 albertel 584: $env{'form.textwidth'}=~/(\d+)\.?(\d*)/;
1.132 sakharuk 585: $textwidth=$1.'.'.$2;
1.130 sakharuk 586: }
1.128 sakharuk 587: my $bubbles_per_line=int($textwidth/$cell_width);
1.151 sakharuk 588: if ($bubbles_per_line > $number_of_bubbles) {
589: $bubbles_per_line=$number_of_bubbles;
590: }elsif (($bubbles_per_line > $number_of_bubbles/2) && ($number_of_bubbles % 2==0)) {$bubbles_per_line=$number_of_bubbles/2;}
1.128 sakharuk 591: my $number_of_tables = int($number_of_bubbles/$bubbles_per_line);
1.90 albertel 592: my @table_range = ();
1.128 sakharuk 593: for (my $i=0;$i<$number_of_tables;$i++) {push @table_range,$bubbles_per_line;}
594: if ($number_of_bubbles % $bubbles_per_line) {
1.90 albertel 595: $number_of_tables++;
1.128 sakharuk 596: push @table_range,($number_of_bubbles % $bubbles_per_line);
1.90 albertel 597: }
1.128 sakharuk 598: $cell_width-=8;
1.136 sakharuk 599: $cell_width=$cell_width*3/4;
1.128 sakharuk 600: return ($cell_width,$number_of_tables,@table_range);
1.90 albertel 601: }
602:
603: sub format_number {
1.153 albertel 604: my ($number,$format,$target,$safeeval)=@_;
1.90 albertel 605: my $ans;
1.153 albertel 606: if ($format eq '') {
1.90 albertel 607: #What is the number? (integer,decimal,floating point)
1.187 albertel 608: if ($number=~/^(\d*\.?\d*)(E|e)[+\-]?(\d*)$/) {
1.113 sakharuk 609: $format = '3e';
1.90 albertel 610: } elsif ($number=~/^(\d*)\.(\d*)$/) {
611: $format = '4f';
612: } elsif ($number=~/^(\d*)$/) {
613: $format = 'd';
614: }
615: }
1.156 albertel 616: if (!$Apache::lonxml::default_homework_loaded) {
617: &Apache::lonxml::default_homework_load($safeeval);
618: }
1.153 albertel 619: $ans=&Apache::run::run("&prettyprint(q\0$number\0,q\0$format\0,q\0$target\0)",$safeeval);
1.90 albertel 620: return $ans;
621: }
622:
623: sub make_numerical_bubbles {
1.184 albertel 624: my ($part,$id,$target,$parstack,$safeeval) =@_;
625:
626: my $number_of_bubbles =
627: &Apache::response::get_response_param($part.'_'.$id,'numbubbles',8);
628:
629: my ($format)=&Apache::lonxml::get_param_var('format',$parstack,$safeeval);
630: my ($answer)=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
631: my (@incorrect)=&Apache::lonxml::get_param_var('incorrect',$parstack,
632: $safeeval);
633: if ($#incorrect eq 0) { @incorrect=(split(/,/,$incorrect[0])); }
634:
1.158 albertel 635: my @bubble_values=();
1.184 albertel 636: my @alphabet=('A'..'Z');
637:
638: &Apache::lonxml::debug("answer is $answer incorrect is @incorrect");
1.119 albertel 639: my @oldseed=&Math::Random::random_get_seed();
1.184 albertel 640: if (@incorrect) {
641: &Apache::lonxml::debug("inside ".(scalar(@incorrect)+1 gt $number_of_bubbles));
642: if (defined($incorrect[0]) &&
643: scalar(@incorrect)+1 >= $number_of_bubbles) {
644: &Apache::lonxml::debug("inside ".(scalar(@incorrect)+1).":$number_of_bubbles");
1.117 albertel 645: &Apache::response::setrandomnumber();
1.184 albertel 646: my @rand_inc=&Math::Random::random_permutation(@incorrect);
1.117 albertel 647: @bubble_values=@rand_inc[0..($number_of_bubbles-2)];
648: @bubble_values=sort {$a <=> $b} (@bubble_values,$answer);
1.184 albertel 649: &Apache::lonxml::debug("Answer was :$answer: returning :".$#bubble_values.": which are :".join(':',@bubble_values));
1.119 albertel 650: &Math::Random::random_set_seed(@oldseed);
1.184 albertel 651:
652: my $correct;
653: for(my $i=0; $i<=$#bubble_values;$i++) {
654: if ($bubble_values[$i] eq $answer) {
655: $correct = $alphabet[$i];
656: last;
657: }
658: }
659:
1.134 albertel 660: if (defined($format) && $format ne '') {
1.158 albertel 661: my @bubble_display;
1.137 albertel 662: foreach my $value (@bubble_values) {
1.158 albertel 663: push(@bubble_display,
664: &format_number($value,$format,$target,$safeeval));
1.134 albertel 665: }
1.184 albertel 666: return (\@bubble_values,\@bubble_display,$correct);
1.158 albertel 667: } else {
1.184 albertel 668: return (\@bubble_values,\@bubble_values,$correct);
1.134 albertel 669: }
1.117 albertel 670: }
1.184 albertel 671: if (defined($incorrect[0]) &&
672: scalar(@incorrect)+1 < $number_of_bubbles) {
673: &Apache::lonxml::warning("Not enough incorrect answers were specified in the incorrect array, ignoring the specified incorrect answers and instead generating them (".join(',',@incorrect).").");
1.127 albertel 674: }
1.117 albertel 675: }
1.90 albertel 676: my @factors = (1.13,1.17,1.25,1.33,1.45); #default values of factors
1.126 albertel 677: my @powers = (1..$number_of_bubbles);
1.90 albertel 678: &Apache::response::setrandomnumber();
679: my $ind=&Math::Random::random_uniform_integer(1,0,$#powers);
680: my $power = $powers[$ind];
681: $ind=&Math::Random::random_uniform_integer(1,0,$#factors);
682: my $factor = $factors[$ind];
1.158 albertel 683: my @bubble_display;
1.90 albertel 684: for ($ind=0;$ind<$number_of_bubbles;$ind++) {
1.91 albertel 685: $bubble_values[$ind] = $answer*($factor**($power-$powers[$#powers-$ind]));
1.158 albertel 686: $bubble_display[$ind] = &format_number($bubble_values[$ind],
1.153 albertel 687: $format,$target,$safeeval);
1.91 albertel 688:
1.90 albertel 689: }
1.184 albertel 690: my $correct = $alphabet[$number_of_bubbles-$power];
1.119 albertel 691: &Math::Random::random_set_seed(@oldseed);
1.184 albertel 692: return (\@bubble_values,\@bubble_display,$correct);
1.51 albertel 693: }
694:
695: sub get_tolrange {
1.89 albertel 696: my ($ans,$tol)=@_;
697: my ($high,$low);
698: if ($tol =~ /%$/) {
699: chop($tol);
700: my $change=$ans*($tol/100.0);
701: $high=$ans+$change;
702: $low=$ans-$change;
703: } else {
704: $high=$ans+$tol;
705: $low=$ans-$tol;
706: }
707: return ($high,$low);
1.52 albertel 708: }
709:
710: sub get_sigrange {
1.89 albertel 711: my ($sig)=@_;
712: &Apache::lonxml::debug("Got a sig of :$sig:");
1.166 albertel 713: my $courseid=$env{'request.course.id'};
714: if (lc($env{"course.$courseid.disablesigfigs"}) eq 'yes') {
1.147 albertel 715: return (15,0);
716: }
1.89 albertel 717: my $sig_lbound;
718: my $sig_ubound;
719: if ($sig eq '') {
720: $sig_lbound = 0; #SIG_LB_DEFAULT
721: $sig_ubound =15; #SIG_UB_DEFAULT
722: } else {
723: ($sig_lbound,$sig_ubound) = split(/,/,$sig);
1.145 albertel 724: if (!defined($sig_lbound)) {
1.89 albertel 725: $sig_lbound = 0; #SIG_LB_DEFAULT
726: $sig_ubound =15; #SIG_UB_DEFAULT
727: }
1.145 albertel 728: if (!defined($sig_ubound)) { $sig_ubound=$sig_lbound; }
1.133 albertel 729: }
730: if (($sig_ubound<$sig_lbound) ||
731: ($sig_lbound > 15) ||
732: ($sig =~/(\+|-)/ ) ) {
733: my $errormsg=&mt("Invalid Significant figures detected")." ($sig)";
1.166 albertel 734: if ($env{'request.state'} eq 'construct') {
1.133 albertel 735: $errormsg.=
736: &Apache::loncommon::help_open_topic('Significant_Figures');
737: }
738: &Apache::lonxml::error($errormsg);
1.52 albertel 739: }
1.89 albertel 740: return ($sig_ubound,$sig_lbound);
1.34 albertel 741: }
742:
743: sub start_stringresponse {
1.89 albertel 744: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
745: my $result;
1.122 albertel 746: my $id = &Apache::response::start_response($parstack,$safeeval);
1.89 albertel 747: if ($target eq 'meta') {
748: $result=&Apache::response::meta_package_write('stringresponse');
1.122 albertel 749: } elsif ($target eq 'edit') {
750: $result.=&Apache::edit::tag_start($target,$token);
751: $result.=&Apache::edit::text_arg('Answer:','answer',$token);
752: $result.=&Apache::edit::select_arg('Type:','type',
753: [['cs','Case Sensitive'],['ci','Case Insensitive'],
754: ['mc','Case Insensitive, Any Order'],
755: ['re','Regular Expression']],$token);
1.152 albertel 756: $result.=&Apache::edit::text_arg('String to display for answer:',
757: 'answerdisplay',$token);
1.122 albertel 758: $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
759: } elsif ($target eq 'modified') {
1.146 albertel 760: my $constructtag;
761: $constructtag=&Apache::edit::get_new_args($token,$parstack,
762: $safeeval,'answer',
763: 'type','answerdisplay');
764: if ($constructtag) {
765: $result = &Apache::edit::rebuild_tag($token);
766: $result.=&Apache::edit::handle_insert();
767: }
768: } elsif ($target eq 'web') {
769: if ( &Apache::response::show_answer() ) {
1.152 albertel 770: my $answer=
771: &Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval);
772: if (!defined $answer || $answer eq '') {
773: $answer=
774: &Apache::lonxml::get_param('answer',$parstack,$safeeval);
775: }
776: $Apache::inputtags::answertxt{$id}=$answer;
1.146 albertel 777: }
1.122 albertel 778: } elsif ($target eq 'answer' || $target eq 'grade') {
779: &Apache::response::reset_params();
1.89 albertel 780: }
781: return $result;
1.34 albertel 782: }
783:
784: sub end_stringresponse {
1.122 albertel 785: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
1.189 albertel 786:
1.122 albertel 787: my $result = '';
788: my $part=$Apache::inputtags::part;
789: my $id=$Apache::inputtags::response[-1];
790: my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
791: my $type=&Apache::lonxml::get_param('type',$parstack,$safeeval);
1.129 www 792: my $answerdisplay=&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval);
1.122 albertel 793: &Apache::lonxml::debug("current $answer ".$token->[2]);
794: if (!$Apache::lonxml::default_homework_loaded) {
795: &Apache::lonxml::default_homework_load($safeeval);
796: }
1.162 albertel 797: if ( $target eq 'grade' && &Apache::response::submitted() ) {
1.140 albertel 798: &Apache::response::setup_params('stringresponse',$safeeval);
1.122 albertel 799: $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
800: if ($Apache::lonhomework::type eq 'exam' ||
1.162 albertel 801: &Apache::response::submitted('scantron')) {
1.189 albertel 802: &Apache::response::scored_response($part,$id);
803:
1.122 albertel 804: } else {
805: my $response = &Apache::response::getresponse();
806: if ( $response =~ /[^\s]/) {
807: my %previous = &Apache::response::check_for_previous($response,
808: $part,$id);
809: &Apache::lonxml::debug("submitted a $response<br>\n");
810: &Apache::lonxml::debug($$parstack[-1] . "\n<br>");
811: $Apache::lonhomework::results{"resource.$part.$id.submission"}=
812: $response;
1.142 albertel 813: my ($ad,$msg);
1.122 albertel 814: if ($type eq 're' ) {
815: # if the RE wasn't in a var it likely got munged,
816: # thus grab it from the var directly
817: # my $testans=$token->[2]->{'answer'};
818: # if ($testans !~ m/^\s*\$/) {
819: # $answer=$token->[2]->{'answer'};
820: # }
1.143 albertel 821: ${$safeeval->varglob('LONCAPA::response')}=$response;
1.179 albertel 822: $result = &Apache::run::run('if ($LONCAPA::response=~m'.$answer.') { return 1; } else { return 0; }',$safeeval);
1.122 albertel 823: &Apache::lonxml::debug("current $response");
824: &Apache::lonxml::debug("current $answer");
825: $ad = ($result) ? 'APPROX_ANS' : 'INCORRECT';
826: } else {
1.143 albertel 827: my $args_ref=
828: \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
829:
830: $$args_ref{'response'}=$response;
1.122 albertel 831: &Apache::lonxml::debug("current $response");
1.143 albertel 832: $$args_ref{'type'}=
833: &Apache::lonxml::get_param('type',$parstack,$safeeval);
1.122 albertel 834: foreach my $key (keys(%Apache::inputtags::params)) {
1.143 albertel 835: $$args_ref{$key}=$Apache::inputtags::params{$key};
1.122 albertel 836: }
837: &Apache::lonxml::debug('answer is'.join(':',$answer));
1.143 albertel 838: @{$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=($answer);
839: ($result, my @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval);
1.142 albertel 840: &Apache::lonxml::debug('msgs are'.join(':',@msgs));
841: my ($awards)=split(/:/,$result);
842: my (@awards) = split(/,/,$awards);
843: ($ad,$msg) = &Apache::inputtags::finalizeawards(\@awards,\@msgs);
1.122 albertel 844: &Apache::lonxml::debug("\n<br>result:$result:$Apache::lonxml::curdepth<br>\n");
845: }
1.163 albertel 846: if ($Apache::lonhomework::type eq 'survey' &&
847: ($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' ||
848: $ad eq 'EXACT_ANS')) {
849: $ad='SUBMITTED';
850: }
1.122 albertel 851: &Apache::response::handle_previous(\%previous,$ad);
852: $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
1.142 albertel 853: $Apache::lonhomework::results{"resource.$part.$id.awardmsg"}=$msg;
1.122 albertel 854: }
855: }
856: } elsif ($target eq 'answer' || $target eq 'analyze') {
857: if ($target eq 'analyze') {
858: push (@{ $Apache::lonhomework::analyze{"parts"} },"$part.$id");
1.125 albertel 859: $Apache::lonhomework::analyze{"$part.$id.type"} = 'stringresponse';
1.154 albertel 860: &Apache::response::check_if_computed($token,$parstack,$safeeval,
861: 'answer');
1.122 albertel 862: }
1.140 albertel 863: &Apache::response::setup_params('stringresponse',$safeeval);
1.122 albertel 864: if ($target eq 'answer') {
1.125 albertel 865: $result.=&Apache::response::answer_header('stringresponse');
1.122 albertel 866: }
867: # foreach my $ans (@answers) {
868: if ($target eq 'answer') {
1.125 albertel 869: $result.=&Apache::response::answer_part('stringresponse',$answer);
1.178 albertel 870: if ($type eq 're') {
871: $result.=&Apache::response::answer_part('stringresponse',
872: $answerdisplay);
873: }
1.122 albertel 874: } elsif ($target eq 'analyze') {
875: push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"} },
876: $answer);
877: }
878: # }
879: my $string='Case Insensitive';
880: if ($type eq 'mc') {
881: $string='Multiple Choice';
882: } elsif ($type eq 'cs') {
883: $string='Case Sensitive';
884: } elsif ($type eq 'ci') {
885: $string='Case Insensitive';
886: } elsif ($type eq 're') {
887: $string='Regular Expression';
888: }
889: if ($target eq 'answer') {
1.166 albertel 890: if ($env{'form.answer_output_mode'} eq 'tex') {
1.125 albertel 891: $result.=&Apache::response::answer_part('stringresponse',
1.122 albertel 892: "$string");
893: } else {
1.125 albertel 894: $result.=&Apache::response::answer_part('stringresponse',
1.122 albertel 895: "<b>$string</b>");
896: }
897: } elsif ($target eq 'analyze') {
898: push (@{$Apache::lonhomework::analyze{"$part.$id.str_type"}},
899: $type);
900: }
901: if ($target eq 'answer') {
1.125 albertel 902: $result.=&Apache::response::answer_footer('stringresponse');
1.122 albertel 903: }
904: } elsif ($target eq 'edit') {
905: $result.='</td></tr>'.&Apache::edit::end_table;
906: }
907: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
908: $target eq 'tex' || $target eq 'analyze') {
1.189 albertel 909: &Apache::lonxml::increment_counter(&Apache::response::repetition());
1.122 albertel 910: }
911: &Apache::response::end_response;
912: return $result;
1.44 albertel 913: }
914:
915: sub start_formularesponse {
1.89 albertel 916: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
917: my $result;
918: if ($target eq 'meta') {
1.104 bowersj2 919: &Apache::response::start_response($parstack,$safeeval);
1.89 albertel 920: $result=&Apache::response::meta_package_write('formularesponse');
1.104 bowersj2 921: &Apache::response::end_response();
1.89 albertel 922: } else {
923: $result.=&start_numericalresponse(@_);
924: }
925: return $result;
1.44 albertel 926: }
927:
928: sub end_formularesponse {
1.89 albertel 929: return end_numericalresponse(@_);
1.3 albertel 930: }
931:
1.190 ! albertel 932: sub start_mathresponse {
! 933: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
! 934: my $result;
! 935: if ($target eq 'meta') {
! 936: &Apache::response::start_response($parstack,$safeeval);
! 937: $result=&Apache::response::meta_package_write('mathresponse');
! 938: &Apache::response::end_response();
! 939: } else {
! 940: $result.=&start_numericalresponse(@_);
! 941: }
! 942: return $result;
! 943: }
! 944:
! 945: sub end_mathresponse {
! 946: return end_numericalresponse(@_);
! 947: }
! 948:
1.1 albertel 949: 1;
1.3 albertel 950: __END__
1.89 albertel 951:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>