File:  [LON-CAPA] / loncom / homework / inputtags.pm
Revision 1.183: download - view: text, annotated - select for diffs
Mon Nov 21 21:51:29 2005 UTC (18 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- de-appendix slots
   - new parm 'useslots' (problems defulat to no, Tasks default to resource)
   - make available and availablestudent exist for problems
   - problems uses check_slot_access
   - problems understand states of 'NOT_IN_A_SLOT' and 'NEEDS_CHECKIN'

    1: # The LearningOnline Network with CAPA
    2: # input  definitons
    3: #
    4: # $Id: inputtags.pm,v 1.183 2005/11/21 21:51:29 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: 
   28: package Apache::inputtags;
   29: use HTML::Entities();
   30: use strict;
   31: use Apache::loncommon;
   32: use Apache::lonlocal;
   33: use Apache::lonnet;
   34: 
   35: BEGIN {
   36:     &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
   37: }
   38: 
   39: #   Initializes a set of global variables used during the parse of the problem.
   40: #
   41: #  @Apache::inputtags::input        - List of current input ids.
   42: #  @Apache::inputtags::inputlist    - List of all input ids seen this problem.
   43: #  @Apache::inputtags::response     - List of all current resopnse ids.
   44: #  @Apache::inputtags::responselist - List of all response ids seen this 
   45: #                                       problem.
   46: #  @Apache::inputtags::hint         - List of all hint ids.
   47: #  @Apache::inputtags::hintlist     - List of all hint ids seen this problem.
   48: #  @Apache::inputtags::previous     - List describing if specific responseds
   49: #                                       have been used
   50: #  @Apache::inputtags::previous_version - Submission responses were used in.
   51: #  $Apache::inputtags::part         - Current part id (valid only in 
   52: #                                       <problem>)
   53: #                                     0 if not in a part.
   54: #  @Apache::inputtags::partlist     - List of part ids seen in the current
   55: #                                       <problem>
   56: #  @Apache::inputtags::status       - List of problem  statuses. First 
   57: #                                     element is the status of the <problem>
   58: #                                     the remainder are for individual <part>s.
   59: #  %Apache::inputtags::params       - Hash of defined parameters for the
   60: #                                     current response.
   61: #  @Apache::inputtags::import       - List of all ids for <import> thes get
   62: #                                     join()ed and prepended.
   63: #  @Apache::inputtags::importlist   - List of all import ids seen.
   64: #  $Apache::inputtags::response_with_no_part
   65: #                                   - Flag set true if we have seen a response
   66: #                                     that is not inside a <part>
   67: #  %Apache::inputtags::answertxt    - <*response> tags store correct
   68: #                                     answer strings for display by <textline/>
   69: #                                     in this hash.
   70: 
   71: sub initialize_inputtags {
   72:     @Apache::inputtags::input=();
   73:     @Apache::inputtags::inputlist=();
   74:     @Apache::inputtags::response=();
   75:     @Apache::inputtags::responselist=();
   76:     @Apache::inputtags::hint=();
   77:     @Apache::inputtags::hintlist=();
   78:     @Apache::inputtags::previous=();
   79:     @Apache::inputtags::previous_version=();
   80:     $Apache::inputtags::part='';
   81:     @Apache::inputtags::partlist=();
   82:     @Apache::inputtags::status=();
   83:     %Apache::inputtags::params=();
   84:     @Apache::inputtags::import=();
   85:     @Apache::inputtags::importlist=();
   86:     $Apache::inputtags::response_with_no_part=0;
   87:     %Apache::inputtags::answertxt=();
   88: }
   89: 
   90: sub check_for_duplicate_ids {
   91:     my %check;
   92:     foreach my $id (@Apache::inputtags::partlist,
   93: 		    @Apache::inputtags::responselist,
   94: 		    @Apache::inputtags::hintlist,
   95: 		    @Apache::inputtags::importlist) {
   96: 	$check{$id}++;
   97:     }
   98:     my @duplicates;
   99:     foreach my $id (sort(keys(%check))) {
  100: 	if ($check{$id} > 1) {
  101: 	    push(@duplicates,$id);
  102: 	}
  103:     }
  104:     if (@duplicates) {
  105: 	&Apache::lonxml::error("Duplicated ids found, problem will operate incorrectly. Duplicated ids seen: ",join(', ',@duplicates));
  106:     }
  107: }
  108: 
  109: sub start_input {
  110:     my ($parstack,$safeeval)=@_;
  111:     my $id = &Apache::lonxml::get_param('id',$parstack,$safeeval);
  112:     if ($id eq '') { $id = $Apache::lonxml::curdepth; }
  113:     push (@Apache::inputtags::input,$id);
  114:     push (@Apache::inputtags::inputlist,$id);
  115:     return $id;
  116: }
  117: 
  118: sub end_input {
  119:     pop @Apache::inputtags::input;
  120:     return '';
  121: }
  122: 
  123: sub addchars {
  124:     my ($fieldid,$addchars)=@_;
  125:     my $output='';
  126:     foreach (split(/\,/,$addchars)) {
  127: 	$output.='<a href="javascript:void(document.forms.lonhomework.'.
  128: 	    $fieldid.'.value+=\''.$_.'\')">'.$_.'</a> ';
  129:     }
  130:     return $output;
  131: }
  132: 
  133: sub start_textfield {
  134:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  135:     my $result = "";
  136:     my $id = &start_input($parstack,$safeeval);
  137:     my $resid=$Apache::inputtags::response[-1];
  138:     if ($target eq 'web') {
  139: 	$Apache::lonxml::evaluate--;
  140: 	if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
  141: 	    my $partid=$Apache::inputtags::part;
  142: 	    my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"');
  143: 	    my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
  144: 	    if ( $cols eq '') { $cols = 80; }
  145: 	    my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
  146: 	    if ( $rows eq '') { $rows = 16; }
  147: 	    my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
  148: 	    $result='';
  149: 	    if ($addchars) {
  150: 		$result.=&addchars('HWVAL_'.$resid,$addchars);
  151: 	    }
  152: 	    push @Apache::lonxml::htmlareafields,'HWVAL_'.$resid;
  153: 	    $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '.
  154: 		"rows=\"$rows\" cols=\"$cols\">".$oldresponse;
  155: 	    if ($oldresponse ne '') {
  156: 
  157: 		#get rid of any startup text if the user has already responded
  158: 		&Apache::lonxml::get_all_text("/textfield",$parser);
  159: 	    }
  160: 	} else {
  161: 	    #right or wrong don't show it
  162: 	    #$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';
  163: 	    $result='';
  164: 	    #get rid of any startup text
  165: 	    &Apache::lonxml::get_all_text("/textfield",$parser);
  166: 	}
  167:     } elsif ($target eq 'grade') {
  168: 	my $seedtext=&Apache::lonxml::get_all_text("/textfield",$parser);
  169: 	if ($seedtext eq $env{'form.HWVAL_'.$resid}) {
  170: 	    # if the seed text is still there it wasn't a real submission
  171: 	    $env{'form.HWVAL_'.$resid}='';
  172: 	}
  173:     } elsif ($target eq 'edit') {
  174: 	$result.=&Apache::edit::tag_start($target,$token);
  175: 	$result.=&Apache::edit::text_arg('Rows:','rows',$token,4);
  176: 	$result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
  177: 	$result.=&Apache::edit::text_arg
  178: 	    ('Click-On Texts (comma sep):','addchars',$token,10);
  179: 	my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);
  180: 	$result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
  181:     } elsif ($target eq 'modified') {
  182: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  183: 						     $safeeval,'rows','cols',
  184: 						     'addchars');
  185: 	if ($constructtag) {
  186: 	    $result = &Apache::edit::rebuild_tag($token);
  187: 	} else {
  188: 	    $result=$token->[4];
  189: 	}
  190: 	$result.=&Apache::edit::modifiedfield("/textfield",$parser);
  191:     } elsif ($target eq 'tex') {
  192: 	my $number_of_lines = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
  193: 	my $width_of_box = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
  194: 	if ($$tagstack[-2] eq 'essayresponse' and $Apache::lonhomework::type eq 'exam') {
  195: 	    $result = '\fbox{\fbox{\parbox{\textwidth-5mm}{';
  196: 	    for (my $i=0;$i<int $number_of_lines*2;$i++) {$result.='\strut \\\\ ';}
  197: 	    $result.='\strut \\\\\strut \\\\\strut \\\\\strut \\\\}}}';
  198: 	} else {
  199: 	    my $TeXwidth=$width_of_box/80;
  200: 	    $result = '\vskip 1 mm \fbox{\fbox{\parbox{'.$TeXwidth.'\textwidth-5mm}{';
  201: 	    for (my $i=0;$i<int $number_of_lines*2;$i++) {$result.='\strut \\\\ ';}
  202: 	    $result.='}}}\vskip 2 mm ';
  203: 	}
  204:     }
  205:     return $result;
  206: }
  207: 
  208: sub end_textfield {
  209:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  210:     my $result;
  211:     if ($target eq 'web') {
  212: 	$Apache::lonxml::evaluate++;
  213: 	if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
  214: 	    return "</textarea>";
  215: 	}
  216:     } elsif ($target eq 'edit') {
  217: 	$result=&Apache::edit::end_table();
  218:     }
  219:     &end_input;
  220:     return $result;
  221: }
  222: 
  223: sub start_textline {
  224:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  225:     my $result = "";
  226:     if ($target eq 'web') {
  227: 	$Apache::lonxml::evaluate--;
  228: 	my $partid=$Apache::inputtags::part;
  229: 	my $id=$Apache::inputtags::response[-1];
  230: 	if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
  231: 	    my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
  232: 	    my $maxlength;
  233: 	    if ($size eq '') { $size=20; } else {
  234: 		if ($size < 20) { $maxlength=$size; }
  235: 	    }
  236: 	    my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"},'<>&"');
  237: 	    if ($Apache::lonhomework::type ne 'exam') {
  238: 		my $addchars=&Apache::lonxml::get_param('addchars',$parstack,$safeeval);
  239: 		$result='';
  240: 		if ($addchars) {
  241: 		    $result.=&addchars('HWVAL_'.$id,$addchars);
  242: 		}
  243: 		my $readonly=&Apache::lonxml::get_param('readonly',$parstack,
  244: 							$safeeval);
  245: 		if (lc($readonly) eq 'yes') {
  246: 		    $readonly=' readonly="readonly" ';
  247: 		} else {
  248: 		    $readonly='';
  249: 		}
  250: 		$result.= '<input type="text" '.$readonly.' name="HWVAL_'.$id.'" value="'.
  251: 		    $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';
  252: 	    }
  253: 	} else {
  254: 	    #right or wrong don't show what was last typed in.
  255: 	    $result='<b>'.$Apache::inputtags::answertxt{$id}.'</b>';
  256: 	    #$result='';
  257: 	}
  258:     } elsif ($target eq 'edit') {
  259: 	$result=&Apache::edit::tag_start($target,$token);
  260: 	$result.=&Apache::edit::text_arg('Size:','size',$token,'5').
  261: 	    &Apache::edit::text_arg('Click-On Texts (comma sep):',
  262: 				    'addchars',$token,10);
  263:         $result.=&Apache::edit::select_arg('Readonly:','readonly',
  264: 					   ['no','yes'],$token);
  265: 	$result.=&Apache::edit::end_row();
  266: 	$result.=&Apache::edit::end_table();
  267:     } elsif ($target eq 'modified') {
  268: 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
  269: 						     $safeeval,'size',
  270: 						     'addchars','readonly');
  271: 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
  272:     } elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
  273: 	my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
  274: 	if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
  275: 	$result='\framebox['.$size.'][s]{\tiny\strut}';
  276:     }
  277:     return $result;
  278: }
  279: 
  280: sub end_textline {
  281:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  282:     if    ($target eq 'web') { $Apache::lonxml::evaluate++; }
  283:     elsif ($target eq 'edit') { return ('','no'); }
  284:     return "";
  285: }
  286: 
  287: sub start_hiddenline {
  288:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  289:     my $result = "";
  290:     if ($target eq 'web') {
  291: 	$Apache::lonxml::evaluate--;
  292: 	if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
  293: 	    my $partid=$Apache::inputtags::part;
  294: 	    my $id=$Apache::inputtags::response[-1];
  295: 	    my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"},'<>&"');
  296: 	    if ($Apache::lonhomework::type ne 'exam') {
  297: 		$result= '<input type="hidden" name="HWVAL_'.$id.'" value="'.
  298: 		    $oldresponse.'" />';
  299: 	    }
  300: 	}
  301:     } elsif ($target eq 'edit') {
  302: 	$result=&Apache::edit::tag_start($target,$token);
  303: 	$result.=&Apache::edit::end_table;
  304:     }
  305:     return $result;
  306: }
  307: 
  308: sub end_hiddenline {
  309:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
  310:     if    ($target eq 'web') { $Apache::lonxml::evaluate++; }
  311:     elsif ($target eq 'edit') { return ('','no'); }
  312:     return "";
  313: }
  314: 
  315: # $part -> partid
  316: # $id -> responseid
  317: # $uploadefiletypes -> comma seperated list of extensions allowed or * for any
  318: # $which -> 'uploadedonly'  -> only newly uploaded files
  319: #           'portfolioonly' -> only allow files from portfolio
  320: #           'both' -> allow files from either location
  321: # $extratext -> additional text to go between the link and the input box
  322: # returns a table row <tr> 
  323: sub file_selector {
  324:     my ($part,$id,$uploadedfiletypes,$which,$extratext)=@_;
  325:     if (!$uploadedfiletypes) { return ''; }
  326: 
  327:     my $jspart=$part;
  328:     $jspart=~s/\./_/g;
  329: 
  330:     my $result;
  331:     
  332:     $result.='<tr><td>';
  333:     if ($uploadedfiletypes ne '*') {
  334: 	$result.=
  335: 	    &mt('Allowed filetypes: <b>[_1]</b>',$uploadedfiletypes).'<br />';
  336:     }
  337:     if ($which eq 'uploadonly' || $which eq 'both') { 
  338: 	$result.=&mt('Submit a file: (only one file can be uploaded)').
  339: 	    ' <br /><input type="file" size="50" name="HWFILE'.
  340: 	    $jspart.'_'.$id.'" /><br />';
  341: 	my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
  342: 
  343: 	if ($uploadedfile) {
  344: 	    my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
  345: 	    &Apache::lonxml::extlink($url);
  346: 	    &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);
  347: 	    my $icon=&Apache::loncommon::icon($url);
  348: 	    my $curfile='<a href="'.$url.'"><img src="'.$icon.
  349: 		'" border="0" />'.$uploadedfile.'</a>';
  350: 	    $result.=&mt('Currently submitted: <tt>[_1]</tt>',$curfile);
  351: 	} else {
  352: 	    #$result.=&mt('(Hand in a file you have prepared on your computer)');
  353: 	}
  354:     }
  355:     if ( $which eq 'both') { 
  356: 	$result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
  357:     }
  358:     if ($which eq 'portfolioonly' || $which eq 'both') { 
  359: 	$result.=$extratext.'<a href='."'".'javascript:void(window.open("/adm/portfolio?mode=selectfile&amp;fieldname=HWPORT'.$jspart.'_'.$id.'","cat","height=600,width=800,scrollbars=1,resizable=1,menubar=2,location=1"))'."'".'>'.
  360: 	    &mt('Select Portfolio Files').'</a><br />'.
  361: 	    '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
  362: 	    '<br />';
  363: 	if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
  364: 	    my @filelist;
  365: 	    foreach my $file (split(',',&Apache::lonnet::unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
  366: 		my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
  367: 		my $url="/uploaded/$domain/$user/portfolio$file";
  368: 		my $icon=&Apache::loncommon::icon($url);
  369: 		push(@filelist,'<a href="'.$url.'"><img src="'.$icon.
  370: 		     '" border="0" />'.$file.'</a>');
  371: 	    }
  372: 	    $result.=&mt("Portfolio files previously selected: <strong>[_1]</strong>",join(', ',@filelist));
  373: 	}
  374:     }
  375:     $result.='</td></tr>'; 
  376:     return $result;
  377: }
  378: 
  379: sub checkstatus {
  380:     my ($value,$awardref,$msgref)=@_;
  381:     for (my $i=0;$i<=$#$awardref;$i++) {
  382: 	if ($$awardref[$i] eq $value) {
  383: 	    return ($$awardref[$i],$$msgref[$i]);
  384: 	}
  385:     }
  386:     return(undef,undef);
  387: }
  388: 
  389: sub valid_award {
  390:     my ($award) =@_;
  391:     foreach my $possibleaward ('EXTRA_ANSWER','MISSING_ANSWER', 'ERROR',
  392: 			       'NO_RESPONSE',
  393: 			       'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR',
  394: 			       'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE',
  395: 			       'UNIT_FAIL', 'NO_UNIT',
  396: 			       'UNIT_NOTNEEDED', 'WANTED_NUMERIC',
  397: 			       'BAD_FORMULA', 'SIG_FAIL', 'INCORRECT', 
  398: 			       'MISORDERED_RANK', 'INVALID_FILETYPE',
  399: 			       'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE',
  400: 			       'APPROX_ANS', 'EXACT_ANS','COMMA_FAIL') {
  401: 	if ($award eq $possibleaward) { return 1; }
  402:     }
  403:     return 0;
  404: }
  405: 
  406: sub finalizeawards {
  407:     my ($awardref,$msgref,$nameref,$reverse)=@_;
  408:     my $result=undef;
  409:     my $award;
  410:     my $msg;
  411:     if ($#$awardref == -1) { $result = "NO_RESPONSE"; }
  412:     if ($result eq '' ) {
  413: 	my $blankcount;
  414: 	foreach $award (@$awardref) {
  415: 	    if ($award eq '') {
  416: 		$result='MISSING_ANSWER';
  417: 		$blankcount++;
  418: 	    }
  419: 	}
  420: 	if ($blankcount == ($#$awardref + 1)) { $result = 'NO_RESPONSE'; }
  421:     }
  422:     if (defined($result)) { return ($result,$msg); }
  423: 
  424:     # these awards are ordered from most important error through best correct
  425:     
  426:     my @awards = ('EXTRA_ANSWER', 'MISSING_ANSWER', 'ERROR', 'NO_RESPONSE',
  427: 		  'TOO_LONG',
  428: 		  'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT',
  429: 		  'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT',
  430: 		  'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA',
  431: 		  'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK',
  432: 		  'INVALID_FILETYPE', 'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE',
  433: 		  'APPROX_ANS', 'EXACT_ANS');
  434:     if ($reverse) { @awards=reverse(@awards); }
  435:     foreach my $possibleaward (@awards) {
  436: 	($result,$msg)=&checkstatus($possibleaward,$awardref,$msgref);
  437: 	if (defined($result)) { return ($result,$msg); }
  438:     }
  439:     return ('ERROR',undef);
  440: }
  441: 
  442: sub decideoutput {
  443:     my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
  444:     my $message='';
  445:     my $button=0;
  446:     my $previousmsg;
  447:     my $bgcolor='orange';
  448:     my $added_computer_text=0;
  449:     my %possiblecolors =
  450: 	( 'correct' => '#aaffaa',
  451: 	  'charged_try' => '#ffaaaa',
  452: 	  'not_charged_try' => '#ffffaa',
  453: 	  'no_message' => '#fffff',
  454: 	  );
  455: 
  456:     my $part = $Apache::inputtags::part;
  457:     my $handgrade = 
  458: 	('yes' eq lc(&Apache::lonnet::EXT("resource.$part.handgrade")));
  459:     
  460:     my $computer = ($handgrade)? ''
  461: 	                       : " ".&mt("Computer's answer now shown above.");
  462:     &Apache::lonxml::debug("handgrade has :$handgrade:");
  463: 
  464:     if ($previous) { $previousmsg=&mt('You have entered that answer before'); }
  465:     
  466:     if      ($solved =~ /^correct/) {
  467: 	$bgcolor=$possiblecolors{'correct'};
  468: 	$message=&mt('You are correct.');
  469: 	if ($awarded < 1 && $awarded > 0) {
  470: 	    $message=&mt('You are partially correct.');
  471: 	    $bgcolor=$possiblecolors{'not_charged_try'};
  472: 	} elsif ($awarded < 1) {
  473: 	    $message=&mt('Incorrect.');
  474: 	    $bgcolor=$possiblecolors{'charged_try'};
  475: 	}
  476: 	if ($env{'request.filename'} =~ 
  477: 	    m|/res/lib/templates/examupload.problem$|) {
  478: 	    $message = &mt("A score has been assigned.");
  479: 	    $added_computer_text=1;
  480: 	} else {
  481: 	    if ($target eq 'tex') {
  482: 		$message = '\textbf{'.$message.'}';
  483: 	    } else {
  484: 		$message = "<b>".$message."</b>";
  485: 		$message.= $computer;
  486: 	    }
  487: 	    $added_computer_text=1;
  488: 	    unless ($env{'course.'.
  489: 			     $env{'request.course.id'}.
  490: 			     '.disable_receipt_display'} eq 'yes') { 
  491: 		$message.=(($target eq 'web')?'<br />':' ').
  492: 		    &mt('Your receipt is').' '.&Apache::lonnet::receipt($Apache::inputtags::part).
  493: 		    (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):'');
  494: 	    }
  495: 	}
  496: 	$button=0;
  497: 	$previousmsg='';
  498:     } elsif ($solved =~ /^excused/) {
  499: 	if ($target eq 'tex') {
  500: 	    $message = ' \textbf{'.&mt('You are excused from the problem.').'} ';
  501: 	} else {
  502: 	    $message = "<b>".&mt('You are excused from the problem.')."</b>";
  503: 	}
  504: 	$bgcolor=$possiblecolors{'charged_try'};
  505: 	$button=0;
  506: 	$previousmsg='';
  507:     } elsif ($award eq 'EXACT_ANS' || $award eq 'APPROX_ANS' ) {
  508: 	if ($solved =~ /^incorrect/ || $solved eq '') {
  509: 	    $message = &mt("Incorrect").".";
  510: 	    $bgcolor=$possiblecolors{'charged_try'};
  511: 	    $button=1;
  512: 	} else {
  513: 	    if ($target eq 'tex') {
  514: 		$message = '\textbf{'.&mt('You are correct.').'}';
  515: 	    } else {
  516: 		$message = "<b>".&mt('You are correct.')."</b>";
  517: 		$message.= $computer;
  518: 	    }
  519: 	    $added_computer_text=1;
  520: 	    unless ($env{'course.'.
  521: 			     $env{'request.course.id'}.
  522: 			     '.disable_receipt_display'} eq 'yes') { 
  523: 		$message.=(($target eq 'web')?'<br />':' ').
  524: 		    'Your receipt is '.&Apache::lonnet::receipt($Apache::inputtags::part).
  525: 		    (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):'');
  526: 	    }
  527: 	    $bgcolor=$possiblecolors{'correct'};
  528: 	    $button=0;
  529: 	    $previousmsg='';
  530: 	}
  531:     } elsif ($award eq 'NO_RESPONSE') {
  532: 	$message = '';
  533: 	$bgcolor=$possiblecolors{'no_feedback'};
  534: 	$button=1;
  535:     } elsif ($award eq 'EXTRA_ANSWER') {
  536: 	$message = &mt('Some extra items were submitted.');
  537: 	$bgcolor=$possiblecolors{'not_charged_try'};
  538: 	$button = 1;
  539:     } elsif ($award eq 'MISSING_ANSWER') {
  540: 	$message = &mt('Some items were not submitted.');
  541: 	$bgcolor=$possiblecolors{'not_charged_try'};
  542: 	$button = 1;
  543:     } elsif ($award eq 'ERROR') {
  544: 	$message = &mt('An error occured while grading your answer.');
  545: 	$bgcolor=$possiblecolors{'not_charged_try'};
  546: 	$button = 1;
  547:     } elsif ($award eq 'TOO_LONG') {
  548: 	$message = &mt("The submitted answer was too long.");
  549: 	$bgcolor=$possiblecolors{'not_charged_try'};
  550: 	$button=1;
  551:     } elsif ($award eq 'WANTED_NUMERIC') {
  552: 	$message = &mt("This question expects a numeric answer.");
  553: 	$bgcolor=$possiblecolors{'not_charged_try'};
  554: 	$button=1;
  555:     } elsif ($award eq 'MISORDERED_RANK') {
  556: 	$message = &mt('You have provided an invalid ranking');
  557: 	if ($target ne 'tex') {
  558: 	    $message.=', '.&mt('please refer to').' '.&Apache::loncommon::help_open_topic('Ranking_Problems','help on ranking problems');
  559: 	}
  560: 	$bgcolor=$possiblecolors{'not_charged_try'};
  561: 	$button=1;
  562:     } elsif ($award eq 'INVALID_FILETYPE') {
  563: 	$message = &mt('Submission won\'t be graded. The type of file submitted is not allowed.');
  564: 	$bgcolor=$possiblecolors{'not_charged_try'};
  565: 	$button=1;
  566:     } elsif ($award eq 'SIG_FAIL') {
  567: 	my ($used,$min,$max)=split(':',$awardmsg);
  568: 	my $word;
  569: 	if ($used < $min) { $word=&mt('more'); }
  570: 	if ($used > $max) { $word=&mt('fewer'); }
  571: 	$message = &mt("Submission not graded.  Use [_2] digits.",$used,$word);
  572: 	$bgcolor=$possiblecolors{'not_charged_try'};
  573: 	$button=1;
  574:     } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') {
  575: 	$message = &mt('Error in instructor specifed unit. This error has been reported to the instructor.', $awardmsg);
  576: 	if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');} 
  577: 	$bgcolor=$possiblecolors{'not_charged_try'};
  578: 	$button=1;
  579:     } elsif ($award eq 'UNIT_INVALID_STUDENT') {
  580: 	$message = &mt('Unable to interpret units. Computer reads units as "[_1]".',&markup_unit($awardmsg,$target));
  581: 	if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');} 
  582: 	$bgcolor=$possiblecolors{'not_charged_try'};
  583: 	$button=1;
  584:     } elsif ($award eq 'UNIT_FAIL' || $award eq 'UNIT_IRRECONCIBLE') {
  585: 	$message = &mt('Incompatible units. No conversion found between "[_1]" and the required units.',&markup_unit($awardmsg,$target));
  586: 	if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units');} 
  587: 	$bgcolor=$possiblecolors{'not_charged_try'};
  588: 	$button=1;
  589:     } elsif ($award eq 'UNIT_NOTNEEDED') {
  590: 	$message = &mt('Only a number required. Computer reads units of "[_1]".',&markup_unit($awardmsg,$target));
  591: 	$bgcolor=$possiblecolors{'not_charged_try'};
  592: 	$button=1;
  593:     } elsif ($award eq 'NO_UNIT') {
  594: 	$message = &mt("Units required").'.';
  595: 	if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Physical_Units')};
  596: 	$bgcolor=$possiblecolors{'not_charged_try'};
  597: 	$button=1;
  598:     } elsif ($award eq 'COMMA_FAIL') {
  599: 	$message = &mt("Proper comma separation is required").'.';
  600: 	$bgcolor=$possiblecolors{'not_charged_try'};
  601: 	$button=1;
  602:     } elsif ($award eq 'BAD_FORMULA') {
  603: 	$message = &mt("Unable to understand formula");
  604: 	$bgcolor=$possiblecolors{'not_charged_try'};
  605: 	$button=1;
  606:     } elsif ($award eq 'INCORRECT') {
  607: 	$message = &mt("Incorrect").'.';
  608: 	$bgcolor=$possiblecolors{'charged_try'};
  609: 	$button=1;
  610:     } elsif ($award eq 'SUBMITTED') {
  611: 	$message = &mt("Your submission has been recorded.");
  612: 	$bgcolor=$possiblecolors{'correct'};
  613: 	$button=1;
  614:     } elsif ($award eq 'DRAFT') {
  615: 	$message = &mt("A draft copy has been saved.");
  616: 	$bgcolor=$possiblecolors{'not_charged_try'};
  617: 	$button=1;
  618:     } elsif ($award eq 'ASSIGNED_SCORE') {
  619: 	$message = &mt("A score has been assigned.");
  620: 	$bgcolor=$possiblecolors{'correct'};
  621: 	$button=0;
  622:     } elsif ($award eq '') {
  623: 	$bgcolor=$possiblecolors{'not_charged_try'};
  624: 	$button=1;
  625:     } else {
  626: 	$message = &mt("Unknown message").": $award";
  627: 	$button=1;
  628:     }
  629:     if (lc($Apache::lonhomework::problemstatus) eq 'no'  && 
  630: 	$Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {
  631: 	$message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
  632: 	$bgcolor=$possiblecolors{'correct'};
  633: 	$button=1;
  634:     }
  635:     if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' && 
  636: 	!$added_computer_text && $target ne 'tex') {
  637: 	$message.= $computer;
  638: 	$added_computer_text=1;
  639:     }
  640:     return ($button,$bgcolor,$message,$previousmsg);
  641: }
  642: 
  643: sub markup_unit {
  644:     my ($unit,$target)=@_;
  645:     if ($target eq 'tex') {
  646: 	return '\texttt{'.&Apache::lonxml::latex_special_symbols($unit).'}'; 
  647:     } else {
  648: 	return "<tt>".$unit."</tt>";
  649:     }
  650: }
  651: 
  652: sub removealldata {
  653:     my ($id)=@_;
  654:     foreach my $key (keys(%Apache::lonhomework::results)) {
  655: 	if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) {
  656: 	    &Apache::lonxml::debug("Removing $key");
  657: 	    delete($Apache::lonhomework::results{$key});
  658: 	}
  659:     }
  660: }
  661: 
  662: sub hidealldata {
  663:     my ($id)=@_;
  664:     foreach my $key (keys(%Apache::lonhomework::results)) {
  665: 	if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) {
  666: 	    &Apache::lonxml::debug("Hidding $key");
  667: 	    my $newkey=$key;
  668: 	    $newkey=~s/^(resource\.\Q$id\E\.[^\.]+\.)(.*)$/${1}hidden${2}/;
  669: 	    $Apache::lonhomework::results{$newkey}=
  670: 		$Apache::lonhomework::results{$key};
  671: 	    delete($Apache::lonhomework::results{$key});
  672: 	}
  673:     }
  674: }
  675: 
  676: sub setgradedata {
  677:     my ($award,$msg,$id,$previously_used) = @_;
  678:     if ($Apache::lonhomework::scantronmode && 
  679: 	&Apache::lonnet::validCODE($env{'form.CODE'})) {
  680: 	$Apache::lonhomework::results{"resource.CODE"}=$env{'form.CODE'};
  681:     } elsif ($Apache::lonhomework::scantronmode && 
  682: 	     $env{'form.CODE'} eq '' &&
  683: 	     $Apache::lonhomework::history{"resource.CODE"} ne '') {
  684: 	$Apache::lonhomework::results{"resource.CODE"}='';
  685:     }
  686: 
  687:     if (!$Apache::lonhomework::scantronmode &&
  688: 	$Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
  689: 	$Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
  690: 	$Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
  691: 	return '';
  692:     } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
  693: 	      /^correct/ || $Apache::lonhomework::scantronmode ||
  694: 	      lc($Apache::lonhomework::problemstatus) eq 'no') {
  695:         # the student doesn't already have it correct,
  696: 	# or we are in a mode (scantron orno problem status) where a correct 
  697:         # can become incorrect
  698: 	# handle assignment of tries and solved status
  699: 	my $solvemsg;
  700: 	if ($Apache::lonhomework::scantronmode) {
  701: 	    $solvemsg='correct_by_scantron';
  702: 	} else {
  703: 	    $solvemsg='correct_by_student';
  704: 	}
  705: 	if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
  706: 	    $Apache::lonhomework::results{"resource.$id.afterduedate"}='';
  707: 	}
  708: 	if ( $award eq 'ASSIGNED_SCORE') {
  709: 	    $Apache::lonhomework::results{"resource.$id.tries"} =
  710: 		$Apache::lonhomework::history{"resource.$id.tries"} + 1;
  711: 	    $Apache::lonhomework::results{"resource.$id.solved"} =
  712: 		$solvemsg;
  713: 	    my $numawards=scalar(@Apache::inputtags::response);
  714: 	    $Apache::lonhomework::results{"resource.$id.awarded"} = 0;
  715: 	    foreach my $res (@Apache::inputtags::response) {
  716: 		$Apache::lonhomework::results{"resource.$id.awarded"}+=
  717: 		    $Apache::lonhomework::results{"resource.$id.$res.awarded"};
  718: 	    }
  719: 	    if ($numawards > 0) {
  720: 		$Apache::lonhomework::results{"resource.$id.awarded"}/=
  721: 		    $numawards;
  722: 	    }
  723: 	} elsif ( $award eq 'APPROX_ANS' || $award eq 'EXACT_ANS' ) {
  724: 	    $Apache::lonhomework::results{"resource.$id.tries"} =
  725: 		$Apache::lonhomework::history{"resource.$id.tries"} + 1;
  726: 	    $Apache::lonhomework::results{"resource.$id.solved"} =
  727: 		$solvemsg;
  728: 	    $Apache::lonhomework::results{"resource.$id.awarded"} = '1';
  729: 	} elsif ( $award eq 'INCORRECT' ) {
  730: 	    $Apache::lonhomework::results{"resource.$id.tries"} =
  731: 		$Apache::lonhomework::history{"resource.$id.tries"} + 1;
  732: 	    if (lc($Apache::lonhomework::problemstatus) eq 'no' ||
  733: 		$Apache::lonhomework::scantronmode) {
  734: 		$Apache::lonhomework::results{"resource.$id.awarded"} = 0;
  735: 	    }
  736: 	    $Apache::lonhomework::results{"resource.$id.solved"} =
  737: 		'incorrect_attempted';
  738: 	} elsif ( $award eq 'SUBMITTED' ) {
  739: 	    $Apache::lonhomework::results{"resource.$id.tries"} =
  740: 		$Apache::lonhomework::history{"resource.$id.tries"} + 1;
  741: 	    $Apache::lonhomework::results{"resource.$id.solved"} =
  742: 		'ungraded_attempted';
  743: 	} elsif ( $award eq 'DRAFT' ) {
  744: 	    $Apache::lonhomework::results{"resource.$id.solved"} = '';
  745: 	} elsif ( $award eq 'NO_RESPONSE' ) {
  746: 	    #no real response so delete any data that got stored
  747: 	    &removealldata($id);
  748: 	    return '';
  749: 	} else {
  750: 	    $Apache::lonhomework::results{"resource.$id.solved"} =
  751: 		'incorrect_attempted';
  752: 	    if (lc($Apache::lonhomework::problemstatus) eq 'no' ||
  753: 		$Apache::lonhomework::scantronmode) {
  754: 		$Apache::lonhomework::results{"resource.$id.tries"} =
  755: 		    $Apache::lonhomework::history{"resource.$id.tries"} + 1;
  756: 		$Apache::lonhomework::results{"resource.$id.awarded"} = 0;
  757: 	    }
  758: 	}
  759: 	if (defined($msg)) {
  760: 	    $Apache::lonhomework::results{"resource.$id.awardmsg"} = $msg;
  761: 	}
  762: 	# did either of the overall awards chage? If so ignore the 
  763: 	# previous check
  764: 	if (($Apache::lonhomework::results{"resource.$id.awarded"} eq
  765: 	     $Apache::lonhomework::history{"resource.$id.awarded"}) &&
  766: 	    ($Apache::lonhomework::results{"resource.$id.solved"} eq
  767: 	     $Apache::lonhomework::history{"resource.$id.solved"})) {
  768: 	    # check if this was a previous submission if it was delete the
  769: 	    # unneeded data and update the previously_used attribute
  770: 	    if ( $previously_used eq 'PREVIOUSLY_USED') {
  771: 		if (lc($Apache::lonhomework::problemstatus) ne 'no') {
  772: 		    delete($Apache::lonhomework::results{"resource.$id.tries"});
  773: 		    $Apache::lonhomework::results{"resource.$id.previous"} = '1';
  774: 		}
  775: 	    } elsif ( $previously_used eq 'PREVIOUSLY_LAST') {
  776: 		#delete all data as they student didn't do anything, but save
  777: 		#the list of collaborators.
  778: 		&removealldata($id);
  779: 		#and since they didn't do anything we were never here
  780: 		return '';
  781: 	    } else {
  782: 		$Apache::lonhomework::results{"resource.$id.previous"} = '0';
  783: 	    }
  784: 	}
  785:     } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} =~
  786: 	      /^correct/ ) {
  787: 	#delete all data as they student already has it correct
  788: 	&removealldata($id);
  789: 	#and since they didn't do anything we were never here
  790: 	return '';
  791:     }
  792:     $Apache::lonhomework::results{"resource.$id.award"} = $award;
  793: }
  794: 
  795: sub grade {
  796:     my ($target) = @_;
  797:     my $id = $Apache::inputtags::part;
  798:     my $response='';
  799:     if ( defined $env{'form.submitted'}) {
  800: 	my (@awards,@msgs);
  801: 	foreach $response (@Apache::inputtags::response) {
  802: 	    &Apache::lonxml::debug("looking for response.$id.$response.awarddetail");
  803: 	    my $value=$Apache::lonhomework::results{"resource.$id.$response.awarddetail"};
  804: 	    &Apache::lonxml::debug("keeping $value from $response for $id");
  805: 	    push (@awards,$value);
  806: 	    $value=$Apache::lonhomework::results{"resource.$id.$response.awardmsg"};
  807: 	    &Apache::lonxml::debug("got message $value from $response for $id");
  808: 	    push (@msgs,$value);
  809: 	}
  810: 	my ($finalaward,$msg) = &finalizeawards(\@awards,\@msgs);
  811: 	my $previously_used;
  812: 	if ( $#Apache::inputtags::previous eq $#awards ) {
  813: 	    my $match=0;
  814: 	    my @matches;
  815: 	    foreach my $versionar (@Apache::inputtags::previous_version) {
  816: 		foreach my $version (@$versionar) {
  817: 		    $matches[$version]++;
  818: 		}
  819: 	    }
  820: 	    foreach my $elem (@matches) {if ($elem eq ($#awards+1)) {$match=1;}}
  821: 	    if ($match) {
  822: 		$previously_used = 'PREVIOUSLY_LAST';
  823: 		foreach my $value (@Apache::inputtags::previous) {
  824: 		    if ($value eq 'PREVIOUSLY_USED' ) {
  825: 			$previously_used = $value;
  826: 			last;
  827: 		    }
  828: 		}
  829: 	    }
  830: 	}
  831: 	&Apache::lonxml::debug("final award $finalaward, $previously_used, message $msg");
  832: 	&setgradedata($finalaward,$msg,$id,$previously_used);
  833:     }
  834:     return '';
  835: }
  836: 
  837: sub gradestatus {
  838:     my ($id,$target) = @_;
  839:     my $showbutton = 1;
  840:     my $bgcolor = '';
  841:     my $message = '';
  842:     my $latemessage = '';
  843:     my $trystr='';
  844:     my $button='';
  845:     my $previousmsg='';
  846: 
  847:     my $status = $Apache::inputtags::status['-1'];
  848:     &Apache::lonxml::debug("gradestatus has :$status:");
  849:     if ( $status ne 'CLOSED' 
  850: 	 && $status ne 'UNAVAILABLE' 
  851: 	 && $status ne 'INVALID_ACCESS' 
  852: 	 && $status ne 'NEEDS_CHECKIN' 
  853: 	 && $status ne 'NOT_IN_A_SLOT') {  
  854: 	my $award = $Apache::lonhomework::history{"resource.$id.award"};
  855: 	my $awarded = $Apache::lonhomework::history{"resource.$id.awarded"};
  856: 	my $solved = $Apache::lonhomework::history{"resource.$id.solved"};
  857: 	my $previous = $Apache::lonhomework::history{"resource.$id.previous"};
  858: 	my $awardmsg = $Apache::lonhomework::history{"resource.$id.awardmsg"};
  859: 	&Apache::lonxml::debug("Found Award |$award|$solved|$awardmsg");
  860: 	if ( $award ne '' || $solved ne '' || $status eq 'SHOW_ANSWER') {
  861: 	    &Apache::lonxml::debug('Getting message');
  862: 	    ($showbutton,$bgcolor,$message,$previousmsg) =
  863: 		&decideoutput($award,$awarded,$awardmsg,$solved,$previous,
  864: 			      $target);
  865: 	    if ($target eq 'tex') {
  866: 		$message='\vskip 2 mm '.$message.' ';
  867: 	    } else {
  868: 		$message="<td bgcolor=\"$bgcolor\">$message</td>";
  869: 		if ($previousmsg) {
  870: 		    $previousmsg="<td bgcolor=\"#aaaaff\">$previousmsg</td>";
  871: 		}
  872: 	    }
  873: 	}
  874: 	my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
  875: 	my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
  876: 	&Apache::lonxml::debug("got maxtries of :$maxtries:");
  877: 	#if tries are set to negative turn off the Tries/Button and messages
  878: 	if (defined($maxtries) && $maxtries < 0) { return ''; }
  879: 	if ( $tries eq '' ) { $tries = '0'; }
  880: 	if ( $maxtries eq '' ) { $maxtries = '2'; } 
  881: 	if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } 
  882: 	my $tries_text=&mt('Tries');
  883: 	if ( $Apache::lonhomework::type eq 'survey' ||
  884: 	     $Apache::lonhomework::parsing_a_task) {
  885: 	    $tries_text=&mt('Submissions');
  886: 	}
  887: 	if ( $showbutton ) {
  888: 	    if ($target eq 'tex') {
  889: 		if ($env{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam' && $env{'form.suppress_tries'} ne 'yes') {
  890: 		    $trystr = ' {\vskip 1 mm \small \textit{'.$tries_text.'} '.$tries.'/'.$maxtries.'} \vskip 2 mm ';
  891: 		} else {
  892: 		    $trystr = '\vskip 0 mm ';
  893: 		}
  894: 	    } else {
  895: 		$trystr = "<td><nobr>".$tries_text." $tries";
  896: 		if ($Apache::lonhomework::parsing_a_task) {
  897: 		} elsif($env{'request.state'} ne 'construct') {
  898: 		    $trystr.="/$maxtries";
  899: 		} else {
  900: 		    if (defined($Apache::inputtags::params{'maxtries'})) {
  901: 			$trystr.="/".$Apache::inputtags::params{'maxtries'};
  902: 		    }
  903: 		}
  904: 		$trystr.="</nobr></td>";
  905: 	    }
  906: 	}
  907: 	if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;}
  908: 	if ( $showbutton ) { 
  909: 	    if ($target ne 'tex') {
  910: 		$button = '<input type="submit" name="submit_'.$id.'" value="'.&mt('Submit Answer').'" />';
  911: 	    }
  912: 	}
  913: 	if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
  914: 	    #last submissions was after due date
  915: 	    $latemessage=&mt(' The last submission was after the Due Date ');;
  916: 	    if ($target eq 'web') {
  917: 		$latemessage='<td bgcolor="#ffaaaa">'.$latemessage.'</td>';
  918: 	    }
  919: 	}
  920:     }
  921:     my $output= $previousmsg.$latemessage.$message.$trystr;
  922:     if ($output =~ /^\s*$/) {
  923: 	return $button;
  924:     } else {
  925: 	if ($target eq 'tex') {
  926: 	    return $button.' \vskip 0 mm '.$output.' ';
  927: 	} else {
  928: 	    return '<table><tr><td>'.$button.'</td>'.$output.'</tr></table>';
  929: 	}
  930:     }
  931: }
  932: 1;
  933: __END__
  934:  

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