Annotation of loncom/homework/inputtags.pm, revision 1.76

1.43      albertel    1: # The LearningOnline Network with CAPA
                      2: # input  definitons
1.47      albertel    3: #
1.76    ! sakharuk    4: # $Id: inputtags.pm,v 1.75 2002/11/27 19:25:56 albertel Exp $
1.47      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: #
1.43      albertel   28: # 2/19 Guy 
1.1       albertel   29: 
                     30: package Apache::inputtags;
1.55      albertel   31: use HTML::Entities();
1.1       albertel   32: use strict;
                     33: 
1.50      harris41   34: BEGIN {
1.65      bowersj2   35:   &Apache::lonxml::register('Apache::inputtags',('textfield','textline'));
1.1       albertel   36: }
                     37: 
1.43      albertel   38: 
1.1       albertel   39: sub initialize_inputtags {
1.43      albertel   40:   # list of current input ids
                     41:   @Apache::inputtags::input=();
                     42:   # list of all input ids seen in this problem
                     43:   @Apache::inputtags::inputlist=();
                     44:   # list of all current response ids
                     45:   @Apache::inputtags::response=();
                     46:   # list of all response ids seen in this problem
                     47:   @Apache::inputtags::responselist=();
                     48:   # list of whether or not a specific response was previously used
                     49:   @Apache::inputtags::previous=();
1.75      albertel   50:   # submission it was used in
                     51:   @Apache::inputtags::previous_version=();
1.43      albertel   52:   # id of current part, 0 means that no part is current (inside <problem> only
                     53:   $Apache::inputtags::part='';
1.46      albertel   54:   # list of problem date statuses, the first element is for <problem>
                     55:   # if there is a second element it is for the current <part>
1.43      albertel   56:   @Apache::inputtags::status=();
1.46      albertel   57:   # hash of defined params for the current response
1.43      albertel   58:   %Apache::inputtags::params=();
1.46      albertel   59:   # list of all ids, for <import>, these get join()ed and prepended
                     60:   @Apache::inputtags::import=();
1.1       albertel   61: }
                     62: 
1.14      albertel   63: sub start_input {
1.43      albertel   64:   my ($parstack,$safeeval)=@_;
                     65:   my $id = &Apache::lonxml::get_param('id',$parstack,$safeeval);
                     66:   if ($id eq '') { $id = $Apache::lonxml::curdepth; }
                     67:   push (@Apache::inputtags::input,$id);
                     68:   push (@Apache::inputtags::inputlist,$id);
                     69:   return $id;
1.14      albertel   70: }
                     71: 
                     72: sub end_input {
1.43      albertel   73:   pop @Apache::inputtags::input;
                     74:   return '';
1.14      albertel   75: }
                     76: 
1.48      albertel   77: sub start_textfield {
1.43      albertel   78:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                     79:   my $result = "";
                     80:   my $id = &start_input($parstack,$safeeval);
1.55      albertel   81:   my $resid=$Apache::inputtags::response[-1];
1.43      albertel   82:   if ($target eq 'web') {
1.57      albertel   83:     $Apache::lonxml::evaluate--;
1.45      albertel   84:     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
1.61      albertel   85: 	my $partid=$Apache::inputtags::part;
                     86: 	my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"});
                     87: 	my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
                     88: 	if ( $cols eq '') { $cols = 80; }
                     89: 	my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
                     90: 	if ( $rows eq '') { $rows = 10; }
                     91: 	$result= '<textarea name="HWVAL'.$resid.'" '.
                     92: 	    "rows=\"$rows\" cols=\"$cols\">".$oldresponse;
                     93: 	if ($oldresponse ne '') {
                     94: 	    #get rid of any startup text if the user has already responded
                     95: 	    &Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
                     96: 	}
1.45      albertel   97:     } else {
1.61      albertel   98: 	#right or wrong don't show it
                     99: 	#$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';
                    100: 	$result='';
                    101: 	#get rid of any startup text
                    102: 	&Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
1.51      albertel  103:     }
1.60      albertel  104:   } elsif ($target eq 'grade') {
1.51      albertel  105:     my $seedtext=&Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
1.55      albertel  106:     if ($seedtext eq $ENV{'form.HWVAL'.$resid}) {
1.51      albertel  107:       # if the seed text is still there it wasn't a real submission
1.55      albertel  108:       $ENV{'form.HWVAL'.$resid}='';
1.30      albertel  109:     }
1.60      albertel  110:   } elsif ($target eq 'edit') {
                    111:     $result.=&Apache::edit::tag_start($target,$token);
                    112:     $result.=&Apache::edit::text_arg('Rows:','rows',$token,4);
                    113:     $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
                    114:     my $bodytext=&Apache::lonxml::get_all_text("/textfield",$$parser[-1]);
1.62      albertel  115:     $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
1.60      albertel  116:   } elsif ($target eq 'modified') {
                    117:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,
                    118: 						 $safeeval,'rows','cols');
                    119:     if ($constructtag) {
                    120:       $result = &Apache::edit::rebuild_tag($token);
                    121:     } else {
                    122:       $result=$token->[4];
                    123:     }
                    124:     $result.=&Apache::edit::modifiedfield();
