Diff for /loncom/homework/bridgetask.pm between versions 1.160 and 1.163

version 1.160, 2006/06/01 19:22:29 version 1.163, 2006/06/09 22:31:36
Line 43  use LONCAPA; Line 43  use LONCAPA;
     
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Instance','InstanceText','Criteria','ClosingParagraph'));      &Apache::lonxml::register('Apache::bridgetask',('Task','IntroParagraph','Dimension','Question','QuestionText','Setup','Instance','InstanceText','Criteria','ClosingParagraph'));
 }  }
   
 sub initialize_bridgetask {  sub initialize_bridgetask {
Line 365  sub file_list { Line 365  sub file_list {
  my $file=$file_url.$partial_file;   my $file=$file_url.$partial_file;
  $file=~s|/+|/|g;   $file=~s|/+|/|g;
  &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);   &Apache::lonnet::allowuploaded('/adm/bridgetask',$file);
  $file_list.='<li><nobr><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.   $file_list.='<li><span style="white-space: nowrap;"><a href="'.$file.'?rawmode=1" target="lonGRDs"><img src="'.
     &Apache::loncommon::icon($file).'" border="0"> '.$file.      &Apache::loncommon::icon($file).'" alt="file icon" border="0" /> '.$file.
     '</a></nobr></li>'."\n";      '</a></span></li>'."\n";
     }      }
     $file_list.="</ul>\n";      $file_list.="</ul>\n";
     return $file_list;      return $file_list;
 }  }
   
   sub grade_mode {
       if ($env{'form.regrade'} || $env{'form.regradeaspecificsubmission'}) {
    return 'regrade';
       }
       return 'queue_grade';
   }
   
 sub webgrade_standard_info {  sub webgrade_standard_info {
     my ($version)=&get_version();      my ($version)=&get_version();
   
     my $file_list = &file_list($Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"});      my $file_list = &file_list($Apache::lonhomework::history{"resource.$version.0.bridgetask.portfiles"});
   
     my %lt=&Apache::lonlocal::texthash('done' => 'Next Item',      my %lt=('done'   => 'Next Item',
        'stop' => 'Quit Grading',      'stop'   => 'Quit Grading',
        'fail' => 'Fail Rest',      'fail'   => 'Fail Rest',
        );      'cancel' => 'Cancel',
              );
       my %lt=&Apache::lonlocal::texthash(%lt);
   
     my $result=<<INFO;      my $result=<<INFO;
   <div class="LC_GRADING_maincontrols">    <div class="LC_GRADING_maincontrols">
   INFO
   
       if (&grade_mode() eq 'regrade') {
    $result.=<<INFO;
       <input type="submit" name="cancel" value="$lt{'cancel'}" />
   INFO
       }
   
       $result.=<<INFO;
     <input type="submit" name="next" value="$lt{'done'}" />      <input type="submit" name="next" value="$lt{'done'}" />
     <input type="submit" name="stop" value="$lt{'stop'}" />      <input type="submit" name="stop" value="$lt{'stop'}" />
     <input type="button" name="fail" value="$lt{'fail'}"       <input type="button" name="fail" value="$lt{'fail'}" 
Line 455  sub start_Task { Line 473  sub start_Task {
     if ($target eq 'web' && $env{'request.state'} eq 'construct') {      if ($target eq 'web' && $env{'request.state'} eq 'construct') {
  $form_tag_start.=&Apache::structuretags::problem_web_to_edit_header($env{'form.rndseed'});   $form_tag_start.=&Apache::structuretags::problem_web_to_edit_header($env{'form.rndseed'});
     }      }
     if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||      if ($target eq 'web' 
  $target eq 'tex') {   || ($target eq 'grade' && !$env{'form.webgrade'}) 
    || $target eq 'answer' 
    || $target eq 'tex') {
  my ($version,$previous)=&get_version();   my ($version,$previous)=&get_version();
  ($status,$accessmsg,my $slot_name,$slot) =    ($status,$accessmsg,my $slot_name,$slot) = 
     &Apache::lonhomework::check_slot_access('0','Task');      &Apache::lonhomework::check_slot_access('0','Task');
Line 592  DONESCREEN Line 612  DONESCREEN
     &mt('Return to resource').'</a></p>';      &mt('Return to resource').'</a></p>';
  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 'cancel') {
       $result.='<b>'.&mt("Cancelled grading.").'</b>'.$back;
  } elsif ($status_code eq 'lock_failed') {   } elsif ($status_code eq 'lock_failed') {
     $result.='<b>'.&mt("Failed to lock the requested record.")      $result.='<b>'.&mt("Failed to lock the requested record.")
  .'</b>'.$back;   .'</b>'.$back;
Line 612  DONESCREEN Line 634  DONESCREEN
  }   }
     }      }
     $webgrade='no';      $webgrade='no';
    }
    if (!$todo || $env{'form.cancel'}) {
     my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);      my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
  }   }
  if ($target eq 'webgrade' && defined($env{'form.queue'})) {   if ($target eq 'webgrade' && defined($env{'form.queue'})) {
Line 702  sub get_key_todo { Line 726  sub get_key_todo {
  if (!$queue) {   if (!$queue) {
     $env{'form.queue'} = $queue = 'none';      $env{'form.queue'} = $queue = 'none';
     #not queued so doing either a re or pre grade      #not queued so doing either a re or pre grade
       #FIXME don't allow pregrade
       &Apache::lonxml::debug("not in queue no lock");
     return ($gradingkey);      return ($gradingkey);
  }   }
   
Line 709  sub get_key_todo { Line 735  sub get_key_todo {
  if ($who eq $me) {   if ($who eq $me) {
     #already have the lock      #already have the lock
     $env{'form.gradingkey'}=&escape($gradingkey);      $env{'form.gradingkey'}=&escape($gradingkey);
       &Apache::lonxml::debug("already locked");
     return ($gradingkey);      return ($gradingkey);
  }   }
   
  if (!defined($who)) {   if (!defined($who)) {
     if (&lock_key($queue,$gradingkey)) {      if (&lock_key($queue,$gradingkey)) {
    &Apache::lonxml::debug("newly locked");
  return ($gradingkey);   return ($gradingkey);
     } else {      } else {
  return (undef,'lock_failed');   return (undef,'lock_failed');
Line 740  sub get_key_todo { Line 768  sub get_key_todo {
     if ($target eq 'webgrade') {      if ($target eq 'webgrade') {
  if ($env{'form.stop'}) {   if ($env{'form.stop'}) {
     return (undef,'stop');      return (undef,'stop');
    } elsif ($env{'form.cancel'}) {
       return (undef,'cancel');
  } elsif ($env{'form.next'}) {   } elsif ($env{'form.next'}) {
     return (undef,'select_user');      return (undef,'select_user');
  }   }
Line 785  sub get_key_todo { Line 815  sub get_key_todo {
   
     if ($env{'form.queuemode'} ne 'selected') {      if ($env{'form.queuemode'} ne 'selected') {
  # don't get something new from the queue if they hit the stop button   # don't get something new from the queue if they hit the stop button
     if (!($env{'form.stop'} && $target eq 'webgrade')       if (!(($env{'form.cancel'} || $env{'form.stop'}) 
         && $target eq 'webgrade') 
     && !$env{'form.gradingaction'}) {      && !$env{'form.gradingaction'}) {
     &Apache::lonxml::debug("Getting anew $queue");      &Apache::lonxml::debug("Getting anew $queue");
     return (&get_from_queue($queue));      return (&get_from_queue($queue));
Line 937  DONEBUTTON Line 968  DONEBUTTON
  } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {   } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
     &Apache::structuretags::finalize_storage();      &Apache::structuretags::finalize_storage();
  }   }
  if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {   if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes' 
       && exists($env{'form.cancel'})) {
       &check_queue_unlock($env{'form.queue'});
       &Apache::lonxml::debug(" cancelled grading .".$env{'form.queue'});
    } elsif ($target eq 'grade' && $env{'form.webgrade'} eq 'yes' 
    && !exists($env{'form.cancel'})) {
     my $optional_required=      my $optional_required=
  &Apache::lonxml::get_param('OptionalRequired',$parstack,   &Apache::lonxml::get_param('OptionalRequired',$parstack,
    $safeeval);     $safeeval);
Line 1091  sub check_queue_unlock { Line 1127  sub check_queue_unlock {
     my $me=$env{'user.name'}.':'.$env{'user.domain'};      my $me=$env{'user.name'}.':'.$env{'user.domain'};
     my $who=&queue_key_locked($queue,$key,$cdom,$cnum);      my $who=&queue_key_locked($queue,$key,$cdom,$cnum);
     if  ($who eq $me) {      if  ($who eq $me) {
    &Apache::lonxml::debug("unlocking my own $who");
  return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);   return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
     } elsif ($allow_not_me) {      } elsif ($allow_not_me) {
  &Apache::lonxml::debug("unlocking $who by $me");   &Apache::lonxml::debug("unlocking $who by $me");
Line 1791  sub get_id { Line 1828  sub get_id {
 }  }
   
 my %dimension;  my %dimension;
   sub start_Setup {
       my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
       undef(%dimension);
       my $dim_id=&get_id($parstack,$safeeval);
       $Apache::bridgetask::dimension=$dim_id;
       undef(@Apache::bridgetask::instance);
       &Apache::lonxml::startredirection();
       return &internal_location($dim_id);
   }
 sub start_Question { return &start_Dimension(@_); }  sub start_Question { return &start_Dimension(@_); }
 sub start_Dimension {  sub start_Dimension {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
Line 2057  sub get_instance { Line 2103  sub get_instance {
  } else {   } else {
     # any other targets no output      # any other targets no output
     undef($result);      undef($result);
    }
    return $result;
       }
   
       sub end_Setup {
    my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
    my $result=&Apache::lonxml::endredirection();
    my $dim=&get_id($parstack,$safeeval);
    my $instance=&get_instance($dim);
    my $version=&get_version();
    if ($target eq 'web') {
       @Apache::scripttag::parser_env = @_;
       $result.=&Apache::scripttag::xmlparse($dimension{'intro'});
       my @instances = $instance;
       if (&Apache::response::showallfoils()) {
    @instances = @{$dimension{'instances'}};
       }
       foreach my $instance (@instances) {
    @Apache::scripttag::parser_env = @_;
    $result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
    @Apache::scripttag::parser_env = @_;
    $result.=&Apache::scripttag::xmlparse($dimension{'questiontext'});
       }
    } elsif ($target eq 'webgrade' 
    || $target eq 'grade' && $env{'form.webgrade'}) {
       # in case of any side effects that we need
       @Apache::scripttag::parser_env = @_;
       &Apache::scripttag::xmlparse($dimension{'intro'});
       @Apache::scripttag::parser_env = @_;
       &Apache::scripttag::xmlparse($dimension{$instance.'.text'});
       @Apache::scripttag::parser_env = @_;
       &Apache::scripttag::xmlparse($dimension{'questiontext'});
    } else {
       # any other targets no output
       undef($result);
  }   }
  return $result;   return $result;
     }      }

Removed from v.1.160  
changed lines
  Added in v.1.163


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