[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
bowersj2
lon-capa-cvs@mail.lon-capa.org
Thu, 25 Sep 2003 18:16:04 -0000
This is a MIME encoded message
--bowersj21064513764
Content-Type: text/plain
bowersj2 Thu Sep 25 14:16:04 2003 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Start adding in "Print from any sequence".
--bowersj21064513764
Content-Type: text/plain
Content-Disposition: attachment; filename="bowersj2-20030925141604.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.237 loncom/interface/lonprintout.pm:1.238
--- loncom/interface/lonprintout.pm:1.237 Mon Sep 22 16:00:08 2003
+++ loncom/interface/lonprintout.pm Thu Sep 25 14:16:04 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.237 2003/09/22 20:00:08 albertel Exp $
+# $Id: lonprintout.pm,v 1.238 2003/09/25 18:16:04 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1035,6 +1035,8 @@
Apache::lonhelper::message->new();
}
+use Data::Dumper;
+
sub printHelper {
my $r = shift;
@@ -1122,8 +1124,8 @@
$helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
- my $url = $helper->{VARS}->{'postdata'};
- $resourceTitle = substr($url, rindex($url, '/') + 1);
+ my $postdata = $helper->{VARS}->{'postdata'};
+ $resourceTitle = substr($postdata, rindex($postdata, '/') + 1);
}
$subdir = &Apache::lonnet::filelocation("", $url);
}
@@ -1146,6 +1148,9 @@
# "Remove all duplicate slashes."
$subdir =~ s|/+|/|g;
+ # If it's a ~ directory, convert back to /home/user/public_html
+ $subdir =~ s/^~(\w+)\//\/home\/$1\/public_html\//;
+
# What can be printed is a very dynamic decision based on
# lots of factors. So we need to dynamically build this list.
# To prevent security leaks, states are only added to the wizard
@@ -1166,20 +1171,30 @@
# $r->print($helper->{VARS}->{'postdata'});
+ # Useful filter strings
+ my $isProblem = '$res->is_problem()';
+ $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
+ my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
+ my $isNotMap = '!$res->is_map()';
+ $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
+ my $isMap = '$res->is_map()';
+ my $symbFilter = '$res->symb()';
+ my $urlValue = '$res->src()';
+
+ $helper->declareVar('SEQUENCE');
+
+ # Useful for debugging: Dump the help vars
+ #$r->print(Dumper($helper->{VARS}));
+ #$r->print($map);
+
# If we're in a sequence...
if (($helper->{'VARS'}->{'construction'} ne '1') &&
- $helper->{VARS}->{'postdata'}) {
+ $helper->{VARS}->{'postdata'} && $sequenceTitle) {
# Allow problems from sequence
- push @{$printChoices}, ["<b>Selected problems</b> in $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];
+ push @{$printChoices}, ["<b>Problems</b> in $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];
# Allow all resources from sequence
- push @{$printChoices}, ["<b>Selected resources</b> in $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
+ push @{$printChoices}, ["<b>Resources</b> in $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
- my $isProblem = '$res->is_problem()';
- $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
- my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
- my $isNotMap = '!$res->is_map()';
- $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
- my $symb = '$res->symb()';
my $helperFragment = <<HELPERFRAGMENT;
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
<message>(mark them then click "next" button) <br /></message>
@@ -1187,7 +1202,7 @@
<nextstate>PAGESIZE</nextstate>
<filterfunc>return $isProblem;</filterfunc>
<mapurl>$map</mapurl>
- <valuefunc>return $symb;</valuefunc>
+ <valuefunc>return $symbFilter;</valuefunc>
</resource>
</state>
@@ -1197,7 +1212,7 @@
<nextstate>PAGESIZE</nextstate>
<filterfunc>return $isNotMap;</filterfunc>
<mapurl>$map</mapurl>
- <valuefunc>return $symb;</valuefunc>
+ <valuefunc>return $symbFilter;</valuefunc>
</resource>
</state>
HELPERFRAGMENT
@@ -1208,14 +1223,11 @@
# If the user is priviledged, allow them to print all
# problems in the course, optionally for selected students
if ($userPriviledged && ($helper->{VARS}->{'postdata'}=~/\/res\//)) {
- push @{$printChoices}, ['Selected problems from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
- push @{$printChoices}, ["Selected problems from $sequenceTitle for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS'];
+ push @{$printChoices}, ['Problems from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
+ if ($sequenceTitle) {
+ push @{$printChoices}, ["Problems from $sequenceTitle for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS'];
+ }
- my $isProblem = '$res->is_problem()';
- $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
- my $isProblemOrMap = '($res->is_problem() || $res->is_map())';
- $isProblemOrMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
- my $symb = '$res->symb()';
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
<state name="ALL_PROBLEMS" title="Select Problem(s) to print">
<message>(mark them then click "next" button) <br /></message>
@@ -1224,7 +1236,7 @@
<nextstate>PAGESIZE</nextstate>
<filterfunc>return $isProblemOrMap;</filterfunc>
<choicefunc>return $isProblem;</choicefunc>
- <valuefunc>return $symb;</valuefunc>
+ <valuefunc>return $symbFilter;</valuefunc>
</resource>
</state>
@@ -1234,7 +1246,7 @@
<resource variable="RESOURCES" multichoice="1" addstatus="1">
<filterfunc>return $isProblem</filterfunc>
<mapurl>$map</mapurl>
- <valuefunc>return $symb</valuefunc>
+ <valuefunc>return $symbFilter</valuefunc>
</resource>
<message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
<choices variable="EMPTY_PAGES">
@@ -1248,9 +1260,9 @@
}
# FIXME: That RE should come from a library somewhere.
- if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $ENV{'request.role.adv'}) {
+ if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $ENV{'request.role.adv'} and $subdir ne '/home/httpd/html/res/') {
push @{$printChoices}, ["Problems from current subdirectory <b>$subdir</b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
-
+
my $f = '$filename';
my $xmlfrag = <<CHOOSE_FROM_SUBDIR;
<state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$subdir</small></b> to print">
@@ -1260,6 +1272,8 @@
<filechoice>return '$subdir';</filechoice>
CHOOSE_FROM_SUBDIR
+ # this is broken up because I really want interpolation above,
+ # and I really DON'T want it below
$xmlfrag .= <<'CHOOSE_FROM_SUBDIR';
<filefilter>return Apache::lonhelper::files::not_old_version($filename) &&
$filename =~ m/\.(problem|exam|quiz|assess|survey|form|library)$/;
@@ -1269,6 +1283,30 @@
CHOOSE_FROM_SUBDIR
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
}
+
+ # Allow the user to select any sequence in the course, feed it to
+ # another resource selector for that sequence
+ push @$printChoices, ["Resources from <b>selected sequence</b> in course",
+ 'map_problems_pages', 'CHOOSE_SEQUENCE'];
+ &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_FROM_ANY_SEQUENCE);
+ <state name="CHOOSE_SEQUENCE" title="Select Sequence To Print From">
+ <message>Select the sequence to print resources from:</message>
+ <resource variable="SEQUENCE">
+ <nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>
+ <filterfunc>return \$res->is_sequence;</filterfunc>
+ <valuefunc>return $urlValue;</valuefunc>
+ </resource>
+ </state>
+ <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
+ <message>(mark desired resources then click "next" button) <br /></message>
+ <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">
+ <nextstate>PAGESIZE</nextstate>
+ <filterfunc>return $isProblem</filterfunc>
+ <mapurl evaluate='1'>return $helper->{VARS}->{'SEQUENCE'};</mapurl>
+ <valuefunc>return $symbFilter;</valuefunc>
+ </resource>
+ </state>
+CHOOSE_FROM_ANY_SEQUENCE
# Generate the first state, to select which resources get printed.
Apache::lonhelper::state->new("START", "Select Printing Options:");
--bowersj21064513764--