Diff for /loncom/homework/lonhomework.pm between versions 1.40 and 1.41

version 1.40, 2001/04/16 23:16:31 version 1.41, 2001/04/26 21:28:33
Line 131  sub check_date { Line 131  sub check_date {
   return ($status,$datemsg);    return ($status,$datemsg);
 }  }
   
 sub handler {  sub showhash {
   my $request=$_[0];    my (%hash) = @_;
       my $resultkey;
  if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}    foreach $resultkey (sort keys %hash) {
         &Apache::lonxml::debug("$resultkey ---- $hash{$resultkey}");
   my (@targets) = &get_target();    }
     &Apache::lonxml::debug("\n<br />restored values^</br>\n");
     return '';
   }
   
   sub setuppermissions {
     $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});
     $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
     return ''
   }
   
   sub setupheader {
     my $request=$_[0];
   if ($ENV{'browser.mathml'}) {    if ($ENV{'browser.mathml'}) {
     $request->content_type('text/xml');      $request->content_type('text/xml');
   } else {    } else {
Line 145  sub handler { Line 156  sub handler {
   }    }
   $request->send_http_header;    $request->send_http_header;
   return OK if $request->header_only;    return OK if $request->header_only;
     &Apache::lonhomework::send_header($request);
     return ''
   }
   
   #setup permissions  sub renderpage {
   $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});    my ($request,$file) = @_;
   $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});  
   
   #check if we know where we are  
   if ($ENV{'request.course.fn'} && !&Apache::lonnet::symbread()) {   
     # if we are browsing we might not be able to know where we are  
     if ($Apache::lonhomework::browse ne 'F') {  
       #should know where we are, so ask  
       $request->internal_redirect('/adm/ambiguous'); return;   
     }  
   }  
   
   &Apache::lonhomework::send_header($request);    my (@targets) = &get_target();
   &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");  
     
   foreach my $target (@targets) {    foreach my $target (@targets) {
     my $file=&Apache::lonnet::filelocation("",$request->uri);  
     my $problem=&Apache::lonnet::getfile($file);      my $problem=&Apache::lonnet::getfile($file);
     if ($problem == -1) {      if ($problem == -1) {
       &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");        &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
       $problem='';        $problem='';
     }      }
       
     my %mystyle;      my %mystyle;
     my $result = '';      my $result = '';
     &Apache::inputtags::initialize_inputtags;      &Apache::inputtags::initialize_inputtags;
Line 188  sub handler { Line 189  sub handler {
       }        }
       if ($Apache::lonhomework::viewgrades eq 'F') {&createmenu('grade',$request); }        if ($Apache::lonhomework::viewgrades eq 'F') {&createmenu('grade',$request); }
     }      }
     if ($target eq 'grade') {      if ($target eq 'grade') { &showhash(%Apache::lonhomework::history); }
       my $resultkey;  
       foreach $resultkey (sort keys %Apache::lonhomework::history) {  
  &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::history{$resultkey}");  
       }  
       &Apache::lonxml::debug("\n<br />restored values^</br>\n");  
     }  
     my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');      my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
     if ($default == -1) {      if ($default == -1) {
       &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");        &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");
Line 219  sub handler { Line 215  sub handler {
       $request->print($result);        $request->print($result);
     }      }
     #$request->print(":Result ends");      #$request->print(":Result ends");
     if ($target eq 'grade') {      if ($target eq 'grade') { &showhash(%Apache::lonhomework::results); }
   
       my $resultkey;      #store new values
       foreach $resultkey (sort keys %Apache::lonhomework::results) {  
  &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::results{$resultkey}");  
       }  
       &Apache::lonxml::debug("\n<br />storing values^</br>\n");  
     }  
       
     my ($temp) = keys %Apache::lonhomework::results;      my ($temp) = keys %Apache::lonhomework::results;
     if ( $temp ne '' ) {      if ( $temp ne '' ) {
       &Apache::lonxml::debug("Store return message:".&Apache::lonnet::cstore(\%Apache::lonhomework::results));        &Apache::lonxml::debug("Store return message:".
        &Apache::lonnet::cstore(\%Apache::lonhomework::results));
     }      }
   }    }
   }
   
   sub handler {
     my $request=$_[0];
   
     if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}
   
     if (&setupheader($request)) { return OK; }
   
     #setup permissions
     $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});
     $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
     &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
   
     my $file=&Apache::lonnet::filelocation("",$request->uri);
   
     #check if we know where we are
     if ($ENV{'request.course.fn'} && !&Apache::lonnet::symbread()) { 
       # if we are browsing we might not be able to know where we are
       if ($Apache::lonhomework::browse ne 'F') {
         #should know where we are, so ask
         $request->internal_redirect('/adm/ambiguous'); return;
       }
     }
   
     if ($ENV{'request.state'} eq "construct") {
       if ( -e $file ) {
         if (!(defined $ENV{'form.showproblem'})) {
    #first visit to problem in construction space
    &view_or_edit_menu($request);
         } else {
    &renderpage($request,$file);
         }
       } else {
         # requested file doesn't exist in contruction space
         &newproblem($request);
       }
     } else {
       # just render the page normally outside of construction space
       &renderpage($request,$file);
     }
   
   &Apache::lonhomework::send_footer($request);    &Apache::lonhomework::send_footer($request);
   # always turn of debug messages    # always turn off debug messages
   $Apache::lonxml::debug=0;    $Apache::lonxml::debug=0;
   return OK;    return OK;
   

Removed from v.1.40  
changed lines
  Added in v.1.41


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