1: # LearningOnline Network with CAPA
2: # option list style responses
3: #
4: # $Id: optionresponse.pm,v 1.93 2003/10/27 19:27:09 albertel Exp $
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: package Apache::optionresponse;
29: use strict;
30: use Apache::response;
31:
32: BEGIN {
33: &Apache::lonxml::register('Apache::optionresponse',('optionresponse'));
34: }
35:
36: sub start_optionresponse {
37: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
38: my $result='';
39: #when in a option response use these
40: &Apache::lonxml::register('Apache::optionresponse',('foilgroup','foil','conceptgroup'));
41: push (@Apache::lonxml::namespace,'optionresponse');
42: my $id = &Apache::response::start_response($parstack,$safeeval);
43: %Apache::hint::option=();
44: if ($target eq 'edit') {
45: $result.=&Apache::edit::start_table($token).
46: "<tr><td>Multiple Option Response Question</td><td>Delete:".
47: &Apache::edit::deletelist($target,$token)
48: ."</td><td> ".
49: &Apache::edit::end_row().
50: &Apache::edit::start_spanning_row().
51: "\n";
52: $result.=&Apache::edit::text_arg('Max Number Of Shown Foils:','max',
53: $token,'4').
54: &Apache::edit::select_arg('Randomize Foil Order','randomize',
55: ['yes','no'],$token).
56: &Apache::edit::end_row().&Apache::edit::start_spanning_row();
57: } elsif ($target eq 'modified') {
58: my $constructtag=&Apache::edit::get_new_args($token,$parstack,
59: $safeeval,'max','randomize');
60: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
61: } elsif ($target eq 'meta') {
62: $result=&Apache::response::meta_package_write('optionresponse');
63: } elsif ($target eq 'analyze') {
64: my $part_id="$Apache::inputtags::part.$id";
65: push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
66: }
67: return $result;
68: }
69:
70: sub end_optionresponse {
71: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
72: &Apache::response::end_response;
73: pop @Apache::lonxml::namespace;
74: &Apache::lonxml::deregister('Apache::optionresponse',('foilgroup','foil','conceptgroup'));
75: my $result;
76: if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
77: return $result;
78: }
79:
80: %Apache::response::foilgroup=();
81: sub start_foilgroup {
82: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
83:
84: my $result='';
85: %Apache::response::foilgroup=();
86: $Apache::optionresponse::conceptgroup=0;
87: &Apache::response::setrandomnumber();
88: if ($target eq 'edit') {
89: my $optionlist="<option></option>\n";
90: my $option;
91: my @opt;
92: eval '@opt ='. &Apache::lonxml::get_param('options',$parstack,$safeeval);
93: my $count=1;
94: foreach $option (@opt) {
95: $optionlist.="<option value=\"$count\">$option</option>\n";
96: $count++;
97: }
98: my $insertlist=&Apache::edit::insertlist($target,$token);
99: $result.=&Apache::edit::start_table($token);
100: $result.= (<<ENDTABLE);
101: <tr><td>Select Options</td>
102: <td>
103: Add new Option: <input type="text" name="$Apache::lonxml::curdepth.options" />
104: </td>
105: <td>Delete an Option:
106: <select name="$Apache::lonxml::curdepth.deleteopt">$optionlist</select>
107: ENDTABLE
108: $result.= &Apache::edit::end_row();
109: $result.= &Apache::edit::start_spanning_row();
110: $result.= $insertlist.'<br />';
111: }
112: if ($target eq 'modified') {
113: my @options;
114: my $optchanged=0;
115: eval '@options ='.&Apache::lonxml::get_param('options',$parstack,$safeeval);
116: if ($ENV{"form.$Apache::lonxml::curdepth.deleteopt"}) {
117: my $delopt=$ENV{"form.$Apache::lonxml::curdepth.deleteopt"};
118: &Apache::lonxml::debug("Deleting :$delopt:");
119: splice(@options,$delopt-1,1);
120: $optchanged=1;
121: }
122: if ($ENV{"form.$Apache::lonxml::curdepth.options"}) {
123: my $newopt = $ENV{"form.$Apache::lonxml::curdepth.options"};
124: if ($options[0]) {
125: push(@options,$newopt);
126: } else {
127: $options[0]=$newopt;
128: }
129: $optchanged=1;
130: }
131: if ($optchanged) {
132: $result = "<foilgroup options=\"(";
133: foreach my $option (@options) {
134: $option=~s/\'/\\\'/g;
135: &Apache::lonxml::debug("adding option :$option:");
136: $result .="'".$option."',";
137: }
138: chop $result;
139: $result.=')">';
140: } # else nothing changed so just use the default mechanism
141: }
142: if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
143: $result .= ' \begin{enumerate} ';
144: }
145: return $result;
146: }
147:
148: sub end_foilgroup {
149: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
150:
151: my $result;
152: if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') {
153: my $tex_option_switch=&Apache::lonxml::get_param('texoptions',$parstack,$safeeval);
154: my $name;
155: my @opt;
156: eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval);
157: if ($target eq 'tex' && $tex_option_switch eq 'nochoice') {@opt=();}
158: &Apache::lonxml::debug("Options are $#opt");
159: my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
160: my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
161: $safeeval,'-2');
162: if ($target eq 'web' || $target eq 'tex') {
163: $result.=&displayfoils($target,$max,$randomize,@opt);
164: } elsif ( $target eq 'answer') {
165: $result.=&displayanswers($max,$randomize,@opt);
166: } elsif ( $target eq 'analyze') {
167: my @shown = &whichfoils($max,$randomize);
168: &Apache::response::analyze_store_foilgroup(\@shown,['text','value']);
169: my $part_id="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
170: push (@{ $Apache::lonhomework::analyze{"$part_id.options"} },@opt);
171: } elsif ( $target eq 'grade') {
172: if ( defined $ENV{'form.submitted'}) {
173: my @whichopt = &whichfoils($max,$randomize);
174: my $temp=1;my $name;
175: my %responsehash;
176: my %grade;
177: my $right=0;
178: my $wrong=0;
179: my $ignored=0;
180: foreach $name (@whichopt) {
181: my $response=&Apache::response::getresponse($temp);
182: if ($ENV{'form.submitted'} eq 'scantron') {
183: $response = $opt[$response];
184: }
185: $responsehash{$name}=$response;
186: if ( $response =~ /[^\s]/) {
187: my $value=$Apache::response::foilgroup{$name.'.value'};
188: &Apache::lonxml::debug("submitted a $response for $value<br />\n");
189: if ($value eq $response) {
190: $grade{$name}='1'; $right++;
191: } else {
192: $grade{$name}='0'; $wrong++;
193: }
194: } else {
195: $ignored++;
196: }
197: $temp++;
198: }
199: my $part=$Apache::inputtags::part;
200: my $id = $Apache::inputtags::response['-1'];
201: my $responsestr=&Apache::lonnet::hash2str(%responsehash);
202: my $gradestr =&Apache::lonnet::hash2str(%grade);
203: my %previous=&Apache::response::check_for_previous($responsestr,
204: $part,$id);
205: &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored");
206: $Apache::lonhomework::results{"resource.$part.$id.submission"}=
207: $responsestr;
208: $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=$gradestr;
209:
210: if (!$Apache::lonhomework::scantronmode) {
211: my $ad;
212: if ($wrong==0 && $ignored==0) {
213: $ad='EXACT_ANS';
214: } elsif ($wrong==0 && $right==0) {
215: #nothing submitted
216: } else {
217: if ($ignored==0) {
218: $ad='INCORRECT';
219: } else {
220: $ad='MISSING_ANSWER';
221: }
222: }
223: $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
224: &Apache::response::handle_previous(\%previous,$ad);
225: } else {
226: my $ad;
227: if ($wrong==0 && $right==0) {
228: #nothing submitted
229: } else {
230: $ad='ASSIGNED_SCORE';
231: }
232: $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
233: $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
234: $right/(scalar(@whichopt));
235: $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
236: scalar(@whichopt);
237: }
238: }
239: }
240: &Apache::lonxml::increment_counter(&getfoilcounts($max));
241: } elsif ($target eq 'edit') {
242: $result.=&Apache::edit::end_table();
243: }
244: if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
245: $result .= '\end{enumerate}';
246: }
247: return $result;
248: }
249:
250: sub getfoilcounts {
251: my ($max)=@_;
252: # +1 since instructors will count from 1
253: my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
254: if (&Apache::response::showallfoils()) { $max=$count; }
255: if ($count>$max) { $count=$max }
256: &Apache::lonxml::debug("Count is $count from $max");
257: return $count;
258: }
259:
260: sub whichfoils {
261: my ($max,$randomize)=@_;
262: return &Apache::response::whichorder($max,$randomize,
263: &Apache::response::showallfoils(),
264: \%Apache::response::foilgroup);
265: }
266:
267: sub displayanswers {
268: my ($max,$randomize,@opt)=@_;
269: if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
270: my @names = @{ $Apache::response::foilgroup{'names'} };
271: my @whichopt = &whichfoils($max,$randomize);
272: my $result=&Apache::response::answer_header('optionresponse');
273: foreach my $name (@whichopt) {
274: $result.=&Apache::response::answer_part('optionresponse',
275: $Apache::response::foilgroup{$name.'.value'})
276: }
277: $result.=&Apache::response::answer_footer('optionresponse');
278: return $result;
279: }
280:
281: sub displayfoils {
282: my ($target,$max,$randomize,@opt)=@_;
283: if (!defined(@{ $Apache::response::foilgroup{'names'} })) {return;}
284: my @names = @{ $Apache::response::foilgroup{'names'} };
285: my @truelist;
286: my @falselist;
287: my $result;
288: my $name;
289: my $displayoptionintex=0;
290: my @alphabet = ('A'..'Z');
291: my @whichopt = &whichfoils($max,$randomize);
292: my $part=$Apache::inputtags::part;
293: my $id=$Apache::inputtags::response[-1];
294: my $break;
295: my $solved=$Apache::lonhomework::history{"resource.$part.solved"};
296: if ( ($target ne 'tex') &&
297: &Apache::response::show_answer() ) {
298: my $temp=1;
299: foreach $name (@whichopt) {
300: my $text=$Apache::response::foilgroup{$name.'.text'};
301: my %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"});
302: my $lastopt=$lastresponse{$name};
303: if ($text!~/^\s*$/) {
304: if ($target eq 'tex') {
305: $break='\vskip 0 mm ';
306: } elsif ($target eq 'web') {
307: $break='<br />';
308: }
309: }
310: $result.=$break;
311: if ($target eq 'web') {
312: my $value=$Apache::response::foilgroup{$name.'.value'};
313: if (!($text=~s|<drawoptionlist\s*/>|$value|)) {
314: if ($text=~/^\s*$/) {
315: $text=$value.$text;
316: } else {
317: $text=$value.': '.$text;
318: }
319: }
320: $result.=$text."\n";
321: } elsif ($target eq 'tex') {
322: $Apache::response::foilgroup{$name.'.text'}=~s/\\item//;
323: if ($max>1) {$result .='\item ';}
324: $result .=' \textit{'.$Apache::response::foilgroup{$name.'.value'}.'}'.
325: ":".$Apache::response::foilgroup{$name.'.text'}."\n";
326: }
327: if ($Apache::lonhomework::type eq 'exam') {
328: if ($target ne 'tex') {
329: $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);
330: } else {
331: $result.=&bubbles(\@alphabet,\@opt);
332: }
333: }
334: $temp++;
335: }
336: } else {
337: my $temp=1;
338: my %lastresponse=&Apache::lonnet::str2hash($Apache::lonhomework::history{"resource.$part.$id.submission"});
339: my $internal_counter=$Apache::lonxml::counter;
340: foreach $name (@whichopt) {
341: my $text=$Apache::response::foilgroup{$name.'.text'};
342: if ($text!~/^\s*$/) {
343: if ($target eq 'tex') {
344: $break='\vskip 0 mm ';
345: } elsif ($target eq 'web') {
346: $break='<br />';
347: }
348: }
349: my $lastopt=$lastresponse{$name};
350: my $optionlist="<option></option>\n";
351: my $option;
352: foreach $option (@opt) {
353: if ($option eq $lastopt) {
354: $optionlist.="<option selected=\"on\">$option</option>\n";
355: } else {
356: $optionlist.="<option>$option</option>\n";
357: }
358: }
359: if ($target ne 'tex') {
360: if ($Apache::lonhomework::type ne 'exam') {
361: $optionlist='<select name="HWVAL_'.
362: $Apache::inputtags::response['-1'].':'.$temp.'">'.
363: $optionlist."</select>\n";
364: }
365: my $text=$Apache::response::foilgroup{$name.'.text'};
366: if (!($text=~s|<drawoptionlist\s*/>|$optionlist|) && $Apache::lonhomework::type ne 'exam') {
367: $text=$optionlist.$text;
368: }
369: $result.=$break.$text."\n";
370: if ($Apache::lonhomework::type eq 'exam') {
371: $result.=&webbubbles(\@opt,\@alphabet,$temp,$lastopt);
372: }
373: $temp++;
374: } else {
375: my $texoptionlist = &optionlist_correction($optionlist);
376: if ($displayoptionintex == 0) {
377: if ($Apache::lonhomework::type eq 'exam') {$texoptionlist='';} #if exam we do not need to show optionlist
378: if ($Apache::response::foilgroup{$name.'.text'}=~m/\\item /) {
379: if ($Apache::lonhomework::type eq 'exam') {
380: $Apache::response::foilgroup{$name.'.text'}=~s/\\item/\\vskip 2 mm/;
381: }
382: if ($Apache::response::foilgroup{$name.'.text'}=~/<drawoptionlist\s*\/>/) {
383: $Apache::response::foilgroup{$name.'.text'}=~s|<drawoptionlist\s*/>| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |;
384: }
385: $result.= $texoptionlist.$Apache::response::foilgroup{$name.'.text'};
386: } else {
387: if ($Apache::lonhomework::type eq 'exam') {
388: $result.= $texoptionlist.' '.$Apache::response::foilgroup{$name.'.text'};
389: } else {
390: $result.= $texoptionlist.'\vspace*{-2 mm}\item '.$Apache::response::foilgroup{$name.'.text'};
391: }
392: }
393: if ($Apache::lonhomework::type eq 'exam') {
394: $result.='\vskip -2 mm\parbox{\textwidth}{\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]\parbox{\textwidth - 5 mm}{'.&bubbles(\@alphabet,\@opt).'}\end{enumerate}} \vskip -9 mm \strut ';
395: $internal_counter++;
396: }
397: $displayoptionintex=1;
398: } else {
399: if ($Apache::response::foilgroup{$name.'.text'}=~m/\\item /) {
400: if ($Apache::lonhomework::type eq 'exam') {
401: $Apache::response::foilgroup{$name.'.text'}=~s/\\item//;
402: }
403: if ($Apache::response::foilgroup{$name.'.text'}=~/<drawoptionlist\s*\/>/) {
404: $Apache::response::foilgroup{$name.'.text'}=~s|<drawoptionlist\s*/>| \\makebox\[0\.3in\]\[b\]\{\\hrulefill\} |;
405: }
406: $result.= $Apache::response::foilgroup{$name.'.text'};
407: } else {
408: if ($Apache::lonhomework::type eq 'exam') {
409: $result.= ' '.$Apache::response::foilgroup{$name.'.text'};
410: } else {
411: $result.= '\item '.$Apache::response::foilgroup{$name.'.text'};
412: }
413: }
414: if ($Apache::lonhomework::type eq 'exam') {
415: $result.='\vskip -2 mm \parbox{\textwidth}{\begin{enumerate}\item[\textbf{'.$internal_counter.'}.]\parbox{\textwidth - 5 mm}{'.&bubbles(\@alphabet,\@opt).'}\end{enumerate}} \vskip -9 mm \strut ';
416: $internal_counter++;
417: }
418: }
419: }
420: }
421: }
422: if ($target ne 'tex') {
423: return $result.$break;
424: } else {
425: return $result;
426: }
427: }
428:
429:
430: sub optionlist_correction {
431:
432: my $texoptionlist = shift;
433: if ($texoptionlist=~/<option selected/ or $texoptionlist=~/<option>[^<]+<\/option>/) {
434: $texoptionlist =~ s/<option><\/option>/\\item \[\] Choices: /;
435: $texoptionlist =~ s/<option>/\{\\bf /g;
436: $texoptionlist =~ s/<option selected="on">/\{\\bf /g;
437: $texoptionlist =~ s/<\/option>/\},/g;
438: $texoptionlist =~ s/,$/\./g;
439: $texoptionlist =~ s/>/\$>\$/g;
440: $texoptionlist =~ s/</\$<\$/g;
441: $texoptionlist =~ s/=/\$=\$/g;
442: $texoptionlist =~ s/\^(\d+)/<m>\$$1\$<\/m>/g;
443: } else {
444: $texoptionlist =~ s/<option><\/option>/\\item \[\] \\vskip -5 mm/;
445: }
446: return $texoptionlist;
447: }
448:
449:
450: sub webbubbles {
451:
452: my ($ropt,$ralphabet,$temp,$lastopt)=@_;
453: my @opt=@$ropt;
454: my @alphabet=@$ralphabet;
455: my $result='';
456: my $number_of_bubbles = $#opt + 1;
457: $result.= '<table border="1"><tr>';
458: for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
459: my $checked='';
460: if ($lastopt eq $opt[$ind]) {
461: $checked=' checked="on" ';
462: }
463: $result.='<td><input type="radio" name="HWVAL_'.
464: $Apache::inputtags::response['-1'].':'.$temp.
465: '" value="'.$opt[$ind].'" '.$checked.' />'.$alphabet[$ind].': '.
466: $opt[$ind].'</td>';
467: }
468: $result.='</tr></table>';
469: return $result;
470: }
471:
472:
473: sub bubbles {
474:
475: my ($ralphabit,$ropt) = @_;
476: my @alphabet = @$ralphabit;
477: my @opt = @$ropt;
478: my ($result,$head,$line) =('','','');
479: my $number_of_bubbles = $#opt + 1;
480: my $current_length = 0;
481: for (my $ind=0;$ind<=$number_of_bubbles;$ind++) {
482: $current_length += (length($opt[$ind])+length($alphabet[$ind])+2)*2;
483: if ($current_length<0.9*$ENV{'form.textwidth'} and $ind!=$number_of_bubbles) {
484: $line.='\hskip -1 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';
485: $head.='lr';
486: } else {
487: $line=~s/\&\s*$//;
488: $result.='\vskip -5 mm\begin{tabular}{'.$head.'}\\\\'.$line.'\\\\\end{tabular}';
489: $line = '\hskip -1 mm {\small \textbf{'.$alphabet[$ind].'}}$\bigcirc$\hskip -1 mm & \hskip -3 mm {\small '.$opt[$ind].'} & ';;
490: $head ='lr';
491: $current_length = (length($opt[$ind])+length($alphabet[$ind]))*2;
492: }
493:
494: }
495: return $result;
496: }
497:
498:
499: sub start_conceptgroup {
500: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
501: $Apache::optionresponse::conceptgroup=1;
502: %Apache::response::conceptgroup=();
503: my $result;
504: if ($target eq 'edit') {
505: $result.=&Apache::edit::tag_start($target,$token,"Concept Grouped Foils");
506: $result.=&Apache::edit::text_arg('Concept:','concept',$token,'50').
507: &Apache::edit::end_row().&Apache::edit::start_spanning_row();
508: }
509: if ($target eq 'modified') {
510: my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'concept');
511: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
512: }
513: return $result;
514: }
515:
516: sub end_conceptgroup {
517: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
518: $Apache::optionresponse::conceptgroup=0;
519: my $result='';
520: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
521: $target eq 'tex' || $target eq 'analyze') {
522: #if not there aren't any foils to display and thus no question
523: &Apache::response::pick_foil_for_concept($target,
524: ['value','text','location'],
525: \%Apache::hint::option,
526: $parstack,$safeeval);
527: } elsif ($target eq 'edit') {
528: $result=&Apache::edit::end_table();
529: }
530: return $result;
531: }
532:
533: sub insert_conceptgroup {
534: my $result="\n\t\t<conceptgroup concept=\"\">".&insert_foil()."\n\t\t</conceptgroup>\n";
535: return $result;
536: }
537:
538: sub start_foil {
539: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
540: my $result='';
541: if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze' ) {
542: &Apache::lonxml::startredirection;
543: } elsif ($target eq 'edit') {
544: $result=&Apache::edit::tag_start($target,$token,"Foil");
545: my $level='-2';
546: if ($$tagstack['-2'] eq 'conceptgroup') { $level = '-3'; }
547: my @opt;
548: eval '@opt ='.&Apache::lonxml::get_param('options',$parstack,$safeeval,$level);
549: $result.=&Apache::edit::text_arg('Name:','name',$token);
550: $result.= &Apache::edit::select_or_text_arg('Correct Option:','value',
551: ['unused',(@opt)],$token,'15');
552: my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
553: $safeeval,'-3');
554: if ($randomize ne 'no') {
555: $result.=&Apache::edit::select_arg('Location:','location',
556: ['random','top','bottom'],$token);
557: }
558: $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
559: } elsif ($target eq 'modified') {
560: my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,
561: 'value','name','location');
562: if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
563: }
564: return $result;
565: }
566:
567: sub end_foil {
568: my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
569: my $text ='';
570: my $result = '';
571: if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
572: $text=&Apache::lonxml::endredirection;
573: if ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') { $text = '\vspace*{-2 mm}\item '.$text; }
574: }
575: if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'
576: || $target eq 'tex' || $target eq 'analyze') {
577: my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
578: if ($value ne 'unused') {
579: my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
580: my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);
581: &Apache::lonxml::debug("Got a name of :$name:");
582: if (!$name) { $name=$Apache::lonxml::curdepth; }
583: &Apache::lonxml::debug("Using a name of :$name:");
584: if ( $Apache::optionresponse::conceptgroup
585: && !&Apache::response::showallfoils() ) {
586: push @{ $Apache::response::conceptgroup{'names'} }, $name;
587: $Apache::response::conceptgroup{"$name.value"} = $value;
588: if ($target eq 'tex' and $Apache::lonhomework::type eq 'exam') {
589: $Apache::response::conceptgroup{"$name.text"} = '\vskip 4 mm $\triangleright$ '.$text;
590: } else {
591: $Apache::response::conceptgroup{"$name.text"} = $text;
592: }
593: $Apache::response::conceptgroup{"$name.location"} = $location;
594: } else {
595: push @{ $Apache::response::foilgroup{'names'} }, $name;
596: $Apache::response::foilgroup{"$name.value"} = $value;
597: if ($target eq 'tex' and $Apache::lonhomework::type eq 'exam') {
598: $Apache::response::foilgroup{"$name.text"} = '\vskip 5 mm $\triangleright$ '.$text;
599: } else {
600: $Apache::response::foilgroup{"$name.text"} = $text;
601: }
602: $Apache::response::foilgroup{"$name.location"} = $location;
603: }
604: }
605: }
606: if ($target eq 'edit') {
607: $result.= &Apache::edit::tag_end($target,$token,'');
608: }
609: return $result;
610: }
611:
612: sub insert_foil {
613: return '
614: <foil name="" value="unused">
615: <startouttext />
616: <endouttext />
617: </foil>';
618: }
619: 1;
620: __END__
621:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>