Diff for /loncom/homework/lonhomework.pm between versions 1.223 and 1.236

version 1.223, 2005/11/15 18:23:17 version 1.236, 2006/02/26 20:01:17
Line 166  sub send_footer { Line 166  sub send_footer {
 }  }
   
 sub proctor_checked_in {  sub proctor_checked_in {
     my ($slot_name,$slot)=@_;      my ($slot_name,$slot,$type)=@_;
     my @allowed=split(",",$slot->{'proctor'});      my @possible_proctors=split(",",$slot->{'proctor'});
     my $version=$Apache::lonhomework::history{'resource.version'};      
     foreach my $possible (@allowed) {       my $key;
  if ($Apache::lonhomework::history{"resource.$version.checkedin"} eq      if ($type eq 'Task') {
     $possible &&   my $version=$Apache::lonhomework::history{'resource.0.version'};
     $Apache::lonhomework::history{"resource.$version.checkedin.slot"}   $key ="resource.$version.0.checkedin";
        eq $slot_name) {      } elsif ($type eq 'problem') {
    $key ='resource.0.checkedin';
       }
       
       foreach my $possible (@possible_proctors) { 
    if ($Apache::lonhomework::history{$key} eq $possible
       && $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) {
     return 1;      return 1;
  }   }
     }      }
       
     return 0;      return 0;
 }  }
   