1.43      albertel  125:   }
                    126:   return $result;
1.6       albertel  127: }
                    128: 
1.48      albertel  129: sub end_textfield {
1.43      albertel  130:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.60      albertel  131:   my $result;
1.43      albertel  132:   if ($target eq 'web') {
1.57      albertel  133:     $Apache::lonxml::evaluate++;
1.45      albertel  134:     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
                    135:       return "</textarea>";
                    136:     }
1.60      albertel  137:   } elsif ($target eq 'edit') {
                    138:     $result=&Apache::edit::end_table();
1.45      albertel  139:   }
1.43      albertel  140:   &end_input;
1.60      albertel  141:   return $result;
1.6       albertel  142: }
                    143: 
1.1       albertel  144: sub start_textline {
1.43      albertel  145:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
                    146:   my $result = "";
                    147:   if ($target eq 'web') {
1.57      albertel  148:     $Apache::lonxml::evaluate--;
1.45      albertel  149:     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
1.61      albertel  150:       my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
1.72      albertel  151:       my $maxlength;
                    152:       if ($size eq '') { $size=20; } else {
                    153: 	if ($size < 20) { $maxlength=$size; }
                    154:       }
1.61      albertel  155:       my $partid=$Apache::inputtags::part;
                    156:       my $id=$Apache::inputtags::response[-1];
                    157:       my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
1.73      sakharuk  158:       if ($Apache::lonhomework::type ne 'exam') {
                    159:         $result= '<input type="text" name="HWVAL'.$id.'" value="'.
                    160: 	    $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';
                    161:       }
1.45      albertel  162:     } else {
1.61      albertel  163:       #right or wrong don't show what was last typed in.
                    164:       #$result='<i>'.$oldresponse.'</i>';
                    165:       $result='';
1.45      albertel  166:     }
1.44      albertel  167:   } elsif ($target eq 'edit') {
1.49      matthew   168:     $result=&Apache::edit::tag_start($target,$token);
1.43      albertel  169:     $result.=&Apache::edit::text_arg('Size:','size',$token,'5')."</td></tr>";
                    170:     $result.=&Apache::edit::end_table;
1.44      albertel  171:   } elsif ($target eq 'modified') {
1.43      albertel  172:     my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size');
                    173:     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
1.74      sakharuk  174:   } elsif ($target eq 'tex') {
1.76    ! sakharuk  175:       my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
        !           176:       if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
        !           177:       $result='\framebox['.$size.'][s]{\tiny\strut}';
1.43      albertel  178:   }
                    179:   return $result;
