Diff for /loncom/homework/inputtags.pm between versions 1.170 and 1.200

version 1.170, 2005/06/28 21:41:08 version 1.200, 2006/07/14 18:12:16
Line 31  use strict; Line 31  use strict;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnet;  use Apache::lonnet;
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
    
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));      &Apache::lonxml::register('Apache::inputtags',('hiddenline','textfield','textline'));
 }  }
   
   #   Initializes a set of global variables used during the parse of the problem.
   #
   #  @Apache::inputtags::input        - List of current input ids.
   #  @Apache::inputtags::inputlist    - List of all input ids seen this problem.
   #  @Apache::inputtags::response     - List of all current resopnse ids.
   #  @Apache::inputtags::responselist - List of all response ids seen this 
   #                                       problem.
   #  @Apache::inputtags::hint         - List of all hint ids.
   #  @Apache::inputtags::hintlist     - List of all hint ids seen this problem.
   #  @Apache::inputtags::previous     - List describing if specific responseds
   #                                       have been used
   #  @Apache::inputtags::previous_version - Submission responses were used in.
   #  $Apache::inputtags::part         - Current part id (valid only in 
   #                                       <problem>)
   #                                     0 if not in a part.
   #  @Apache::inputtags::partlist     - List of part ids seen in the current
   #                                       <problem>
   #  @Apache::inputtags::status       - List of problem  statuses. First 
   #                                     element is the status of the <problem>
   #                                     the remainder are for individual <part>s.
   #  %Apache::inputtags::params       - Hash of defined parameters for the
   #                                     current response.
   #  @Apache::inputtags::import       - List of all ids for <import> thes get
   #                                     join()ed and prepended.
   #  @Apache::inputtags::importlist   - List of all import ids seen.
   #  $Apache::inputtags::response_with_no_part
   #                                   - Flag set true if we have seen a response
   #                                     that is not inside a <part>
   #  %Apache::inputtags::answertxt    - <*response> tags store correct
   #                                     answer strings for display by <textline/>
   #                                     in this hash.
   
 sub initialize_inputtags {  sub initialize_inputtags {
     # list of current input ids  
     @Apache::inputtags::input=();      @Apache::inputtags::input=();
     # list of all input ids seen in this problem  
     @Apache::inputtags::inputlist=();      @Apache::inputtags::inputlist=();
     # list of all current response ids  
     @Apache::inputtags::response=();      @Apache::inputtags::response=();
     # list of all response ids seen in this problem  
     @Apache::inputtags::responselist=();      @Apache::inputtags::responselist=();
     # list of whether or not a specific response was previously used      @Apache::inputtags::hint=();
       @Apache::inputtags::hintlist=();
     @Apache::inputtags::previous=();      @Apache::inputtags::previous=();
     # submission it was used in  
     @Apache::inputtags::previous_version=();      @Apache::inputtags::previous_version=();
     # id of current part, 0 means that no part is current   
     # (inside <problem> only  
     $Apache::inputtags::part='';      $Apache::inputtags::part='';
     # list of all part ids seen  
     @Apache::inputtags::partlist=();      @Apache::inputtags::partlist=();
     # list of problem date statuses, the first element is for <problem>  
     # if there is a second element it is for the current <part>  
     @Apache::inputtags::status=();      @Apache::inputtags::status=();
     # hash of defined params for the current response  
     %Apache::inputtags::params=();      %Apache::inputtags::params=();
     # list of all ids, for <import>, these get join()ed and prepended  
     @Apache::inputtags::import=();      @Apache::inputtags::import=();
     # list of all import ids seen  
     @Apache::inputtags::importlist=();      @Apache::inputtags::importlist=();
     # just used to note whether we have seen a response that isn't in a part  
     $Apache::inputtags::response_with_no_part=0;      $Apache::inputtags::response_with_no_part=0;
     # storage location so the begin <*response> tag can generate the correct  
     # answer string for display by the <textline />  
     %Apache::inputtags::answertxt=();      %Apache::inputtags::answertxt=();
 }  }
   
