File:  [LON-CAPA] / loncom / homework / matchresponse.pm
Revision 1.93: download - view: text, annotated - select for diffs
Fri Jan 22 22:42:51 2016 UTC (8 years, 3 months ago) by damieng
Branches: MAIN
CVS tags: HEAD
using a div and CSS instead of br to better control spaces around foils, especially when a div or p is used before the response

    1: # The LearningOnline Network with CAPA
    2: # Full matching style response
    3: #
    4: # $Id: matchresponse.pm,v 1.93 2016/01/22 22:42:51 damieng 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: 
   29: package Apache::matchresponse;
   30: use strict;
   31: use HTML::Entities();
   32: use Math::Random();
   33: use Apache::optionresponse();
   34: use Apache::lonlocal;
   35: use Apache::lonnet;
   36: use Apache::lonxml;
   37: use POSIX qw(ceil);
   38: 
   39: BEGIN {
   40:     &Apache::lonxml::register('Apache::matchresponse',('matchresponse'));
   41: }
   42: 
   43: sub start_matchresponse {
   44:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   45:     my $result;
   46:     #when in a matchresponse use these
   47:     &Apache::lonxml::register('Apache::matchresponse',
   48: 			      ('foilgroup','foil','conceptgroup','item',
   49: 			       'itemgroup'));
   50:     push (@Apache::lonxml::namespace,'matchresponse');
   51:     my $id = &Apache::response::start_response($parstack,$safeeval);
   52:     %Apache::hint::match=();
   53:     undef(%Apache::response::foilnames);
   54:     if ($target eq 'meta') {
   55: 	$result=&Apache::response::meta_package_write('matchresponse');
   56:     } elsif ($target eq 'edit' ) {
   57: 	$result.=&Apache::edit::start_table($token).
   58: 	    '<tr><td>'.&Apache::loncommon::insert_folding_button().&Apache::lonxml::description($token).'</td>'
   59:            .'<td><span class="LC_nobreak">'.&mt('Delete?').' '
   60: 	   .&Apache::edit::deletelist($target,$token)
   61:            .'</span></td>'
   62:            .'<td>&nbsp;'.&Apache::edit::end_row()
   63: 	   .&Apache::edit::start_spanning_row();
   64: 	
   65: 	$result.=
   66: 	    &Apache::edit::text_arg('Max Number Of Shown Foils:','max',$token,'4').
   67: 	    &Apache::edit::select_arg('Randomize Foil Order:','randomize',
   68: 				      ['yes','no'],$token).
   69: 	    &Apache::edit::end_row().&Apache::edit::start_spanning_row()."\n";
   70:     } elsif ($target eq 'modified') {
   71: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
   72: 						     $safeeval,'max',
   73: 						     'randomize');
   74: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
   75:     } elsif ($target eq 'analyze') {
   76: 	my $part_id="$Apache::inputtags::part.$id";
   77:         $Apache::lonhomework::analyze{"$part_id.type"} = 'matchresponse';
   78: 	push (@{ $Apache::lonhomework::analyze{"parts"} },$part_id);
   79: 	push (@{ $Apache::lonhomework::analyze{"$part_id.bubble_lines"} },
   80: 	      1);
   81:     }
   82:     return $result;
   83: }
   84: 
   85: sub end_matchresponse {
   86:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   87:     my $result;
   88:     if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
   89:     &Apache::response::end_response;
   90:     pop @Apache::lonxml::namespace;
   91:     &Apache::lonxml::deregister('Apache::matchresponse',
   92: 				('foilgroup','foil','conceptgroup'));
   93:     undef(%Apache::response::foilnames);
   94:     return $result;
   95: }
   96: 
   97: %Apache::response::itemgroup=();
   98: sub start_itemgroup {
   99:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  100:     my $result;
  101:     %Apache::response::itemgroup=();
  102:     %Apache::matchresponse::itemtable=();
  103: 
  104:     if ($target eq 'edit') {
  105: 	$result=&Apache::edit::tag_start($target,$token);
  106: 	$result.=&Apache::edit::select_arg('Randomize Order:','randomize',
  107: 					   ['yes','no'],$token);
  108: 	$result.=&Apache::edit::select_arg('Items Display Location:',
  109: 					   'location',
  110: 					   ['top','bottom','left','right'],
  111: 					   $token);
  112: 	$result.=&Apache::edit::select_arg('Items Display Direction:',
  113: 					   'direction',
  114: 					   ['vertical','horizontal'],
  115: 					   $token);
  116:         $result.=&Apache::edit::select_arg('Items Columns:',
  117:                                            'columns',
  118:                                            [['','default'],'1','2','3','4'],
  119:                                             $token);
  120: 	$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  121:     } elsif ($target eq 'modified') {
  122: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  123: 						     $safeeval,'randomize',
  124: 						     'location','direction',
  125:                                                      'columns');
  126: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  127:     } elsif ($target eq 'web' or $target eq 'tex') {
  128: 	$Apache::matchresponse::itemtable{'location'}=
  129: 	    &Apache::lonxml::get_param('location',$parstack,$safeeval);
  130: 	$Apache::matchresponse::TeXitemgroupwidth=&Apache::lonxml::get_param('TeXitemgroupwidth',$parstack,$safeeval,undef,0);
  131:     }
  132:     return $result;
  133: }
  134: 
  135: sub end_itemgroup {
  136:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  137:     my $result;
  138: 
  139:     if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
  140:     if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') {
  141:         if(!@{ $Apache::response::itemgroup{'names'} }) { return; }
  142:     } else {
  143:         return;
  144:     }
  145:     my @names=@{ $Apache::response::itemgroup{'names'} };
  146:     my $randomize =&Apache::lonxml::get_param('randomize',$parstack,$safeeval);
  147:     if ($randomize ne 'no' ) {
  148: 	@names=&Apache::response::whichorder($#names+1,$randomize,0,
  149: 					 \%Apache::response::itemgroup);
  150:     }
  151:     if ($target eq 'analyze') {
  152: 	my $partid="$Apache::inputtags::part.$Apache::inputtags::response[-1]";
  153: 	push (@{ $Apache::lonhomework::analyze{"$partid.items"} }, @names);
  154:     }
  155:     my %letter_name_map;
  156:     my %name_letter_map;
  157:     my @alphabet=('A'..'Z');
  158:     my $i=0;
  159:     foreach my $name (@names) {
  160: 	$letter_name_map{$alphabet[$i]}=$name;
  161: 	$name_letter_map{$name}=$alphabet[$i];
  162: 	$i++;
  163:     }
  164:     $Apache::response::itemgroup{'letter_name_map'}=\%letter_name_map;
  165:     $Apache::response::itemgroup{'name_letter_map'}=\%name_letter_map;
  166:     my $direction=&Apache::lonxml::get_param('direction',$parstack,$safeeval);
  167:     my $columns=&Apache::lonxml::get_param('columns',$parstack,$safeeval);
  168:     
  169:     unless ($columns =~ /^\d+$/) {
  170:         undef($columns);
  171:     }
  172:     if ($target eq 'web') {
  173: 	
  174: 	my $table='<table class="LC_itemgroup">'; # extra space to match what latex does.
  175:         if ((!$columns) || ($columns < 0)) {
  176:             if ($direction eq 'horizontal') {
  177:                 if (@names > 0) { 
  178:                     $columns = scalar(@names);
  179:                 } else {
  180:                     $columns = 1;
  181:                 }
  182:             } else {
  183:                 $columns = 1;
  184:             }
  185:         }
  186:         my $rows=ceil(scalar(@names)/$columns);
  187:         my $endloop = $columns*$rows;
  188:         for (my $i=0; $i<$endloop; $i++) {
  189:             my $label = '&nbsp;';
  190:             my $item = '&nbsp;';
  191:             my $index;
  192:             if ($direction eq 'horizontal') {
  193:                 $index = $i;
  194:             } else {
  195:                 $index = ($i % $columns)*$rows+int($i/$columns);
  196:             }
  197:             if ($index < scalar(@names)) {
  198:                 $label = $alphabet[$index];
  199:                 $item = $Apache::response::itemgroup{$names[$index].'.text'};
  200:             }
  201:             if ($i % $columns == 0) {
  202:                 $table.='<tr>';
  203:             }
  204:             $table.= '<td>'.$label.'</td><td>'.$item.'</td>';
  205:             if ($columns > 1) {
  206:                 $table .= '<td>&nbsp;</td>';
  207:             }
  208:             if ( ! (($i+1) % $columns) ) {
  209:                 $table.='</tr>';
  210:             }
  211:         }
  212: 	$table.='</table>';
  213: 	$Apache::matchresponse::itemtable{'display'}=$table;
  214: 	$Apache::lonxml::post_evaluate=0;
  215:     } elsif ($target eq 'tex') {
  216: 	my $table=' \begin{description}\setlength{\leftmargin}{2em}\setlength{\labelwidth}{1em}\setlength{\itemsep}{0.5pt plus1pt minus2pt}\setlength{\listparindent}{0em} ';
  217: 	my $i=0;
  218:         my ($numrows,$bubbles_per_row);
  219:         if ($Apache::lonhomework::type eq 'exam') {
  220:             ($numrows,$bubbles_per_row) = 
  221:                 &Apache::optionresponse::getnumrows(scalar(@names)); 
  222:         } else {
  223:             $numrows = 1;
  224:         }
  225: 	foreach my $name (@names) {
  226: 	    # $Apache::response::itemgroup{$name.'.text'}=~s/\$\$/\$/g;
  227:             my $item;
  228:             if (($numrows > 1) && ($bubbles_per_row > 0)) {
  229:                 my $num = 1+int($i/$bubbles_per_row);
  230:                 my $idx = int($i % $bubbles_per_row);
  231:                 if ($idx == 0) {
  232:                     if ($num == 1) {
  233:                         $table .= '\item[\footnotesize {'.&mt('(first line)').'}]';
  234:                     } else {
  235:                         $table .= '\item[\footnotesize {'.&mt('(next line)').'}]';
  236:                     }
  237:                 }
  238:                 $item = $alphabet[$idx];
  239:             } else {
  240:                 $item = $alphabet[$i];
  241:             }
  242: 	    $table.='\item['.$item.'] '.
  243: 		$Apache::response::itemgroup{$name.'.text'};
  244: 	    $i++;
  245: 	}
  246: 	$table.=' \end{description}  \strut ';
  247: 	if ($Apache::lonhomework::type eq 'exam')  {$table.='\vskip -13 mm \strut ';}
  248: 	$Apache::matchresponse::itemtable{'display'}=$table;
  249: 	$Apache::lonxml::post_evaluate=0;
  250:     }
  251:     return $result;
  252: }
  253: 
  254: sub start_item {
  255:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  256:     my $result='';
  257:     if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  258: 	&Apache::lonxml::startredirection;
  259:     } elsif ($target eq 'edit') {
  260: 	my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
  261: 						 $safeeval,'-2');
  262: 	$result=&Apache::edit::tag_start($target,$token,"Item");
  263: 	$result.=&Apache::edit::text_arg('Name:','name',$token);
  264: 	if ($randomize ne 'no') {
  265: 	    $result.=
  266:                      &Apache::edit::select_arg('Location:','location',
  267: 					       ['random','top','bottom'],
  268: 					       $token);
  269: 	}
  270: 	$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  271:     } elsif ($target eq 'modified') {
  272: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  273: 						     $safeeval,'name',
  274: 						     'location');
  275: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  276:     }
  277:     return $result;
  278: }
  279: 
  280: sub end_item {
  281:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  282:     my $text ='';
  283:     my $result = '';
  284:     if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  285: 	$text=&Apache::lonxml::endredirection;
  286:     }
  287:     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  288: 	$target eq 'edit' || $target eq 'tex' || $target eq 'analyze') {
  289: 	my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
  290: 	my $location=&Apache::lonxml::get_param('location',$parstack,
  291: 						$safeeval);
  292: 	&Apache::lonxml::debug("Got a name of :$name:");
  293: 	if ($name eq "") { $name=$Apache::lonxml::curdepth; }
  294: 	&Apache::lonxml::debug("Using a name of :$name:");
  295: 	push @{ $Apache::response::itemgroup{'names'} }, $name;
  296: 	$Apache::response::itemgroup{"$name.text"} = $text;
  297: 	$Apache::response::itemgroup{"$name.location"} = $location;
  298:     }
  299:     if ($target eq 'edit') {
  300: 	$result.= &Apache::edit::tag_end($target,$token,'');
  301:     }
  302:     return $result;
  303: }
  304: 
  305: sub insert_item {
  306:     return '
  307: <item name="">
  308: <startouttext />
  309: <endouttext />
  310: </item>';
  311: }
  312: 
  313: %Apache::response::foilgroup=();
  314: sub start_foilgroup {
  315:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  316:     my $result;
  317:     %Apache::response::foilgroup=();
  318:     $Apache::matchresponse::conceptgroup=0;
  319:     &Apache::response::pushrandomnumber(undef,$target);
  320:     if ($target eq 'edit') {
  321: 	$result.=&Apache::edit::start_table($token)
  322: 	    .'<tr><td>'.&Apache::loncommon::insert_folding_button()
  323:             .&mt('Collection Of Foils').'</td>'
  324:             .'<td><span class="LC_nobreak">'.&mt('Delete?')
  325: 	    .&Apache::edit::deletelist($target,$token)
  326: 	    .'</span></td>'
  327:             .'<td>&nbsp;'.&Apache::edit::end_row()
  328:             .&Apache::edit::start_spanning_row()."\n";
  329:     }
  330:     return $result;
  331: }
  332: 
  333: sub end_foilgroup {
  334:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  335:     my $result;
  336:     my $part        = $Apache::inputtags::part;
  337:     my $response_id = $Apache::inputtags::response[-1];
  338: 
  339:     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex' || $target eq 'analyze') {
  340: 	my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
  341: 	my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
  342: 						   $safeeval,'-2');
  343: 	if ($target eq 'web' || $target eq 'tex') {
  344: 	    $result=&displayfoils($target,$max,$randomize);
  345: 	    $Apache::lonxml::post_evaluate=0;
  346: 	} elsif ($target eq 'answer' ) {
  347: 	    $result=&displayanswers($max,$randomize);
  348: 	} elsif ( $target eq 'grade') {
  349: 	    &grade_response($max,$randomize);
  350: 	} elsif ( $target eq 'analyze') {
  351: 	    my @shown=&whichfoils($max,$randomize);
  352: 	    &Apache::response::analyze_store_foilgroup(\@shown,
  353: 						 ['text','value','location']);
  354: 	    #FIXME need to store options in some way
  355: 	}
  356:         my ($numrows,$bubbles_per_row);
  357:         if (($target eq 'tex') && ($Apache::lonhomework::type eq 'exam')) {
  358:             my $numitems;
  359:             if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') {
  360:                 $numitems = scalar(@{ $Apache::response::itemgroup{'names'} });
  361:                 ($numrows,$bubbles_per_row) =
  362:                     &Apache::optionresponse::getnumrows($numitems);
  363:             }
  364:         }
  365:         if ($numrows < 1) {
  366:             $numrows = 1;
  367:         }
  368:         my $increment = &getfoilcounts($max) * $numrows;
  369: 	&Apache::lonxml::increment_counter($increment,"$part.$response_id");
  370: 	if ($target eq 'analyze') {
  371: 	    &Apache::lonhomework::set_bubble_lines();
  372: 	}
  373: 
  374:     } elsif ($target eq 'edit') {
  375: 	$result=&Apache::edit::end_table();
  376:     }
  377:     &Apache::response::poprandomnumber();
  378:     return $result;
  379: }
  380: 
  381: sub whichfoils {
  382:     my ($max,$randomize)=@_;
  383:     return &Apache::response::whichorder(&getfoilcounts($max),
  384: 					 $randomize,
  385: 					 &Apache::response::showallfoils(),
  386: 					 \%Apache::response::foilgroup);
  387: }
  388: 
  389: sub displayanswers {
  390:     my ($max,$randomize,@opt)=@_;
  391:     if (ref($Apache::response::foilgroup{'names'}) eq 'ARRAY') {
  392:         if (!@{ $Apache::response::foilgroup{'names'} }) { return; }
  393:     } else {
  394:         return;
  395:     }
  396:     my @names = @{ $Apache::response::foilgroup{'names'} };
  397:     my @whichfoils = &Apache::response::whichorder(&getfoilcounts($max),
  398: 						   $randomize,
  399: 					  &Apache::response::showallfoils(),
  400: 					 \%Apache::response::foilgroup);
  401:     my %name_letter_map;
  402:     if (ref($Apache::response::itemgroup{'name_letter_map'}) eq 'HASH') {
  403:         if (%{$Apache::response::itemgroup{'name_letter_map'}}) {
  404: 	    %name_letter_map=
  405: 	        %{ $Apache::response::itemgroup{'name_letter_map'} };
  406:         }
  407:     }
  408:     my $result;
  409:     if ($Apache::lonhomework::type eq 'exam') {
  410: 	my $i=0;
  411: 	foreach my $name (@whichfoils) {
  412: 	    $result.=&Apache::response::answer_header('matchresponse',$i++);
  413: 	    my $value_name=$Apache::response::foilgroup{$name.'.value'};
  414: 	    my $letter=$name_letter_map{$value_name};
  415: 	    $result.=&Apache::response::answer_part('matchresponse',$letter);
  416: 	    $result.=&Apache::response::answer_footer('matchresponse');
  417: 	}
  418:     } else {
  419: 	$result=&Apache::response::answer_header('matchresponse');
  420: 	foreach my $name (@whichfoils) {
  421: 	    my $value_name=$Apache::response::foilgroup{$name.'.value'};
  422: 	    my $letter=$name_letter_map{$value_name};
  423: 	    $result.=&Apache::response::answer_part('matchresponse',$letter);
  424: 	}
  425: 	$result.=&Apache::response::answer_footer('matchresponse');
  426:     }
  427:     return $result;
  428: }
  429: 
  430: 
  431: sub grade_response {
  432:     my ($max,$randomize)=@_;
  433:     my (@whichfoils)=&Apache::response::whichorder(&getfoilcounts($max),
  434: 						   $randomize,
  435: 				            &Apache::response::showallfoils(),
  436: 				           \%Apache::response::foilgroup);
  437:     if (!&Apache::response::submitted()) { return; }
  438:     my %responsehash;
  439:     my %grade;
  440:     my %answerhash;
  441:     my ($temp,$right,$wrong,$ignored)=(1,0,0,0);
  442:     my %letter_name_map;
  443:     if (ref($Apache::response::itemgroup{'letter_name_map'}) eq 'HASH') {
  444:         if (%{$Apache::response::itemgroup{'letter_name_map'}}) {
  445: 	    %letter_name_map=
  446: 	        %{ $Apache::response::itemgroup{'letter_name_map'} };
  447:         }
  448:     }
  449:     my @items;
  450:     my $numitems = scalar(@{ $Apache::response::itemgroup{'names'} });
  451:     my ($numrows,$bubbles_per_row);
  452:     if ($Apache::lonhomework::scantronmode) {
  453:         my $numitems = scalar(@{ $Apache::response::itemgroup{'names'} });
  454:         ($numrows,$bubbles_per_row) =
  455:             &Apache::optionresponse::getnumrows($numitems);
  456:     }
  457:     if ($numrows < 1) {
  458:         $numrows = 1;
  459:     }
  460:     my @alphabet=('A'..'Z');
  461:     my %nums_from_letters;
  462:     for (my $i=0; $i<@alphabet; $i++) {
  463:         $nums_from_letters{$alphabet[$i]} = $i;
  464:     }
  465:     foreach my $name (@whichfoils) {
  466:         my $response;
  467:         if ($numrows > 1) {
  468:             my $num = $temp;
  469:             my $totalnum;
  470:             for (my $i=0; $i<$numrows; $i++) {
  471:                 my $item = &Apache::response::getresponse($num,'letter');
  472:                 if ($item =~ /^\w$/) {
  473:                     $totalnum = $i*$bubbles_per_row + $nums_from_letters{$item};
  474:                 }
  475:                 $num ++;
  476:             }
  477:             if ($totalnum =~ /^\d+$/) {
  478:                 $response = $alphabet[$totalnum];
  479:             }
  480:             $temp += $numrows;
  481:         } else {
  482: 	    $response = &Apache::response::getresponse($temp,'letter');
  483:             $temp ++;
  484:         }
  485: 	push(@items,$response);
  486: 	my $responsename = $letter_name_map{$response};
  487: 	my $value=$Apache::response::foilgroup{$name.'.value'};
  488:         if ($Apache::lonhomework::type eq 'randomizetry') {
  489:             $answerhash{$name} = $value;
  490:         }
  491: 	if ( $response =~ /[^\s]/) {
  492: 	    $responsehash{$name}=$responsename;
  493: 	    &Apache::lonxml::debug("submitted a $response($responsename) for $value<br />\n");
  494: 	    if ($value eq $responsename) {
  495: 		$grade{$name}='1'; $right++;
  496: 	    } else {
  497: 		$grade{$name}='0'; $wrong++;
  498: 	    }
  499: 	} else {
  500: 	    $ignored++;
  501: 	}
  502:     }
  503:     my $part=$Apache::inputtags::part;
  504:     my $nonlenient=&Apache::optionresponse::grading_is_nonlenient($part);
  505:     my $id = $Apache::inputtags::response['-1'];
  506:     my $responsestr=&Apache::lonnet::hash2str(%responsehash);
  507:     my $itemstr    =&Apache::lonnet::array2str(@items);
  508:     my $gradestr   =&Apache::lonnet::hash2str(%grade);
  509:     my %previous=&Apache::response::check_for_previous($responsestr,$part,$id);
  510:     &Apache::lonxml::debug("Got $right right and $wrong wrong, and $ignored were ignored ");
  511:     $Apache::lonhomework::results{"resource.$part.$id.submission"}=
  512: 	$responsestr;
  513:     $Apache::lonhomework::results{"resource.$part.$id.submissionitems"}=
  514: 	$itemstr;
  515:     $Apache::lonhomework::results{"resource.$part.$id.submissiongrading"}=
  516: 	$gradestr;
  517:     if ($Apache::lonhomework::type eq 'randomizetry') {
  518:         $Apache::lonhomework::results{"resource.$part.$id.foilorder"} = &Apache::lonnet::array2str(@whichfoils);
  519:     }
  520:     if (($Apache::lonhomework::type eq 'survey') ||
  521:         ($Apache::lonhomework::type eq 'surveycred') ||
  522:         ($Apache::lonhomework::type eq 'anonsurvey') ||
  523:         ($Apache::lonhomework::type eq 'anonsurveycred')) {
  524: 	if ($ignored == 0) {
  525: 	    my $ad;
  526:             if ($Apache::lonhomework::type eq 'anonsurvey') {
  527:                 $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='ANONYMOUS';
  528:             } elsif ($Apache::lonhomework::type eq 'anonsurveycred') {
  529:                 $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='ANONYMOUS_CREDIT';
  530:             } elsif ($Apache::lonhomework::type eq 'surveycred') {
  531:                 $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='SUBMITTED_CREDIT';
  532:             } else {
  533:                 $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='SUBMITTED';
  534:             }
  535: 	    &Apache::response::handle_previous(\%previous,$ad);
  536: 	} elsif ($wrong==0 && $right==0) {
  537: 	} else {
  538: 	    my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='MISSING_ANSWER';
  539: 	    &Apache::response::handle_previous(\%previous,$ad);
  540: 	}
  541:     } elsif ($nonlenient) {
  542:         my $ad;
  543:         if ($wrong==0 && $ignored==0) {
  544:             $ad='EXACT_ANS';
  545:         } elsif ($wrong==0 && $right==0) {
  546:             #nothing submitted
  547:         } else {
  548:             if ($ignored==0) {
  549:                 $ad='INCORRECT';
  550:             } else {
  551:                 $ad='MISSING_ANSWER';
  552:             }
  553:         }
  554:         $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
  555:         &Apache::response::handle_previous(\%previous,$ad);
  556:     } else {
  557:         my $ad;
  558:         if ($wrong==0 && $right==0) {
  559:             #nothing submitted only assign a score if we
  560:             #need to override a previous grade
  561:             if (defined($Apache::lonhomework::history{"resource.$part.$id.awarddetail"})) {
  562:                 $ad='ASSIGNED_SCORE';
  563:             }
  564:         } else {
  565:             $ad='ASSIGNED_SCORE';
  566:         }
  567:         $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
  568:         $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
  569:             $right/(scalar(@whichfoils));
  570:         $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
  571:             scalar(@whichfoils);
  572:     }
  573: }
  574: 
  575: sub format_prior_answer {
  576:     my ($mode,$answer,$other_data) = @_;
  577:     my %answer      =&Apache::lonnet::str2hash($answer);
  578:     my $foil_order  =$other_data->[0];
  579:     my %grading     =&Apache::lonnet::str2hash($other_data->[1]);
  580:     my @items       =&Apache::lonnet::str2array($other_data->[2]);
  581:     my $output;
  582:     
  583:     foreach my $name (@{ $foil_order }) {
  584: 	my $item = &HTML::Entities::encode(shift(@items),'<>&"');
  585:         if ($item eq '') {
  586:             $item = '&nbsp;';
  587:         }
  588: 	$output .= '<tr><td>'.$item.'</td></tr>';
  589:     }
  590:     return if (!defined($output));
  591: 
  592:     $output = '<table class="LC_prior_match">'.$output.'</table>';
  593:     return $output;
  594: }
  595: 
  596: sub itemdisplay {
  597:     my ($location)=@_;
  598:     if ($location eq 'top' &&
  599: 	!defined($Apache::matchresponse::itemtable{'location'})) {
  600: 	return $Apache::matchresponse::itemtable{'display'};
  601:     }
  602:     if ($Apache::matchresponse::itemtable{'location'} eq $location) {
  603: 	return $Apache::matchresponse::itemtable{'display'};
  604:     }
  605:     return undef;
  606: }
  607: 
  608: sub displayfoils {
  609:     my ($target,$max,$randomize)=@_;
  610:     my ($tabsize, $lefttabsize, $righttabsize);
  611: 
  612:     my $result;
  613:     my $question;
  614:     my (@whichfoils)=&Apache::response::whichorder(&getfoilcounts($max),
  615: 						   $randomize,
  616: 				            &Apache::response::showallfoils(),
  617: 				           \%Apache::response::foilgroup);
  618:     my $part=$Apache::inputtags::part;
  619:     my $solved=$Apache::lonhomework::history{"resource.$part.solved"};
  620:     my %letter_name_map;
  621:     if (ref($Apache::response::itemgroup{'letter_name_map'}) eq 'HASH') {
  622:         if (%{$Apache::response::itemgroup{'letter_name_map'}}) {
  623: 	    %letter_name_map=
  624: 	        %{ $Apache::response::itemgroup{'letter_name_map'} };
  625:         }
  626:     }
  627:     my %name_letter_map;
  628:     if (ref($Apache::response::itemgroup{'name_letter_map'}) eq 'HASH') {
  629:         if (%{$Apache::response::itemgroup{'name_letter_map'}}) {
  630: 	    %name_letter_map=
  631: 	        %{ $Apache::response::itemgroup{'name_letter_map'} };
  632:         }
  633:     }
  634:     if ( &Apache::response::show_answer() && ($target ne 'tex')) {
  635: 	foreach my $name (@whichfoils) {
  636: 	    my $text=$Apache::response::foilgroup{$name.'.text'};
  637: 	    my $value=$Apache::response::foilgroup{$name.'.value'};
  638: 	    my $letter=$name_letter_map{$value};
  639: 	    if ($target eq 'tex') {
  640: 		$question.=' \\\\ '.$letter.':'.$text;
  641: 	    } else {
  642: 		$question.='<br /><b>'.$letter.':</b> '.$text;
  643: 	    }
  644: 	}
  645:     } else {
  646: 	my $i = 0;
  647: 	my $temp=1;
  648: 	my $id=$Apache::inputtags::response[-1];
  649: 	my $part=$Apache::inputtags::part;
  650:         my ($lastresponse,$newvariation);
  651:         if ((($Apache::lonhomework::history{"resource.$part.type"} eq 'randomizetry') ||
  652:             ($Apache::lonhomework::type eq 'randomizetry')) &&
  653:             ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
  654:             if ($env{'form.'.$part.'.rndseed'} ne
  655:                 $Apache::lonhomework::history{"resource.$part.rndseed"}) {
  656:                 $newvariation = 1;
  657:             }
  658:         }
  659:         unless ($newvariation) {
  660:             if ((($env{'form.grade_username'} eq '') && ($env{'form.grade_domain'} eq '')) ||
  661:                 (($env{'form.grade_username'} eq $env{'user.name'}) &&
  662:                  ($env{'form.grade_domain'} eq $env{'user.domain'}))) {
  663:                 $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"};
  664:             } else {
  665:                 unless (($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurvey') ||
  666:                         ($Apache::lonhomework::history{"resource.$part.type"} eq 'anonsurveycred')) {
  667:                     $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"};
  668:                 }
  669:             }
  670:         }
  671: 
  672: 	my %lastresponse=&Apache::lonnet::str2hash($lastresponse);    
  673: 	my @alphabet=('A'..'Z');
  674: 	my @used_letters=sort(keys(%letter_name_map));
  675: 	my $internal_counter=$Apache::lonxml::counter;
  676:         my ($numrows,$bubbles_per_row);
  677:         if (($target eq 'tex') && ($Apache::lonhomework::type eq 'exam')) {
  678:             ($numrows,$bubbles_per_row) = 
  679:                 &Apache::optionresponse::getnumrows(scalar(@used_letters));
  680:         } else {
  681:             $numrows = 1;
  682:         }
  683: 	foreach my $name (@whichfoils) {
  684: 	    my $lastopt=$lastresponse{$name};
  685: 	    my $last_letter=$name_letter_map{$lastopt};
  686: 	    my $optionlist = '';
  687: 	    if ($target ne 'tex') {
  688: 		$optionlist="<option></option>\n";
  689: 	    } else {
  690: 		if ($Apache::lonhomework::type ne 'exam') {
  691:                     if($env{'form.pdfFormFields'} eq 'yes'
  692:                        && $Apache::inputtags::status['-1'] eq 'CAN_ANSWER') {
  693:                         my $fieldname = $env{'request.symb'} . '&part_'. $Apache::inputtags::part .'&matchresponse'. '&HWVAL_' . $Apache::inputtags::response['-1'] . ':' . $temp . '&submit_' . $Apache::inputtags::part . '&';
  694:                         $optionlist = &Apache::lonxml::print_pdf_start_combobox($fieldname);
  695:                     } else {
  696: 
  697:                         $optionlist='\framebox[10 mm][s]{\tiny\strut}';
  698:                     }
  699:                 }
  700: 	    }
  701: 	    my $option;
  702: 	    foreach $option (@used_letters) {
  703: 		if ($option eq $last_letter) {
  704: 		    if ($target ne 'tex') {
  705:                         $optionlist.="<option selected=\"selected\">$option</option>\n";
  706:                     } elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes'
  707:                              && $Apache::inputtags::status['-1'] eq 'CAN_ANSWER'
  708:                              && $Apache::lonhomework::type ne 'exam') {
  709:                         $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option);
  710:                     }
  711: 		} else {
  712: 		    if ($target ne 'tex') {
  713:                         $optionlist.="<option>$option</option>\n";
  714:                     } elsif ($target eq 'tex' && $env{'form.pdfFormFields'} eq 'yes'
  715:                              && $Apache::inputtags::status['-1'] eq 'CAN_ANSWER'
  716:                              && $Apache::lonhomework::type ne 'exam') {
  717:                         $optionlist .= &Apache::lonxml::print_pdf_add_combobox_option($option);
  718:                     }
  719: 		}
  720: 	    }
  721: 	    if ($target ne 'tex' && $Apache::lonhomework::type ne 'exam') {
  722: 	        $optionlist='<select onchange="javascript:setSubmittedPart(\''.
  723: 		  $part.'\');" name="HWVAL_'.
  724: 		    $Apache::inputtags::response[-1].':'.$temp.'">'.
  725: 		        $optionlist."</select>\n";
  726: 	    }
  727: 	    my $text=$Apache::response::foilgroup{$name.'.text'};
  728: 	    #
  729:             #  Factor out the tex computations of the left/right 1/2 minipage
  730: 	    #  widths for left or right positioning.  This allows us
  731: 	    #  to, if necessary constrain the bubble widths:
  732: 	    #
  733: 	    if ($target eq 'tex'   &&
  734: 		(&itemdisplay('left') || &itemdisplay('right'))) {
  735: 		$tabsize=&Apache::londefdef::recalc($env{'form.textwidth'});
  736: 		($lefttabsize,$righttabsize)=(0,0);
  737: 		if ($Apache::matchresponse::TeXitemgroupwidth ne '') {
  738: 		    $Apache::matchresponse::TeXitemgroupwidth=~/(\d*.?\d*)/;
  739: 		    $lefttabsize=$tabsize*$1/100;	
  740: 		    $righttabsize=0.95*($tabsize-$lefttabsize);
  741: 		} else {
  742: 		    $tabsize=~/(\d+\.?\d*)/;
  743: 		    $lefttabsize=$1/2.1;
  744: 		    $righttabsize=0.95*($1-$lefttabsize);
  745: 		}
  746: 	    }
  747: 	    if ($target ne 'tex') {
  748: 		if ($Apache::lonhomework::type ne 'exam') {
  749: 		    $question.="<br />\n".$optionlist.$text;
  750: 		} else {
  751: 		    $question.="<br />\n".$text;
  752: 		}
  753: 		if ($Apache::lonhomework::type eq 'exam') {
  754: 		    my @blank;
  755: 		    $question.=&Apache::optionresponse::webbubbles(\@used_letters,\@blank,$temp,$last_letter);
  756: 		}
  757: 	    } else {		
  758: 		# Note that if left or right positioned, we must
  759: 		# confine the bubbles to righttabsize:
  760: 		#
  761: 		if ($Apache::lonhomework::type eq 'exam') {
  762: 		    $question.=' '.$optionlist.$text."\n";
  763: 		    my @emptyItems = ();
  764: 		    for (my $i=0;$i<=$#used_letters;$i++) {push @emptyItems, ' ';}
  765: 		    $question.='\vskip -1 mm\noindent\begin{list}{}{\setlength{\listparindent}{0mm}\setlength{\leftmargin}{2mm}}'
  766: 			.'\item \hskip -3mm ';
  767:                     if ($numrows == 1) {
  768:                         $question .= '\textbf{'.$internal_counter.'}';
  769:                     } else {
  770:                         my $linetext;
  771:                         for (my $i=0; $i<$numrows; $i++) {
  772:                             $linetext .= $internal_counter+$i.', ';
  773:                         }
  774:                         $linetext =~ s/,\s$//;
  775:                         $question .= '\small {\textbf{'.$linetext.'}} '.
  776:                                      '\hskip 2 mm {\footnotesize '.
  777:                                      &mt('(Bubble once in [_1] lines)',$numrows).
  778:                                      '} \vskip 3 mm';
  779:                     }
  780:                     my $max_width;
  781: 		    if (&itemdisplay('left') || &itemdisplay('right')) {
  782:                         $max_width = $righttabsize;
  783:                     }
  784: 		    $question .= '\vskip -4 mm' . &Apache::optionresponse::bubbles(\@used_letters,\@emptyItems,'',$max_width,$numrows,$bubbles_per_row,$internal_counter);
  785: 		    $question .= '\end{list} \vskip -8 mm \strut ';
  786: 		    $internal_counter += $numrows;
  787: 	        } else {
  788:                     if($env{'form.pdfFormFields'} eq 'yes' 
  789:                             && $Apache::inputtags::status['-1'] eq 'CAN_ANSWER') {
  790:                         $question .= " $optionlist ". &Apache::lonxml::print_pdf_end_combobox($text).'\strut';
  791:                     } else {
  792:                         $question.=' '.$optionlist.$text.'\strut\\\\\strut '."\n";
  793:                     }
  794: 		}
  795:             } 
  796: 	    $temp++;
  797: 	}
  798:     }
  799:     if ($result=&itemdisplay('top')) {
  800: 	$result.=$question;
  801:     } elsif ($result=&itemdisplay('bottom')) {
  802: 	$result=$question.$result;
  803:     } elsif ($result=&itemdisplay('right')) {
  804: 	if ($target ne 'tex') {
  805: 	    #remove the first <br />
  806: 	    $question=~s|<br />||;
  807: 	    $result='<table><tr><td valign="top">'.$question.
  808: 		'</td><td valign="top">'.$result.'</td></tr></table>';
  809: 	} else {
  810: 	    $lefttabsize.=' mm ';
  811: 	    $righttabsize.=' mm ';
  812: 	    $result='\setlength{\tabcolsep}{1 mm}\begin{tabular}{p{'.$righttabsize.'}p{'.$lefttabsize.'}}\begin{minipage}{'.$righttabsize.'}'.$question.'\end{minipage}&\begin{minipage}{'.$lefttabsize.'}'.$result.'\end{minipage}\end{tabular}';
  813: 	}
  814:     } elsif ($result=&itemdisplay('left')) {
  815: 	if ($target ne 'tex') {
  816: 	    #remove the first <br />
  817: 	    $question=~s|<br />||;
  818: 	    $result='<table><tr><td valign="top">'.$result.
  819: 		'</td><td valign="top">'.$question.'</td></tr></table>';
  820: 	} else {
  821: 	    $lefttabsize.=' mm ';
  822: 	    $righttabsize.=' mm ';
  823: 	    $result='\setlength{\tabcolsep}{1 mm}\begin{tabular}{p{'.$lefttabsize.'}p{'.$righttabsize.'}}\begin{minipage}{'.$lefttabsize.'}'.$result.'\end{minipage}&\begin{minipage}{'.$righttabsize.'}'.$question.'\end{minipage}\end{tabular}';
  824: 	}
  825:     }
  826:     if ($target eq 'web') {
  827:         my $questiontype;
  828:         if ($Apache::lonhomework::type eq 'randomizetry') {
  829:             $questiontype = $Apache::lonhomework::type;
  830:         }
  831: 	&Apache::response::setup_prior_tries_hash(\&format_prior_answer,
  832: 						  [\@whichfoils,
  833: 						   'submissiongrading',
  834: 						   'submissionitems'],
  835:                                                   $questiontype);
  836:     }
  837:     if ($target ne 'tex') {$result.="<br />";} else {$result.=' \\\\ ';}
  838:     return $result;
  839: }
  840: 
  841: sub getfoilcounts {
  842:     my ($max)=@_;
  843:     # +1 since instructors will count from 1
  844:     my $count = $#{ $Apache::response::foilgroup{'names'} }+1;
  845:     if (&Apache::response::showallfoils()) { $max=$count; }
  846:     if ($count>$max) { $count=$max } 
  847:     &Apache::lonxml::debug("Count is $count from $max");
  848:     return $count;
  849: }
  850: 
  851: 
  852: sub start_conceptgroup {
  853:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  854:     $Apache::matchresponse::conceptgroup=1;
  855:     %Apache::response::conceptgroup=();
  856:     my $result;
  857:     if ($target eq 'edit') {
  858: 	$result.=&Apache::edit::tag_start($target,$token,
  859: 					  "Concept Grouped Foils");
  860: 	$result.=&Apache::edit::text_arg('Concept:','concept',$token,'50').
  861: 	    &Apache::edit::end_row().&Apache::edit::start_spanning_row();
  862:     }
  863:     if ($target eq 'modified') {
  864: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  865: 						     $safeeval,'concept');
  866: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  867:     }
  868:     return $result;
  869: }
  870: 
  871: sub end_conceptgroup {
  872:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  873:     $Apache::matchresponse::conceptgroup=0;
  874:     my $result='';
  875:     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  876: 	$target eq 'tex' || $target eq 'analyze') {
  877: 	&Apache::response::pick_foil_for_concept($target,
  878: 						 ['value','text','location'],
  879: 						 \%Apache::hint::match,
  880: 						 $parstack,$safeeval);
  881:     } elsif ($target eq 'edit') {
  882: 	$result=&Apache::edit::end_table();
  883:     }
  884:     return $result;
  885: }
  886: 
  887: sub insert_conceptgroup {
  888:     my $result="\n\t\t<conceptgroup concept=\"\">".&insert_foil()."\n\t\t</conceptgroup>\n";
  889:     return $result;
  890: }
  891: 
  892: sub start_foil {
  893:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  894:     my $result='';
  895:     if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  896: 	&Apache::lonxml::startredirection;
  897: 	if ($target eq 'analyze') {
  898: 	    &Apache::response::check_if_computed($token,$parstack,$safeeval,'value');
  899: 	}
  900:     } elsif ($target eq 'edit') {
  901: 	$result=&Apache::edit::tag_start($target,$token,"Foil");
  902: 	my $level='-2';
  903: 	if ($$tagstack[-2] eq 'conceptgroup') { $level = '-3'; }
  904: 	$result.=&Apache::edit::text_arg('Name:','name',$token);
  905: 	my @names;
  906: 	if (ref($Apache::response::itemgroup{'names'}) eq 'ARRAY') {
  907:             if (@{ $Apache::response::itemgroup{'names'} }) {
  908: 	        @names=@{ $Apache::response::itemgroup{'names'} };
  909:             }
  910: 	}
  911: 	$result.= &Apache::edit::select_or_text_arg('Correct Option:','value',['unused',@names],$token,'15');
  912: 	my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
  913: 						 $safeeval,'-3');
  914: 	if ($randomize ne 'no') {
  915: 	    $result.=&Apache::edit::select_arg('Location:','location',
  916: 					     ['random','top','bottom'],$token);
  917: 	}
  918: 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  919:     } elsif ($target eq 'modified') {
  920: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  921: 						     $safeeval,'value',
  922: 						     'name','location');
  923: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  924:     }
  925:     return $result;
  926: }
  927: 
  928: sub end_foil {
  929:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  930:     my $text ='';
  931:     my $result = '';
  932:     if ($target eq 'web' || $target eq 'tex' || $target eq 'analyze') {
  933: 	$text=&Apache::lonxml::endredirection;
  934:     }
  935: 
  936:     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  937: 	$target eq 'tex' || $target eq 'analyze') {
  938: 	if ($target eq 'tex' && $Apache::lonhomework::type eq 'exam') {
  939: 	    $text='\vskip 5mm $\triangleright$ '.$text;
  940: 	}
  941: 	my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
  942: 	if ($value ne 'unused') {
  943: 	    my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
  944: 	    &Apache::lonxml::debug("Got a name of :$name:");
  945: 	    if (!$name) {
  946: 		&Apache::lonxml::warning(&mt('Foils without names exist. This can cause problems to malfunction.'));
  947: 		$name=$Apache::lonxml::curdepth;
  948: 	    }
  949: 	    &Apache::lonxml::debug("Using a name of :$name:");
  950: 	    if (defined($Apache::response::foilnames{$name})) {
  951: 		&Apache::lonxml::error(&mt("Foil name [_1] appears more than once. Foil names need to be unique.",'<b><tt>'.$name.'</tt></b>'));
  952: 	    }
  953: 	    $Apache::response::foilnames{$name}++;
  954: 	    my $location =&Apache::lonxml::get_param('location',$parstack,
  955: 						     $safeeval);
  956: 	    if ( $Apache::matchresponse::conceptgroup
  957: 		 && !&Apache::response::showallfoils() ) {
  958: 
  959: 		push @{ $Apache::response::conceptgroup{'names'} }, $name;
  960: 		$Apache::response::conceptgroup{"$name.value"} = $value;
  961: 		$Apache::response::conceptgroup{"$name.text"} = $text;
  962: 		$Apache::response::conceptgroup{"$name.location"} = $location;
  963: 	    } else {
  964: 
  965: 		push @{ $Apache::response::foilgroup{'names'} }, $name;
  966: 		$Apache::response::foilgroup{"$name.value"} = $value;
  967: 		$Apache::response::foilgroup{"$name.text"} = $text;
  968: 		$Apache::response::foilgroup{"$name.location"} = $location;
  969: 	    }
  970: 	}
  971:     }
  972:     if ($target eq 'edit') {
  973: 	$result.= &Apache::edit::tag_end($target,$token,'');
  974:     }
  975:     return $result;
  976: }
  977: 
  978: sub insert_foil {
  979:     return '
  980: <foil name="" value="unused">
  981: <startouttext />
  982: <endouttext />
  983: </foil>';
  984: }
  985: 
  986: 1;
  987: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>