Diff for /loncom/homework/bridgetask.pm between versions 1.102 and 1.105

version 1.102, 2006/02/08 22:04:34 version 1.105, 2006/02/09 22:34:35
Line 198  sub add_grading_button { Line 198  sub add_grading_button {
  $result.='<p>'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);   $result.='<p>'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
  $result.=' <input type="submit" name="reviewasubmission" value="'.   $result.=' <input type="submit" name="reviewasubmission" value="'.
     &mt("Select an entry from the review queue").'" /> </p>'."\n";      &mt("Select an entry from the review queue").'" /> </p>'."\n";
  $result.=' <input type="submit" name="regradeasubmission" value="'.   $result.='<p> <input type="submit" name="regradeasubmission" value="'.
     &mt("Select a user to regrade.").'" /> </p>'."\n";      &mt("Select a user to regrade.").'" /> </p>'."\n";
     }   $result.='<p> <input type="submit" name="regradeaspecificsubmission" value="'.
       &mt("Regrade user:").'" />'."\n";
    $result.='<input type="text" size="12" name="gradinguser" />';
    $result.=&Apache::loncommon::select_dom_form($env{'user.domain'},
        'gradingdomain');
    $result.=' '.
       &Apache::loncommon::selectstudent_link('gradesubmission',
      'gradinguser',
      'gradingdomain');
    $result.=&Apache::loncommon::studentbrowser_javascript();
     }
     return $result;      return $result;
 }  }
   