Line 75  sub check_for_duplicate_ids { Line 94  sub check_for_duplicate_ids {
     my %check;      my %check;
     foreach my $id (@Apache::inputtags::partlist,      foreach my $id (@Apache::inputtags::partlist,
     @Apache::inputtags::responselist,      @Apache::inputtags::responselist,
       @Apache::inputtags::hintlist,
     @Apache::inputtags::importlist) {      @Apache::inputtags::importlist) {
  $check{$id}++;   $check{$id}++;
     }      }
Line 114  sub addchars { Line 134  sub addchars {
 }  }
   
 sub start_textfield {  sub start_textfield {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result = "";      my $result = "";
     my $id = &start_input($parstack,$safeeval);      my $id = &start_input($parstack,$safeeval);
     my $resid=$Apache::inputtags::response[-1];      my $resid=$Apache::inputtags::response[-1];
Line 132  sub start_textfield { Line 152  sub start_textfield {
     if ($addchars) {      if ($addchars) {
  $result.=&addchars('HWVAL_'.$resid,$addchars);   $result.=&addchars('HWVAL_'.$resid,$addchars);
     }      }
     push @Apache::lonxml::htmlareafields,'HWVAL_'.$resid;      &Apache::lonhtmlcommon::add_htmlareafields('HWVAL_'.$resid);
     $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '.      $result.= '<textarea wrap="hard" name="HWVAL_'.$resid.'" id="HWVAL_'.$resid.'" '.
  "rows=\"$rows\" cols=\"$cols\">".$oldresponse;   "rows=\"$rows\" cols=\"$cols\">".$oldresponse;
     if ($oldresponse ne '') {      if ($oldresponse ne '') {
   
  #get rid of any startup text if the user has already responded   #get rid of any startup text if the user has already responded
  &Apache::lonxml::get_all_text("/textfield",$parser);   &Apache::lonxml::get_all_text("/textfield",$parser,$style);
     }      }
  } else {   } else {
     #right or wrong don't show it      #right or wrong don't show it
     #$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';      #$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';
     $result='';      $result='';
     #get rid of any startup text      #get rid of any startup text
     &Apache::lonxml::get_all_text("/textfield",$parser);      &Apache::lonxml::get_all_text("/textfield",$parser,$style);
  }   }
     } elsif ($target eq 'grade') {      } elsif ($target eq 'grade') {
  my $seedtext=&Apache::lonxml::get_all_text("/textfield",$parser);   my $seedtext=&Apache::lonxml::get_all_text("/textfield",$parser,
      $style);
  if ($seedtext eq $env{'form.HWVAL_'.$resid}) {   if ($seedtext eq $env{'form.HWVAL_'.$resid}) {
     # if the seed text is still there it wasn't a real submission      # if the seed text is still there it wasn't a real submission
     $env{'form.HWVAL_'.$resid}='';      $env{'form.HWVAL_'.$resid}='';
Line 159  sub start_textfield { Line 180  sub start_textfield {
  $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);   $result.=&Apache::edit::text_arg('Columns:','cols',$token,4);
  $result.=&Apache::edit::text_arg   $result.=&Apache::edit::text_arg
     ('Click-On Texts (comma sep):','addchars',$token,10);      ('Click-On Texts (comma sep):','addchars',$token,10);
  my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser);   my $bodytext=&Apache::lonxml::get_all_text("/textfield",$parser,
      $style);
  $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);   $result.=&Apache::edit::editfield($token->[1],$bodytext,'Text you want to appear by default:',80,2);
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my $constructtag=&Apache::edit::get_new_args($token,$parstack,   my $constructtag=&Apache::edit::get_new_args($token,$parstack,
Line 203  sub end_textfield { Line 225  sub end_textfield {
     return $result;      return $result;
 }  }
   
   sub exam_score_line {
       my ($target) = @_;
   
       my $result;
       if ($target eq 'tex') {
    my $repetition = &Apache::response::repetition();
    $result.='\begin{enumerate}';
    if ($env{'request.state'} eq "construct" ) {$result.='\item[\strut]';}
    foreach my $i (0..$repetition-1) {
       $result.='\item[\textbf{'.
    ($Apache::lonxml::counter+$i).
    '}.]\textit{Leave blank on scoring form}\vskip 0 mm';
    }
    $result.= '\end{enumerate}';
       }
   
       return $result;
   }
   
   sub exam_box {
       my ($target) = @_;
       my $result;
   
       if ($target eq 'tex') {
    $result .= '\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
    $result .= &exam_score_line($target);
       } elsif ($target eq 'web') {
    my $id=$Apache::inputtags::response[-1];
    $result.= '<br /><br />
                      <textarea name="HWVAL_'.$id.'" rows="4" cols="50">
                      </textarea> <br /><br />';
       }
       return $result;
   }
   
   sub needs_exam_box {
       my ($tagstack) = @_;
       my @tags = ('formularesponse',
    'stringresponse',
    'reactionresponse',
    'organicresponse',
    );
   
       foreach my $tag (@tags) {
    if (grep(/\Q$tag\E/,@$tagstack)) {
       return 1;
    }
       }
       return 0;
   }
   
 sub start_textline {  sub start_textline {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result = "";      my $result = "";
Line 210  sub start_textline { Line 283  sub start_textline {
  $Apache::lonxml::evaluate--;   $Apache::lonxml::evaluate--;
  my $partid=$Apache::inputtags::part;   my $partid=$Apache::inputtags::part;
  my $id=$Apache::inputtags::response[-1];   my $id=$Apache::inputtags::response[-1];
  if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {   if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER'
       || lc($Apache::lonhomework::problemstatus) eq 'no'
       || ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER' 
    && $Apache::lonhomework::history{"resource.$partid.solved"} !~ /^correct/ )) {
     my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);      my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
     my $maxlength;      my $maxlength;
     if ($size eq '') { $size=20; } else {      if ($size eq '') { $size=20; } else {
Line 225  sub start_textline { Line 301  sub start_textline {
  }   }
  my $readonly=&Apache::lonxml::get_param('readonly',$parstack,   my $readonly=&Apache::lonxml::get_param('readonly',$parstack,
  $safeeval);   $safeeval);
  if (lc($readonly) eq 'yes') {   if (lc($readonly) eq 'yes' 
       || $Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
     $readonly=' readonly="readonly" ';      $readonly=' readonly="readonly" ';
  } else {   } else {
     $readonly='';      $readonly='';
  }   }
  $result.= '<input type="text" '.$readonly.' name="HWVAL_'.$id.'" value="'.   my $name = 'HWVAL_'.$id;
    if ($Apache::inputtags::status[-1] eq 'CANNOT_ANSWER') {
       $name = "none";
    }
    $result.= '<input type="text" '.$readonly.' name="'.$name.'" value="'.
     $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';      $oldresponse.'" size="'.$size.'" maxlength="'.$maxlength.'" />';
     }      }
       if ($Apache::lonhomework::type eq 'exam'
    && &needs_exam_box($tagstack)) {
    $result.=&exam_box($target);
       }
  } 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='<b>'.$Apache::inputtags::answertxt{$id}.'</b>';      $result='<b>'.$Apache::inputtags::answertxt{$id}.'</b>';
Line 252  sub start_textline { Line 337  sub start_textline {
      $safeeval,'size',       $safeeval,'size',
      'addchars','readonly');       'addchars','readonly');
  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') {      } elsif ($target eq 'tex' 
        && $Apache::lonhomework::type ne 'exam') {
  my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);   my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
  if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}   if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
  $result='\framebox['.$size.'][s]{\tiny\strut}';   $result='\framebox['.$size.'][s]{\tiny\strut}';
   
       } elsif ($target eq 'tex' 
        && $Apache::lonhomework::type eq 'exam'
        && &needs_exam_box($tagstack)) {
    $result.=&exam_box($target);
     }      }
     return $result;      return $result;
 }  }
Line 285  sub start_hiddenline { Line 376  sub start_hiddenline {
  $result=&Apache::edit::tag_start($target,$token);   $result=&Apache::edit::tag_start($target,$token);
  $result.=&Apache::edit::end_table;   $result.=&Apache::edit::end_table;
     }      }
   
       if ( ($target eq 'web' || $target eq 'tex')
    && $Apache::lonhomework::type eq 'exam'
    && &needs_exam_box($tagstack)) {
    $result.=&exam_box($target);
       }
     return $result;      return $result;
 }  }
   
Line 301  sub end_hiddenline { Line 398  sub end_hiddenline {
 # $which -> 'uploadedonly'  -> only newly uploaded files  # $which -> 'uploadedonly'  -> only newly uploaded files
 #           'portfolioonly' -> only allow files from portfolio  #           'portfolioonly' -> only allow files from portfolio
 #           'both' -> allow files from either location  #           'both' -> allow files from either location
   # $extratext -> additional text to go between the link and the input box
 # returns a table row <tr>   # returns a table row <tr> 
 sub file_selector {  sub file_selector {
     my ($part,$id,$uploadedfiletypes,$which)=@_;      my ($part,$id,$uploadedfiletypes,$which,$extratext)=@_;
     if (!$uploadedfiletypes) { return ''; }      if (!$uploadedfiletypes) { return ''; }
   
     my $jspart=$part;      my $jspart=$part;
Line 324  sub file_selector { Line 422  sub file_selector {
   
  if ($uploadedfile) {   if ($uploadedfile) {
     my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};      my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
     push (@Apache::lonxml::extlinks,$url);      &Apache::lonxml::extlink($url);
     &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);      &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);
     my $icon=&Apache::loncommon::icon($url);      my $icon=&Apache::loncommon::icon($url);
     my $curfile='<a href="'.$url.'"><img src="'.$icon.      my $curfile='<a href="'.$url.'"><img src="'.$icon.
Line 338  sub file_selector { Line 436  sub file_selector {
  $result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';   $result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
     }      }
     if ($which eq 'portfolioonly' || $which eq 'both') {       if ($which eq 'portfolioonly' || $which eq 'both') { 
  $result.='<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"))'."'".'>'.   $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"))'."'".'>'.
     &mt('Select Portfolio Files').'</a><br />'.      &mt('Select Portfolio Files').'</a><br />'.
     '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.      '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
     '<br />';      '<br />';
  if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){   if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
     my @filelist;      my (@file_list,@bad_file_list);
     foreach my $file (split(',',&Apache::lonnet::unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {      foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
  my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();   my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
  my $url="/uploaded/$domain/$user/portfolio$file";   my $url="/uploaded/$domain/$user/portfolio$file";
  my $icon=&Apache::loncommon::icon($url);   my $icon=&Apache::loncommon::icon($url);
  push(@filelist,'<a href="'.$url.'"><img src="'.$icon.   push(@file_list,'<a href="'.$url.'"><img src="'.$icon.
      '" border="0" />'.$file.'</a>');       '" border="0" />'.$file.'</a>');
    if (! &Apache::lonnet::stat_file($url)) {
       &Apache::lonnet::logthis("bad file is $url");
       push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon.
    '" border="0" />'.$file.'</a>');
    }
       }
       my $files = '<span class="LC_filename">'.
    join('</span>, <span class="LC_filename">',@file_list).
    '</span>';
       $result.=&mt("Portfolio files previously selected: [_1]",$files);
       if (@bad_file_list) {
    my $bad_files = '<span class="LC_filename">'.
       join('</span>, <span class="LC_filename">',@bad_file_list).
       '</span>';
    $result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files);
     }      }
     $result.=&mt("Portfolio files previously selected: <strong>[_1]</strong>",join(', ',@filelist));  
  }   }
     }      }
     $result.='</td></tr>';       $result.='</td></tr>'; 
Line 368  sub checkstatus { Line 480  sub checkstatus {
     return(undef,undef);      return(undef,undef);
 }  }
   
   sub valid_award {
       my ($award) =@_;
       foreach my $possibleaward ('EXTRA_ANSWER','MISSING_ANSWER', 'ERROR',
          'NO_RESPONSE',
          'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR',
          'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE',
          'UNIT_FAIL', 'NO_UNIT',
          'UNIT_NOTNEEDED', 'WANTED_NUMERIC',
          'BAD_FORMULA', 'SIG_FAIL', 'INCORRECT', 
          'MISORDERED_RANK', 'INVALID_FILETYPE',
          'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE',
          'APPROX_ANS', 'EXACT_ANS','COMMA_FAIL') {
    if ($award eq $possibleaward) { return 1; }
       }
       return 0;
   }
   
 sub finalizeawards {  sub finalizeawards {
     my ($awardref,$msgref)=@_;      my ($awardref,$msgref,$nameref,$reverse)=@_;
     my $result=undef;      my $result=undef;
     my $award;      my $award;
     my $msg;      my $msg;
Line 385  sub finalizeawards { Line 514  sub finalizeawards {
  if ($blankcount == ($#$awardref + 1)) { $result = 'NO_RESPONSE'; }   if ($blankcount == ($#$awardref + 1)) { $result = 'NO_RESPONSE'; }
     }      }
     if (defined($result)) { return ($result,$msg); }      if (defined($result)) { return ($result,$msg); }
     foreach my $possibleaward ('MISSING_ANSWER', 'ERROR', 'NO_RESPONSE',  
        'TOO_LONG', 'UNIT_INVALID_INSTRUCTOR',      # these awards are ordered from most important error through best correct
        'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE',      
        'UNIT_FAIL', 'NO_UNIT',      my @awards = ('EXTRA_ANSWER', 'MISSING_ANSWER', 'ERROR', 'NO_RESPONSE',
        'UNIT_NOTNEEDED', 'WANTED_NUMERIC',    'TOO_LONG',
        'BAD_FORMULA', 'SIG_FAIL', 'INCORRECT',     'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT',
        'MISORDERED_RANK', 'INVALID_FILETYPE',    'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT',
        'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE',    'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA',
        'APPROX_ANS', 'EXACT_ANS','COMMA_FAIL') {    'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK',
     'INVALID_FILETYPE', 'DRAFT', 'SUBMITTED', 'ASSIGNED_SCORE',
     'APPROX_ANS', 'EXACT_ANS');
       if ($reverse) { @awards=reverse(@awards); }
       foreach my $possibleaward (@awards) {
  ($result,$msg)=&checkstatus($possibleaward,$awardref,$msgref);   ($result,$msg)=&checkstatus($possibleaward,$awardref,$msgref);
  if (defined($result)) { return ($result,$msg); }   if (defined($result)) { return ($result,$msg); }
     }      }
Line 414  sub decideoutput { Line 547  sub decideoutput {
   'no_message' => '#fffff',    'no_message' => '#fffff',
   );    );
   
       my $part = $Apache::inputtags::part;
       my $handgrade = 
    ('yes' eq lc(&Apache::lonnet::EXT("resource.$part.handgrade")));
       
       my $computer = ($handgrade)? ''
                          : " ".&mt("Computer's answer now shown above.");
       &Apache::lonxml::debug("handgrade has :$handgrade:");
   
     if ($previous) { $previousmsg=&mt('You have entered that answer before'); }      if ($previous) { $previousmsg=&mt('You have entered that answer before'); }
           
     if      ($solved =~ /^correct/) {      if ($solved =~ /^correct/) {
  $bgcolor=$possiblecolors{'correct'};          $bgcolor=$possiblecolors{'correct'};
  $message=&mt('You are correct.');   $message=&mt('You are correct.');
  if ($awarded < 1 && $awarded > 0) {   if ($awarded < 1 && $awarded > 0) {
     $message=&mt('You are partially correct.');      $message=&mt('You are partially correct.');
Line 426  sub decideoutput { Line 567  sub decideoutput {
     $message=&mt('Incorrect.');      $message=&mt('Incorrect.');
     $bgcolor=$possiblecolors{'charged_try'};      $bgcolor=$possiblecolors{'charged_try'};
  }   }
  if ($award eq 'ASSIGNED_SCORE') {   if ($env{'request.filename'} =~ 
       m|/res/lib/templates/examupload.problem$|) {
     $message = &mt("A score has been assigned.");      $message = &mt("A score has been assigned.");
       $added_computer_text=1;
  } else {   } else {
     if ($target eq 'tex') {      if ($target eq 'tex') {
  $message = '\textbf{'.$message.'}';   $message = '\textbf{'.$message.'}';
     } else {      } else {
  $message = "<b>".$message."</b>";   $message = "<b>".$message."</b>";
  $message.=" ".&mt("Computer's answer now shown above.");   $message.= $computer;
     }      }
     $added_computer_text=1;      $added_computer_text=1;
     unless ($env{'course.'.      unless ($env{'course.'.
Line 465  sub decideoutput { Line 608  sub decideoutput {
  $message = '\textbf{'.&mt('You are correct.').'}';   $message = '\textbf{'.&mt('You are correct.').'}';
     } else {      } else {
  $message = "<b>".&mt('You are correct.')."</b>";   $message = "<b>".&mt('You are correct.')."</b>";
  $message.=" ".&mt("Computer's answer now shown above.");   $message.= $computer;
     }      }
     $added_computer_text=1;      $added_computer_text=1;
     unless ($env{'course.'.      unless ($env{'course.'.
Line 483  sub decideoutput { Line 626  sub decideoutput {
  $message = '';   $message = '';
  $bgcolor=$possiblecolors{'no_feedback'};   $bgcolor=$possiblecolors{'no_feedback'};
  $button=1;   $button=1;
       } elsif ($award eq 'EXTRA_ANSWER') {
    $message = &mt('Some extra items were submitted.');
    $bgcolor=$possiblecolors{'not_charged_try'};
    $button = 1;
     } elsif ($award eq 'MISSING_ANSWER') {      } elsif ($award eq 'MISSING_ANSWER') {
  $message = &mt('Some items were not submitted.');   $message = &mt('Some items were not submitted.');
  $bgcolor=$possiblecolors{'not_charged_try'};   $bgcolor=$possiblecolors{'not_charged_try'};
Line 567  sub decideoutput { Line 714  sub decideoutput {
  $bgcolor=$possiblecolors{'correct'};   $bgcolor=$possiblecolors{'correct'};
  $button=0;   $button=0;
     } elsif ($award eq '') {      } elsif ($award eq '') {
  $bgcolor=$possiblecolors{'not_charged_try'};   if ($handgrade && $Apache::inputtags::status[-1] eq 'SHOW_ANSWER') {
       $message = &mt("Nothing submitted.");
       $bgcolor=$possiblecolors{'charged_try'};
    } else {
       $bgcolor=$possiblecolors{'not_charged_try'};
    }
  $button=1;   $button=1;
     } else {      } else {
  $message = &mt("Unknown message").": $award";   $message = &mt("Unknown message").": $award";
  $button=1;   $button=1;
     }      }
       my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
       foreach my $resid(@Apache::inputtags::response){
           if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) {
       $message.='<br />';
       my @files = split(/\s*,\s*/,
         $Apache::lonhomework::history{"resource.$part.$resid.handback"});
       my $file_msg;
       foreach my $file (@files) {
    $file_msg.= '<br /><a href="/uploaded/'."$domain/$user".'/'.$file.'">'.$file.'</a>';
       }
       $message .= &mt('Returned file(s): [_1]',$file_msg);
    }
       }
   
     if (lc($Apache::lonhomework::problemstatus) eq 'no'  &&       if (lc($Apache::lonhomework::problemstatus) eq 'no'  && 
  $Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {   $Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {
  $message = &mt("Answer Submitted: Your final submission will be graded after the due date.");   $message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
Line 581  sub decideoutput { Line 747  sub decideoutput {
     }      }
     if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' &&       if ($Apache::inputtags::status[-1] eq 'SHOW_ANSWER' && 
  !$added_computer_text && $target ne 'tex') {   !$added_computer_text && $target ne 'tex') {
  $message.=" ".&mt("Computer's answer now shown above.");   $message.= $computer;
  $added_computer_text=1;   $added_computer_text=1;
     }      }
     return ($button,$bgcolor,$message,$previousmsg);      return ($button,$bgcolor,$message,$previousmsg);
Line 737  sub setgradedata { Line 903  sub setgradedata {
  return '';   return '';
     }      }
     $Apache::lonhomework::results{"resource.$id.award"} = $award;      $Apache::lonhomework::results{"resource.$id.award"} = $award;
       if ($award eq 'SUBMITTED') {
    &Apache::response::add_to_gradingqueue();
       }
 }  }
   
 sub grade {  sub grade {
Line 793  sub gradestatus { Line 962  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' && $status ne 'UNAVAILABLE' &&      if ( $status ne 'CLOSED' 
  $status ne 'INVALID_ACCESS') {     && $status ne 'UNAVAILABLE' 
    && $status ne 'INVALID_ACCESS' 
    && $status ne 'NEEDS_CHECKIN' 
    && $status ne 'NOT_IN_A_SLOT') {  
  my $award = $Apache::lonhomework::history{"resource.$id.award"};   my $award = $Apache::lonhomework::history{"resource.$id.award"};
  my $awarded = $Apache::lonhomework::history{"resource.$id.awarded"};   my $awarded = $Apache::lonhomework::history{"resource.$id.awarded"};
  my $solved = $Apache::lonhomework::history{"resource.$id.solved"};   my $solved = $Apache::lonhomework::history{"resource.$id.solved"};

Removed from v.1.170  
changed lines
  Added in v.1.200


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