Diff for /loncom/homework/lonhomework.pm between versions 1.113 and 1.126

version 1.113, 2003/03/07 23:43:21 version 1.126, 2003/05/13 01:56:32
Line 50  use Apache::essayresponse(); Line 50  use Apache::essayresponse();
 use Apache::externalresponse();  use Apache::externalresponse();
 use Apache::rankresponse();  use Apache::rankresponse();
 use Apache::matchresponse();  use Apache::matchresponse();
   #use Apache::chemresponse();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use HTML::Entities();  use HTML::Entities();
 use Apache::loncommon();  use Apache::loncommon();
Line 60  BEGIN { Line 61  BEGIN {
 }  }
   
 sub get_target {  sub get_target {
   if ( $ENV{'request.state'} eq "published") {    if (($ENV{'request.state'} eq "published") ||
         ($ENV{'request.state'} eq "uploaded")) {
     if ( defined($ENV{'form.grade_target'}  )       if ( defined($ENV{'form.grade_target'}  ) 
  && ($ENV{'form.grade_target'} eq 'tex')) {   && ($ENV{'form.grade_target'} eq 'tex')) {
       return ($ENV{'form.grade_target'});        return ($ENV{'form.grade_target'});
     } elsif ( defined($ENV{'form.grade_target'}  )       } elsif ( defined($ENV{'form.grade_target'}  ) 
  && ($Apache::lonhomework::viewgrades == 'F' )) {   && ($Apache::lonhomework::viewgrades eq 'F' )) {
       return ($ENV{'form.grade_target'});        return ($ENV{'form.grade_target'});
     }      }
     
     if ( defined($ENV{'form.submitted'})) {      if ( defined($ENV{'form.submitted'}) &&
    ( !defined($ENV{'form.resetdata'}))) {
       return ('grade', 'web');        return ('grade', 'web');
     } else {      } else {
       return ('web');        return ('web');
Line 206  sub check_access { Line 209  sub check_access {
     $datemsg = "was due on $lastdate, and answers will be available on $date";      $datemsg = "was due on $lastdate, and answers will be available on $date";
   }    }
   if ($status eq 'CAN_ANSWER') {    if ($status eq 'CAN_ANSWER') {
     #check #tries      #check #tries, and if correct.
     my $tries = $Apache::lonhomework::history{"resource.$id.tries"};      my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
     my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");      my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
     if ( $tries eq '' ) { $tries = '0'; }      if ( $tries eq '' ) { $tries = '0'; }
     if ( $maxtries eq '' ) { $maxtries = '2'; }       if ( $maxtries eq '' ) { $maxtries = '2'; } 
     if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }       if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } 
       if($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/
         && lc($Apache::lonhomework::problemstatus) ne 'no') {
    $status = 'CANNOT_ANSWER';
       }
   }    }
   
   if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&    if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&
Line 284  sub setuppermissions { Line 291  sub setuppermissions {
 }  }
   
 sub setupheader {  sub setupheader {
   my $request=$_[0];      my $request=$_[0];
   if ($ENV{'browser.mathml'}) {      if ($ENV{'browser.mathml'}) {
     $request->content_type('text/xml');   $request->content_type('text/xml');
   } else {      } else {
     $request->content_type('text/html');   $request->content_type('text/html');
   }      }
   if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {      $request->content_encoding('UTF-8');
     &Apache::loncommon::no_cache($request);      if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {
   }   &Apache::loncommon::no_cache($request);
   $request->send_http_header;      }
   return OK if $request->header_only;      $request->send_http_header;
   return ''      return OK if $request->header_only;
       return ''
 }  }
   
 sub handle_save_or_undo {  sub handle_save_or_undo {
Line 370  sub analyze { Line 378  sub analyze {
     my %allparts;      my %allparts;
     my $rndseed=$ENV{'form.rndseed'};      my $rndseed=$ENV{'form.rndseed'};
     &analyze_header($request);      &analyze_header($request);
       my %prog_state=
    &Apache::lonhtmlcommon::Create_PrgWin($request,'Analyze Progress',
         'Getting Problem Variants',
         $ENV{'form.numtoanalyze'});
     for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) {      for(my $i=1;$i<$ENV{'form.numtoanalyze'}+1;$i++) {
    &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,
    'last problem');
  my $subresult=&Apache::lonnet::ssi($request->uri,   my $subresult=&Apache::lonnet::ssi($request->uri,
    ('grade_target' => 'analyze'),     ('grade_target' => 'analyze'),
    ('rndseed' => $i));     ('rndseed' => $i));
  &Apache::lonxml::debug(":$subresult:");   &Apache::lonxml::debug(":$subresult:");
  (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);   (my $garbage,$subresult)=split(/_HASH_REF__/,$subresult,2);
  my %analyze=&Apache::lonnet::str2hash($subresult);   my %analyze=&Apache::lonnet::str2hash($subresult);
  $Apache::lonxml::debug=1;   my @parts;
  &Apache::lonhomework::showhash(%analyze);   if (defined(@{ $analyze{'parts'} })) {
  $Apache::lonxml::debug=0;      @parts=@{ $analyze{'parts'} };
  my @parts = @{ $analyze{'parts'} };   }
  foreach my $part (@parts) {   foreach my $part (@parts) {
     if (!exists($allparts{$part})) {$allparts{$part}=1;};      if (!exists($allparts{$part})) {$allparts{$part}=1;};
     if ($analyze{$part.'.type'} eq 'numericalresponse' ||      if ($analyze{$part.'.type'} eq 'numericalresponse' ||
Line 391  sub analyze { Line 405  sub analyze {
     }      }
  }   }
     }      }
       &Apache::lonhtmlcommon::Update_PrgWin($request,\%prog_state,
     'Analyzing Results');
     foreach my $part (keys(%allparts)) {      foreach my $part (keys(%allparts)) {
  if (defined(@{ $overall{$part.'.answer'} })) {   if (defined(@{ $overall{$part.'.answer'} })) {
     $request->print('<table><tr><td>Part '.$part.'</td></tr>');      $request->print('<table><tr><td>Part '.$part.'</td></tr>');
Line 404  sub analyze { Line 420  sub analyze {
     ' is not analyzabale at this time</p>');      ' is not analyzabale at this time</p>');
  }   }
     }      }
       &Apache::lonhtmlcommon::Close_PrgWin($request,\%prog_state);
     &analyze_footer($request);      &analyze_footer($request);
     &Apache::lonhomework::showhash(%overall);      &Apache::lonhomework::showhash(%overall);
     return $result;      return $result;
Line 413  sub editxmlmode { Line 430  sub editxmlmode {
   my ($request,$file) = @_;    my ($request,$file) = @_;
   my $result;    my $result;
   my $problem=&Apache::lonnet::getfile($file);    my $problem=&Apache::lonnet::getfile($file);
   if ($problem == -1) {    if ($problem eq -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='';
   }    }
Line 469  sub renderpage { Line 486  sub renderpage {
   foreach my $target (@targets) {    foreach my $target (@targets) {
     #my $t0 = [&gettimeofday()];      #my $t0 = [&gettimeofday()];
     my $problem=&Apache::lonnet::getfile($file);      my $problem=&Apache::lonnet::getfile($file);
     if ($problem == -1) {      if ($problem eq -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='';
     }      }
Line 522  sub get_template_list { Line 539  sub get_template_list {
     }      }
   }    }
   if (@allnames && !$result) {    if (@allnames && !$result) {
     $result="<option>Select a $extension type</option>\n<option>".      $result="<option>Select a $extension template</option>\n<option>".
       join('</option><option>',sort(@allnames)).'</option>';        join('</option><option>',sort(@allnames)).'</option>';
   }    }
   return $result;    return $result;
Line 590  sub handler { Line 607  sub handler {
   #my $t0 = [&gettimeofday()];    #my $t0 = [&gettimeofday()];
   my $request=$_[0];    my $request=$_[0];
   
 #  if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}  
   $Apache::lonxml::debug=$ENV{'user.debug'};    $Apache::lonxml::debug=$ENV{'user.debug'};
   
   if (&setupheader($request)) { return OK; }    if (&setupheader($request)) { return OK; }
Line 622  sub handler { Line 638  sub handler {
     }      }
   }    }
   
     my ($symb) = &Apache::lonxml::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);
     if ($ENV{'request.state'} eq "construct" || $symb eq '') {
         if ($ENV{'form.resetdata'} eq 'Reset Submissions' ||
     $ENV{'form.resetdata'} eq 'New Problem Variation' ) {
     my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
     &Apache::lonnet::tmpreset($symb,'',$domain,$name);
         }
     }
   if ($ENV{'request.state'} eq "construct") {    if ($ENV{'request.state'} eq "construct") {
     if ($ENV{'form.resetdata'} eq 'Reset Submissions') {  
       my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();  
       &Apache::lonnet::tmpreset($symb,'',$domain,$name);  
     }  
     if ( -e $file ) {      if ( -e $file ) {
       if (!(defined $ENV{'form.problemmode'})) {        if (!(defined $ENV{'form.problemmode'})) {
  #first visit to problem in construction space   #first visit to problem in construction space

Removed from v.1.113  
changed lines
  Added in v.1.126


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