Annotation of loncom/homework/matchresponse.pm, revision 1.4
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # Full matching style response
3: #
1.4 ! albertel 4: # $Id: matchresponse.pm,v 1.3 2003/02/20 09:30:42 albertel Exp $
1.1 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: #
28: # 2/21 Guy
29:
30: package Apache::matchresponse;
31: use strict;
32: use HTML::Entities();
33: use Math::Random();
34:
35: BEGIN {
36: &Apache::lonxml::register('Apache::matchresponse',('matchresponse'));
37: }
38:
39: sub start_matchresponse {
40: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
41: my $result;
42: #when in a matchresponse use these
43: &Apache::lonxml::register('Apache::matchresponse',
44: ('foilgroup','foil','conceptgroup','item',
45: 'itemgroup'));
46: push (@Apache::lonxml::namespace,'matchresponse');
47: my $id = &Apache::response::start_response($parstack,$safeeval);
48: %Apache::hint::match=();
49: if ($target eq 'meta') {
50: $result=&Apache::response::meta_package_write('matchresponse');
51: } elsif ($target eq 'edit' ) {
52: $result.=&Apache::edit::start_table($token).
53: '<tr><td>'.&Apache::lonxml::description($token)."</td><td>Delete:".
54: &Apache::edit::deletelist($target,$token)
55: ."</td><td> ".&Apache::edit::end_row()
56: .&Apache::edit::start_spanning_row();
57:
58: $result.=
59: &Apache::edit::text_arg('Max Number Of Shown Foils:','max',$token,'4').
60: &Apache::edit::select_arg('Randomize Foil Order','randomize',
61: ['yes','no'],$token).
62: &Apache::edit::end_row().&Apache::edit::start_spanning_row()."\n";
63: } elsif ($target eq 'modified') {
64: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
65: $safeeval,'max',
66: 'randomize');
67: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
68: }
69: return $result;
70: }
71:
72: sub end_matchresponse {
73: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
74: my $result;
75: if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
76: &Apache::response::end_response;
77: pop @Apache::lonxml::namespace;
78: &Apache::lonxml::deregister('Apache::matchresponse',
79: ('foilgroup','foil','conceptgroup'));
80: return $result;
81: }
82:
83: %Apache::response::itemgroup=();
84: sub start_itemgroup {
85: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
86: my $result;
87: %Apache::response::itemgroup=();
1.4 ! albertel 88: %Apache::matchresponse::itemtable=();
1.1 albertel 89: if ($target eq 'edit') {
90: $result=&Apache::edit::tag_start($target,$token);
91: $result.=&Apache::edit::select_arg('Randomize Order:','randomize',
92: ['yes','no'],$token);
1.4 ! albertel 93: $result.=&Apache::edit::select_arg('Items Display Location:',
! 94: 'location',
! 95: ['top','bottom','left','right'],
! 96: $token);
1.1 albertel 97: $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
1.4 ! albertel 98: } elsif ($target eq 'modified') {
! 99: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
! 100: $safeeval,'randomize',
! 101: 'location');
! 102: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
! 103: } elsif ($target eq 'web') {
! 104: $Apache::matchresponse::itemtable{'location'}=
! 105: &Apache::lonxml::get_param('location',$parstack,$safeeval);
1.1 albertel 106: }
107: return $result;
108: }
109:
110: sub end_itemgroup {
111: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
112: my $result;
113:
114: if (!defined(@{ $Apache::response::itemgroup{'names'} })) { return; }
115: my @names=@{ $Apache::response::itemgroup{'names'} };
116: my $randomize =&Apache::lonxml::get_param('randomize',$parstack,$safeeval);
1.2 albertel 117: if ($randomize ne 'no' ) {
1.3 albertel 118: @names=&whichorder($#names+1,$randomize,0,
119: \%Apache::response::itemgroup)
1.1 albertel 120: }
121: my %letter_name_map;
122: my %name_letter_map;
123: my @alphabet=('A'..'Z');
124: my $i=0;
125: foreach my $name (@names) {
126: $letter_name_map{$alphabet[$i]}=$name;
127: $name_letter_map{$name}=$alphabet[$i];
128: $i++;
129: }
130: $Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map;
131: $Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map;
132: if ($target eq 'web') {
1.4 ! albertel 133: my $table='<table>';
1.1 albertel 134: my $i=0;
135: foreach my $name (@names) {
1.4 ! albertel 136: $table.='<tr><td>'.$alphabet[$i].'</td><td>'.
1.1 albertel 137: $Apache::response::itemgroup{$name.'.text'}.
138: '</td></tr>';
139: $i++;
140: }
1.4 ! albertel 141: $table.='</table>';
! 142: $Apache::matchresponse::itemtable{'display'}=$table;
1.1 albertel 143: } elsif ($target eq 'edit') { $result=&Apache::edit::end_table(); }
144: return $result;
145: }
146:
147: sub start_item {
148: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
149: my $result='';
150: if ($target eq 'web' ) {
151: &Apache::lonxml::startredirection;
152: } elsif ($target eq 'edit') {
1.3 albertel 153: my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
154: $safeeval,'-2');
1.1 albertel 155: $result=&Apache::edit::tag_start($target,$token,"Item");
156: $result.=&Apache::edit::text_arg('Name:','name',$token);
1.3 albertel 157: if ($randomize ne 'no') {
158: $result.=&Apache::edit::select_arg('Location:','location',
159: ['random','top','bottom'],
160: $token);
161: }
162: $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
1.1 albertel 163: } elsif ($target eq 'modified') {
164: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
1.3 albertel 165: $safeeval,'name',
166: 'location');
1.1 albertel 167: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
168: }
169: return $result;
170: }
171:
172: sub end_item {
173: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
174: my $text ='';
175: my $result = '';
176: if ($target eq 'web') {
177: $text=&Apache::lonxml::endredirection;
178: }
179: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
180: $target eq 'edit') {
181: my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
1.3 albertel 182: my $location=&Apache::lonxml::get_param('location',$parstack,
183: $safeeval);
1.1 albertel 184: &Apache::lonxml::debug("Got a name of :$name:");
185: if (!$name) { $name=$Apache::lonxml::curdepth; }
186: &Apache::lonxml::debug("Using a name of :$name:");
187: push @{ $Apache::response::itemgroup{'names'} }, $name;
188: $Apache::response::itemgroup{"$name.text"} = $text;
1.3 albertel 189: $Apache::response::itemgroup{"$name.location"} = $location;
1.1 albertel 190: }
191: if ($target eq 'edit') {
192: $result.= &Apache::edit::tag_end($target,$token,'');
193: }
194: return $result;
195: }
196:
197: sub insert_item {
198: return '
199: <item name="">
200: <startouttext />
201: <endouttext />
202: </item>';
203: }
204:
205: %Apache::response::foilgroup=();
206: sub start_foilgroup {
207: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
208: my $result;
209: %Apache::response::foilgroup=();
210: $Apache::matchresponse::conceptgroup=0;
211: &Apache::response::setrandomnumber();
212: if ($target eq 'edit') {
213: $result.=&Apache::edit::start_table($token)
214: ."<tr><td>Collection Of Foils</td><td>Delete:"
215: .&Apache::edit::deletelist($target,$token)
216: ."</td><td> ".&Apache::edit::end_row()
217: .&Apache::edit::start_spanning_row()."\n";
218: }
219: return $result;
220: }
221:
222: sub end_foilgroup {
223: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
224: my $result;
225: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer') {
226: my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
227: my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
228: $safeeval,'-2');
229: if ($target eq 'web') {
230: $result=&displayfoils($target,$max,$randomize);
231: } elsif ($target eq 'answer' ) {
232: $result=&displayanswers($max,$randomize);
233: } elsif ( $target eq 'grade') {
234: &grade_response($max,$randomize);
235: }
236: } elsif ($target eq 'edit') {
237: $result=&Apache::edit::end_table();
238: }
239: return $result;
240: }
241:
242: sub displayanswers {
243: my ($max,$randomize,@opt)=@_;
244: if (!defined(@{ $Apache::response::foilgroup{'names'} })) { return; }
245: my @names = @{ $Apache::response::foilgroup{'names'} };
1.3 albertel 246: my @whichfoils = &whichorder(&getfoilcounts($max),$randomize,
247: &Apache::response::showallfoils(),
248: \%Apache::response::foilgroup);
1.1 albertel 249: my $result=&Apache::response::answer_header('matchresponse');
250: my %name_letter_map;
251: if (defined(%{ $Apache::response::itemgroup{'name_letter_map'} })) {
252: %name_letter_map=
253: %{ $Apache::response::itemgroup{'name_letter_map'} };
254: }
255: foreach my $name (@whichfoils) {
256: my $value_name=$Apache::response::foilgroup{$name.'.value'};
257: my $letter=$name_letter_map{$value_name};
258: $result.=&Apache::response::answer_part('matchresponse',$letter);
259: }
260: $result.=&Apache::response::answer_footer('matchresponse');
261: return $result;
262: }
263:
264:
265: sub grade_response {
266: my ($max,$randomize)=@_;
1.3 albertel 267: my (@whichfoils)=&whichorder(&getfoilcounts($max),$randomize,
268: &Apache::response::showallfoils(),
269: \%Apache::response::foilgroup);
1.1 albertel 270: if (!defined($ENV{'form.submitted'})) { return; }
271: my %responsehash;
272: my %grade;
273: my ($temp,$right,$wrong,$ignored)=(0,0,0,0);
274: my %letter_name_map;
275: if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) {
276: %letter_name_map=
277: %{ $Apache::response::itemgroup{'letter_name_map'} };
278: }
279: foreach my $name (@whichfoils) {
280: my $response = $ENV{'form.HWVAL_'.$Apache::inputtags::response['-1'].":$temp"};
281: my $responsename = $letter_name_map{$response};
282: $responsehash{$name}=$responsename;
283: my $value=$Apache::response::foilgroup{$name.'.value'};
284: if ( $response =~ /[^\s]/) {
285: &Apache::lonxml::debug("submitted a $response for $value<br />\n");
286: if ($value eq $responsename) {
287: $grade{$name}='1'; $right++;
288: } else {
289: $grade{$name}='0'; $wrong++;
290: }
291: } else {
292: $ignored++;
293: }
294: $temp++;
295: }
296: my $part=$Apache::inputtags::part;
297: my $id = $Apache::inputtags::response['-1'];
298: my $responsestr=&Apache::lonnet::hash2str(%responsehash);
299: my $gradestr =&Apache::lonnet::hash2str(%grade);
300: my %previous =&Apache::response::check_for_previous($responsestr,
301: $part,$id);
302: &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored ");
303: my $ad;
304: if ($wrong==0 && $ignored==0) {
305: $ad='EXACT_ANS';
306: } elsif ($wrong==0 && $right==0) {
307: #nothing submitted
308: } else {
309: if ($ignored==0) {
310: $ad='INCORRECT';
311: } else {
312: $ad='MISSING_ANSWER';
313: }
314: }
315: $Apache::lonhomework::results{"resource.$part.$id.submission"}=
316: $responsestr;
317: $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=
318: $gradestr;
319: $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
320: &Apache::response::handle_previous(\%previous,$ad);
321: }
322:
1.4 ! albertel 323: sub itemdisplay {
! 324: my ($location)=@_;
! 325: if ($location eq 'top' &&
! 326: !defined($Apache::matchresponse::itemtable{'location'})) {
! 327: return $Apache::matchresponse::itemtable{'display'};
! 328: }
! 329: if ($Apache::matchresponse::itemtable{'location'} eq $location) {
! 330: return $Apache::matchresponse::itemtable{'display'};
! 331: }
! 332: return undef;
! 333: }
1.1 albertel 334: sub displayfoils {
335: my ($target,$max,$randomize)=@_;
336: my $result;
1.4 ! albertel 337: my $question;
1.3 albertel 338: my (@whichfoils)=&whichorder(&getfoilcounts($max),$randomize,
339: &Apache::response::showallfoils(),
340: \%Apache::response::foilgroup);
1.1 albertel 341: my $part=$Apache::inputtags::part;
342: my $solved=$Apache::lonhomework::history{"resource.$part.solved"};
343: my $status=$Apache::inputtags::status[-1];
344: my %letter_name_map;
345: if (defined(%{ $Apache::response::itemgroup{'letter_name_map'} })) {
346: %letter_name_map=
347: %{ $Apache::response::itemgroup{'letter_name_map'} };
348: }
349: my %name_letter_map;
350: if (defined(%{ $Apache::response::itemgroup{'name_letter_map'} })) {
351: %name_letter_map=
352: %{ $Apache::response::itemgroup{'name_letter_map'} };
353: }
354: if (($solved =~ /^correct/) || ($status eq 'SHOW_ANSWER')) {
355: foreach my $name (@whichfoils) {
356: my $text=$Apache::response::foilgroup{$name.'.text'};
357: my $value=$Apache::response::foilgroup{$name.'.value'};
358: my $letter=$name_letter_map{$value};
1.4 ! albertel 359: $question.='<br />'.$letter.':'.$text;
1.1 albertel 360: }
361: } else {
362: my $i = 0;
363: my $temp=0;
364: my $id=$Apache::inputtags::response[-1];
365: my $part=$Apache::inputtags::part;
366: my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"};
367: my %lastresponse=&Apache::lonnet::str2hash($lastresponse);
368: foreach my $name (@whichfoils) {
369: my $lastopt=$lastresponse{$name};
370: my $last_letter=$name_letter_map{$lastopt};
371: my $optionlist="<option></option>\n";
372: my $option;
373: foreach $option (sort(keys(%letter_name_map))) {
374: if ($option eq $last_letter) {
375: $optionlist.="<option selected=\"on\">$option</option>\n";
376: } else {
377: $optionlist.="<option>$option</option>\n";
378: }
379: }
380: $optionlist='<select name="HWVAL_'.
381: $Apache::inputtags::response[-1].':'.$temp.'">'.
382: $optionlist."</select>\n";
383: my $text=$Apache::response::foilgroup{$name.'.text'};
1.4 ! albertel 384: $question.='<br />'.$optionlist.$text."\n";
1.1 albertel 385: $temp++;
386: }
1.4 ! albertel 387: }
! 388: if ($result=&itemdisplay('top')) {
! 389: $result.=$question;
! 390: } elsif ($result=&itemdisplay('bottom')) {
! 391: $result=$question.$result;
! 392: } elsif ($result=&itemdisplay('right')) {
! 393: $result='<table><tr><td>'.$question.'</td><td>'.$result.
! 394: '</td></tr></table>';
! 395: } elsif ($result=&itemdisplay('left')) {
! 396: $result='<table><tr><td>'.$result.'</td><td>'.$question.
! 397: '</td></tr></table>';
1.1 albertel 398: }
399: $result.="<br />";
400: return $result;
401: }
402:
403: sub getfoilcounts {
404: my ($max)=@_;
405: # +1 since instructors will count from 1
406: my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
407: if (&Apache::response::showallfoils()) { $max=$count; }
408: if ($count>$max) { $count=$max }
409: &Apache::lonxml::debug("Count is $count from $max");
410: return $count;
411: }
412:
1.3 albertel 413: sub whichorder {
414: my ($max,$randomize,$showall,$hash)=@_;
415: #&Apache::lonxml::debug("man $max randomize $randomize");
416: if (!defined(@{ $$hash{'names'} })) { return; }
417: my @names = @{ $$hash{'names'} };
1.1 albertel 418: my @whichopt =();
419: my (%top,@toplist,%bottom,@bottomlist);
1.3 albertel 420: if (!($showall || ($randomize eq 'no'))) {
1.1 albertel 421: my $current=0;
422: foreach my $name (@names) {
423: $current++;
1.3 albertel 424: if ($$hash{"$name.location"} eq 'top') {
1.1 albertel 425: $top{$name}=$current;
1.3 albertel 426: } elsif ($$hash{"$name.location"} eq 'bottom') {
1.1 albertel 427: $bottom{$name}=$current;
428: }
429: }
430: }
431: while ((($#whichopt+1) < $max) && ($#names > -1)) {
1.3 albertel 432: #&Apache::lonxml::debug("Have $#whichopt max is $max");
1.1 albertel 433: my $aopt;
1.3 albertel 434: if ($showall || ($randomize eq 'no')) {
1.1 albertel 435: $aopt=0;
436: } else {
437: $aopt=int(&Math::Random::random_uniform() * ($#names+1));
438: }
1.3 albertel 439: #&Apache::lonxml::debug("From $#whichopt $max $#names elms, picking $aopt");
1.1 albertel 440: $aopt=splice(@names,$aopt,1);
1.3 albertel 441: #&Apache::lonxml::debug("Picked $aopt");
1.1 albertel 442: if ($top{$aopt}) {
443: $toplist[$top{$aopt}]=$aopt;
444: } elsif ($bottom{$aopt}) {
445: $bottomlist[$bottom{$aopt}]=$aopt;
446: } else {
447: push (@whichopt,$aopt);
448: }
449: }
450: for (my $i=0;$i<=$#toplist;$i++) {
451: if ($toplist[$i]) { unshift(@whichopt,$toplist[$i]) }
452: }
453: for (my $i=0;$i<=$#bottomlist;$i++) {
454: if ($bottomlist[$i]) { push(@whichopt,$bottomlist[$i]) }
455: }
456:
457: return @whichopt;
458: }
459:
460: sub start_conceptgroup {
461: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
462: $Apache::matchresponse::conceptgroup=1;
463: %Apache::response::conceptgroup=();
464: my $result;
465: if ($target eq 'edit') {
466: $result.=&Apache::edit::tag_start($target,$token,
467: "Concept Grouped Foils");
468: $result.=&Apache::edit::text_arg('Concept:','concept',$token,'50').
469: &Apache::edit::end_row().&Apache::edit::start_spanning_row();
470: }
471: if ($target eq 'modified') {
472: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
473: $safeeval,'concept');
474: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
475: }
476: return $result;
477: }
478:
479: sub end_conceptgroup {
480: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
481: $Apache::matchresponse::conceptgroup=0;
482: my $result='';
483: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ) {
484: #if not there aren't any foils to display and thus no question
485: if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
486: my @names = @{ $Apache::response::conceptgroup{'names'} };
487: my $pick=int(&Math::Random::random_uniform() * ($#names+1));
488: my $name=$names[$pick];
489: push @{ $Apache::response::foilgroup{'names'} }, $name;
490: $Apache::response::foilgroup{"$name.value"} =
491: $Apache::response::conceptgroup{"$name.value"};
492: $Apache::response::foilgroup{"$name.text"} =
493: $Apache::response::conceptgroup{"$name.text"};
494: $Apache::response::foilgroup{"$name.location"} =
495: $Apache::response::conceptgroup{"$name.location"};
496: my $concept = &Apache::lonxml::get_param('concept',$parstack,
497: $safeeval);
498: $Apache::response::foilgroup{"$name.concept"} = $concept;
499: &Apache::lonxml::debug("Selecting $name in $concept");
500: if ($target eq 'web') {
501: my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
502: push(@{ $Apache::hint::match{"$part_id.concepts"} },
503: $concept);
504: $Apache::hint::match{"$part_id.concept.$concept"}=
505: $Apache::response::conceptgroup{'names'};
506: }
507: }
508: } elsif ($target eq 'edit') {
509: $result=&Apache::edit::end_table();
510: }
511: return $result;
512: }
513:
514: sub insert_conceptgroup {
515: my $result="\n\t\t<conceptgroup concept=\"\">".&insert_foil()."\n\t\t</conceptgroup>\n";
516: return $result;
517: }
518:
519: sub start_foil {
520: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
521: my $result='';
522: if ($target eq 'web' ) {
523: &Apache::lonxml::startredirection;
524: } elsif ($target eq 'edit') {
525: $result=&Apache::edit::tag_start($target,$token,"Foil");
526: my $level='-2';
527: if ($$tagstack[-2] eq 'conceptgroup') { $level = '-3'; }
528: $result.=&Apache::edit::text_arg('Name:','name',$token);
529: my @names;
530: if (defined(@{ $Apache::response::itemgroup{'names'} })) {
531: @names=@{ $Apache::response::itemgroup{'names'} };
532: }
533: $result.= &Apache::edit::select_or_text_arg('Correct Option:','value',['unused',@names],$token,'15');
534: my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
535: $safeeval,'-3');
536: if ($randomize ne 'no') {
537: $result.=&Apache::edit::select_arg('Location:','location',
538: ['random','top','bottom'],$token);
539: }
540: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
541: } elsif ($target eq 'modified') {
542: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
543: $safeeval,'value',
544: 'name','location');
545: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
546: }
547: return $result;
548: }
549:
550: sub end_foil {
551: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
552: my $text ='';
553: my $result = '';
554: if ($target eq 'web') {
555: $text=&Apache::lonxml::endredirection;
556: }
557: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer') {
558: my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
559: if ($value ne 'unused') {
560: my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
561: my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);
562: &Apache::lonxml::debug("Got a name of :$name:");
563: if (!$name) { $name=$Apache::lonxml::curdepth; }
564: &Apache::lonxml::debug("Using a name of :$name:");
565: if ( $Apache::matchresponse::conceptgroup
566: && !&Apache::response::showallfoils() ) {
567: push @{ $Apache::response::conceptgroup{'names'} }, $name;
568: $Apache::response::conceptgroup{"$name.value"} = $value;
569: $Apache::response::conceptgroup{"$name.text"} = $text;
570: $Apache::response::conceptgroup{"$name.location"} = $location;
571: } else {
572: push @{ $Apache::response::foilgroup{'names'} }, $name;
573: $Apache::response::foilgroup{"$name.value"} = $value;
574: $Apache::response::foilgroup{"$name.text"} = $text;
575: $Apache::response::foilgroup{"$name.location"} = $location;
576: }
577: }
578: }
579: if ($target eq 'edit') {
580: $result.= &Apache::edit::tag_end($target,$token,'');
581: }
582: return $result;
583: }
584:
585: sub insert_foil {
586: return '
587: <foil name="" value="unused">
588: <startouttext />
589: <endouttext />
590: </foil>';
591: }
592: 1;
593: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>