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

version 1.37, 2001/02/13 18:42:06 version 1.40, 2001/04/16 23:16:31
Line 30  sub get_target { Line 30  sub get_target {
  return ('web');   return ('web');
       }        }
     } else {      } else {
       #return ('edit');        return ('grade','web');
       #edit is currently broken        if ( $ENV{'form.submitted'} eq 'edit' ) {
       return ('web');   return ('modified','edit');
         } else {
    return ('edit');
         }
     }      }
   }    }
   return ();    return ();
Line 55  sub createmenu { Line 58  sub createmenu {
   my ($which,$request)=@_;    my ($which,$request)=@_;
   if ($which eq 'grade') {    if ($which eq 'grade') {
     $request->print('<script language="JavaScript">       $request->print('<script language="JavaScript"> 
           hwkmenu=window.open("/res/adm/pages/homeworkmenu.html","LONCAPAhomeworkmenu",            hwkmenu=window.open("/res/adm/pages/homeworkmenu.html","homeworkremote",
                  "height=350,width=150,menubar=no");                   "height=350,width=150,menubar=no");
           </script>');            </script>');
   }    }
Line 131  sub check_date { Line 134  sub check_date {
 sub handler {  sub handler {
   my $request=$_[0];    my $request=$_[0];
       
  if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;} else {$Apache::lonxml::debug=0;}   if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}
       
   my (@targets) = &get_target();    my (@targets) = &get_target();
   
Line 146  sub handler { Line 149  sub handler {
   #setup permissions    #setup permissions
   $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});    $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});
   $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});    $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
   &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");  
   
   #check if we know where we are    #check if we know where we are
   if ($ENV{'request.course.fn'} && !&Apache::lonnet::symbread()) {     if ($ENV{'request.course.fn'} && !&Apache::lonnet::symbread()) { 
Line 158  sub handler { Line 160  sub handler {
   }    }
   
   &Apache::lonhomework::send_header($request);    &Apache::lonhomework::send_header($request);
     &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 $file=&Apache::lonnet::filelocation("",$request->uri);
Line 171  sub handler { Line 174  sub handler {
     my $result = '';      my $result = '';
     &Apache::inputtags::initialize_inputtags;      &Apache::inputtags::initialize_inputtags;
     %Apache::lonhomework::results=();      %Apache::lonhomework::results=();
     %Apache::lonhomework::history=&Apache::lonnet::restore;      %Apache::lonhomework::history=&Apache::lonnet::restore();
     #ignore error conditions      #ignore error conditions
     my ($temp)=keys %Apache::lonhomework::history ;      my ($temp)=keys %Apache::lonhomework::history ;
     if ($temp =~ m/^error:.*/) { %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") {
   $request->print("In construction space, submissions ignored<br>");    $request->print("In construction space, submissions ignored<br />");
  } else {   } else {
   $request->print("Browsing or <a href=\"/adm/ambiguous\">ambiguous</a> reference, submissions ignored<br>");    $request->print("Browsing or <a href=\"/adm/ambiguous\">ambiguous</a> reference, submissions ignored<br />");
  }   }
       }        }
       if ($Apache::lonhomework::viewgrades eq 'F') {&createmenu('grade',$request); }        if ($Apache::lonhomework::viewgrades eq 'F') {&createmenu('grade',$request); }
Line 190  sub handler { Line 193  sub handler {
       foreach $resultkey (sort keys %Apache::lonhomework::history) {        foreach $resultkey (sort keys %Apache::lonhomework::history) {
  &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::history{$resultkey}");   &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::history{$resultkey}");
       }        }
       &Apache::lonxml::debug("\n<br>restored values^</br>\n");        &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) {
Line 201  sub handler { Line 204  sub handler {
  $default.&setup_vars($target),%mystyle);   $default.&setup_vars($target),%mystyle);
   
     #$request->print("Result follows:");      #$request->print("Result follows:");
     $request->print($result);      if ($target eq 'modified') {
         my $fileout = &Apache::lonnet::filelocation("",$request->uri);
         my $filesave=$fileout.".bak";
   
         my $fs=Apache::File->new(">$filesave");
         print $fs $problem;
         $request->print("<b>Making Backup to $filesave</b><br />");
   
         my $fh=Apache::File->new(">$fileout");
         print $fh $result;
         $request->print("<b>Saving Modifications to $fileout</b><br />");
       } else {
         $request->print($result);
       }
     #$request->print(":Result ends");      #$request->print(":Result ends");
     if ($target eq 'grade') {      if ($target eq 'grade') {
   
Line 209  sub handler { Line 225  sub handler {
       foreach $resultkey (sort keys %Apache::lonhomework::results) {        foreach $resultkey (sort keys %Apache::lonhomework::results) {
  &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::results{$resultkey}");   &Apache::lonxml::debug("$resultkey ---- $Apache::lonhomework::results{$resultkey}");
       }        }
       &Apache::lonxml::debug("\n<br>storing values^</br>\n");        &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));
     }      }
   }    }
   &Apache::lonhomework::send_footer($request);    &Apache::lonhomework::send_footer($request);
       # always turn of debug messages
     $Apache::lonxml::debug=0;
   return OK;    return OK;
   
 }  }

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


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