Diff for /loncom/homework/structuretags.pm between versions 1.309 and 1.318

version 1.309, 2005/11/03 11:32:00 version 1.318, 2005/11/08 21:09:08
Line 115  sub page_start { Line 115  sub page_start {
     &Apache::lonxml::fontsettings();           &Apache::lonxml::fontsettings();     
     }      }
     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') {   if ($env{'environment.remote'} eq 'off') {
  if ($target eq 'web' || $target eq 'edit') {      if ($target eq 'web' || $target eq 'edit') {
     $body_tag_start=&Apache::loncommon::bodytag();   $body_tag_start=&Apache::loncommon::bodytag();
     $body_tag_start.=&Apache::lonxml::message_location();   $body_tag_start.=&Apache::lonxml::message_location();
       }
    } else {
       if ($target eq 'web' || $target eq 'edit') {
    $body_tag_start=&Apache::loncommon::bodytag(undef,undef,undef,1);
    $body_tag_start.=&Apache::lonxml::message_location();
       }
  }   }
     } elsif (!defined($found{'body'})) {      } elsif (!defined($found{'body'})) {
  my $background=&Apache::lonxml::get_param('background',$parstack,   my $background=&Apache::lonxml::get_param('background',$parstack,
Line 175  sub setup_rndseed { Line 181  sub setup_rndseed {
     my ($symb)=&Apache::lonxml::whichuser();      my ($symb)=&Apache::lonxml::whichuser();
     if ($env{'request.state'} eq "construct" || $symb eq '' ||      if ($env{'request.state'} eq "construct" || $symb eq '' ||
           $Apache::lonhomework::history{'resource.CODE'}) {            $Apache::lonhomework::history{'resource.CODE'}) {
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
    ['rndseed']);
  $rndseed=$env{'form.rndseed'};   $rndseed=$env{'form.rndseed'};
  if (!$rndseed) {   if (!$rndseed) {
     $rndseed=$Apache::lonhomework::history{'rndseed'};      $rndseed=$Apache::lonhomework::history{'rndseed'};
Line 245  sub option { Line 253  sub option {
   
 sub problem_web_to_edit_header {  sub problem_web_to_edit_header {
     my ($rndseed)=@_;      my ($rndseed)=@_;
     my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />      my $result.='<input type="hidden" name="problemmode" value="'.&mt('View').'" />';
              <input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />      if (!$Apache::lonhomework::parsing_a_task) {
              <input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />   $result .= '<input type="submit" name="problemmode" accesskey="e" value="'.&mt('Edit').'" />';
       }
       $result .= '<input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />
              <input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" />               <input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" />
              <input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" />               <input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" />
              <nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" />               <nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" />
Line 255  sub problem_web_to_edit_header { Line 265  sub problem_web_to_edit_header {
        $rndseed.'"         $rndseed.'"
            onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr>             onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr>
              <label><input type="checkbox" name="showallfoils" ';               <label><input type="checkbox" name="showallfoils" ';
       my $show_all_foils_text = 
    ($Apache::lonhomework::parsing_a_task) ?
    &mt('&nbsp;Show&nbsp;All&nbsp;Instances')
    : &mt('&nbsp;Show&nbsp;All&nbsp;Foils');
   
     if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; }      if (defined($env{'form.showallfoils'})) { $result.='checked="on"'; }
     $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').      $result.= ' />'.$show_all_foils_text.
  &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').   &Apache::loncommon::help_open_topic('Problem_Editor_Testing_Area','Testing Problems').
  '</label><hr />';   '</label><hr />';
     $result.="      if (!$Apache::lonhomework::parsing_a_task) {
    $result.="
 <nobr>  <nobr>
 Problem Status:  Problem Status:
 <select name='problemstate'>  <select name='problemstate'>
Line 290  Feedback Mode: Line 306  Feedback Mode:
 </nobr>  </nobr>
 <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />  <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />
 <hr />";  <hr />";
     my $numtoanalyze=$env{'form.numtoanalyze'};   my $numtoanalyze=$env{'form.numtoanalyze'};
     if (!$numtoanalyze) { $numtoanalyze=20; }   if (!$numtoanalyze) { $numtoanalyze=20; }
     $result.= '<input type="submit" name="problemmode" value='.   $result.= '<input type="submit" name="problemmode" value='.
  &mt('"Calculate answers').'" /> for      &mt('"Calculate answers').'" /> for
              <input type="text" name="numtoanalyze" value="'.               <input type="text" name="numtoanalyze" value="'.
      $numtoanalyze.'" size="5" /> '.&mt('versions of this problem').       $numtoanalyze.'" size="5" /> '.&mt('versions of this problem').
      '.'.&Apache::loncommon::help_open_topic("Analyze_Problem",       '.'.&Apache::loncommon::help_open_topic("Analyze_Problem",
      '',undef,undef,300).       '',undef,undef,300).
      '<hr />';       '<hr />';
       }
     return $result;      return $result;
 }  }
   
Line 422  sub firstaccess_msg { Line 439  sub firstaccess_msg {
 ENDCHECKOUT  ENDCHECKOUT
 }  }
   
 # initializes the problem globals across the inputtags, lonhomework, and   
 # structuretags modules.  
 #  
 #   
 sub init_problem_globals {  sub init_problem_globals {
     my ($type)=@_;      my ($type)=@_;
     #initialize globals      #initialize globals
Line 499  sub get_problem_status { Line 512  sub get_problem_status {
 sub start_problem {  sub start_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   
       # We'll use the redirection to fix up printing of duedates.
       &Apache::lonxml::startredirection();
   
     # Problems don't nest and we don't allow more than one <problem> in      # Problems don't nest and we don't allow more than one <problem> in
     # a .problem file.      # a .problem file.
     #      #
Line 670  sub start_problem { Line 686  sub start_problem {
     my $toc_line='\vskip 1 mm\noindent '.$startminipage.      my $toc_line='\vskip 1 mm\noindent '.$startminipage.
  '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';   '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
   
     #  Figure out what the due date is and if we need to print it in the problem header.      #  Figure out what the due date is and if we need to print
     #  We have been logging the last due date written to file.        #  it in the problem header.  We have been logging the
     #      #  last due date written to file. 
   
   
     my $duetime = &Apache::lonnet::EXT("resource.$id.duedate");       my $duetime = &Apache::lonnet::EXT("resource.$id.duedate"); 
     my $duedate = POSIX::strftime("%c",localtime($duetime));      my $duedate = POSIX::strftime("%c",localtime($duetime));
     my $temp_file;      my $temp_file;
     my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";      my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
   
     # Figure out what the last printed due date is or set it to the epoch if no duedates      # Figure out what the last printed due date is or set it
     # have been printed.      # to the epoch if no duedates have been printed.
   
     my $due_file_content = 0;      #   If the file does not yet exist, time is the epoch.      my $due_file_content = 0;      #   If the file does not yet exist, time is the epoch.
     if (-e $filename) {      if (-e $filename) {
Line 690  sub start_problem { Line 705  sub start_problem {
  $due_file_content = $due_file[$#due_file];   $due_file_content = $due_file[$#due_file];
  chomp $due_file_content;   chomp $due_file_content;
     }       } 
     # The big change; Due do the comparison on   
     # the absolute time rather than textual time since that is format independent.      # comparisons of the absolute times
     #  
     if ($due_file_content != $duetime) {      if ($due_file_content != $duetime) {
  $temp_file = Apache::File->new('>'.$filename);   $temp_file = Apache::File->new('>'.$filename);
  print $temp_file "$duetime\n";   print $temp_file "$duetime\n";
Line 716  sub start_problem { Line 730  sub start_problem {
  }   }
     }      }
  }   }
  &Apache::lonxml::startredirection; # We'll do redirection to deal with duedates.  
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.   $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
     &problem_edit_header();      &problem_edit_header();
Line 736  sub start_problem { Line 749  sub start_problem {
   
 sub end_problem {  sub end_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result='';      my $result= &Apache::lonxml::endredirection(); # started in &start_problem
     if ($target eq 'tex') {  
  $result = &Apache::lonxml::endredirection;  
     }  
     my $status=$Apache::inputtags::status['-1'];      my $status=$Apache::inputtags::status['-1'];
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||      if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
  $target eq 'tex') {   $target eq 'tex') {
Line 807  sub end_problem { Line 818  sub end_problem {
  $result.=&Apache::response::meta_response_order();   $result.=&Apache::response::meta_response_order();
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  &Apache::lonxml::debug("in end_problem with $target, edit");   &Apache::lonxml::debug("in end_problem with $target, edit");
  $result = &problem_edit_footer();   $result .= &problem_edit_footer();
     }      }
   
     if ($env{'request.state'} eq 'construct' && $target eq 'web') {      if ($env{'request.state'} eq 'construct' && $target eq 'web') {
Line 1179  sub ordered_show_check { Line 1190  sub ordered_show_check {
   
 sub start_part {  sub start_part {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
       &Apache::lonxml::startredirection(); # we'll use redirection to fix up 
                                            # duedates.
     my $result='';      my $result='';
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);      my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
     if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }      if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
Line 1287  sub end_part { Line 1300  sub end_part {
     my $status=$Apache::inputtags::status['-1'];      my $status=$Apache::inputtags::status['-1'];
     my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);      my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
     my $in_order_show=&ordered_show_check();      my $in_order_show=&ordered_show_check();
     my $result='';      my $result= &Apache::lonxml::endredirection(); # started in &start_part
     if ( $target eq 'meta' ) {      if ($target eq 'grade') {
  $result='';  
     } elsif ($target eq 'grade') {  
  if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&   if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&
     !$hidden && $in_order_show) {      !$hidden && $in_order_show) {
     $result=&Apache::inputtags::grade;      $result.=&Apache::inputtags::grade;
  } else {   } else {
     # move any submission data to .hidden      # move any submission data to .hidden
     &Apache::inputtags::hidealldata($Apache::inputtags::part);      &Apache::inputtags::hidealldata($Apache::inputtags::part);
Line 1305  sub end_part { Line 1316  sub end_part {
  if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') {   if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') {
     $gradestatus='';      $gradestatus='';
  }   }
  $result=$gradestatus;   $result.=$gradestatus;
  if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';}    if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';} 
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result=&Apache::edit::end_table();   $result.=&Apache::edit::end_table();
     }      }
     pop @Apache::inputtags::status;      pop @Apache::inputtags::status;
     $Apache::inputtags::part='';      $Apache::inputtags::part='';

Removed from v.1.309  
changed lines
  Added in v.1.318


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