Annotation of loncom/homework/matchresponse.pm, revision 1.81.2.1

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

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