Diff for /loncom/homework/structuretags.pm between versions 1.288 and 1.302

version 1.288, 2005/04/18 22:39:35 version 1.302, 2005/09/23 20:16:50
Line 68  sub end_tex { Line 68  sub end_tex {
     return '';      return '';
 }  }
   
   sub body_tag_start {
       my ($target,$background,$bgcolor)=@_;
       my $body_tag_start='<body onload="'.&Apache::lonmenu::loadevents().'" '.
    'onunload="'.&Apache::lonmenu::unloadevents().'" ';
       if ($env{'browser.imagesuppress'} eq 'on') { $background=''; }
       if ($background) {
    $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
       $background;
    $body_tag_start.='background="'.$background.'" ';
       } else {
    if (($bgcolor) && ($env{'browser.blackwhite'} ne 'on')) {
       $body_tag_start.='bgcolor="'.$bgcolor.'" ';
    } else {
       $body_tag_start.='bgcolor="#ffffff"';
    }
       }
       if ($env{'browser.fontenhance'} eq 'on') {
    $body_tag_start.=' style="font-size: x-large;" ';
       }
       $body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1);
       
       &Apache::lontexconvert::jsMath_reset();
       if ($env{'environment.texengine'} eq 'jsMath') {
    $body_tag_start.=&Apache::lontexconvert::jsMath_header();
       }
       return $body_tag_start;
   }
   
 sub page_start {  sub page_start {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my %found;      my %found;
Line 90  sub page_start { Line 118  sub page_start {
     my $body_tag_start;      my $body_tag_start;
     if (!defined($found{'body'}) && $env{'request.state'} eq 'construct'      if (!defined($found{'body'}) && $env{'request.state'} eq 'construct'
  && $env{'environment.remote'} eq 'off') {   && $env{'environment.remote'} eq 'off') {
  $body_tag_start=&Apache::loncommon::bodytag();   if ($target eq 'web' || $target eq 'edit') {
  $body_tag_start.=&Apache::lonxml::message_location();      $body_tag_start=&Apache::loncommon::bodytag();
       $body_tag_start.=&Apache::lonxml::message_location();
    }
     } elsif (!defined($found{'body'})) {      } elsif (!defined($found{'body'})) {
  $body_tag_start='<body onload="'.&Apache::lonmenu::loadevents().'" '.  
     'onunload="'.&Apache::lonmenu::unloadevents().'" ';  
  my $background=&Apache::lonxml::get_param('background',$parstack,   my $background=&Apache::lonxml::get_param('background',$parstack,
   $safeeval);    $safeeval);
  if ($env{'browser.imagesuppress'} eq 'on') { $background=''; }   my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack,
  if ($background) {         $safeeval);
     $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=   $body_tag_start=&body_tag_start($target,$background,$bgcolor);
  $background;   if ( ($target eq 'web' || $target eq 'webgrade')
     $body_tag_start.='background="'.$background.'" ';       && $env{'request.state'} ne 'construct') {
  } else {  
     my $bgcolor=&Apache::lonxml::get_param('bgcolor',$parstack,  
    $safeeval);  
     if (($bgcolor) && ($env{'browser.blackwhite'} ne 'on')) {  
  $body_tag_start.='bgcolor="'.$bgcolor.'" ';  
     } else {  
  $body_tag_start.='bgcolor="#ffffff"';  
     }  
  }  
  if ($env{'browser.fontenhance'} eq 'on') {  
     $body_tag_start.=' style="font-size: x-large;" ';  
  }  
  $body_tag_start.='>'.&Apache::lonmenu::menubuttons(undef,$target,1);  
  if ($env{'environment.texengine'} eq 'jsMath') {  
     $body_tag_start.='<script type="text/javascript">  
                      function NoFontMessage () {}  
                    </script>'."\n".  
        '<script src="/adm/jsMath/jsMath.js"></script>'."\n";  
  }  
  if ($target eq 'web' && $env{'request.state'} ne 'construct') {  
     my ($symb,undef,undef,undef,$publicuser)=      my ($symb,undef,undef,undef,$publicuser)=
  &Apache::lonxml::whichuser();   &Apache::lonxml::whichuser();
     if ($symb eq '' && !$publicuser) {      if ($symb eq '' && !$publicuser) {
Line 321  sub initialize_storage { Line 329  sub initialize_storage {
 # if running user has student role.    # if running user has student role.  
 sub finalize_storage {  sub finalize_storage {
     my $result;      my $result;
     my ($temp) = keys %Apache::lonhomework::results;      if (%Apache::lonhomework::results) {
     if ( $temp ne '' ) {  
  my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();   my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
  if ($env{'request.state'} eq 'construct' || $symb eq '') {   if ($env{'request.state'} eq 'construct' || $symb eq '') {
     $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};      $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};
Line 340  sub finalize_storage { Line 347  sub finalize_storage {
     }      }
     return $result;      return $result;
 }  }
   use Data::Dumper;
   
 # -------------------------------------------------------------store_aggregates  # -------------------------------------------------------------store_aggregates
 # Sends hash of values to be incremented in nohist_resourcetracker.db  # Sends hash of values to be incremented in nohist_resourcetracker.db
Line 365  sub store_aggregates { Line 373  sub store_aggregates {
         }          }
         if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {          if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {
             $aggregate{$symb."\0".$part."\0users"} = 1;              $aggregate{$symb."\0".$part."\0users"} = 1;
           } else {
               my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); 
               if ($last_reset) {
                   if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {
                       $aggregate{$symb."\0".$part."\0users"} = 1;
                   }
               }
         }          }
         $aggregate{$symb."\0".$part."\0attempts"} = 1;          $aggregate{$symb."\0".$part."\0attempts"} = 1;
     }      }
     &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,      if (keys (%aggregate) > 0) {
   $cdomain,$cname);    &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
                               $cdomain,$cname);
       }
 }  }
   
 sub checkout_msg {  sub checkout_msg {
Line 506  sub start_problem { Line 523  sub start_problem {
     &Apache::lonxml::debug("Using default type, problem, :$uri:");      &Apache::lonxml::debug("Using default type, problem, :$uri:");
  }   }
     }      }
       $Apache::lonhomework::default_type = $Apache::lonhomework::type;
   
     #added vars to the scripting enviroment      #added vars to the scripting enviroment
     my $expression='$external::part=\''.$Apache::inputtags::part.'\';';      my $expression='$external::part=\''.$Apache::inputtags::part.'\';';
Line 548  sub start_problem { Line 566  sub start_problem {
                              value="'.$env{'form.username'}.'" />';                               value="'.$env{'form.username'}.'" />';
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
  $form_tag_start.=   $form_tag_start.=
     ' <input type="checkbox" name="showallfoils" ';      ' <label><input type="checkbox" name="showallfoils" ';
  if (defined($env{'form.showallfoils'})) {   if (defined($env{'form.showallfoils'})) {
     $form_tag_start.='checked="on"';      $form_tag_start.='checked="on"';
  }   }
  $form_tag_start.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils');   $form_tag_start.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').
       '</label>';
     }      }
     $form_tag_start.='<hr />';      $form_tag_start.='<hr />';
  }   }
Line 626  sub start_problem { Line 645  sub start_problem {
     }      }
     my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");      my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
     if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }      if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }
       if (lc($env{'course.'.$env{'request.course.id'}.
       '.disableexampointprint'}) eq 'yes') {
    $allow_print_points=0;
       }
     my $duedate = &Apache::lonnet::EXT("resource.$id.duedate");       my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); 
     $duedate = POSIX::strftime("%c",localtime($duedate));      $duedate = POSIX::strftime("%c",localtime($duedate));
     my $temp_file;      my $temp_file;
