File:  [LON-CAPA] / loncom / homework / radiobuttonresponse.pm
Revision 1.57: download - view: text, annotated - select for diffs
Thu Oct 17 17:13:44 2002 UTC (21 years, 6 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- Rewrite counter code

    1: # The LearningOnline Network with CAPA
    2: # mutliple choice style responses
    3: #
    4: # $Id: radiobuttonresponse.pm,v 1.57 2002/10/17 17:13:44 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # 2/21 Guy
   29: 
   30: package Apache::radiobuttonresponse;
   31: use strict;
   32: use HTML::Entities();
   33: 
   34: BEGIN {
   35:   &Apache::lonxml::register('Apache::radiobuttonresponse',('radiobuttonresponse'));
   36: }
   37: 
   38: sub start_radiobuttonresponse {
   39:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   40:   my $result;
   41:   #when in a radiobutton response use these
   42:   &Apache::lonxml::register('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup'));
   43:   push (@Apache::lonxml::namespace,'radiobuttonresponse');
   44:   my $id = &Apache::response::start_response($parstack,$safeeval);
   45:   if ($target eq 'meta') {
   46:     $result=&Apache::response::meta_package_write('radiobuttonresponse');
   47:   } elsif ($target eq 'edit' ) {
   48:     $result.=&Apache::edit::start_table($token).
   49: 	'<tr><td>'.&Apache::lonxml::description($token)."</td><td>Delete:".
   50: 	&Apache::edit::deletelist($target,$token)
   51: 	."</td><td>&nbsp".&Apache::edit::end_row()
   52:         .&Apache::edit::start_spanning_row();
   53: 
   54:     $result.=
   55: 	&Apache::edit::text_arg('Max Number Of Shown Foils:','max',$token,'4').
   56: 	&Apache::edit::select_arg('Randomize Foil Order','randomize',
   57: 				  ['yes','no'],$token).
   58:         &Apache::edit::end_row().&Apache::edit::start_spanning_row()."\n";
   59:   } elsif ($target eq 'modified') {
   60:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,
   61: 						 $safeeval,'max','randomize');
   62:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
   63:   } elsif ($target eq 'tex') {
   64:       $result .= '\begin{enumerate}';
   65:   }
   66:   return $result;
   67: }
   68: 
   69: sub end_radiobuttonresponse {
   70:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   71:   my $result;
   72:   if ($target eq 'edit') { $result=&Apache::edit::end_table(); }
   73:   if ($target eq 'tex') { $result .= '\end{enumerate}'; }
   74:   &Apache::response::end_response;
   75:   pop @Apache::lonxml::namespace;
   76:   &Apache::lonxml::deregister('Apache::radiobuttonresponse',('foilgroup','foil','conceptgroup'));
   77:   return $result;
   78: }
   79: 
   80: %Apache::response::foilgroup=();
   81: sub start_foilgroup {
   82:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   83:   my $result;
   84:   %Apache::response::foilgroup=();
   85:   $Apache::radiobuttonresponse::conceptgroup=0;
   86:   &Apache::response::setrandomnumber();
   87:   if ($target eq 'tex' && $Apache::lonhomework::type eq 'exam') {
   88:       $result.='\item[\textbf{'.$Apache::lonxml::counter.'}.]';
   89:       &Apache::lonxml::increment_counter();
   90:   }
   91:   return $result;
   92: }
   93: 
   94: sub storesurvey {
   95:   if ( !defined($ENV{'form.submitted'})) { return ''; }
   96:   my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']};
   97:   &Apache::lonxml::debug("Here I am!:$response:");
   98:   if ( $response !~ /[0-9]+/) { return ''; }
   99:   my $id = $Apache::inputtags::response['-1'];
  100:   my @whichfoils=@{ $Apache::response::foilgroup{'names'} };
  101:   my %responsehash;
  102:   $responsehash{$whichfoils[$response]}=$response;
  103:   $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.submission"}=&Apache::lonnet::hash2str(%responsehash);
  104:   $Apache::lonhomework::results{"resource.$Apache::inputtags::part.$id.awarddetail"}='SUBMITTED';
  105:   &Apache::lonxml::debug("submitted a $response<br />\n");
  106:   return '';
  107: }
  108: 
  109: sub grade_response {
  110:   my ($max,$randomize)=@_;
  111:   #keep the random numbers the same must always call this
  112:   my ($answer,@whichfoils)=&whichfoils($max,$randomize);
  113:   if (!defined($ENV{'form.submitted'})) { return; }
  114:   my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']};
  115:   if ( $response !~ /[0-9]+/) { return; }
  116:   my $part=$Apache::inputtags::part;
  117:   my $id = $Apache::inputtags::response['-1'];
  118:   my %responsehash;
  119:   $responsehash{$whichfoils[$response]}=$response;
  120:   my $responsestr=&Apache::lonnet::hash2str(%responsehash);
  121:   my %previous=&Apache::response::check_for_previous($responsestr,
  122: 						     $part,$id);
  123:   $Apache::lonhomework::results{"resource.$part.$id.submission"}=
  124:     $responsestr;
  125:   &Apache::lonxml::debug("submitted a $response<br />\n");
  126:   my $ad;
  127:   if ($response == $answer) {
  128:     $ad='EXACT_ANS';
  129:   } else {
  130:     $ad='INCORRECT';
  131:   }
  132:   $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
  133:   &Apache::response::handle_previous(\%previous,$ad);
  134: }
  135: 
  136: sub end_foilgroup {
  137:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  138: 
  139:   my $result;
  140:   if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') {
  141:     my $style = $Apache::lonhomework::type;
  142:     if ( $style eq 'survey' ) {
  143:       if ($target eq 'web' || $target eq 'answer' || $target eq 'tex') {
  144: 	$result=&displayallfoils();
  145:       } elsif ( $target eq 'grade' ) {
  146: 	$result=&storesurvey();
  147:       }
  148:     } else {
  149:       my $name;
  150:       my $max = &Apache::lonxml::get_param('max',$parstack,$safeeval,'-2');
  151:       my $randomize = &Apache::lonxml::get_param('randomize',$parstack,
  152: 						 $safeeval,'-2');
  153:       if ($target eq 'web' || $target eq 'tex') {
  154: 	$result=&displayfoils($target,$max,$randomize);
  155:       } elsif ($target eq 'answer' ) {
  156: 	$result=&displayanswers($max,$randomize);
  157:       } elsif ( $target eq 'grade') {
  158: 	&grade_response($max,$randomize);
  159:       }
  160:     }
  161:   }
  162:   return $result;
  163: }
  164: 
  165: sub getfoilcounts {
  166:   my @names;
  167:   my $truecnt=0;
  168:   my $falsecnt=0;
  169:   my $name;
  170:   if ( $Apache::response::foilgroup{'names'} ) {
  171:     @names= @{ $Apache::response::foilgroup{'names'} };
  172:   }
  173:   foreach $name (@names) {
  174:     if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
  175:       $truecnt++;
  176:     } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'false') {
  177:       $falsecnt++;
  178:     }
  179:   }
  180:   return ($truecnt,$falsecnt);
  181: }
  182: 
  183: sub displayallfoils {
  184:   my $result;
  185:   &Apache::lonxml::debug("survey style display");
  186:   my @names = @{ $Apache::response::foilgroup{'names'} };
  187:   my $temp=0;
  188:   my $id=$Apache::inputtags::response['-1'];
  189:   my $part=$Apache::inputtags::part;
  190:   my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"};
  191:   my %lastresponse=&Apache::lonnet::str2hash($lastresponse);
  192:   if (($Apache::lonhomework::history{"resource.$part.solved"} =~ /^correct/)  || ($Apache::inputtags::status[-1] eq  'SHOW_ANSWER')) {
  193:     foreach my $name (@names) {
  194:       if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') {
  195: 	$result.="<br />".$Apache::response::foilgroup{$name.'.value'};
  196: 	if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
  197: 	  $result.='<b>';
  198: 	}
  199: 	$result .= $Apache::response::foilgroup{$name.'.text'};
  200: 	if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
  201: 	  $result.='</b>';
  202: 	}
  203:       }
  204:     }
  205:   } else {
  206:     foreach my $name (@names) {
  207:       if ($Apache::response::foilgroup{$name.'.value'} ne 'unused') {
  208: 	$result.="<br /><input type=\"radio\" name=\"HWVAL$Apache::inputtags::response['-1']\" value=\"$temp\" ";
  209: 	if (defined($lastresponse{$name})) { $result .= 'checked="on"'; }
  210: 	$result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</input>\n";
  211: 	$temp++;
  212:       }
  213:     }
  214:   }
  215:   return $result;
  216: }
  217: 
  218: sub whichfoils {
  219:   my ($max,$randomize)=@_;
  220: 
  221:   my @truelist;
  222:   my @falselist;
  223:   my @whichfalse =();
  224:   my ($truecnt,$falsecnt) = &getfoilcounts();
  225:   my $count=0;
  226:   # we will add in 1 of the true statements
  227:   if (($falsecnt+1)>$max) { $count=$max } else { $count=$falsecnt+1; }
  228:   my $answer=int(&Math::Random::random_uniform() * ($count));
  229:   &Apache::lonxml::debug("Count is $count, $answer is $answer");
  230:   my @names;
  231:   if ( $Apache::response::foilgroup{'names'} ) {
  232:       @names= @{ $Apache::response::foilgroup{'names'} };
  233:   }
  234:   if (&Apache::response::showallfoils()) {
  235:       @whichfalse=@names;
  236:   } elsif ($randomize eq 'no') {
  237:       &Apache::lonxml::debug("No randomization");
  238:       my $havetrue=0;
  239:       foreach my $name (@names) {
  240: 	  if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
  241: 	      if (!$havetrue ) {
  242: 		  push(@whichfalse,$name); $havetrue++; $answer=$#whichfalse;
  243: 	      }
  244: 	  } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'false') {
  245: 	      push (@whichfalse,$name);
  246: 	  } elsif ($Apache::response::foilgroup{$name.'.value'} eq 'unused') {
  247: 	  } else {
  248: 	      &Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in <foilgroup>"));
  249: 	  }
  250:       }
  251:   } else {
  252:     my $current=0;
  253:     &Apache::lonhomework::showhash(%Apache::response::foilgroup);
  254:     my (%top,%bottom);
  255:     #first find out where everyone wants to be
  256:     foreach my $name (@names) {
  257: 	$current++;
  258: 	if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
  259: 	    push (@truelist,$name);
  260: 	    if ($Apache::response::foilgroup{$name.'.location'} eq 'top') {
  261: 		$top{$name}=$current;
  262: 	    } elsif ($Apache::response::foilgroup{$name.'.location'} eq 'bottom') {
  263: 		$bottom{$name}=$current;
  264: 	    }
  265: 	} elsif ($Apache::response::foilgroup{$name.'.value'} eq 'false') {
  266: 	    push (@falselist,$name);
  267: 	    if ($Apache::response::foilgroup{$name.'.location'} eq 'top') {
  268: 		$top{$name}=$current;
  269: 	    } elsif ($Apache::response::foilgroup{$name.'.location'} eq 'bottom') {
  270: 		$bottom{$name}=$current;
  271: 	    }
  272: 	} elsif ($Apache::response::foilgroup{$name.'.value'} eq 'unused') {
  273: 	} else {
  274: 	    &Apache::lonxml::error(&HTML::Entities::encode("No valid value assigned ($Apache::response::foilgroup{$name.'.value'}) for foil $name in <foilgroup>"));
  275: 	}
  276:     }
  277:     #pick a true statement
  278:     my $whichtrue = int(&Math::Random::random_uniform() * ($#truelist+1));
  279:     &Apache::lonxml::debug("Max is $max, From $#truelist elms, picking $whichtrue");
  280:     my $numinserted;
  281:     my (@toplist, @bottomlist);
  282:     my $topcount=0;
  283:     # assign everyone to either toplist/bottomlist or whichfalse
  284:     # which false is randomized, toplist bottomlist are in order
  285:     while ((($numinserted) < $max-1) && ($#falselist > -1)) {
  286: 	&Apache::lonxml::debug("Have $#whichfalse max is $max");
  287: 	my $afalse=int(&Math::Random::random_uniform() * ($#falselist+1));
  288: 	&Apache::lonxml::debug("From $#falselist elms, picking $afalse");
  289: 	$afalse=splice(@falselist,$afalse,1);
  290: 	&Apache::lonxml::debug("Picked $afalse");
  291: 	&Apache::lonhomework::showhash(('names'=>\@names));
  292: 	&Apache::lonhomework::showhash(%top);
  293: 	if ($top{$afalse}) {
  294: 	    $toplist[$top{$afalse}]=$afalse;
  295: 	    $topcount++;
  296: 	} elsif ($bottom{$afalse}) {
  297: 	    $bottomlist[$bottom{$afalse}]=$afalse;
  298: 	} else {
  299: 	    push (@whichfalse,$afalse);
  300: 	}
  301:     }
  302:     my $truename=$truelist[$whichtrue];
  303:     my $dosplice=1;
  304:     #insert the true statement, keeping track of where it wants to be
  305:     if ($Apache::response::foilgroup{$truename.'.location'} eq 'top' ) {
  306: 	$toplist[$top{$truename}]=$truename;
  307: 	$answer=-1;
  308: 	foreach my $top (reverse(@toplist)) {
  309: 	    if ($top) { $answer++;}
  310: 	    if ($top eq $truename) { last; }
  311: 	}
  312: 	$dosplice=0;
  313:     } elsif ($Apache::response::foilgroup{$truename.'.location'} eq 'bottom') {
  314: 	$bottomlist[$bottom{$truename}]=$truename;
  315: 	$answer=-1;
  316: 	foreach my $bot (@bottomlist) {
  317: 	    if ($bot) { $answer++;}
  318: 	    if ($bot eq $truename) { last; }
  319: 	}
  320: 	$answer+=$topcount+$#whichfalse+1;
  321: 	$dosplice=0;
  322:     } else {
  323: 	if ($topcount>0) { 
  324: 	  $answer = int(&Math::Random::random_uniform() * ($#whichfalse+1))
  325: 	    + $topcount;
  326: 	}
  327:     }
  328:     #add the top items to the top, bottom items to the bottom
  329:     for (my $i=0;$i<=$#toplist;$i++) {
  330: 	if ($toplist[$i]) { unshift(@whichfalse,$toplist[$i]) }
  331:     }
  332:     for (my $i=0;$i<=$#bottomlist;$i++) {
  333: 	if ($bottomlist[$i]) { push(@whichfalse,$bottomlist[$i]) }
  334:     }
  335:     #if the true statement is randomized insert it into the list
  336:     if ($dosplice) { splice(@whichfalse,$answer,0,$truelist[$whichtrue]); }
  337:   }
  338:   &Apache::lonxml::debug("Answer is $answer");
  339:   return ($answer,@whichfalse);
  340: }
  341: 
  342: sub displayfoils {
  343:   my ($target,$max,$randomize)=@_;
  344:   my $result;
  345: 
  346:   my ($answer,@whichfoils)=&whichfoils($max,$randomize);
  347:   if ($Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"} =~ /^correct/ || ($Apache::inputtags::status[-1] eq  'SHOW_ANSWER')) {
  348:     foreach my $name (@whichfoils) {
  349:       if ($target ne 'tex') {
  350: 	  $result.="<br />";
  351:       } else {
  352: 	  $result.='\vskip 0 mm \item ';
  353:       }
  354:       if ($Apache::response::foilgroup{$name.'.value'} eq 'true') { 
  355: 	  if ($target ne 'tex') { $result.='Correct:<b>'; } else { $result.='Correct: ';}
  356:       } else {
  357: 	$result.='Incorrect:';
  358:       }
  359:       if ($target ne 'tex') {
  360: 	  $result.=$Apache::response::foilgroup{$name.'.text'}."</input>\n";
  361:       } else {
  362: 	  $result.=$Apache::response::foilgroup{$name.'.text'};
  363:       }
  364:       if ($Apache::response::foilgroup{$name.'.value'} eq 'true') {
  365: 	  if ($target ne 'tex') { $result.='</b>';}
  366:       }
  367:     }
  368:   } else {
  369:     my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
  370:     my $i = 0;
  371:     my $temp=0;  
  372:     my $id=$Apache::inputtags::response['-1'];
  373:     my $part=$Apache::inputtags::part;
  374:     my $lastresponse=$Apache::lonhomework::history{"resource.$part.$id.submission"};
  375:     my %lastresponse=&Apache::lonnet::str2hash($lastresponse);
  376:     foreach my $name (@whichfoils) {
  377:       if ($target ne 'tex') {
  378: 	  $result.="<br /><input type=\"radio\" name=\"HWVAL$Apache::inputtags::response['-1']\" value=\"$temp\" ";
  379: 	  if (defined($lastresponse{$name})) { $result .= 'checked="on"'; }
  380: 	  $result .= '>'.$Apache::response::foilgroup{$name.'.text'}."</input>\n";
  381: 	  if ($Apache::lonhomework::type eq 'exam') {
  382: 	      $result .= '<table border="1"><tr><td>A: &nbsp;&nbsp;Correct</td><td>B: &nbsp;&nbsp;Incorrect</td></tr></table>';
  383: 	  }
  384:       } else {
  385: 	  if ($Apache::lonhomework::type eq 'exam') {
  386: 	      $result .= '{\small \textbf{'.$alphabet[$i].'}}$\bigcirc$'.$Apache::response::foilgroup{$name.'.text'}.'\\\\';
  387: 	      $i++;
  388: 	  } else {
  389: 	      $result .= '\item '.$Apache::response::foilgroup{$name.'.text'};
  390: 	  }
  391:       }
  392:       $temp++;
  393:     }
  394:   }
  395:   if ($target ne 'tex') { $result.="<br />"; } else { $result.='\vskip 0 mm '; }
  396:   return $result;
  397: }
  398: 
  399: sub displayanswers {
  400:   my ($max,$randomize)=@_;
  401:   my ($answer,@whichopt) = &whichfoils($max,$randomize);
  402:   my $result=&Apache::response::answer_header('radiobuttonresponse');
  403:   foreach my $name (@whichopt) {
  404:     $result.=&Apache::response::answer_part('radiobuttonresponse',
  405: 		     $Apache::response::foilgroup{$name.'.value'})
  406:   }
  407:   $result.=&Apache::response::answer_footer('radiobuttonresponse');
  408:   return $result;
  409: }
  410: 
  411: sub start_conceptgroup {
  412:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  413:   $Apache::radiobuttonresponse::conceptgroup=1;
  414:   %Apache::response::conceptgroup=();
  415:   my $result;
  416:   if ($target eq 'edit') {
  417:     $result.=&Apache::edit::tag_start($target,$token);
  418:     $result.=&Apache::edit::text_arg('Concept:','concept',$token,'50').
  419: 	&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  420:   } elsif ($target eq 'modified') {
  421:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  422: 						 $safeeval,'concept');
  423:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  424:   }
  425:   return $result;
  426: }
  427: 
  428: sub end_conceptgroup {
  429:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  430:   $Apache::radiobuttonresponse::conceptgroup=0;
  431:   my $result;
  432:   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'  || $target eq 'tex') {
  433:     if (defined(@{ $Apache::response::conceptgroup{'names'} })) {
  434:       my @names = @{ $Apache::response::conceptgroup{'names'} };
  435:       my $pick=int(&Math::Random::random_uniform() * ($#names+1));
  436:       my $name=$names[$pick];
  437:       push @{ $Apache::response::foilgroup{'names'} }, $name;
  438:       $Apache::response::foilgroup{"$name.text"} =  $Apache::response::conceptgroup{"$name.text"};
  439:       $Apache::response::foilgroup{"$name.value"} = $Apache::response::conceptgroup{"$name.value"};
  440:       $Apache::response::foilgroup{"$name.location"} = $Apache::response::conceptgroup{"$name.location"};
  441:       my $concept = &Apache::lonxml::get_param('concept',$parstack,$safeeval);
  442:       $Apache::response::foilgroup{"$name.concept"} = $concept;
  443:       &Apache::lonxml::debug("Selecting $name in $concept");
  444:     }
  445:   } elsif ($target eq 'edit') {
  446:     $result=&Apache::edit::end_table();
  447:   }
  448:   return $result;
  449: }
  450: 
  451: sub insert_conceptgroup {
  452:   my $result="\n\t\t<conceptgroup concept=\"\">".&insert_foil()."\n\t\t</conceptgroup>\n";
  453:   return $result;
  454: }
  455: 
  456: sub start_foil {
  457:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  458:   my $result='';
  459:   if ($target eq 'web' || $target eq 'tex') {
  460:     &Apache::lonxml::startredirection;
  461:   } elsif ($target eq 'edit') {
  462:     $result=&Apache::edit::tag_start($target,$token);
  463:     $result.=&Apache::edit::text_arg('Name:','name',$token);
  464:     $result.=&Apache::edit::select_or_text_arg('Correct Option:','value',
  465: 				       ['unused','true','false'],$token);
  466:     my $randomize=&Apache::lonxml::get_param('randomize',$parstack,
  467: 					     $safeeval,'-3');
  468:     if ($randomize ne 'no') {
  469:       $result.=&Apache::edit::select_arg('Location:','location',
  470: 					 ['random','top','bottom'],$token);
  471:     }
  472:     $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  473:   } elsif ($target eq 'modified') {
  474:      my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,
  475: 						  'value','name','location');
  476:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  477:   } 
  478:   return $result;
  479: }
  480: 
  481: sub end_foil {
  482:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  483:   my $text='';
  484:   if ($target eq 'web' || $target eq 'tex') { $text=&Apache::lonxml::endredirection; }
  485:   if ($target eq 'web' || $target eq 'grade' || $target eq 'answer'  || $target eq 'tex') {
  486:     my $value = &Apache::lonxml::get_param('value',$parstack,$safeeval);
  487:     if ($value ne 'unused') {
  488:       my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval);
  489:       my $location =&Apache::lonxml::get_param('location',$parstack,$safeeval);
  490:       if (!$name) { $name=$Apache::lonxml::curdepth; }
  491:       if ( $Apache::radiobuttonresponse::conceptgroup
  492: 	   && !&Apache::response::showallfoils() ) {
  493: 	push @{ $Apache::response::conceptgroup{'names'} }, $name;
  494: 	$Apache::response::conceptgroup{"$name.value"} = $value;
  495: 	$Apache::response::conceptgroup{"$name.text"} = $text;	
  496: 	$Apache::response::conceptgroup{"$name.location"} = $location;	
  497:       } else {
  498: 	push @{ $Apache::response::foilgroup{'names'} }, $name;
  499: 	$Apache::response::foilgroup{"$name.value"} = $value;
  500: 	$Apache::response::foilgroup{"$name.text"} = $text;
  501: 	$Apache::response::foilgroup{"$name.location"} = $location;
  502:       }
  503:     }
  504:   }
  505:   return '';
  506: }
  507: 
  508: sub insert_foil {
  509:   return '
  510: <foil name="" value="unused">
  511: <startouttext />
  512: <endouttext />
  513: </foil>';
  514: }
  515: 1;
  516: __END__
  517:  

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