Diff for /loncom/homework/lonhomework.pm between versions 1.53 and 1.57

version 1.53, 2001/08/17 14:24:29 version 1.57, 2001/08/20 23:31:07
Line 1 Line 1
 # The LON-CAPA Homework handler  # The LON-CAPA Homework handler
 # Guy Albertelli  # Guy Albertelli
 # 11/30 Gerd Kortemeyer  # 11/30 Gerd Kortemeyer
 # 6/1 Gerd Kortemeyer  # 6/1,8/17,8/18 Gerd Kortemeyer
   
 package Apache::lonhomework;  package Apache::lonhomework;
 use strict;  use strict;
Line 131  sub check_access { Line 131  sub check_access {
     if ( $maxtries eq '' ) { $maxtries = '2'; }       if ( $maxtries eq '' ) { $maxtries = '2'; } 
     if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }       if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } 
   }    }
   
     if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&
         (!$Apache::lonhomework::history{"resource.0.outtoken"})) {
         return ('UNCHECKEDOUT','needs to be checked out');
     }
   
   
   &Apache::lonxml::debug("sending back :$status:$datemsg:");    &Apache::lonxml::debug("sending back :$status:$datemsg:");
   if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) {    if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) {
     &Apache::lonxml::debug("should be allowed to browse a resource when closed");      &Apache::lonxml::debug("should be allowed to browse a resource when closed");
Line 145  sub check_access { Line 152  sub check_access {
   return ($status,$datemsg);    return ($status,$datemsg);
 }  }
   
   # ----------------------------------------------------------------- whichuser
   # returns a list of $symb, $courseid, $domain, $name that is correct for
   # calls to lonnet functions for this setup.
   # - looks for form.grade_ parameters
   sub whichuser {
     my $symb=&Apache::lonnet::symbread();
     my $courseid=$ENV{'request.course.id'};
     my $domain=$ENV{'user.domain'};
     my $name=$ENV{'user.name'};
     if (defined($ENV{'form.grade_symb'})) {
       my $tmp_courseid=$ENV{'form.grade_courseid'};
       my $allowed=&Apache::lonnet::allowed('mgr',$tmp_courseid);
       if ($allowed) {
         $symb=$ENV{'form.grade_symb'};
         $courseid=$ENV{'form.grade_courseid'};
         $domain=$ENV{'form.grade_domain'};
         $name=$ENV{'form.grade_username'};
       }
     }
     return ($symb,$courseid,$domain,$name);
   }
   
 sub showhash {  sub showhash {
   my (%hash) = @_;    my (%hash) = @_;
   my $resultkey;    my $resultkey;
Line 218  sub renderpage { Line 247  sub renderpage {
     my $result = '';      my $result = '';
     &Apache::inputtags::initialize_inputtags;      &Apache::inputtags::initialize_inputtags;
     &Apache::edit::initialize_edit;      &Apache::edit::initialize_edit;
     %Apache::lonhomework::results=();  
     %Apache::lonhomework::history=&Apache::lonnet::restore();  
     #ignore error conditions  
     my ($temp)=keys %Apache::lonhomework::history ;  
     if ($temp =~ m/^error:.*/) { %Apache::lonhomework::history=(); }   
     if ($target eq 'web') {      if ($target eq 'web') {
       if (&Apache::lonnet::symbread() eq '') {        if (&Apache::lonnet::symbread() eq '') {
  if ($ENV{'request.state'} eq "construct") {   if ($ENV{'request.state'} eq "construct") {
Line 255  sub renderpage { Line 279  sub renderpage {
       $request->print($result);        $request->print($result);
     }      }
     #$request->print(":Result ends");      #$request->print(":Result ends");
     if ($target eq 'grade') { &showhash(%Apache::lonhomework::results); }  
   
     #store new values  
     my ($temp) = keys %Apache::lonhomework::results;  
     if ( $temp ne '' ) {  
       &Apache::lonxml::debug("Store return message:".  
      &Apache::lonnet::cstore(\%Apache::lonhomework::results));  
     }  
     #my $td=&tv_interval($t0);      #my $td=&tv_interval($t0);
   }    }
 }  }

Removed from v.1.53  
changed lines
  Added in v.1.57


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