Line 515  DONESCREEN Line 525  DONESCREEN
         #       Hrrm, vaildation pass should perhaps say 'not_locked'          #       Hrrm, vaildation pass should perhaps say 'not_locked'
         #       perhaps do a search if there is a key that is mine and if          #       perhaps do a search if there is a key that is mine and if
         #       there isn't reshow the queue....          #       there isn't reshow the queue....
  my ($todo,$status_code)=&get_key_todo($target);   my ($todo,$status_code,$msg)=&get_key_todo($target);
   
  if ($todo) {   if ($todo) {
     &setup_env_for_other_user($todo,$safeeval);      &setup_env_for_other_user($todo,$safeeval);
Line 544  DONESCREEN Line 554  DONESCREEN
  if      ($status_code eq 'stop') {   if      ($status_code eq 'stop') {
     $result.='<b>'.&mt("Stopped grading.").'</b>'.$back;      $result.='<b>'.&mt("Stopped grading.").'</b>'.$back;
  } elsif ($status_code eq 'lock_failed') {   } elsif ($status_code eq 'lock_failed') {
     $result.='<b>'.&mt("Failed to lock the request record.")      $result.='<b>'.&mt("Failed to lock the requested record.")
  .'</b>'.$back;   .'</b>'.$back;
  } elsif ($status_code eq 'unlock') {   } elsif ($status_code eq 'unlock') {
     $result.='<b>'.&mt("Unlocked the requested record.")      $result.='<b>'.&mt("Unlocked the requested record.")
Line 556  DONESCREEN Line 566  DONESCREEN
     $result.=&select_user();      $result.=&select_user();
  } elsif ($status_code eq 'unable') {   } elsif ($status_code eq 'unable') {
     $result.='<b>'.&mt("Unable to aqcuire a user to grade.").'</b>'.$back;      $result.='<b>'.&mt("Unable to aqcuire a user to grade.").'</b>'.$back;
    } elsif ($status_code eq 'not_allowed') {
       $result.='<b>'.&mt('Not allowed to grade the requested user.').' '.$msg.'</b>'.$back;
  } else {   } else {
     $result.='<b>'.&mt("No user to be graded.").'</b>'.$back;      $result.='<b>'.&mt("No user to be graded.").'</b>'.$back;
  }   }
Line 622  sub get_key_todo { Line 634  sub get_key_todo {
  return (undef,'select_user');   return (undef,'select_user');
     }      }
   
   
       my $me=$env{'user.name'}.'@'.$env{'user.domain'};
   
       #need to try both queues..
       if (defined($env{'form.regradeaspecificsubmission'}) &&
    defined($env{'form.gradinguser'})               &&
    defined($env{'form.gradingdomain'})               ) {
    my ($symb,$cid)=&Apache::lonxml::whichuser();
    my $cnum  = $env{'course.'.$cid.'.num'};
    my $cdom  = $env{'course.'.$cid.'.domain'};
    my $uname = $env{'form.gradinguser'};
    my $udom  = $env{'form.gradingdomain'};
   
    my $gradingkey=&encode_queue_key($symb,$udom,$uname);
   
    my $queue;
   
    if      (&in_queue('gradingqueue',$symb,$cdom,$cnum,$udom,$uname)) {
       $env{'form.queue'} = $queue = 'gradingqueue';
    } elsif (&in_queue('reviewqueue' ,$symb,$cdom,$cnum,$udom,$uname)) {
       $env{'form.queue'} = $queue = 'reviewqueue';
    }
   
    if (!$queue) {
       $env{'form.queue'} = $queue = 'none';
       #not queued so doing either a re or pre grade
       return ($gradingkey);
    }
   
    my $who=&queue_key_locked($queue,$gradingkey);
    if ($who eq $me) {
       #already have the lock
       $env{'form.gradingkey'}=&Apache::lonnet::escape($gradingkey);
       return ($gradingkey);
    }
   
    if (!defined($who)) {
       if (&lock_key($queue,$gradingkey)) {
    return ($gradingkey);
       } else {
    return (undef,'lock_failed');
       }
    }
   
    #otherwise (defined($who) && $who ne $me) some else has it...
    return (undef,'not_allowed',
    &mt('Another user ([_1]) currently has the record for [_2] locked.',
       $who,$env{'form.gradinguser'}.'@'.$env{'form.gradingdomain'}));
       }
   
   
     my $queue=$env{'form.queue'};      my $queue=$env{'form.queue'};
   
     if (!defined($queue)) {      if (!defined($queue)) {
Line 649  sub get_key_todo { Line 712  sub get_key_todo {
  && $env{'form.queuemode'} eq 'selected') {   && $env{'form.queuemode'} eq 'selected') {
   
  my $who=&queue_key_locked($queue,$gradingkey);   my $who=&queue_key_locked($queue,$gradingkey);
  my $me=$env{'user.name'}.'@'.$env{'user.domain'};  
  if ($who eq $me) {   if ($who eq $me) {
     &Apache::lonxml::debug("Found a key was given to me");      &Apache::lonxml::debug("Found a key was given to me");
     return ($gradingkey,'selected');      return ($gradingkey,'selected');
Line 1101  sub show_queue { Line 1163  sub show_queue {
     if ($tmp=~/^error: 2 /) {      if ($tmp=~/^error: 2 /) {
  return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";   return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
     }      }
     $result.="\n<h3>Current Queue - $symb $queue </h3><table border='1'><tr>";      my $title=&Apache::lonnet::gettitle($symb);
     if ($with_selects) { $result.="<th></th>"; }      $result.="\n<h3>Current Queue - $title $queue </h3><table border='1'><tr>";
     $result.="<th>resource</th><th>user</th><th>type</th><th>data</th></tr>";      if ($with_selects) { $result.="<th>Status</th><th></th>"; }
       $result.="<th>user</th><th>data</th></tr>";
     foreach my $key (sort(keys(%queue))) {      foreach my $key (sort(keys(%queue))) {
  my ($symb,$uname,$udom) = &decode_queue_key($key);   my ($symb,$uname,$udom) = &decode_queue_key($key);
  if (!defined($classlist->{$uname.':'.$udom})) { next; }   if (!defined($classlist->{$uname.':'.$udom})) { next; }
  if ($key=~/locked$/ && !$with_selects) {   if ($key=~/locked$/ && !$with_selects) {
     my $title=&Apache::lonnet::gettitle($symb);      $result.="<tr><td>$uname</td>";
     $result.="<tr><td>$title</td><td>$uname</td>";      $result.='<td>'.$queue{$key}.'</td></tr>';
     $result.='<td>lock</td><td>'.$queue{$key}.'</td></tr>';  
  } elsif ($key=~/timestamp$/ && !$with_selects) {   } elsif ($key=~/timestamp$/ && !$with_selects) {
     my ($symb,undef) = split("\0",$key);      $result.="<tr><td></td>";
     my $title=&Apache::lonnet::gettitle($symb);      $result.='<td>'.
     $result.="<tr><td>$title</td><td></td>";  
     $result.='<td>last queue modification time</td><td>'.  
  &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";   &Apache::lonlocal::locallocaltime($queue{$key})."</td></tr>";
  } elsif ($key!~/(timestamp|locked)$/) {   } elsif ($key!~/(timestamp|locked)$/) {
     my $title=&Apache::lonnet::gettitle($symb);  
     $result.="<tr>";      $result.="<tr>";
     my $slot=$queue{$key}->[0];      my $slot=$queue{$key}->[0];
     my %slot_data=&Apache::lonnet::get_slot($slot);      my %slot_data=&Apache::lonnet::get_slot($slot);
     if ($with_selects) {      if ($with_selects) {
  my $ekey=&Apache::lonnet::escape($key);   my $ekey=&Apache::lonnet::escape($key);
  my ($action,$description)=('select',&mt('Select'));   my ($action,$description,$status)=('select',&mt('Select'));
  if (exists($queue{"$key\0locked"})) {   if (exists($queue{"$key\0locked"})) {
     my $me=$env{'user.name'}.'@'.$env{'user.domain'};      my $me=$env{'user.name'}.'@'.$env{'user.domain'};
       $status=&mt('Locked by <tt>[_1]</tt>',$queue{"$key\0locked"});
     if ($me eq $queue{"$key\0locked"}) {      if ($me eq $queue{"$key\0locked"}) {
  ($action,$description)=('resume',&mt('Resume'));   ($action,$description)=('resume',&mt('Resume'));
     } else {      } else {
Line 1140  sub show_queue { Line 1200  sub show_queue {
  }   }
  if (time > $slot_data{'endtime'}) {   if (time > $slot_data{'endtime'}) {
     $result.=(<<FORM);      $result.=(<<FORM);
   <td>$status</td>
 <td>  <td>
 <form method="POST">  <form style="display: inline" method="POST">
  <input type="hidden" name="gradingkey" value="$ekey" />   <input type="hidden" name="gradingkey" value="$ekey" />
  <input type="hidden" name="queue" value="$queue" />   <input type="hidden" name="queue" value="$queue" />
  <input type="hidden" name="gradingaction" value="$action" />   <input type="hidden" name="gradingaction" value="$action" />
Line 1157  FORM Line 1218  FORM
     $result.='<td>'.&mt("In Progress").'</td>'      $result.='<td>'.&mt("In Progress").'</td>'
  }   }
     }      }
     $result.="<td>$title</td><td>$uname</td>";      $result.= "<td>".$fullname->{$uname.':'.$udom}.
     $result.='<td>queue entry</td><td>Slot: '.$slot.' End time: '.   " <tt>($uname\@$udom)</tt> </td>";
       $result.='<td>Slot: '.$slot.' End time: '.
  &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).   &Apache::lonlocal::locallocaltime($slot_data{'endtime'}).
  "</td></tr>";   "</td></tr>";
  }   }

Removed from v.1.102  
changed lines
  Added in v.1.105


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