Diff for /loncom/homework/lonhomework.pm between versions 1.178.2.1 and 1.187

version 1.178.2.1, 2004/09/27 18:38:33 version 1.187, 2004/12/17 22:30:30
Line 52  use Apache::Constants qw(:common); Line 52  use Apache::Constants qw(:common);
 use HTML::Entities();  use HTML::Entities();
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 #use Time::HiRes qw( gettimeofday tv_interval );  use Time::HiRes qw( gettimeofday tv_interval );
   
 BEGIN {  BEGIN {
     &Apache::lonxml::register_insert();      &Apache::lonxml::register_insert();
Line 292  sub check_access { Line 292  sub check_access {
     $status = 'CANNOT_ANSWER';      $status = 'CANNOT_ANSWER';
  }   }
     }      }
     if ($status eq 'CAN_ANSWER') {      if ($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER') {
  my $interval=&Apache::lonnet::EXT("resource.$id.interval");   my $interval=&Apache::lonnet::EXT("resource.$id.interval");
  &Apache::lonxml::debug("looking for interval $interval");   &Apache::lonxml::debug("looking for interval $interval");
  if ($interval) {   if ($interval) {
Line 385  sub setuppermissions { Line 385  sub setuppermissions {
                                                '/'.$ENV{'request.course.sec'});                                                 '/'.$ENV{'request.course.sec'});
     }      }
     $Apache::lonhomework::viewgrades = $viewgrades;      $Apache::lonhomework::viewgrades = $viewgrades;
       if ($Apache::lonhomework::browse eq 'F' && 
    $ENV{'form.devalidatecourseresdata'} eq 'on') {
    my (undef,$courseid) = &Apache::lonxml::whichuser();
    &Apache::lonnet::devalidatecourseresdata($ENV{"course.$courseid.num"},
         $ENV{"course.$courseid.domain"});
       }
     return ''      return ''
 }  }
   