1.1       albertel  180: }
                    181: 
                    182: sub end_textline {
1.43      albertel  183:   my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
1.57      albertel  184:   if    ($target eq 'web') { $Apache::lonxml::evaluate++; }
                    185:   elsif ($target eq 'edit') { return ('','no'); }
1.43      albertel  186:   return "";
1.9       albertel  187: }
                    188: 
                    189: sub finalizeawards {
1.43      albertel  190:   my $result='';
                    191:   my $award;
                    192:   if ($#_ == '-1') { $result = "NO_RESPONSE"; }
                    193:   if ($result eq '' ) {
1.54      albertel  194:     my $blankcount;
                    195:     foreach $award (@_) {
                    196:       if ($award eq '') {
                    197: 	$result='MISSING_ANSWER';
                    198: 	$blankcount++;
                    199:       }
                    200:     }
                    201:     if ($blankcount == ($#_ + 1)) { $result = 'NO_RESPONSE'; }
1.56      albertel  202:   }
                    203:   if ($result eq '' ) {
                    204:     foreach $award (@_) { if ($award eq 'MISSING_ANSWER') {$result='MISSING_ANSWER'; last;}}
1.43      albertel  205:   }
                    206:   if ($result eq '' ) {
                    207:     foreach $award (@_) { if ($award eq 'ERROR') {$result='ERROR'; last;}}
                    208:   }
                    209:   if ($result eq '' ) {
                    210:     foreach $award (@_) { if ($award eq 'NO_RESPONSE') {$result='NO_RESPONSE'; last;} }
                    211:   }
                    212: 
                    213:   if ($result eq '' ) {
                    214:     foreach $award (@_) { 
                    215:       if ($award eq 'UNIT_FAIL' ||
                    216: 	  $award eq 'NO_UNIT' ||
                    217: 	  $award eq 'UNIT_NOTNEEDED') {
                    218: 	$result=$award; last;
                    219:       }
                    220:     }
                    221:   }
                    222:   if ($result eq '' ) {
                    223:     foreach $award (@_) { 
                    224:       if ($award eq 'WANTED_NUMERIC' || 
                    225: 	  $award eq 'BAD_FORMULA') {$result=$award; last;}
                    226:     }
                    227:   }
                    228:   if ($result eq '' ) {
                    229:     foreach $award (@_) { if ($award eq 'SIG_FAIL') {$result=$award; last;} }
                    230:   }
                    231:   if ($result eq '' ) {
                    232:     foreach $award (@_) { if ($award eq 'INCORRECT') {$result=$award; last;} }
                    233:   }
                    234:   if ($result eq '' ) {
1.59      ng        235:     foreach $award (@_) { if ($award eq 'DRAFT') {$result=$award; last;} }
                    236:   }
                    237:   if ($result eq '' ) {
1.43      albertel  238:     foreach $award (@_) { if ($award eq 'SUBMITTED') {$result=$award; last;} }
                    239:   }
                    240:   if ($result eq '' ) {
                    241:     foreach $award (@_) { if ($award eq 'APPROX_ANS') {$result=$award; last;} }
                    242:   }
                    243:   if ($result eq '' ) { $result='EXACT_ANS'; }
                    244:   return $result
1.9       albertel  245: }
                    246: 
1.10      albertel  247: sub decideoutput {
1.68      sakharuk  248:   my ($award,$solved,$previous,$target)=@_;
1.43      albertel  249:   my $message='';
                    250:   my $button=0;
                    251:   my $previousmsg;
                    252: 
                    253:   if ($previous) { $previousmsg='You have entered that answer before'; }
                    254: 
                    255:   if      ($solved =~ /^correct/) {
1.68      sakharuk  256:     if ($target eq 'tex') {
                    257:       $message = '\textbf{You are correct}. Your receipt is '.
1.43      albertel  258:       &Apache::lonnet::receipt;
1.68      sakharuk  259:     } else {
                    260:       $message = "<b>You are correct.</b> Your receipt is ".
                    261:       &Apache::lonnet::receipt;
                    262:     }
1.43      albertel  263:     $button=0;
                    264:     $previousmsg='';
                    265:   } elsif ($solved =~ /^excused/) {
                    266:     $message = "<b>You are excused from the problem.</b>";
                    267:     $button=0;
                    268:     $previousmsg='';
                    269:   } elsif ($award eq 'EXACT_ANS' || $award eq 'APPROX_ANS' ) {
                    270:     if ($solved =~ /^incorrect/ || $solved eq '') {
                    271:       $message = "Incorrect";
                    272:       $button=1;
1.37      albertel  273:     } else {
1.43      albertel  274:       $message = "<b>You are correct.</b> Your receipt is ".
                    275: 	&Apache::lonnet::receipt;
                    276:       $button=0;
                    277:       $previousmsg='';
                    278:     }
                    279:   } elsif ($award eq 'NO_RESPONSE') {
                    280:     $message = '';
                    281:     $button=1;
                    282:   } elsif ($award eq 'MISSING_ANSWER') {
                    283:     $message = 'Some parts were not submitted';
                    284:     $button = 1;
                    285:   } elsif ($award eq 'WANTED_NUMERIC') {
                    286:     $message = "This question expects a numeric answer";
                    287:     $button=1;
                    288:   } elsif ($award eq 'SIG_FAIL') {
                    289:     $message = "Please adjust significant figures.";# you provided %s significant figures";
                    290:     $button=1;
                    291:   } elsif ($award eq 'UNIT_FAIL') {
                    292:     $message = "Units incorrect."; #Computer reads units as %s";
                    293:     $button=1;
                    294:   } elsif ($award eq 'UNIT_NOTNEEDED') {
                    295:     $message = "Only a number required.";# Computer reads units of %s";
                    296:     $button=1;
                    297:   } elsif ($award eq 'NO_UNIT') {
                    298:     $message = "Units required";
                    299:     $button=1;
                    300:   } elsif ($award eq 'BAD_FORMULA') {
                    301:     $message = "Unable to understand formula";
                    302:     $button=1;
                    303:   } elsif ($award eq 'INCORRECT') {
                    304:     $message = "Incorrect";
                    305:     $button=1;
                    306:   } elsif ($award eq 'SUBMITTED') {
                    307:     $message = "Your submission has been recorded.";
                    308:     $button=1;
1.59      ng        309:   } elsif ($award eq 'DRAFT') {
                    310:     $message = "A draft copy has been saved.";
                    311:     $button=1;
1.43      albertel  312:   } else {
                    313:     $message = "Unknown message: $award";
                    314:     $button=1;
                    315:   }
                    316:   return ($button,$message,$previousmsg);
1.12      albertel  317: }
                    318: 
                    319: sub setgradedata {
1.43      albertel  320:   my ($award,$id,$previously_used) = @_;
                    321:   # if the student already has it correct, don't modify the status
1.71      albertel  322:   if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
                    323:       $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
1.53      albertel  324:     $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
                    325:     return '';
                    326:   } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
1.43      albertel  327:        /^correct/ ) {
                    328:     #handle assignment of tries and solved status
1.53      albertel  329:     if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
                    330:       $Apache::lonhomework::results{"resource.$id.afterduedate"}='';
                    331:     }
1.43      albertel  332:     if ( $award eq 'APPROX_ANS' || $award eq 'EXACT_ANS' ) {
                    333:       $Apache::lonhomework::results{"resource.$id.tries"} =
                    334: 	$Apache::lonhomework::history{"resource.$id.tries"} + 1;
                    335:       $Apache::lonhomework::results{"resource.$id.solved"} =
                    336: 	'correct_by_student';
                    337:       $Apache::lonhomework::results{"resource.$id.awarded"} = '1';
                    338:     } elsif ( $award eq 'INCORRECT' ) {
                    339:       $Apache::lonhomework::results{"resource.$id.tries"} =
                    340: 	$Apache::lonhomework::history{"resource.$id.tries"} + 1;
                    341:       $Apache::lonhomework::results{"resource.$id.solved"} =
1.59      ng        342: 	'incorrect_attempted'
1.43      albertel  343:     } elsif ( $award eq 'SUBMITTED' ) {
                    344:       $Apache::lonhomework::results{"resource.$id.tries"} =
                    345: 	$Apache::lonhomework::history{"resource.$id.tries"} + 1;
                    346:       $Apache::lonhomework::results{"resource.$id.solved"} =
                    347: 	'ungraded_attempted';
1.59      ng        348:     } elsif ( $award eq 'DRAFT' ) {
                    349:       $Apache::lonhomework::results{"resource.$id.solved"} = '';
1.43      albertel  350:     } elsif ( $award eq 'NO_RESPONSE' ) {
                    351:       return '';
                    352:     } else {
                    353:       $Apache::lonhomework::results{"resource.$id.solved"} =
                    354: 	'incorrect_attempted';
                    355:     }
                    356: 
                    357:     # check if this was a previous submission if it was delete the
                    358:     # unneeded data and update the previously_used attribute
                    359:     if ( $previously_used eq 'PREVIOUSLY_USED') {
                    360:       delete($Apache::lonhomework::results{"resource.$id.tries"});
                    361:       $Apache::lonhomework::results{"resource.$id.previous"} = '1';
                    362:     } elsif ( $previously_used eq 'PREVIOUSLY_LAST') {
1.58      ng        363:       #delete all data as they student didn't do anything, but save
                    364:       #the list of collaborators.
1.43      albertel  365:       foreach my $key (keys(%Apache::lonhomework::results)) {
1.58      ng        366: 	if (($key =~ /^resource\.$id\./) && ($key !~ /\.collaborators$/)) {
1.43      albertel  367: 	  &Apache::lonxml::debug("Removing $key");
1.63      sakharuk  368:   delete($Apache::lonhomework::results{$key});
1.43      albertel  369: 	}
                    370:       }
                    371:       #and since they didn't do anything we were never here
                    372:       return '';
                    373:     } else {
                    374:       $Apache::lonhomework::results{"resource.$id.previous"} = '0';
1.40      albertel  375:     }
1.43      albertel  376:   }
                    377:   $Apache::lonhomework::results{"resource.$id.award"} = $award;
1.10      albertel  378: }
                    379: 
