Diff for /loncom/homework/lonhomework.pm between versions 1.245 and 1.251

version 1.245, 2006/05/12 01:20:44 version 1.251, 2006/06/20 03:33:55
Line 161  sub proctor_checked_in { Line 161  sub proctor_checked_in {
     my ($slot_name,$slot,$type)=@_;      my ($slot_name,$slot,$type)=@_;
     my @possible_proctors=split(",",$slot->{'proctor'});      my @possible_proctors=split(",",$slot->{'proctor'});
           
       return 1 if (!@possible_proctors);
   
     my $key;      my $key;
     if ($type eq 'Task') {      if ($type eq 'Task') {
  my $version=$Apache::lonhomework::history{'resource.0.version'};   my $version=$Apache::lonhomework::history{'resource.0.version'};
Line 168  sub proctor_checked_in { Line 170  sub proctor_checked_in {
     } elsif ($type eq 'problem') {      } elsif ($type eq 'problem') {
  $key ='resource.0.checkedin';   $key ='resource.0.checkedin';
     }      }
           # backward compatability, used to be username@domain, 
       # now is username:domain
       my $who = $Apache::lonhomework::history{$key};
       if ($who !~ /:/) {
    $who =~ tr/@/:/;
       }     
     foreach my $possible (@possible_proctors) {       foreach my $possible (@possible_proctors) { 
  if ($Apache::lonhomework::history{$key} eq $possible   if ($who eq $possible
     && $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) {      && $Apache::lonhomework::history{$key.'.slot'} eq $slot_name) {
     return 1;      return 1;
  }   }
Line 238  sub check_slot_access { Line 245  sub check_slot_access {
     my ($status,$datemsg)=&check_access($id);      my ($status,$datemsg)=&check_access($id);
           
     my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");      my $useslots = &Apache::lonnet::EXT("resource.$id.useslots");
     if ($useslots ne 'resource' && $useslots ne 'map') {      if ($useslots ne 'resource' && $useslots ne 'map' 
    && $useslots ne 'map_map') {
  return ($status,$datemsg);   return ($status,$datemsg);
     }      }
   
Line 383  sub check_access { Line 391  sub check_access {
   
  foreach my $temp ("opendate","duedate","answerdate") {   foreach my $temp ("opendate","duedate","answerdate") {
     $lastdate = $date;      $lastdate = $date;
     $date = &Apache::lonnet::EXT("resource.$id.$temp");      if ($temp eq 'duedate') {
    $date = &due_date($id);
       } else {
    $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");
     if ($thistype =~ /^(con_lost|no_such_host)/ ||      if ($thistype =~ /^(con_lost|no_such_host)/ ||
  $date     =~ /^(con_lost|no_such_host)/) {   $date     =~ /^(con_lost|no_such_host)/) {
Line 451  sub check_access { Line 464  sub check_access {
     &Apache::lonxml::debug("looking for accesstime $first_access");      &Apache::lonxml::debug("looking for accesstime $first_access");
     if (!$first_access) {      if (!$first_access) {
  $status='NOT_YET_VIEWED';   $status='NOT_YET_VIEWED';
  $datemsg=&seconds_to_human_length($interval);   my $due_date = &due_date($id);
     } else {   $datemsg=&seconds_to_human_length($due_date-time);
  my $newdate=localtime($first_access+$interval);  
  if (time > ($first_access+$interval)) {  
     $status='CLOSED';  
     $datemsg = &mt("was due on")." $newdate".&mt(", and answers will be available on")." $date";  
  } else {  
     $datemsg = &mt("is due at")." $newdate";  
  }  
     }      }
  }   }
     }      }
   
   #if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&    #if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&
   #    (!$Apache::lonhomework::history{"resource.0.outtoken"})) {    #    (!$Apache::lonhomework::history{"resource.0.outtoken"})) {
   #    return ('UNCHECKEDOUT','needs to be checked out');    #    return ('UNCHECKEDOUT','needs to be checked out');
Line 478  sub check_access { Line 485  sub check_access {
   
     return ($status,$datemsg);      return ($status,$datemsg);
 }  }
   # this should work exactly like the copy in lonnavmaps.pm
   sub due_date {
       my ($part_id,$symb,$udom,$uname)=@_;
       my $date;
       my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb,
          $udom,$uname);
       &Apache::lonxml::debug("looking for interval $part_id $symb $interval");
       my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb,
          $udom,$uname);
       &Apache::lonxml::debug("looking for due_date $part_id $symb $due_date");
       if (defined($interval)) {
    my $first_access=&Apache::lonnet::get_first_access('map',$symb);
    if (defined($first_access)) {
       $interval = $first_access+$interval;
       $date = ($interval < $due_date)? $interval : $due_date;
    } else {
       $date = $due_date;
    }
       } else {
    $date = $due_date;
       }
       return $date
   }
   
 sub seconds_to_human_length {  sub seconds_to_human_length {
     my ($length)=@_;      my ($length)=@_;

Removed from v.1.245  
changed lines
  Added in v.1.251


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