[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm lonprintout.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Wed, 05 Jan 2005 12:07:27 -0000
This is a MIME encoded message
--foxr1104926847
Content-Type: text/plain
foxr Wed Jan 5 07:07:27 2005 EDT
Modified files:
/loncom/interface lonprintout.pm lonhelper.pm
Log:
Implement page/column breaks forced between arbitrary resources on the page.
There are few design compromises that need to be documented here:
- Checkboxes in the helper could only be put prior to the actual resource.
Therefore pagebreaks will come >prior< to the resource the check is at.
This seems a bit more visually intuitive than to have the checkbox first and then
the pagebreak after the resource.
- There's a nasty design tension about what to do if they check a page break
for a resource they decided not to print (I'm devious to even think about this):
I had two choices on how to mange the page break locations
o An array of page break resources.
o A hash of page break resources.
The problem with a hash is that it is not order preserving which is a problem if the
user can print out the same resource several times on a print job. This is not
as strange a case as you may think.. consider a resource that's boiler-plate.
The problem with an array is that if the user checks a resource which is not in the
printed set that throws things off since, again, given the possibility of repeated
resources I don't see a reliable way to get back in step with the resources.
I chose the latter relying on 'intelligent use' of the user interface.. which
I know is a mistake, so I'm supplementing this with documentation of the
problem/issue for others to see.
--foxr1104926847
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20050105070727.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.349 loncom/interface/lonprintout.pm:1.350
--- loncom/interface/lonprintout.pm:1.349 Tue Jan 4 16:59:22 2005
+++ loncom/interface/lonprintout.pm Wed Jan 5 07:07:27 2005
@@ -1,7 +1,7 @@
-# The LearningOnline Network
+# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.349 2005/01/04 21:59:22 albertel Exp $
+# $Id: lonprintout.pm,v 1.350 2005/01/05 12:07:27 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1014,10 +1014,22 @@
my $flag_latex_header_remove = 'NO';
my $flag_page_in_sequence = 'NO';
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
+ my @page_breaks = split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'};
+ my $page_index = 0;
my $prevassignment='';
&Apache::lonnet::delenv('form.counter');
&Apache::lonxml::init_counter();
for (my $i=0;$i<=$#master_seq;$i++) {
+
+ # Note due to document structure, not allowed to put \newpage
+ # prior to the first resource
+
+ if (($master_seq[$i] eq $page_breaks[$page_index])) {
+ $page_index++;
+ if($i != 0) {
+ $result.="\\newpage\n";
+ }
+ }
my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
$urlp=&Apache::lonnet::clutter($urlp);
$form{'symb'}=$master_seq[$i];
@@ -1135,6 +1147,7 @@
$helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1;
}
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
+
#loop over students
my $flag_latex_header_remove = 'NO';
my %moreenv;
@@ -1145,6 +1158,7 @@
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75');
my $student_counter=-1;
foreach my $person (@students) {
+
my $duefile="/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due";
if (-e $duefile) {
my $temp_file = Apache::File->new('>>'.$duefile);
@@ -1411,11 +1425,25 @@
$namepostfix="\\\\Name: ";
$fullname = "CODE - ".$moreenv->{'CODE'};
}
+ my @page_breaks = split /\|\|\|/,$helper->{'VARS'}->{'FINISHPAGE'};
+ my $page_index = 0;
+ my $i = 0;
#goes through all resources, checks if they are available for
#current student, and produces output
&Apache::lonnet::delenv('form.counter');
&Apache::lonxml::init_counter();
foreach my $curresline (@{$master_seq}) {
+ if ($curresline eq $page_breaks[$page_index]) {
+ #
+ # Due to document structure, we cannot put a
+ # page break prior to the first document
+ #
+ if($i != 0) {
+ $current_output.= "\\newpage\n";
+ }
+ $page_index++;
+ }
+ $i++;
if ( !($type eq 'problems' &&
($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
@@ -1527,6 +1555,9 @@
# }
# return OK;
+
+
+
&output_data($r,$helper,\%parmhash);
return OK;
}
@@ -1692,6 +1723,7 @@
# If we're in a sequence...
if (($helper->{'VARS'}->{'construction'} ne '1') &&
+
$helper->{VARS}->{'postdata'} &&
$helper->{VARS}->{'assignment'}) {
# Allow problems from sequence
@@ -1708,7 +1740,7 @@
<filterfunc>return $isProblem;</filterfunc>
<mapurl>$map</mapurl>
<valuefunc>return $symbFilter;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='Newpage' variable='FINISHPAGE' />
</resource>
</state>
@@ -1720,7 +1752,7 @@
<filterfunc>return $isNotMap;</filterfunc>
<mapurl>$map</mapurl>
<valuefunc>return $symbFilter;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='Newpage' variable='FINISHPAGE' />
</resource>
</state>
HELPERFRAGMENT
@@ -1732,6 +1764,7 @@
# problems in the course, optionally for selected students
if ($userPriviledged &&
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) {
+
push @{$printChoices}, ['<b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);
<state name="ALL_PROBLEMS" title="Select Problem(s) to print">
@@ -1742,7 +1775,7 @@
<filterfunc>return $isProblemOrMap;</filterfunc>
<choicefunc>return $isNotMap;</choicefunc>
<valuefunc>return $symbFilter;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='Newpage' variable='FINISHPAGE' />
</resource>
</state>
ALL_PROBLEMS
@@ -1758,7 +1791,7 @@
<filterfunc>return $isProblem;</filterfunc>
<mapurl>$map</mapurl>
<valuefunc>return $symbFilter;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='New Page' variable='FINISHPAGE' />
</resource>
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
<choices variable="EMPTY_PAGES">
@@ -1821,7 +1854,7 @@
<filterfunc>return $isNotMap;</filterfunc>
<mapurl>$map</mapurl>
<valuefunc>return $symbFilter;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='Newpage' variable='FINISHPAGE' />
</resource>
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
<choices variable="EMPTY_PAGES">
@@ -1905,7 +1938,7 @@
<nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>
<filterfunc>return \$res->is_sequence;</filterfunc>
<valuefunc>return $urlValue;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='Newpage' variable='FINISHPAGE' />
</resource>
</state>
<state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
@@ -1916,7 +1949,7 @@
<filterfunc>return $isProblem</filterfunc>
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>
<valuefunc>return $symbFilter;</valuefunc>
- <option text='End Page' variable='FINISHPAGE' />
+ <option text='Newpage' variable='FINISHPAGE' />
</resource>
</state>
CHOOSE_FROM_ANY_SEQUENCE
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.90 loncom/interface/lonhelper.pm:1.91
--- loncom/interface/lonhelper.pm:1.90 Mon Jan 3 08:45:31 2005
+++ loncom/interface/lonhelper.pm Wed Jan 5 07:07:27 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# .helper XML handler to implement the LON-CAPA helper
#
-# $Id: lonhelper.pm,v 1.90 2005/01/03 13:45:31 foxr Exp $
+# $Id: lonhelper.pm,v 1.91 2005/01/05 12:07:27 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1871,16 +1871,28 @@
if (!defined($paramHash->{OPTION_TEXTS})) {
$paramHash->{OPTION_TEXTS} = [ ];
$paramHash->{OPTION_VARS} = [ ];
-
+
}
+ # OPTION_TEXTS is a list of the text attribute
+ # values used to create column headings.
+ # OPTION_VARS is a list of the variable names, used to create the checkbox
+ # inputs.
# We're ok with empty elements. as place holders
# Although the 'variable' element should really exist.
+ #
+
my $option_texts = $paramHash->{OPTION_TEXTS};
my $option_vars = $paramHash->{OPTION_VARS};
-
push(@$option_texts, $token->[2]{'text'});
push(@$option_vars, $token->[2]{'variable'});
+ # Need to create and declare the option variables as well to make them
+ # persistent.
+ #
+ my $varname = $token->[2]{'variable'};
+ $helper->declareVar($varname);
+
+
return '';
}
@@ -1989,9 +2001,10 @@
my $resource_name =
HTML::Entities::encode(&$valueFunc($resource),"<>&\"'");
if($option_vars) {
- foreach my $var (@$option_vars) {
+ foreach my $option_var (@$option_vars) {
$col .=
- "<td align='center'><input type='checkbox' name ='$var'.forminput' value='".
+ "<td align='center'><input type='checkbox' name ='$option_var".
+ ".forminput' value='".
$resource_name . "' /> </td>";
}
}
--foxr1104926847--