1.9       albertel  380: sub grade {
1.43      albertel  381:   my ($target) = @_;
                    382:   my $id = $Apache::inputtags::part;
                    383:   my $response='';
                    384:   if ( defined $ENV{'form.submitted'}) {
                    385:     my @awards = ();
                    386:     foreach $response (@Apache::inputtags::responselist) {
                    387:       &Apache::lonxml::debug("looking for response.$id.$response.awarddetail");
                    388:       my $value=$Apache::lonhomework::results{"resource.$id.$response.awarddetail"};
1.54      albertel  389:       &Apache::lonxml::debug("keeping $value from $response for $id");
                    390:       push (@awards,$value);
1.43      albertel  391:     }
                    392:     my $finalaward = &finalizeawards(@awards);
                    393:     my $previously_used;
                    394:     if ( $#Apache::inputtags::previous eq $#awards ) {
1.75      albertel  395: 	my $match=0;
                    396: 	my @matches;
                    397: 	foreach my $versionar (@Apache::inputtags::previous_version) {
                    398: 	    foreach my $version (@$versionar) {
                    399: 		$matches[$version]++;
                    400: 	    }
                    401: 	}
                    402: 	foreach my $elem (@matches) {if ($elem eq ($#awards+1)) {$match=1;}}
                    403: 	if ($match) {
                    404: 	    $previously_used = 'PREVIOUSLY_LAST';
                    405: 	    foreach my $value (@Apache::inputtags::previous) {
                    406: 		if ($value eq 'PREVIOUSLY_USED' ) {
                    407: 		    $previously_used = $value;
                    408: 		    last;
                    409: 		}
                    410: 	    }
1.43      albertel  411: 	}
                    412:     }
                    413:     &Apache::lonxml::debug("final award $finalaward, $previously_used");
                    414:     &setgradedata($finalaward,$id,$previously_used);
                    415:   }
                    416:   return '';
1.1       albertel  417: }
                    418: 
1.11      albertel  419: sub gradestatus {
1.63      sakharuk  420:   my ($id,$target) = @_;
1.43      albertel  421:   my $showbutton = 1;
                    422:   my $message = '';
1.53      albertel  423:   my $latemessage = '';
1.43      albertel  424:   my $trystr='';
                    425:   my $button='';
                    426:   my $previousmsg='';
                    427: 
                    428:   my $status = $Apache::inputtags::status['-1'];
                    429:   &Apache::lonxml::debug("gradestatus has :$status:");
                    430:   if ( $status ne 'CLOSED' ) {  
                    431:     my $award = $Apache::lonhomework::history{"resource.$id.award"};
                    432:     my $solved = $Apache::lonhomework::history{"resource.$id.solved"};
                    433:     my $previous = $Apache::lonhomework::history{"resource.$id.previous"};
                    434:     &Apache::lonxml::debug("Found Award |$award|$solved|");
                    435:     if ( $award ne '' ) {
                    436:       &Apache::lonxml::debug('Getting message');
                    437:       ($showbutton,$message,$previousmsg) =
1.68      sakharuk  438: 	&decideoutput($award,$solved,$previous,$target);
1.63      sakharuk  439:       if ($target eq 'tex') {
                    440: 	$message=' '.$message.' ';
                    441:       } else {
                    442: 	$message="<td bgcolor=\"#aaffaa\">$message</td>";
                    443: 	if ($previousmsg) {
                    444: 	  $previousmsg="<td bgcolor=\"#ffaaaa\">$previousmsg</td>";
                    445: 	}
1.43      albertel  446:       }
                    447:     }
                    448:     my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
                    449:     my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
                    450:     &Apache::lonxml::debug("got maxtries of :$maxtries:");
                    451:     if ( $tries eq '' ) { $tries = '0'; }
                    452:     if ( $maxtries eq '' ) { $maxtries = '2'; } 
                    453:     if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } 
                    454:     if ( $showbutton ) {
1.63      sakharuk  455:       if ($target eq 'tex') {
1.69      sakharuk  456: 	  if ($ENV{'request.state'} ne "construct") {
1.70      sakharuk  457: 	      $trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 0 mm ';
1.67      sakharuk  458: 	  }
1.63      sakharuk  459:       } else {
                    460:          $trystr = "<td>Tries $tries/$maxtries</td>";
                    461:       }
1.43      albertel  462:     }
                    463:     if ( $status eq 'SHOW_ANSWER' || $status eq 'CANNOT_ANSWER') {$showbutton = 0;}
                    464:     if ( $showbutton ) { 
1.63      sakharuk  465:       if ($target ne 'tex') {
                    466:         $button = '<br /><input type="submit" name="submit" value="Submit Answer" />';
                    467:       }
1.43      albertel  468:     }
1.53      albertel  469:     if ($Apache::lonhomework::history{"resource.$id.afterduedate"}) {
                    470:       #last submissions was after due date
1.63      sakharuk  471:       if ($target eq 'tex') {
                    472: 	  $latemessage=' The last submission was after the Due Date ';
                    473:       } else {
                    474:         $latemessage="<td bgcolor=\"#ffaaaa\">The last submission was after the Due Date</td>";
                    475:       }
1.53      albertel  476:     }
1.43      albertel  477:   }
1.53      albertel  478:   my $output= $previousmsg.$latemessage.$message.$trystr;
1.43      albertel  479:   if ($output =~ /^\s*$/) {
                    480:     return $button;
                    481:   } else {
1.63      sakharuk  482:     if ($target eq 'tex') {
                    483:       return $button.' \vskip 0 mm '.$output.' ';
                    484:     } else {
                    485:       return $button.'<table><tr>'.$output.'</tr></table>';
                    486:     }
1.43      albertel  487:   }
1.11      albertel  488: }
1.1       albertel  489: 1;
                    490: __END__
1.43      albertel  491:  

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