File:  [LON-CAPA] / loncom / homework / hint.pm
Revision 1.62: download - view: text, annotated - select for diffs
Tue Mar 7 22:42:47 2006 UTC (18 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: version_2_3_X, version_2_2_X, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, HEAD
- was double ending a <table>
- was not closing the final row in the table

    1: # The LearningOnline Network with CAPA 
    2: # implements the tags that control the hints
    3: #
    4: # $Id: hint.pm,v 1.62 2006/03/07 22:42:47 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 me&aree 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::hinttags; 
   30: 
   31: use strict;
   32: use Apache::lonnet;
   33: use capa;
   34: use Apache::lonlocal;
   35: 
   36: BEGIN {
   37:     &Apache::lonxml::register('Apache::hinttags',('hintgroup','hintpart','numericalhint','stringhint','formulahint','optionhint','radiobuttonhint'));
   38: }
   39: 
   40: 
   41: @Apache::hint::which=();
   42: sub start_hintgroup {
   43:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   44:     my $skiptoend='0';
   45:     my $result;
   46: 
   47:     if ($target eq 'web') {
   48: 	my $id=$Apache::inputtags::part;
   49: 	my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
   50: 	if ( $numtries eq '') { $numtries = 0; }
   51: 	my $hinttries=&Apache::response::get_response_param($id,"hinttries",1);
   52: 	&Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
   53: 	my $gradestatus=
   54: 	    $Apache::lonhomework::history{"resource.$id.solved"};
   55: 	my $showoncorrect=lc(&Apache::lonxml::get_param('showoncorrect',$parstack,$safeeval));	
   56: 	&Apache::lonxml::debug("onc orrect $showoncorrect, $gradestatus");
   57: 	if ( ($showoncorrect ne 'yes' && &Apache::response::show_answer()) ||
   58: 	     ( $numtries < $hinttries) ) {
   59: 	    &Apache::lonxml::debug("Grabbin all");
   60: 	    &Apache::lonxml::get_all_text("/hintgroup",$parser,$style);
   61: 	}
   62: 	&Apache::lonxml::startredirection;
   63:     } elsif ($target eq 'tex') {
   64: 	$result .= '\keephidden{';
   65:     } elsif ($target eq 'edit') {
   66: 	$result.=&Apache::edit::tag_start($target,$token);
   67: 	$result.=&Apache::edit::select_arg('Show hint even if problem Correct:','showoncorrect',[['no',&mt('No')],['yes',&mt('Yes')]],$token);
   68: 	$result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
   69:     } elsif ($target eq 'modified') {
   70: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'showoncorrect');
   71:        if ($constructtag) {
   72:            $result =&Apache::edit::rebuild_tag($token);
   73:            $result.=&Apache::edit::handle_insert();
   74:        }
   75:     }
   76:     @Apache::hint::which=();
   77:     return $result;
   78: }
   79: 
   80: sub end_hintgroup {
   81:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   82:     my $result;
   83: 
   84:     if ($target eq 'web') {
   85: 	my $id=$Apache::inputtags::part;
   86: 	my $numtries=$Apache::lonhomework::history{"resource.$id.tries"};
   87: 	if ( $numtries eq '') { $numtries = 0; }
   88: 	my $hinttries=&Apache::response::get_response_param($id,"hinttries",1);
   89: 	&Apache::lonxml::debug("found :$id:$numtries:$hinttries:");
   90: 	my $hinttext=&Apache::lonxml::endredirection;
   91: 	if ($Apache::lonhomework::type ne 'exam' &&
   92: 	    $numtries >= $hinttries && $hinttext =~/\S/) {
   93: 	    $result='<table bgcolor="#dddddd"><tr><td>'.
   94: 		$hinttext.'</td></tr></table>';
   95: 	}
   96:     } elsif ($target eq 'edit') {
   97: 	$result.=&Apache::edit::end_row().&Apache::edit::end_table();
   98:     } elsif ($target eq 'tex') {
   99: 	$result .= '}';
  100:     }
  101:     @Apache::hint::which=();
  102:     return $result;
  103: }
  104: 
  105: sub start_numericalhint {
  106:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  107:     #do everything in end, so intervening <responseparams> work
  108:     &Apache::response::start_hintresponse($parstack,$safeeval);
  109:     my $result;
  110:     if ($target eq 'edit') {
  111: 	$result.=&Apache::edit::tag_start($target,$token);
  112: 	$result.=&Apache::edit::text_arg('Name:','name',$token);
  113: 	$result.=&Apache::edit::text_arg('Answer:','answer',$token);
  114: 	if ($token->[1] eq 'numericalhint') {
  115: 	    $result.=&Apache::edit::text_arg('Unit:','unit',$token,5).
  116: 		&Apache::loncommon::help_open_topic('Physical_Units');
  117: 	    $result.=&Apache::edit::text_arg('Format:','format',$token,4).
  118: 		&Apache::loncommon::help_open_topic('Numerical_Response_Format');
  119: 	} elsif ($token->[1] eq 'stringhint') {
  120: 	    $result.=&Apache::edit::select_arg('Type:','type',
  121: 			    [['cs','Case Sensitive'],['ci','Case Insensitive'],
  122: 			     ['mc','Case Insensitive, Any Order']],$token);
  123: 	} elsif ($token->[1] eq 'formulahint') {
  124: 	    $result.=&Apache::edit::text_arg('Sample Points:','samples',$token,40);
  125: 	}
  126: 	$result.=&Apache::edit::end_row();
  127: 	$result.=&Apache::edit::start_spanning_row();
  128:     } elsif ($target eq 'modified') {
  129: 	my $constructtag;
  130: 	if ($token->[1] eq 'numericalhint') {
  131: 	    $constructtag=&Apache::edit::get_new_args($token,$parstack,
  132: 						     $safeeval,'name',
  133: 						     'answer','unit','format');
  134: 	} elsif ($token->[1] eq 'stringhint') {
  135: 	    $constructtag=&Apache::edit::get_new_args($token,$parstack,
  136: 						     $safeeval,'name','answer',
  137: 						     'type');
  138: 	} elsif ($token->[1] eq 'formulahint') {
  139: 	    $constructtag=&Apache::edit::get_new_args($token,$parstack,
  140: 						     $safeeval,'name','answer',
  141: 						     'samples');
  142: 	}
  143: 	if ($constructtag) {
  144: 	    $result  = &Apache::edit::rebuild_tag($token);
  145: 	    $result .= &Apache::edit::handle_insert();
  146: 	}
  147:     } elsif ($target eq 'web') {
  148: 	&Apache::response::reset_params();
  149:     }
  150:     return $result;
  151: }
  152: 
  153: sub end_numericalhint {
  154:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  155:     my $result;
  156:     if ($target eq 'web') {
  157: 	if (!$Apache::lonxml::default_homework_loaded) {
  158: 	    &Apache::lonxml::default_homework_load($safeeval);
  159: 	}
  160: 	$safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
  161: 	my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
  162: 	&Apache::response::setup_params('numericalhint',$safeeval);
  163: 	my $partid=$Apache::inputtags::part;
  164: 	my $id=$Apache::inputtags::hint[-1];
  165: 	#id submissions occured under
  166: 	my $submitid=$Apache::inputtags::response[-1];
  167: 	my $response = $Apache::lonhomework::history{
  168: 			    "resource.$partid.$submitid.submission"};
  169: 	&Apache::lonxml::debug("hintgroup is using $response<br />\n");
  170: 	my $hideunit=&Apache::response::get_response_param($partid.'_'.$submitid,'turnoffunit');
  171: 	my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
  172: 	$$args_ref{'response'}=$response;
  173: 	#need to get all possible parms
  174: 	foreach my $arg ('type','tol','sig','ans_fmt','unit','calc',
  175: 			 'samples') {
  176: 	    $$args_ref{$arg}=
  177: 		&Apache::lonxml::get_param($arg,$parstack,$safeeval);
  178: 	}
  179: 	foreach my $key (keys(%Apache::inputtags::params)) {
  180: 	    $$args_ref{$key}=$Apache::inputtags::params{$key};
  181: 	}
  182: 	if (lc($hideunit) eq "yes") { delete($$args_ref{'unit'}); }
  183: 	if ($$tagstack[-1] eq 'formulahint') {
  184: 	    $$args_ref{'type'}='fml';
  185: 	} elsif ($$tagstack[-1] eq 'numericalhint') {
  186: 	    $$args_ref{'type'}='float';
  187: 	}
  188: 	my @answer=&Apache::lonxml::get_param_var('answer',$parstack,$safeeval);
  189: 	&Apache::lonxml::debug('answer is'.join(':',@answer));
  190: 	@{$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=@answer;
  191: 		
  192: 	($result,my @msgs) = &Apache::run::run("&caparesponse_check_list()",
  193: 						$safeeval);
  194: 	&Apache::lonxml::debug('msgs are'.join(':',@msgs));
  195: 	&Apache::lonxml::debug("result:$result:$Apache::lonxml::curdepth");
  196: 	my ($awards)=split(/:/,$result);
  197: 	my (@awards) = split(/,/,$awards);
  198: 	my ($ad, $msg) = &Apache::inputtags::finalizeawards(\@awards,\@msgs);
  199: 	if ($ad eq 'EXACT_ANS' || $ad eq 'APPROX_ANS') { push (@Apache::hint::which,$name); }
  200: 	$result='';
  201:     } elsif ($target eq 'meta') {
  202: 	$result=&Apache::response::meta_package_write($token->[1]);
  203:     } elsif ($target eq 'edit') {
  204: 	$result.=&Apache::edit::end_row().&Apache::edit::end_table();
  205:     }
  206:     &Apache::response::end_hintresponse();
  207:     return $result;
  208: }
  209: 
  210: sub start_formulahint {
  211:     return &start_numericalhint(@_);
  212: }
  213: 
  214: sub end_formulahint {
  215:     return &end_numericalhint(@_);
  216: }
  217: 
  218: sub start_stringhint {
  219:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  220:     #do everything in end, so intervening <responseparams> work
  221:     &Apache::response::start_hintresponse($parstack,$safeeval);
  222:     my $result;
  223:     if ($target eq 'edit') {
  224: 	$result.=&Apache::edit::tag_start($target,$token);
  225: 	$result.=&Apache::edit::text_arg('Name:','name',$token);
  226: 	$result.=&Apache::edit::text_arg('Answer:','answer',$token);
  227: 	$result.=&Apache::edit::select_arg('Type:','type',
  228: 			 [['cs','Case Sensitive'],['ci','Case Insensitive'],
  229: 			  ['mc','Case Insensitive, Any Order'],
  230: 			  ['re','Regular Expression']],$token);
  231: 	$result.=&Apache::edit::end_row();
  232: 	$result.=&Apache::edit::start_spanning_row();
  233:     } elsif ($target eq 'modified') {
  234: 	my $constructtag;
  235: 	$constructtag=&Apache::edit::get_new_args($token,$parstack,
  236: 						  $safeeval,'name','answer',
  237: 						  'type');
  238: 	$result  = &Apache::edit::rebuild_tag($token);
  239: 	$result .= &Apache::edit::handle_insert();
  240:     } elsif ($target eq 'web') {
  241: 	&Apache::response::reset_params();
  242:     }
  243:     return $result;
  244: }
  245: 
  246: sub end_stringhint {
  247:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  248:     my $result;
  249:     if ($target eq 'web') {
  250: 	if (!$Apache::lonxml::default_homework_loaded) {
  251: 	    &Apache::lonxml::default_homework_load($safeeval);
  252: 	}
  253: 	my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
  254: 	$safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
  255: 	my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
  256: 	&Apache::response::setup_params('stringhint',$safeeval);
  257: 	my $partid=$Apache::inputtags::part;
  258: 	my $id=$Apache::inputtags::hint[-1];
  259: 	#id submissions occured under
  260: 	my $submitid=$Apache::inputtags::response[-1];
  261: 	my $response = $Apache::lonhomework::history{
  262: 			    "resource.$partid.$submitid.submission"};
  263: 	&Apache::lonxml::debug("hintgroup is using $response<br />\n");
  264: 	my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
  265: 	$$args_ref{'response'}=$response;
  266: 	my $type=$$args_ref{'type'}=&Apache::lonxml::get_param('type',$parstack,$safeeval);
  267: 	my ($ad,$msg);
  268: 	if ($type eq 're' ) {
  269: 	    ${$safeeval->varglob('LONCAPA::response')}=$response;
  270: 	    my $compare='=';
  271: 	    if ($answer=~/^\s*NOT\s*/) {
  272: 		$answer=~s/^\s*NOT\s*//;
  273: 		$compare='!';
  274: 	    }
  275: 	    my $test='$LONCAPA::response'.$compare.'~m'.$answer;
  276: 	    &Apache::lonxml::debug("test $test");
  277: 	    $result = &Apache::run::run("return $test",$safeeval);
  278: 	    &Apache::lonxml::debug("current $response");
  279: 	    &Apache::lonxml::debug("current $answer");
  280: 	    $ad = ($result) ? 'APPROX_ANS' : 'INCORRECT';
  281: 	} else { 
  282: 	    foreach my $key (keys(%Apache::inputtags::params)) {
  283: 		$$args_ref{$key}=$Apache::inputtags::params{$key};
  284: 	    }
  285: 	    &Apache::lonxml::debug('answer is'.$answer);
  286: 	    @{$safeeval->varglob('LONCAPA::CAPAresponse_answer')}=($answer);
  287: 	    
  288: 	    ($result,my @msgs)=&Apache::run::run("&caparesponse_check_list()",
  289: 						   $safeeval);
  290: 	    &Apache::lonxml::debug('msgs are'.join(':',@msgs));
  291: 	    &Apache::lonxml::debug("result:$result:$Apache::lonxml::curdepth");
  292: 	    my ($awards)=split(/:/,$result);
  293: 	    my (@awards) = split(/,/,$awards);
  294: 	    ($ad, $msg) = &Apache::inputtags::finalizeawards(\@awards,\@msgs);
  295: 	}
  296: 	if ($ad eq 'EXACT_ANS' || $ad eq 'APPROX_ANS') { 
  297: 	    push (@Apache::hint::which,$name);
  298: 	}
  299: 	$result='';
  300:     } elsif ($target eq 'meta') {
  301: 	$result=&Apache::response::meta_package_write($token->[1]);
  302:     } elsif ($target eq 'edit') {
  303: 	$result.=&Apache::edit::end_row().&Apache::edit::end_table();
  304:     }
  305:     &Apache::response::end_hintresponse();
  306:     return $result;
  307: }
  308: 
  309: # a part shows if it is on, if no specific parts are on, then default shows
  310: sub start_hintpart {
  311:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
  312: 
  313:     my $show ='0';
  314:     my $result = '';
  315:     if ($target eq 'web') {
  316: 	my $on= &Apache::lonxml::get_param('on',$parstack,$safeeval);
  317: 	&Apache::lonxml::debug("hintpart sees $on and ,$#Apache::hint::which");
  318: 	if ( $on eq 'default' && $#Apache::hint::which == '-1') {
  319: 	    $show=1;
  320: 	} else {
  321: 	    my $which;
  322: 	    foreach $which (@Apache::hint::which) { if ($which eq $on) { $show = 1; last } }
  323: 	}
  324: 	if (!$show) {
  325: 	    &Apache::lonxml::get_all_text("/hintpart",$parser,$style);
  326: 	}
  327:     } elsif ($target eq 'grade') {
  328: 	&Apache::lonxml::get_all_text("/hintpart",$parser,$style);
  329:     } elsif ($target eq 'edit') {
  330: 	$result.= &Apache::edit::tag_start($target,$token);
  331: 	$result.= &Apache::edit::text_arg('On:','on',$token);
  332: 	$result.= &Apache::edit::end_row();
  333: 	$result.= &Apache::edit::start_spanning_row();
  334:     } elsif ($target eq 'modified') {
  335: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  336: 						     $safeeval,'on');
  337: 	if ($constructtag) {
  338: 	    $result = &Apache::edit::rebuild_tag($token);
  339: 	    $result.=&Apache::edit::handle_insert();
  340: 	}
  341:     }
  342:     return $result;
  343: }
  344: 
  345: sub end_hintpart {
  346:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  347:     my $result;
  348:     if ($target eq 'edit') {
  349: 	$result.=&Apache::edit::end_row().&Apache::edit::end_table();
  350:     }
  351:     return $result;
  352: }
  353: 
  354: sub start_optionhint {
  355:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  356:     my $result;
  357:     &Apache::response::start_hintresponse($parstack,$safeeval);
  358:     if ($target eq 'edit') {
  359: 	$result.=&Apache::edit::tag_start($target,$token);
  360: 	$result.=&Apache::edit::text_arg('Name:','name',$token);
  361: 	$result.=&Apache::edit::text_arg('Answer:','answer',$token,40);
  362: 	$result.=&Apache::edit::text_arg('Concept:','concept',$token,50);
  363:     } elsif ($target eq 'modified') {
  364: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  365: 						     $safeeval,'name',
  366: 						     'answer','concept');
  367: 	if ($constructtag) {
  368: 	    $result  = &Apache::edit::rebuild_tag($token);
  369: 	    $result .= &Apache::edit::handle_insert();
  370: 	}
  371:     } elsif ($target eq 'meta') {
  372: 	$result=&Apache::response::meta_package_write('numericalhint');
  373:     }
  374:     return $result;
  375: }
  376: 
  377: sub end_optionhint {
  378:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  379:     my $result;
  380:     if ($target eq 'web') {
  381: 	my ($foilmatch,$conceptmatch)=(-1,-1);
  382: 	my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
  383: 	my $partid=$Apache::inputtags::part;
  384: 	#id submissions occured under
  385: 	my $submitid=$Apache::inputtags::response[-1];
  386: 	my $part_id="$partid.$submitid";
  387: 	my %answer;
  388: 	my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
  389: 	if ($answer) {
  390: 	    eval('%answer ='.$answer);
  391: 	    &Apache::lonxml::debug("answwer hash");
  392: 	    &Apache::lonhomework::showhash(%answer);
  393: 	    my $response = $Apache::lonhomework::history{
  394: 				            "resource.$part_id.submission"};
  395: 	    my %response=&Apache::lonnet::str2hash($response);
  396: 	    &Apache::lonhomework::showhash(%response);
  397: 	    foreach my $foil (keys(%answer)) {
  398: 		$foilmatch=1;
  399: 		if ($answer{$foil} ne $response{$foil}) {$foilmatch=0;last;}
  400: 	    }
  401: 	}
  402: 	my %concept;
  403: 	my $constr=&Apache::lonxml::get_param('concept',$parstack,$safeeval);
  404: 	if ( $constr ) { eval('%concept ='.$constr);	}
  405: 	my $response = $Apache::lonhomework::history{
  406: 					"resource.$part_id.submissiongrading"};
  407: 	my %response=&Apache::lonnet::str2hash($response);
  408: 	foreach my $concept (keys(%concept)) {
  409: 	    my $compare;
  410: 	    if ($concept{$concept} eq 'correct') {$compare=1}else{$compare=0}
  411: 	    $conceptmatch=1;
  412: 	    if (ref($Apache::hint::option{"$part_id.concepts"})) {
  413: 		foreach my $foil (@{ $Apache::hint::option{"$part_id.concept.$concept"} }) {
  414: 		    &Apache::lonxml::debug("compare -$foil- -$response{$foil}-$compare-");
  415: 		    if ( exists($response{$foil}) && 
  416: 			 $response{$foil} ne $compare) {$conceptmatch=0;last;}
  417: 		}
  418: 	    } else {
  419: 		$conceptmatch=0;
  420: 	    }
  421: 	    if ($conceptmatch eq '0') { last; }
  422: 	}
  423: 	if ( ($conceptmatch eq '-1' || $conceptmatch eq '1') &&
  424: 	     ($foilmatch    eq '-1' || $foilmatch    eq '1') ) {
  425: 	    push(@Apache::hint::which,$name);
  426: 	}
  427:     } elsif ($target eq 'edit') {
  428: 	$result.=&Apache::edit::end_row().&Apache::edit::end_table();
  429:     }
  430:     &Apache::response::end_hintresponse();
  431:     return $result;
  432: }
  433: 
  434: sub start_radiobuttonhint {
  435:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  436:     my $result;
  437:     &Apache::response::start_hintresponse($parstack,$safeeval);
  438:     if ($target eq 'edit') {
  439: 	$result.=&Apache::edit::tag_start($target,$token);
  440: 	$result.=&Apache::edit::text_arg('Name:','name',$token);
  441: 	$result.=&Apache::edit::text_arg('Answer:','answer',$token);
  442:     } elsif ($target eq 'modified') {
  443: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  444: 						     $safeeval,'name',
  445: 						     'answer');
  446: 	if ($constructtag) {
  447: 	    $result  = &Apache::edit::rebuild_tag($token);
  448: 	    $result .= &Apache::edit::handle_insert();
  449: 	}
  450:     } elsif ($target eq 'meta') {
  451: 	$result=&Apache::response::meta_package_write('numericalhint');
  452:     }
  453:     return $result;
  454: }
  455: 
  456: sub end_radiobuttonhint {
  457:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  458:     my $result;
  459:     if ($target eq 'web') {
  460: 	my $name= &Apache::lonxml::get_param('name',$parstack,$safeeval);
  461: 	my @answer;
  462: 	my $answer=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
  463: 	eval('@answer ='.$answer);
  464: 	my $partid=$Apache::inputtags::part;
  465: 	#id submissions occured under
  466: 	my $submitid=$Apache::inputtags::response[-1];
  467: 	my $part_id="$partid.$submitid";
  468: 	my $response = $Apache::lonhomework::history{
  469: 			    "resource.$part_id.submission"};
  470: 	($response)=&Apache::lonnet::str2hash($response);
  471: 	&Apache::lonxml::debug("response is $response");
  472: 	
  473: 	if ($answer[0] eq 'foil') {
  474: 	    shift(@answer);
  475: 	    foreach my $answer (@answer) {
  476: 		if ($response eq $answer) {
  477: 		    push (@Apache::hint::which,$name);
  478: 		    last;
  479: 		}
  480: 	    }
  481: 	} elsif ($answer[0] eq 'concept') {
  482: 	    shift(@answer);
  483: 	    foreach my $answer (@answer) {
  484: 		if (ref($Apache::hint::radiobutton{"$part_id.concept.".$answer})) {
  485: 		    my @names=@{ $Apache::hint::radiobutton{"$part_id.concept.".$answer} };
  486: 		    if (grep(/^\Q$response\E$/,@names)) {
  487: 			push(@Apache::hint::which,$name);
  488: 			last;
  489: 		    }
  490: 		}
  491: 	    }
  492: 	}
  493:     } elsif ($target eq 'edit') {
  494: 	$result.=&Apache::edit::end_row().&Apache::edit::end_table();
  495:     }
  496:     &Apache::response::end_hintresponse();
  497:     return $result;
  498: }
  499: 1;
  500: __END__

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