Line 735  sub end_problem { Line 758  sub end_problem {
  }   }
  if ($target eq 'answer' && ($env{'request.state'} eq 'construct')   if ($target eq 'answer' && ($env{'request.state'} eq 'construct')
     && $env{'form.answer_output_mode'} ne 'tex') {      && $env{'form.answer_output_mode'} ne 'tex') {
     $result.='</html>'; # normally we get it from xmlend, but in CSTR      $result.=&Apache::lonxml::xmlend().'</html>';
                           # normally we get it from above, but in CSTR
                         # we always show answer mode too.                          # we always show answer mode too.
  }   }
     } elsif ($target eq 'meta') {      } elsif ($target eq 'meta') {
Line 1117  sub start_part { Line 1141  sub start_part {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result='';      my $result='';
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);      my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
     if ($id eq '') { $id = $Apache::lonxml::curdepth; }      if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
     $Apache::inputtags::part=$id;      $Apache::inputtags::part=$id;
     push(@Apache::inputtags::partlist,$id);      push(@Apache::inputtags::partlist,$id);
     @Apache::inputtags::response=();      @Apache::inputtags::response=();
Line 1187  sub start_part { Line 1211  sub start_part {
     if (defined($maxtries) && $maxtries < 0) {      if (defined($maxtries) && $maxtries < 0) {
  $allow_print_points=0;   $allow_print_points=0;
     }      }
       if (lc($env{'course.'.$env{'request.course.id'}.
       '.disableexampointprint'}) eq 'yes') {
    $allow_print_points=0;
       }
     if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}      if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}
  } elsif ($target eq 'web') {   } elsif ($target eq 'web') {
     $result.='<a name="'.&Apache::lonnet::escape($Apache::inputtags::part).'" />';      $result.='<a name="'.&Apache::lonnet::escape($Apache::inputtags::part).'" />';
Line 1244  sub end_part { Line 1272  sub end_part {
     }      }
     pop @Apache::inputtags::status;      pop @Apache::inputtags::status;
     $Apache::inputtags::part='';      $Apache::inputtags::part='';
       $Apache::lonhomework::type = $Apache::lonhomework::default_type;
     return $result;      return $result;
 }  }
   
Line 1251  sub start_preduedate { Line 1280  sub start_preduedate {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' || $target eq 'tex') {
  &Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']);   &Apache::lonxml::debug("State in preduedate is ". $Apache::inputtags::status['-1']);
  if ($Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&   if (!$Apache::lonhomework::scantronmode &&
       $Apache::inputtags::status['-1'] ne 'CAN_ANSWER' &&
     $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {      $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') {
     &Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER'));      &Apache::lonxml::debug("Wha? ". ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER'));
     &Apache::lonxml::get_all_text("/preduedate",$parser);      &Apache::lonxml::get_all_text("/preduedate",$parser);
Line 1267  sub end_preduedate { Line 1297  sub end_preduedate {
 sub start_postanswerdate {  sub start_postanswerdate {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     if ($target eq 'web' || $target eq 'grade') {      if ($target eq 'web' || $target eq 'grade') {
  if ($Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {   if ($Apache::lonhomework::scantronmode ||
       $Apache::inputtags::status['-1'] ne 'SHOW_ANSWER') {
     &Apache::lonxml::get_all_text("/postanswerdate",$parser);      &Apache::lonxml::get_all_text("/postanswerdate",$parser);
  }   }
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {

Removed from v.1.288  
changed lines
  Added in v.1.302


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