Line 191  sub check_ip_acc { Line 198  sub check_ip_acc {
     my $ip=$ENV{'REMOTE_ADDR'};      my $ip=$ENV{'REMOTE_ADDR'};
     my $name;      my $name;
     foreach my $pattern (split(',',$acc)) {      foreach my $pattern (split(',',$acc)) {
    $pattern =~ s/^\s*//;
    $pattern =~ s/\s*$//;
  if ($pattern =~ /\*$/) {   if ($pattern =~ /\*$/) {
     #35.8.*      #35.8.*
     $pattern=~s/\*//;      $pattern=~s/\*//;
Line 230  sub check_ip_acc { Line 239  sub check_ip_acc {
     return $allowed;      return $allowed;
 }  }
   
 sub check_task_access {  sub check_slot_access {
       my ($id,$type)=@_;
   
     # does it pass normal muster      # does it pass normal muster
     # yes we really do want the default args passing      my ($status,$datemsg)=&check_access($id);
     my ($status,$datemsg)=&check_access;      
       my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");
       if ($useslots ne 'resource') {
    return ($status,$datemsg);
       }
   
     if ($status eq 'SHOW_ANSWER' ||      if ($status eq 'SHOW_ANSWER' ||
  $status eq 'CLOSED' ||   $status eq 'CLOSED' ||
  $status eq 'CANNOT_ANSWER' ||  
  $status eq 'INVALID_ACCESS' ||   $status eq 'INVALID_ACCESS' ||
  $status eq 'UNAVAILABLE') {   $status eq 'UNAVAILABLE') {
  return ($status,$datemsg);   return ($status,$datemsg);
Line 244  sub check_task_access { Line 259  sub check_task_access {
     if ($env{'request.state'} eq "construct") {      if ($env{'request.state'} eq "construct") {
  return ($status,$datemsg);   return ($status,$datemsg);
     }      }
     my $version=$Apache::lonhomework::history{'resource.version'};      
     if ($Apache::lonhomework::history{"resource.$version.checkedin"} &&      if ($type eq 'Task') {
  $Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {   my $version=$Apache::lonhomework::history{'resource.version'};
  return ('SHOW_ANSWER');   if ($Apache::lonhomework::history{"resource.$version.0.checkedin"} &&
       $Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass') {
       return ('SHOW_ANSWER');
    }
     }      }
     my ($id)=@_;  
     my @slots=      my @slots=
  (split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")),   (split(':',&Apache::lonnet::EXT("resource.$id.availablestudent")),
  split(':',&Apache::lonnet::EXT("resource.$id.available")));   split(':',&Apache::lonnet::EXT("resource.$id.available")));
Line 274  sub check_task_access { Line 292  sub check_task_access {
  }   }
     }      }
     if ($slotstatus eq 'NEEDS_CHECKIN' &&      if ($slotstatus eq 'NEEDS_CHECKIN' &&
  &proctor_checked_in($slot_name,$returned_slot)) {   &proctor_checked_in($slot_name,$returned_slot,$type)) {
  &Apache::lonxml::debug("protoctor checked in");   &Apache::lonxml::debug("protoctor checked in");
  $slotstatus='CAN_ANSWER';   $slotstatus='CAN_ANSWER';
     }      }
     if ( $slotstatus eq 'NOT_IN_A_SLOT' &&   
  $Apache::lonhomework::history{"resource.$version.checkedin"}) {      my ($is_correct,$got_grade,$checkedin);
  if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {      if ($type eq 'Task') {
    my $version=$Apache::lonhomework::history{'resource.0.version'};
    $got_grade = 
       ($Apache::lonhomework::history{"resource.$version.0.status"} 
        =~ /^(?:pass|fail)$/);
    $is_correct =  
       ($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass'
        || $Apache::lonhomework::history{"resource.0.solved"} =~ /^correct_/ );
    $checkedin =
       $Apache::lonhomework::history{"resource.$version.0.checkedin"};
       } elsif ($type eq 'problem') {
    $got_grade = 1;
    $checkedin = $Apache::lonhomework::history{"resource.0.checkedin"};
       }
       
       &Apache::lonxml::debug(" slot is $slotstatus checkedin ($checkedin) got_grade ($got_grade) is_correct ($is_correct)");
       
       # has a current checked in recrd, but hasn't got a grade, must be awaiting
       # a grade
       if ($checkedin 
    && !$got_grade) {
    return ('WAITING_FOR_GRADE');
       }
   
       if ($slotstatus eq 'NOT_IN_A_SLOT' 
    && $checkedin ) {
   
    if ($got_grade) {
     return ('SHOW_ANSWER');      return ('SHOW_ANSWER');
  } else {   } else {
     return ('WAITING_FOR_GRADE');      return ('WAITING_FOR_GRADE');
  }   }
   
     }      }
       if ( $is_correct) {
    return ('SHOW_ANSWER');
       }
       if ( $status eq 'CANNOT_ANSWER' && 
    ($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) {
    return ($status,$datemsg);
       }
   
     return ($slotstatus,$datemsg,$slot_name,$returned_slot);      return ($slotstatus,$datemsg,$slot_name,$returned_slot);
 }  }
   
Line 297  sub check_access { Line 351  sub check_access {
     my $status;      my $status;
     my $datemsg = '';      my $datemsg = '';
     my $lastdate = '';      my $lastdate = '';
     my $temp;  
     my $type;      my $type;
     my $passed;      my $passed;
   
Line 334  sub check_access { Line 387  sub check_access {
     return($status,$date);      return($status,$date);
  }   }
   
  foreach $temp ("opendate","duedate","answerdate") {   foreach my $temp ("opendate","duedate","answerdate") {
     $lastdate = $date;      $lastdate = $date;
     $date = &Apache::lonnet::EXT("resource.$id.$temp");      $date = &Apache::lonnet::EXT("resource.$id.$temp");
     my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");      my $thistype = &Apache::lonnet::EXT("resource.$id.$temp.type");
Line 718  sub editxmlmode { Line 771  sub editxmlmode {
  my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,   my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
  ($env{'environment.remote'} ne 'off'));   ($env{'environment.remote'} ne 'off'));
  my $html=&Apache::lonxml::xmlbegin();   my $html=&Apache::lonxml::xmlbegin();
  $result.=$html.$bodytag.   my $head="<head><title>EditXML $file</title>".
       &Apache::edit::js_change_detection()."</head>";
   
    $result.=$html.$head.$bodytag.
     &renderpage($request,$file,['no_output_web'],1).      &renderpage($request,$file,['no_output_web'],1).
     &Apache::lonxml::message_location().'      &Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.              <form '.&Apache::edit::form_change_detection().' name="lonhomework" method="POST" action="'.
     &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.      &HTML::Entities::encode($env{'request.uri'},'<>&"').'">'.
     &Apache::structuretags::remember_problem_state().'      &Apache::structuretags::remember_problem_state().'
             <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />              <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />
             <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />              <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />
             <input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />              <input type="submit" '.&Apache::edit::submit_ask_anyway().'name="problemmode" accesskey="e" value="'.&mt('Edit').'" />
               <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" />
             <hr />              <hr />
             <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" />              <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" />
             <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" />              <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" />
             <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" />  
             <hr />              <hr />
             ' . $xml_help . '              ' . $xml_help . '
             <textarea style="width:100%" rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.              <textarea '.&Apache::edit::element_change_detection().' style="width:100%" rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
     &HTML::Entities::encode($problem,'<>&"').'</textarea>      &HTML::Entities::encode($problem,'<>&"').'</textarea><br />
               <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes').'" />
               <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" />
             </form></body></html>';              </form></body></html>';
  &Apache::lonxml::add_messages(\$result);   &Apache::lonxml::add_messages(\$result);
  $request->print($result);   $request->print($result);
Line 939  sub handler { Line 997  sub handler {
  if ($Apache::lonhomework::browse ne 'F' &&    if ($Apache::lonhomework::browse ne 'F' && 
     $env{'request.state'} ne "construct") {      $env{'request.state'} ne "construct") {
     #should know where we are, so ask      #should know where we are, so ask
     if ( &Apache::lonnet::mod_perl_version() == 2 ) {  
  &Apache::lonnet::cleanenv();  
     }  
     &Apache::lonnet::logthis(&Apache::lonnet::mod_perl_version());  
     $request->internal_redirect('/adm/ambiguous'); return OK;      $request->internal_redirect('/adm/ambiguous'); return OK;
  }   }
     }      }
Line 951  sub handler { Line 1005  sub handler {
     &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'});      &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'});
     my ($symb) = &Apache::lonxml::whichuser();      my ($symb) = &Apache::lonxml::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);      &Apache::lonxml::debug('symb is '.$symb);
     if ($env{'request.state'} eq "construct" || $symb eq '') {  
  if ($env{'form.resetdata'} eq &mt('Reset Submissions') ||  
     $env{'form.resetdata'} eq &mt('New Problem Variation') ||  
     $env{'form.newrandomization'} eq &mt('New Randomization')) {  
     my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();  
     &Apache::lonnet::tmpreset($symb,'',$domain,$name);  
     &Apache::lonxml::debug("Attempt reset");  
  }  
     }  
     if ($env{'request.state'} eq "construct") {      if ($env{'request.state'} eq "construct") {
  if ( -e $file ) {   if ( -e $file ) {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},

Removed from v.1.223  
changed lines
  Added in v.1.236


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