Line 449  sub handle_save_or_undo { Line 455  sub handle_save_or_undo {
   
 sub analyze_header {  sub analyze_header {
     my ($request) = @_;      my ($request) = @_;
       my $bodytag='<body bgcolor="#ffffff">';
       if ($ENV{'environment.remote'} eq 'off') {
    $bodytag=&Apache::loncommon::bodytag();
       }
     my $result.='<html>      my $result.='<html>
             <head><title>'.&mt("Analyzing a problem").'</title></head>              <head><title>'.&mt("Analyzing a problem").'</title></head>
             <body bgcolor="#FFFFFF">'.&Apache::lonxml::message_location().'              '.$bodytag.&Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.              <form name="lonhomework" method="POST" action="'.
     &HTML::Entities::encode($ENV{'request.uri'},'<>&"').'">      &HTML::Entities::encode($ENV{'request.uri'},'<>&"').'">'.
       &Apache::structuretags::remember_problem_state().'
             <input type="submit" name="problemmode" value="'.&mt("EditXML").'" />              <input type="submit" name="problemmode" value="'.&mt("EditXML").'" />
             <input type="submit" name="problemmode" value="'.&mt('Edit').'" />              <input type="submit" name="problemmode" value="'.&mt('Edit').'" />
             <hr />              <hr />
Line 488  sub analyze { Line 499  sub analyze {
     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,   &Apache::lonhtmlcommon::Increment_PrgWin($request,\%prog_state,
  &mt('last problem'));   &mt('last problem'));
    if (&Apache::loncommon::connection_aborted($request)) { return; }
  my $subresult=&Apache::lonnet::ssi($request->uri,   my $subresult=&Apache::lonnet::ssi($request->uri,
    ('grade_target' => 'analyze'),     ('grade_target' => 'analyze'),
    ('rndseed' => $i+$rndseed));     ('rndseed' => $i+$rndseed));
Line 513  sub analyze { Line 525  sub analyze {
     foreach my $part (sort(keys(%allparts))) {      foreach my $part (sort(keys(%allparts))) {
  if (defined(@{ $overall{$part.'.answer'} })) {   if (defined(@{ $overall{$part.'.answer'} })) {
     my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] });      my $num_cols=scalar(@{ $overall{$part.'.answer'}->[0] });
     $request->print('<table><tr><td colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part.'</td></tr>');      $request->print('<table><tr><th colspan="'.($num_cols+1).'">'.&mt('Part').' '.$part.'</th></tr>');
     my %frequency;      my %frequency;
     foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {      foreach my $answer (sort {$a->[0] <=> $b->[0]} (@{ $overall{$part.'.answer'} })) {
  $frequency{join("\0",@{ $answer })}++;   $frequency{join("\0",@{ $answer })}++;
     }      }
     $request->print('<tr><td colspan="'.($num_cols).'">'.&mt('Answer').'</td><td>'.&mt('Frequency').'</td></tr>');      $request->print('<tr><th colspan="'.($num_cols).'">'.&mt('Answer').'</th><th>'.&mt('Frequency').'</th></tr>');
     foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) {      foreach my $answer (sort {(split("\0",$a))[0] <=> (split("\0",$b))[0]} (keys(%frequency))) {
  $request->print('<tr><td align="right">'.   $request->print('<tr><td align="right">'.
  join('</td><td align="right">',split("\0",$answer)).   join('</td><td align="right">',split("\0",$answer)).
Line 570  sub editxmlmode { Line 582  sub editxmlmode {
  if ($cols > 80) { $cols = 80; }   if ($cols > 80) { $cols = 80; }
  if ($cols < 70) { $cols = 70; }   if ($cols < 70) { $cols = 70; }
  if ($rows < 20) { $rows = 20; }   if ($rows < 20) { $rows = 20; }
  $result.='<html><body bgcolor="#FFFFFF">'.   my $bodytag='<body bgcolor="#ffffff">';
     &Apache::lonxml::message_location().'   if ($ENV{'environment.remote'} eq 'off') {
       $bodytag=&Apache::loncommon::bodytag();
    }
    $result.='<html>'.$bodytag.&Apache::lonxml::message_location().'
             <form name="lonhomework" method="POST" action="'.              <form name="lonhomework" method="POST" action="'.
     &HTML::Entities::encode($ENV{'request.uri'},'<>&"').'">      &HTML::Entities::encode($ENV{'request.uri'},'<>&"').'">'.
       &Apache::structuretags::remember_problem_state().'
             <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />              <input type="hidden" name="problemmode" value="'.&mt('EditXML').'" />
             <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />              <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />
             <input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />              <input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />
Line 600  sub renderpage { Line 616  sub renderpage {
     &Apache::lonxml::debug("Running targets ".join(':',@targets));      &Apache::lonxml::debug("Running targets ".join(':',@targets));
     my $overall_result;      my $overall_result;
     foreach my $target (@targets) {      foreach my $target (@targets) {
    # FIXME need to do something intelligent when a problem goes
           # from viewable to not viewable due to map conditions
    #&setuppermissions();
    #if (   $Apache::lonhomework::browse ne '2'
    #    && $Apache::lonhomework::browse ne 'F' ) {
    #    $request->print(" You most likely shouldn't see me.");
    #}
  #my $t0 = [&gettimeofday()];   #my $t0 = [&gettimeofday()];
  my $problem=&Apache::lonnet::getfile($file);   my $problem=&Apache::lonnet::getfile($file);
  if ($problem eq -1) {   if ($problem eq -1) {
Line 697  sub newproblem { Line 720  sub newproblem {
     $errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n";      $errormsg='<p><font color="red">'.&mt('You did not select a template.').'</font></p>'."\n";
  }   }
  my $instructions;   my $instructions;
  my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);   my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
    ($ENV{'environment.remote'} ne 'off'));
  if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");}   if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'<br />'.&mt("Then");}
  my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new',   my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new',
   'resource' => 'resource',    'resource' => 'resource',
Line 750  sub handler { Line 774  sub handler {
     my $request=$_[0];      my $request=$_[0];
           
     $Apache::lonxml::debug=$ENV{'user.debug'};      $Apache::lonxml::debug=$ENV{'user.debug'};
     if (&setupheader($request)) { return OK; }  
     $ENV{'request.uri'}=$request->uri;      $ENV{'request.uri'}=$request->uri;
   
     &setuppermissions();      &setuppermissions();
     &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");      &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
     # some times multiple problemmodes are submitted, need to select      # some times multiple problemmodes are submitted, need to select
Line 780  sub handler { Line 802  sub handler {
     $request->internal_redirect('/adm/ambiguous'); return;      $request->internal_redirect('/adm/ambiguous'); return;
  }   }
     }      }
       if (&setupheader($request)) { return OK; }
   
     my ($symb) = &Apache::lonxml::whichuser();      my ($symb) = &Apache::lonxml::whichuser();
     &Apache::lonxml::debug('symb is '.$symb);      &Apache::lonxml::debug('symb is '.$symb);

Removed from v.1.178.2.1  
changed lines
  Added in v.1.187


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