Diff for /loncom/homework/lonhomework.pm between versions 1.190 and 1.194

version 1.190, 2004/12/22 22:05:40 version 1.194, 2005/01/28 09:49:52
Line 116  sub get_target { Line 116  sub get_target {
     return ('web','answer');      return ('web','answer');
  }   }
     } elsif ( $ENV{'form.problemmode'} eq &mt('Edit') ||      } elsif ( $ENV{'form.problemmode'} eq &mt('Edit') ||
       $ENV{'form.problemmode'} ee 'Edit') {        $ENV{'form.problemmode'} eq 'Edit') {
  if ( $ENV{'form.submitted'} eq 'edit' ) {   if ( $ENV{'form.submitted'} eq 'edit' ) {
     if ( $ENV{'form.submit'} eq &mt('Submit Changes and View') ) {      if ( $ENV{'form.submit'} eq &mt('Submit Changes and View') ) {
  return ('modified','web','answer');   return ('modified','web','answer');
Line 320  sub check_access { Line 320  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=' '.$interval.' seconds';   $datemsg=&seconds_to_human_length($interval);
     } else {      } else {
  my $newdate=localtime($first_access+$interval);   my $newdate=localtime($first_access+$interval);
  if (time > ($first_access+$interval)) {   if (time > ($first_access+$interval)) {
Line 348  sub check_access { Line 348  sub check_access {
     return ($status,$datemsg);      return ($status,$datemsg);
 }  }
   
   sub seconds_to_human_length {
       my ($length)=@_;
   
       my $seconds=$length%60; $length=int($length/60);
       my $minutes=$length%60; $length=int($length/60);
       my $hours=$length%24;   $length=int($length/24);
       my $days=$length;
   
       my $timestr;
       if ($days > 0) { $timestr.=&mt('[quant,_1,day]',$days); }
       if ($hours > 0) { $timestr.=($timestr?", ":"").
     &mt('[quant,_1,hour]',$hours); }
       if ($minutes > 0) { $timestr.=($timestr?", ":"").
       &mt('[quant,_1,minute]',$minutes); }
       if ($seconds > 0) { $timestr.=($timestr?", ":"").
       &mt('[quant,_1,second]',$seconds); }
       return $timestr;
   }
   
 sub showhash {  sub showhash {
     my (%hash) = @_;      my (%hash) = @_;
     &showhashsubset(\%hash,'.');      &showhashsubset(\%hash,'.');
Line 358  sub showarray { Line 377  sub showarray {
     my ($array)=@_;      my ($array)=@_;
     my $string="(";      my $string="(";
     foreach my $elm (@{ $array }) {      foreach my $elm (@{ $array }) {
  if (ref($elm)) {   if (ref($elm) eq 'ARRAY') {
     if ($elm =~ /ARRAY/ ) {      $string.=&showarray($elm);
  $string.=&showarray($elm);   } elsif (ref($elm) eq 'HASH') {
     }      $string.= "HASH --- \n<br />";
       $string.= &showhashsubset($elm,'.');
  } else {   } else {
     $string.="$elm,"      $string.="$elm,"
  }   }
Line 375  sub showhashsubset { Line 395  sub showhashsubset {
     my ($hash,$keyre) = @_;      my ($hash,$keyre) = @_;
     my $resultkey;      my $resultkey;
     foreach $resultkey (sort keys %$hash) {      foreach $resultkey (sort keys %$hash) {
  if ($resultkey =~ /$keyre/) {   if ($resultkey !~ /$keyre/) { next; }
     if (ref($$hash{$resultkey})) {   if (ref($$hash{$resultkey})  eq 'ARRAY' ) {
  if ($$hash{$resultkey} =~ /ARRAY/ ) {      &Apache::lonxml::debug("$resultkey ---- ".
     &Apache::lonxml::debug("$resultkey ---- ".     &showarray($$hash{$resultkey}));
    &showarray($$hash{$resultkey}));   } elsif (ref($$hash{$resultkey}) eq 'HASH' ) {
  } elsif ($$hash{$resultkey} =~ /HASH/ ) {      &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
     &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");      &showhashsubset($$hash{$resultkey},'.');
     &showhashsubset($$hash{$resultkey},'.');   } else {
  } else {      &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
     &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");  
  }  
     } else {  
  &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");  
     }  
  }   }
     }      }
     &Apache::lonxml::debug("\n<br />restored values^</br>\n");      &Apache::lonxml::debug("\n<br />restored values^</br>\n");
Line 424  sub setupheader { Line 439  sub setupheader {
     if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {      if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {
  &Apache::loncommon::no_cache($request);   &Apache::loncommon::no_cache($request);
     }      }
       $request->set_last_modified(&Apache::lonnet::metadata($request->uri,
     'lastrevisiondate');
     $request->send_http_header;      $request->send_http_header;
     return OK if $request->header_only;      return OK if $request->header_only;
     return ''      return ''
Line 799  sub handler { Line 816  sub handler {
     $Apache::lonxml::debug=$ENV{'user.debug'};      $Apache::lonxml::debug=$ENV{'user.debug'};
     $ENV{'request.uri'}=$request->uri;      $ENV{'request.uri'}=$request->uri;
     &setuppermissions();      &setuppermissions();
     &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");  
     # some times multiple problemmodes are submitted, need to select      # some times multiple problemmodes are submitted, need to select
     # the last one      # the last one
     &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});      if ( defined($ENV{'form.problemmode'}) && ref($ENV{'form.problemmode'}) ) {
     if ( defined($ENV{'form.problemmode'}) &&  
  ref($ENV{'form.problemmode'}) ) {  
  &Apache::lonxml::debug("Problem Mode ".join(",",@$ENV{'form.problemmode'}));  
  my $mode=$ENV{'form.problemmode'}->[-1];   my $mode=$ENV{'form.problemmode'}->[-1];
  undef $ENV{'form.problemmode'};   undef $ENV{'form.problemmode'};
  $ENV{'form.problemmode'}=$mode;   $ENV{'form.problemmode'}=$mode;
     }      }
     &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});  
     my $file=&Apache::lonnet::filelocation("",$request->uri);      my $file=&Apache::lonnet::filelocation("",$request->uri);
   
     #check if we know where we are      #check if we know where we are
Line 827  sub handler { Line 840  sub handler {
  }   }
     }      }
     if (&setupheader($request)) { return OK; }      if (&setupheader($request)) { return OK; }
       &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
       &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{'request.state'} eq "construct" || $symb eq '') {
Line 849  sub handler { Line 863  sub handler {
  $ENV{'form.problemmode'}='View';   $ENV{'form.problemmode'}='View';
  &renderpage($request,$file);   &renderpage($request,$file);
     } elsif ($ENV{'form.problemmode'} eq &mt('EditXML') ||      } elsif ($ENV{'form.problemmode'} eq &mt('EditXML') ||
      $ENV{'form.problemmode'} eq 'EditXML' {       $ENV{'form.problemmode'} eq 'EditXML') {
  &editxmlmode($request,$file);   &editxmlmode($request,$file);
     } elsif ($ENV{'form.problemmode'} eq &mt('Calculate answers')) {      } elsif ($ENV{'form.problemmode'} eq &mt('Calculate answers')) {
  &analyze($request,$file);   &analyze($request,$file);

Removed from v.1.190  
changed lines
  Added in v.1.194


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