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

version 1.318, 2005/11/08 21:09:08 version 1.319, 2005/11/09 12:04:23
Line 661  sub start_problem { Line 661  sub start_problem {
  }   }
     }      }
  } elsif ($target eq 'tex') {   } elsif ($target eq 'tex') {
     my $startminipage = '';      $result .= 'INSERTTEXFRONTMATTERHERE';
     if (not $env{'form.problem_split'}=~/yes/) {  
  $startminipage = '\begin{minipage}{\textwidth}';  
     }  
     my $id = $Apache::inputtags::part;  
     my $weight = &Apache::lonnet::EXT("resource.$id.weight");  
     my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');  
     my @packages = split /,/,$packages;  
     my $allow_print_points = 0;  
     foreach my $partial_key (@packages) {  
  if ($partial_key=~m/^part_0$/) {  
     $allow_print_points=1;  
  }  
     }  
     my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");  
     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 $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');  
     my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent ';  
     my $toc_line='\vskip 1 mm\noindent '.$startminipage.  
  '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';  
   
     #  Figure out what the due date is and if we need to print  
     #  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 $duedate = POSIX::strftime("%c",localtime($duetime));  
     my $temp_file;  
     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 have been printed.  
   
     my $due_file_content = 0;      #   If the file does not yet exist, time is the epoch.  
     if (-e $filename) {  
  $temp_file = Apache::File->new($filename);  
  my @due_file      = <$temp_file>;  
  $due_file_content = $due_file[$#due_file];  
  chomp $due_file_content;  
     }   
   
     # comparisons of the absolute times  
     if ($due_file_content != $duetime) {  
  $temp_file = Apache::File->new('>'.$filename);  
  print $temp_file "$duetime\n";  
  if (not $env{'request.symb'} =~ m/\.page_/) {  
     if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {  
  $result .= $begin_doc.  
     '\textit{Due date: '.$duedate.'} '.$toc_line;  
     } else {  
  $result .= $begin_doc.$toc_line;  
  if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}  
     }  
  } else {  
     $result .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';  
  }  
     } else {  
  if (not $env{'request.symb'} =~ m/\.page_/) {  
     $result .= $begin_doc.$toc_line;  
     if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}  
  } else {  
     $result .= '\vskip 1mm \\\\\\\\';  
  }  
     }  
  }   }
     } 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.
Line 751  sub end_problem { Line 685  sub end_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result= &Apache::lonxml::endredirection(); # started in &start_problem      my $result= &Apache::lonxml::endredirection(); # started in &start_problem
   
       # Figure out the front matter which was too deeply coupled for me to easily
       # unravel and replace the INSERTTEXFRONTMATTERHERE in result with it.
       # note that we do this in end_problem because whether or not we display
       # due dates depends on whether due dates have already been displayed in the problem parts.
   
       if ($target eq 'tex') {
    my $frontmatter   = '';
    my $startminipage = '';
    if (not $env{'form.problem_split'}=~/yes/) {
       $startminipage = '\begin{minipage}{\textwidth}';
    }
    my $id = $Apache::inputtags::part;
    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
    my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');
    my @packages = split /,/,$packages;
    my $allow_print_points = 0;
    foreach my $partial_key (@packages) {
       if ($partial_key=~m/^part_0$/) {
    $allow_print_points=1;
       }
    }
    my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
    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 $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
    my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent ';
    my $toc_line='\vskip 1 mm\noindent '.$startminipage.
       '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
   
    #  Figure out what the due date is and if we need to print
    #  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 $duedate = POSIX::strftime("%c",localtime($duetime));
    my $temp_file;
    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 have been printed.
   
    my $due_file_content = 0;      #   If the file does not yet exist, time is the epoch.
    if (-e $filename) {
       $temp_file = Apache::File->new($filename);
       my @due_file      = <$temp_file>;
       $due_file_content = $due_file[$#due_file];
       chomp $due_file_content;
    } 
   
    # We display the due date iff it is not the same as the last
    # duedate in problem header ($due_file_content), and
    # none of our parts displayed a duedate.
    #
    my $parts_with_displayduedate;
    if (defined $Apache::outputtags::showonce{'displayduedate'}) {
       $parts_with_displayduedate = 
    scalar(@{$Apache::outputtags::showonce{'displayduedate'}});
    } else {
       $parts_with_displayduedate = 0;
    }
    if (($due_file_content != $duetime) && ($parts_with_displayduedate == 0) ) {
       $temp_file = Apache::File->new('>'.$filename);
       print $temp_file "$duetime\n";
       if (not $env{'request.symb'} =~ m/\.page_/) {
    if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
       $frontmatter .= $begin_doc.
    '\textit{Due date: '.$duedate.'} '.$toc_line;
    } else {
       $frontmatter.= $begin_doc.$toc_line;
       if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
    }
       } else {
    $frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';
       }
    } else {
       if (not $env{'request.symb'} =~ m/\.page_/) {
    $frontmatter .= $begin_doc.$toc_line;
    if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
       } else {
    $frontmatter .= '\vskip 1mm \\\\\\\\';
       }
    }
    $result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/;
       }
   
     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') {

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


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