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

version 1.188, 2004/12/20 12:16:47 version 1.190, 2004/12/22 22:05:40
Line 54  use Apache::loncommon(); Line 54  use Apache::loncommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Time::HiRes qw( gettimeofday tv_interval );  use Time::HiRes qw( gettimeofday tv_interval );
 use Apache::lonnet();  use Apache::lonnet();
 #  
 # FIXME!!!!!!!  
 #   Be nice if someone   
 #    - Took credit/blame for this module.  
 #    - At least commented the purpose of each major  
 #      sub  
 #    - Even better commented the major blocks.  
 #  
 #  I'll have a go at it for what I need.  
 #     ?'s- mean maybe this is right.  
 #          The number of ?'s represents the rough level  
 #          of doubt I have about rightness, with ??? representing  
 #          uncertainty based on the first blush interpretation.  
 #          ?? - I have some code to back up this interpretation.  
 #          ?  - I"m pretty sure I understand the code that backs up this  
 #               interpretation.  
 #         ???? - Absolutely clueless.  
 #          .  - I'm pretty sure the interpretation is correct.  
 #  RF.  
   
   
 # 'Exported' Variables:  
   
 #   viewgrades is 'F' if users are not allowed to view the grades.. T otherwise.  # FIXME - improve commenting
   
 $Apache::lonhomework::viewgrades = 'F'; # By default cannot.  
   
 #  Internal variables.  
   
 my $DEBUG=0; # set nonzero to enable debugging.  
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register_insert();      &Apache::lonxml::register_insert();
 }  }
   
 #  
 #   Issue debug log messages.    
 # Parameters:  
 #    The log message to issue.  
 # Implicit Inputs:  
 #    DEBUG   - If non zero the message is issued, otherwise not.  
 #  
 sub Debug {  
     my ($message) = @_;  
   
     if($DEBUG) {  
  my @call_context = caller(1);  
  my $prefix = "$call_context[3]:$call_context[2]:: ";  
  &Apache::lonnet::logthis($prefix.$message);  
     }  
 }  
   
 #  #
 #   I believe this sub defines how to render the  # Decides what targets to render for.
 #   problem based on the context of the rendering?  
 # Implicit inputs:  # Implicit inputs:
 #   Various session environment variables:  #   Various session environment variables:
 #      request.state - State of the resource actually ??  #      request.state -  published  - is a /res/ resource
 #                       published  - Examining in resource space.  #                       uploaded   - is a /uploaded/ resource
 #                       uploaded   - Not sure how this happens?????  #                       contruct   - is a /priv/ resource
 #                       contruct   - Rendering in construction space for viewing.  #      form.grade_target - a form parameter requesting a specific target
 #      form.grade_target -   
 sub get_target {  sub get_target {
     &Debug("request.state = $ENV{'request.state'}");      &Apache::lonxml::debug("request.state = $ENV{'request.state'}");
     if( defined($ENV{'form.grade_target'})) {      if( defined($ENV{'form.grade_target'})) {
  &Debug("form.grade_target = $ENV{'form.grade_target'}");   &Apache::lonxml::debug("form.grade_target= $ENV{'form.grade_target'}");
     } else {      } else {
  &Debug("form.grade_target <undefined>");   &Apache::lonxml::debug("form.grade_target <undefined>");
     }      }
     if (($ENV{'request.state'} eq "published") ||      if (($ENV{'request.state'} eq "published") ||
  ($ENV{'request.state'} eq "uploaded")) {   ($ENV{'request.state'} eq "uploaded")) {
Line 160  sub get_target { Line 115  sub get_target {
  } else {   } else {
     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') {
  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 671  sub editxmlmode { Line 627  sub editxmlmode {
     }      }
     return '';      return '';
 }  }
   
 #  #
 #    Render the page in whatever target desired.  #    Render the page in whatever target desired.
 #  #
   
 sub renderpage {  sub renderpage {
     my ($request,$file) = @_;      my ($request,$file) = @_;
   
Line 866  sub handler { Line 822  sub handler {
     if ( &Apache::lonnet::mod_perl_version() == 2 ) {      if ( &Apache::lonnet::mod_perl_version() == 2 ) {
  &Apache::lonnet::cleanenv();   &Apache::lonnet::cleanenv();
     }      }
     $request->internal_redirect('/adm/ambiguous'); return;      &Apache::lonnet::logthis(&Apache::lonnet::mod_perl_version());
       $request->internal_redirect('/adm/ambiguous'); return OK;
  }   }
     }      }
     if (&setupheader($request)) { return OK; }      if (&setupheader($request)) { return OK; }
Line 891  sub handler { Line 848  sub handler {
  #&view_or_edit_menu($request);   #&view_or_edit_menu($request);
  $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' {
  &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.188  
changed lines
  Added in v.1.190


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