'.$/;
}
@@ -2426,9 +2582,12 @@ CHOOSE_STUDENTS
$codechoice='Default ';
}
&Apache::lonxml::xmlparse($r, 'helper', <
+
SELECT_PROBLEMS
- Number of anonymous assignments to print:
+ Fill out one of the forms below
+
+ Generate new CODEd Assignments
+ Number of CODEd assignments to print:
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
@@ -2450,9 +2609,10 @@ CHOOSE_STUDENTS
$codechoice
-
-
- Enter a CODE to print:
+
+
+ Print a Specific CODE
+ Enter a CODE to print:
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} &&
@@ -2465,25 +2625,24 @@ CHOOSE_STUDENTS
}
-
+
$code_selection
-
-
- Reprint a set of saved CODEs:
+
+ Reprint a Set of Saved CODEs
+ Select saved CODEs:
$namechoice
-
$resource_selector
CHOOSE_ANON1
if ($helper->{VARS}->{'assignment'}) {
- push @{$printChoices}, [&mt("Selected Resources from folder [_1] for selected students ",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1'];
- push @{$printChoices}, [&mt("Selected Resources from folder [_1] for anonymous students ",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2'];
+ push @{$printChoices}, [&mt("Selected Resources from folder [_1] for selected people ",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1'];
+ push @{$printChoices}, [&mt("Selected Resources from folder [_1] for CODEd assignments ",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2'];
}
@@ -2496,7 +2655,7 @@ CHOOSE_ANON1
return $isNotMap;
$map
return $symbFilter;
-
+ $start_new_option
@@ -2534,9 +2693,12 @@ RESOURCE_SELECTOR
CHOOSE_STUDENTS1
&Apache::lonxml::xmlparse($r, 'helper', <
+
SELECT_RESOURCES
- Number of anonymous assignments to print:
+ Fill out one of the forms below
+
+ Generate new CODEd Assignments
+ Number of CODEd assignments to print:
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
@@ -2558,9 +2720,9 @@ CHOOSE_STUDENTS1
$codechoice
-
-
- Enter a CODE to print:
+
+ Print a Specific CODE
+ Enter a CODE to print:
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} &&
@@ -2573,27 +2735,37 @@ CHOOSE_STUDENTS1
}
-
+
$code_selection
- Reprint a set of saved CODEs:
+
+ Reprint a Set of Saved CODEs
+ Select saved CODEs:
$namechoice
-
$resource_selector
CHOOSE_ANON2
}
# 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 $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {
- push @{$printChoices}, [&mt("Selected Problems from current subdirectory [_1] ",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
+ if (($perm{'pav'}
+ && $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'
+ && (defined($helper->{'VARS'}->{'construction'})
+ ||
+ (&Apache::lonnet::allowed('bre',$subdir) eq 'F'
+ &&
+ $helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)
+ ))
+ && $helper->{VARS}->{'assignment'} eq ""
+ ) {
- my $f = '$filename';
+ my $pretty_dir = &Apache::lonnet::hreflocation($subdir);
+ push @{$printChoices}, [&mt("Selected Problems from current subdirectory [_1] ",$pretty_dir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
my $xmlfrag = <
+
PAGESIZE
@@ -2614,7 +2786,7 @@ CHOOSE_FROM_SUBDIR
# Allow the user to select any sequence in the course, feed it to
# another resource selector for that sequence
- if (!$helper->{VARS}->{'construction'}) {
+ if (!$helper->{VARS}->{'construction'} && !$is_published) {
push @$printChoices, ["Selected Resources from selected folder in course",
'select_sequences', 'CHOOSE_SEQUENCE'];
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
@@ -2637,10 +2809,10 @@ CHOOSE_FROM_SUBDIR
PAGESIZE
- return $isProblem
+ return $isNotMap
return '$escapedSequenceName';
return $symbFilter;
-
+ $start_new_option
CHOOSE_FROM_ANY_SEQUENCE
@@ -2661,7 +2833,10 @@ CHOOSE_FROM_ANY_SEQUENCE
if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or
($helper->{VARS}->{'construction'} eq '1')) {
- addMessage("Print: ");
+ addMessage("".
+ ''.
+ &mt('Print').
+ " : ");
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'ANSWER_TYPE';
$helper->declareVar('ANSWER_TYPE');
@@ -2677,10 +2852,16 @@ CHOOSE_FROM_ANY_SEQUENCE
if ($perm{'pav'}) {
if (!$startedTable) {
- addMessage("LaTeX mode: ");
+ addMessage("".
+ ''.
+ &mt('LaTeX mode').
+ " : ");
$startedTable = 1;
} else {
- addMessage(" LaTeX mode: ");
+ addMessage(" ".
+ ''.
+ &mt('LaTeX mode').
+ " : ");
}
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'LATEX_TYPE';
@@ -2696,7 +2877,10 @@ CHOOSE_FROM_ANY_SEQUENCE
}
Apache::lonhelper::dropdown->new();
- addMessage(" Print Table of Contents: ");
+ addMessage(" ".
+ ''.
+ &mt('Print Table of Contents').
+ " : ");
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'TABLE_CONTENTS';
$helper->declareVar('TABLE_CONTENTS');
@@ -2707,7 +2891,10 @@ CHOOSE_FROM_ANY_SEQUENCE
addMessage(" ");
if (not $helper->{VARS}->{'construction'}) {
- addMessage("Print Index: ");
+ addMessage(" ".
+ ''.
+ &mt('Print Index').
+ " : ");
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'TABLE_INDEX';
$helper->declareVar('TABLE_INDEX');
@@ -2716,7 +2903,10 @@ CHOOSE_FROM_ANY_SEQUENCE
['Yes', 'yes'] ];
Apache::lonhelper::dropdown->new();
addMessage(" ");
- addMessage("Print Discussions: ");
+ addMessage(" ".
+ ''.
+ &mt('Print Discussions').
+ " : ");
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'PRINT_DISCUSSIONS';
$helper->declareVar('PRINT_DISCUSSIONS');
@@ -2738,14 +2928,21 @@ CHOOSE_FROM_ANY_SEQUENCE
if ($helper->{'VARS'}->{'construction'}) {
my $stylevalue=$env{'construct.style'};
+ my $randseedtext=&mt("Use random seed");
+ my $stylefiletext=&mt("Use style file");
+
my $xmlfrag .= <<"RNDSEED";
- Use random seed:
+
+ $randseedtext :
+
return $helper->{VARS}->{'curseed'};
- Use style file:
+
+ $stylefiletext :
+
Select style file
Show all foils?
@@ -2969,6 +3166,7 @@ sub new {
$self->{NEXTSTATE} = shift;
bless($self);
+
return $self;
}
@@ -2978,8 +3176,10 @@ sub render {
my $result = '';
my $var = $self->{'variable'};
+
+
if (defined $self->{ERROR_MSG}) {
- $result .= '' . $self->{ERROR_MSG} . ' ';
+ $result .= '' . $self->{ERROR_MSG} . ' ';
}
my $format = $helper->{VARS}->{$self->{'formatvar'}};
@@ -2998,90 +3198,120 @@ sub render {
}
-
- my ($width_and_units,
- $height_and_units,
- $margin_and_units) =
- &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
-
-
- my ($width, $wunits) = split(/ /, $width_and_units);
- my ($height, $hunits) = split(/ /, $height_and_units);
- my ($margin, $munits) = split(/ /, $margin_and_units);
-
-
-
- # This code is a bit ugly and not very scalable with additional units.
- # but I'm not sure my poor perlmanship knows a better way yet RF
-
- my ($wuoptions, $huoptions, $muoptions);
+ my %size;
+ ($size{'width_and_units'},
+ $size{'height_and_units'},
+ $size{'margin_and_units'})=
+ &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
- if ($wunits eq 'cm') {
- $wuoptions = 'cm in ';
- } else {
- $wuoptions = 'in cm ';
- }
- if ($hunits eq 'cm') {
- $huoptions = 'cm in ';
- } else {
- $huoptions = 'in cm ';
- }
- if ($munits eq 'cm') {
- $muoptions = 'cm in ';
- } else {
- $muoptions = 'in cm ';
+ foreach my $dimension ('width','height','margin') {
+ ($size{$dimension},$size{$dimension.'_unit'}) =
+ split(/ +/, $size{$dimension.'_and_units'},2);
+
+ foreach my $unit ('cm','in') {
+ $size{$dimension.'_options'} .= '';
+ }
}
- $result .= <How should the column be formatted?
+How should each column be formatted?
-Hint: Some instructors like to leave scratch space for the student by
-making the width much smaller than the width of the page.
+
ELEMENTHTML
return $result;
}
-# If the user didn't select 1 column, skip this state.
+
sub preprocess {
my $self = shift;
my $helper = Apache::lonhelper::getHelper();
my $format = $helper->{VARS}->{$self->{'formatvar'}};
+
+ # If the user does not have 'pav' privilege, set default widths and
+ # on to the next state right away.
+ #
+ if (!$perm{'pav'}) {
+ my $var = $self->{'variable'};
+ my $format = $helper->{VARS}->{$self->{'formatvar'}};
+
+ my ($laystyle, $cols, $papersize) = split(/\|/, $format);
+ ($papersize) = split(/ /, $papersize);
+
+
+ if ($laystyle eq 'L') {
+ $laystyle = 'album';
+ } else {
+ $laystyle = 'book';
+ }
+ # Figure out some good defaults for the print out and set them:
+
+ my %size;
+ ($size{'width'},
+ $size{'height'},
+ $size{'lmargin'})=
+ &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
+
+ foreach my $dim ('width', 'height', 'lmargin') {
+ my ($value, $units) = split(/ /, $size{$dim});
+
+ $helper->{VARS}->{"$var.".$dim} = $value;
+ $helper->{VARS}->{"$var.".$dim.'unit'} = $units;
+
+ }
+
+
+ # Transition to the next state
+
+ $helper->changeState($self->{NEXTSTATE});
+ }
return 1;
}
@@ -3103,14 +3333,22 @@ sub postprocess {
# /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed
# by an optional period, followed by digits, ending the string
- if ($width !~ /^-?[0-9]+(\.[0-9]*)?$/) {
+ if ($width !~ /^-?[0-9]*(\.[0-9]*)?$/) {
$error .= "Invalid width; please type only a number. \n";
}
- if ($height !~ /^-?[0-9]+(\.[0-9]*)?$/) {
+ if ($height !~ /^-?[0-9]*(\.[0-9]*)?$/) {
$error .= "Invalid height; please type only a number. \n";
}
- if ($lmargin !~ /^-?[0-9]+(\.[0-9]*)?$/) {
+ if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) {
$error .= "Invalid left margin; please type only a number. \n";
+ } else {
+ # Adjust for LaTeX 1.0 inch margin:
+
+ if ($env{"form.${var}.lmarginunit"} eq "in") {
+ $helper->{VARS}->{$var.'.lmargin'} = $lmargin - 1;
+ } else {
+ $helper->{VARS}->{$var.'.lmargin'} = $lmargin - 2.54;
+ }
}
if (!$error) {