[LON-CAPA-cvs] cvs: loncom /homework structuretags.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Wed, 09 Nov 2005 12:04:23 -0000
foxr Wed Nov 9 07:04:23 2005 EDT
Modified files:
/loncom/homework structuretags.pm
Log:
Only display duedates in problem headers if there are no
<displayduedate> tags in the problem body or <part>s.
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.318 loncom/homework/structuretags.pm:1.319
--- loncom/homework/structuretags.pm:1.318 Tue Nov 8 16:09:08 2005
+++ loncom/homework/structuretags.pm Wed Nov 9 07:04:23 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: structuretags.pm,v 1.318 2005/11/08 21:09:08 albertel Exp $
+# $Id: structuretags.pm,v 1.319 2005/11/09 12:04:23 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -661,74 +661,8 @@
}
}
} elsif ($target eq 'tex') {
- 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;
- }
-
- # 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 \\\\\\\\';
- }
- }
+ $result .= 'INSERTTEXFRONTMATTERHERE';
+
}
} elsif ($target eq 'edit') {
$result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
@@ -751,6 +685,94 @@
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
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'];
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
$target eq 'tex') {