Diff for /loncom/homework/inputtags.pm between versions 1.68 and 1.78

version 1.68, 2002/10/24 19:20:17 version 1.78, 2003/01/13 21:22:43
Line 47  sub initialize_inputtags { Line 47  sub initialize_inputtags {
   @Apache::inputtags::responselist=();    @Apache::inputtags::responselist=();
   # list of whether or not a specific response was previously used    # list of whether or not a specific response was previously used
   @Apache::inputtags::previous=();    @Apache::inputtags::previous=();
     # submission it was used in
     @Apache::inputtags::previous_version=();
   # id of current part, 0 means that no part is current (inside <problem> only    # id of current part, 0 means that no part is current (inside <problem> only
   $Apache::inputtags::part='';    $Apache::inputtags::part='';
   # list of problem date statuses, the first element is for <problem>    # list of problem date statuses, the first element is for <problem>
Line 120  sub start_textfield { Line 122  sub start_textfield {
       $result=$token->[4];        $result=$token->[4];
     }      }
     $result.=&Apache::edit::modifiedfield();      $result.=&Apache::edit::modifiedfield();
     } elsif ($target eq 'tex') {
         if ($$tagstack[-2] eq 'essayresponse' and $Apache::lonhomework::type eq 'exam') {
     my $number_of_lines= &Apache::lonxml::get_param('rows',$parstack,$safeeval);
     $result = '\fbox{\fbox{\parbox{\textwidth-5mm}{';
    for (my $i=0;$i<int $number_of_lines*2;$i++) {$result.='\strut \\\\ ';}
    $result.='\strut \\\\\strut \\\\\strut \\\\\strut \\\\}}}';
         }
   }    }
   return $result;    return $result;
 }  }
Line 146  sub start_textline { Line 155  sub start_textline {
     $Apache::lonxml::evaluate--;      $Apache::lonxml::evaluate--;
     if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {      if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
       my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);        my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
       if ($size eq '') { $size=20; }        my $maxlength;
         if ($size eq '') { $size=20; } else {
    if ($size < 20) { $maxlength=$size; }
         }
       my $partid=$Apache::inputtags::part;        my $partid=$Apache::inputtags::part;
       my $id=$Apache::inputtags::response[-1];        my $id=$Apache::inputtags::response[-1];
       my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});        my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$id.submission"});
       $result= '<input type="text" name="HWVAL'.$id.'" value="'.        if ($Apache::lonhomework::type ne 'exam') {
  $oldresponse.'" size="'.$size.'" />';          $result= '<input type="text" name="HWVAL'.$id.'" value="'.
       $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';
         }
     } else {      } else {
       #right or wrong don't show what was last typed in.        #right or wrong don't show what was last typed in.
       #$result='<i>'.$oldresponse.'</i>';        #$result='<i>'.$oldresponse.'</i>';
Line 164  sub start_textline { Line 178  sub start_textline {
   } elsif ($target eq 'modified') {    } elsif ($target eq 'modified') {
     my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size');      my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'size');
     if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }      if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
     } elsif ($target eq 'tex' and $Apache::lonhomework::type ne 'exam') {
         my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
         if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
         $result='\framebox['.$size.'][s]{\tiny\strut}';
   }    }
   return $result;    return $result;
 }  }
Line 308  sub decideoutput { Line 326  sub decideoutput {
 sub setgradedata {  sub setgradedata {
   my ($award,$id,$previously_used) = @_;    my ($award,$id,$previously_used) = @_;
   # if the student already has it correct, don't modify the status    # if the student already has it correct, don't modify the status
   if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER') {    if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
         $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
     $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;      $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
     return '';      return '';
   } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~    } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
Line 380  sub grade { Line 399  sub grade {
     my $finalaward = &finalizeawards(@awards);      my $finalaward = &finalizeawards(@awards);
     my $previously_used;      my $previously_used;
     if ( $#Apache::inputtags::previous eq $#awards ) {      if ( $#Apache::inputtags::previous eq $#awards ) {
       $previously_used = 'PREVIOUSLY_LAST';   my $match=0;
       foreach my $value (@Apache::inputtags::previous) {   my @matches;
  if ($value eq 'PREVIOUSLY_USED' ) {   foreach my $versionar (@Apache::inputtags::previous_version) {
   $previously_used = $value;      foreach my $version (@$versionar) {
   last;   $matches[$version]++;
       }
    }
    foreach my $elem (@matches) {if ($elem eq ($#awards+1)) {$match=1;}}
    if ($match) {
       $previously_used = 'PREVIOUSLY_LAST';
       foreach my $value (@Apache::inputtags::previous) {
    if ($value eq 'PREVIOUSLY_USED' ) {
       $previously_used = $value;
       last;
    }
       }
  }   }
       }  
     }      }
     &Apache::lonxml::debug("final award $finalaward, $previously_used");      &Apache::lonxml::debug("final award $finalaward, $previously_used");
     &setgradedata($finalaward,$id,$previously_used);      &setgradedata($finalaward,$id,$previously_used);
Line 405  sub gradestatus { Line 434  sub gradestatus {
   
   my $status = $Apache::inputtags::status['-1'];    my $status = $Apache::inputtags::status['-1'];
   &Apache::lonxml::debug("gradestatus has :$status:");    &Apache::lonxml::debug("gradestatus has :$status:");
   if ( $status ne 'CLOSED' ) {      if ( $status ne 'CLOSED' && $status ne 'UNAVAILABLE') {  
     my $award = $Apache::lonhomework::history{"resource.$id.award"};      my $award = $Apache::lonhomework::history{"resource.$id.award"};
     my $solved = $Apache::lonhomework::history{"resource.$id.solved"};      my $solved = $Apache::lonhomework::history{"resource.$id.solved"};
     my $previous = $Apache::lonhomework::history{"resource.$id.previous"};      my $previous = $Apache::lonhomework::history{"resource.$id.previous"};
Line 431  sub gradestatus { Line 460  sub gradestatus {
     if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; }       if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } 
     if ( $showbutton ) {      if ( $showbutton ) {
       if ($target eq 'tex') {        if ($target eq 'tex') {
   if ((not $ENV{'request.role'}=~m/^au\./) and (not $ENV{'request.role'}=~m/^ca\./)) {    if ($ENV{'request.state'} ne "construct") {
       $trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} ';        $trystr = ' {\small \textit{Tries} '.$tries.'/'.$maxtries.'} \vskip 0 mm ';
   }    }
       } else {        } else {
          $trystr = "<td>Tries $tries/$maxtries</td>";           $trystr = "<td>Tries $tries/$maxtries</td>";

Removed from v.1.68  
changed lines
  Added in v.1.78


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