File:
[LON-CAPA] /
loncom /
interface /
lonprintout.pm
Revision
1.514:
download - view:
text,
annotated -
select for diffs
Tue Jan 29 11:21:18 2008 UTC (16 years, 7 months ago) by
foxr
Branches:
MAIN
CVS tags:
version_2_6_2,
HEAD
BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.BZ5518 - Make legal column width sme as for Letter.
1: # The LearningOnline Network
2: # Printout
3: #
4: # $Id: lonprintout.pm,v 1.514 2008/01/29 11:21:18 foxr Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: # http://www.lon-capa.org/
26: #
27: #
28: package Apache::lonprintout;
29:
30: use strict;
31: use Apache::Constants qw(:common :http);
32: use Apache::lonxml;
33: use Apache::lonnet;
34: use Apache::loncommon;
35: use Apache::inputtags;
36: use Apache::grades;
37: use Apache::edit;
38: use Apache::File();
39: use Apache::lonnavmaps;
40: use Apache::admannotations;
41:
42: use LONCAPA::map();
43: use POSIX qw(strftime);
44: use Apache::lonlocal;
45: use Carp;
46: use LONCAPA;
47:
48: my %perm;
49: my %parmhash;
50: my $resources_printed;
51:
52: # Fetch the contents of a resource, uninterpreted.
53: # This is used here to fetch a latex file to be included
54: # verbatim into the printout<
55: # NOTE: Ask Guy if there is a lonnet function similar to this?
56: #
57: # Parameters:
58: # URL of the file
59: #
60: sub fetch_raw_resource {
61: my ($url) = @_;
62:
63: my $filename = &Apache::lonnet::filelocation("", $url);
64: my $contents = &Apache::lonnet::getfile($filename);
65:
66: if ($contents == -1) {
67: return "File open failed for $filename"; # This will bomb the print.
68: }
69: return $contents;
70:
71:
72: }
73:
74: # Fetch the annotations associated with a URL and
75: # put a centered 'annotations:' title.
76: # This is all suppressed if the annotations are empty.
77: #
78: sub annotate {
79: my ($symb) = @_;
80:
81: my $annotation_text = &Apache::admannotations::get_annotation($symb, 1);
82:
83:
84: my $result = "";
85:
86: if (length($annotation_text) > 0) {
87: $result .= '\\hspace*{\\fill} \\\\[\\baselineskip] \textbf{Annotations:} \\\\ ';
88: $result .= "\n";
89: $result .= &Apache::lonxml::latex_special_symbols($annotation_text,""); # Escape latex.
90: $result .= "\n\n";
91: }
92: return $result;
93: }
94:
95: #
96: # printf_style_subst item format_string repl
97: #
98: # Does printf style substitution for a format string that
99: # can have %[n]item in it.. wherever, %[n]item occurs,
100: # rep is substituted in format_string. Note that
101: # [n] is an optional integer length. If provided,
102: # repl is truncated to at most [n] characters prior to
103: # substitution.
104: #
105: sub printf_style_subst {
106: my ($item, $format_string, $repl) = @_;
107: my $result = "";
108: while ($format_string =~ /(%)(\d*)\Q$item\E/g ) {
109: my $fmt = $1;
110: my $size = $2;
111: my $subst = $repl;
112: if ($size ne "") {
113: $subst = substr($subst, 0, $size);
114:
115: # Here's a nice edge case.. supose the end of the
116: # substring is a \. In that case may have just
117: # chopped off a TeX escape... in that case, we append
118: # " " for the trailing character, and let the field
119: # spill over a bit (sigh).
120: # We don't just chop off the last character in order to deal
121: # with one last pathology, and that would be if substr had
122: # trimmed us to e.g. \\\
123:
124:
125: if ($subst =~ /\\$/) {
126: $subst .= " ";
127: }
128: }
129: my $item_pos = pos($format_string);
130: $result .= substr($format_string, 0, $item_pos - length($size) -2) . $subst;
131: $format_string = substr($format_string, pos($format_string));
132: }
133:
134: # Put the residual format string into the result:
135:
136: $result .= $format_string;
137:
138: return $result;
139: }
140:
141:
142: # Format a header according to a format.
143: #
144:
145: # Substitutions:
146: # %a - Assignment name.
147: # %c - Course name.
148: # %n - Student name.
149: #
150: sub format_page_header {
151: my ($width, $format, $assignment, $course, $student) = @_;
152:
153: $width = &recalcto_mm($width); # Get width in mm.
154: # Default format?
155:
156: if ($format eq '') {
157: # For the default format, we may need to truncate
158: # elements.. To do this we need to get the page width.
159: # we assume that each character is about 2mm in width.
160: # (correct for the header text size??). We ignore
161: # any formatting (e.g. boldfacing in this).
162: #
163: # - Allow the student/course to be one line.
164: # but only truncate the course.
165: # - Allow the assignment to be 2 lines (wrapped).
166: #
167: my $chars_per_line = $width/2; # Character/textline.
168:
169:
170: my $firstline = "$student $course";
171: if (length($firstline) > $chars_per_line) {
172: my $lastchar = $chars_per_line - length($student) - 1;
173: if ($lastchar > 0) {
174: $course = substr($course, 0, $lastchar);
175: } else { # Nothing left of course:
176: $course = '';
177: }
178: }
179: if (length($assignment) > $chars_per_line) {
180: $assignment = substr($assignment, 0, $chars_per_line);
181: }
182:
183: $format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
184:
185: } else {
186: # An open question is how to handle long user formatted page headers...
187: # A possible future is to support e.g. %na so that the user can control
188: # the truncation of the elements that can appear in the header.
189: #
190: $format = &printf_style_subst("a", $format, $assignment);
191: $format = &printf_style_subst("c", $format, $course);
192: $format = &printf_style_subst("n", $format, $student);
193:
194: # If the user put %'s in the format string, they must be escaped
195: # to \% else LaTeX will think they are comments and terminate
196: # the line.. which is bad!!!
197:
198:
199: }
200:
201:
202: return $format;
203:
204: }
205:
206: #
207: # Convert a numeric code to letters
208: #
209: sub num_to_letters {
210: my ($num) = @_;
211: my @nums= split('',$num);
212: my @num_to_let=('A'..'Z');
213: my $word;
214: foreach my $digit (@nums) { $word.=$num_to_let[$digit]; }
215: return $word;
216: }
217: # Convert a letter code to numeric.
218: #
219: sub letters_to_num {
220: my ($letters) = @_;
221: my @letters = split('', uc($letters));
222: my %substitution;
223: my $digit = 0;
224: foreach my $letter ('A'..'J') {
225: $substitution{$letter} = $digit;
226: $digit++;
227: }
228: # The substitution is done as below to preserve leading
229: # zeroes which are needed to keep the code size exact
230: #
231: my $result ="";
232: foreach my $letter (@letters) {
233: $result.=$substitution{$letter};
234: }
235: return $result;
236: }
237:
238: # Determine if a code is a valid numeric code. Valid
239: # numeric codes must be comprised entirely of digits and
240: # have a correct number of digits.
241: #
242: # Parameters:
243: # value - proposed code value.
244: # num_digits - Number of digits required.
245: #
246: sub is_valid_numeric_code {
247: my ($value, $num_digits) = @_;
248: # Remove leading/trailing whitespace;
249: $value =~ s/^\s*//g;
250: $value =~ s/\s*$//g;
251:
252: # All digits?
253: if ($value !~ /^[0-9]+$/) {
254: return "Numeric code $value has invalid characters - must only be digits";
255: }
256: if (length($value) != $num_digits) {
257: return "Numeric code $value incorrect number of digits (correct = $num_digits)";
258: }
259: return undef;
260: }
261: # Determines if a code is a valid alhpa code. Alpha codes
262: # are ciphers that map [A-J,a-j] -> 0..9 0..9.
263: # They also have a correct digit count.
264: # Parameters:
265: # value - Proposed code value.
266: # num_letters - correct number of letters.
267: # Note:
268: # leading and trailing whitespace are ignored.
269: #
270: sub is_valid_alpha_code {
271: my ($value, $num_letters) = @_;
272:
273: # strip leading and trailing spaces.
274:
275: $value =~ s/^\s*//g;
276: $value =~ s/\s*$//g;
277:
278: # All alphas in the right range?
279: if ($value !~ /^[A-J,a-j]+$/) {
280: return "Invalid letter code $value must only contain A-J";
281: }
282: if (length($value) != $num_letters) {
283: return "Letter code $value has incorrect number of letters (correct = $num_letters)";
284: }
285: return undef;
286: }
287:
288: # Determine if a code entered by the user in a helper is valid.
289: # valid depends on the code type and the type of code selected.
290: # The type of code selected can either be numeric or
291: # Alphabetic. If alphabetic, the code, in fact is a simple
292: # substitution cipher for the actual numeric code: 0->A, 1->B ...
293: # We'll be nice and be case insensitive for alpha codes.
294: # Parameters:
295: # code_value - the value of the code the user typed in.
296: # code_option - The code type selected from the set in the scantron format
297: # table.
298: # Returns:
299: # undef - The code is valid.
300: # other - An error message indicating what's wrong.
301: #
302: sub is_code_valid {
303: my ($code_value, $code_option) = @_;
304: my ($code_type, $code_length) = ('letter', 6); # defaults.
305: open(FG, $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
306: foreach my $line (<FG>) {
307: my ($name, $type, $length) = (split(/:/, $line))[0,2,4];
308: if($name eq $code_option) {
309: $code_length = $length;
310: if($type eq 'number') {
311: $code_type = 'number';
312: }
313: }
314: }
315: my $valid;
316: if ($code_type eq 'number') {
317: return &is_valid_numeric_code($code_value, $code_length);
318: } else {
319: return &is_valid_alpha_code($code_value, $code_length);
320: }
321:
322: }
323:
324: # Compare two students by name. The students are in the form
325: # returned by the helper:
326: # user:domain:section:last, first:status
327: # This is a helper function for the perl sort built-in therefore:
328: # Implicit Inputs:
329: # $a - The first element to compare (global)
330: # $b - The second element to compare (global)
331: # Returns:
332: # -1 - $a < $b
333: # 0 - $a == $b
334: # +1 - $a > $b
335: # Note that the initial comparison is done on the last names with the
336: # first names only used to break the tie.
337: #
338: #
339: sub compare_names {
340: # First split the names up into the primary fields.
341:
342: my ($u1, $d1, $s1, $n1, $stat1) = split(/:/, $a);
343: my ($u2, $d2, $s2, $n2, $stat2) = split(/:/, $b);
344:
345: # Now split the last name and first name of each n:
346: #
347:
348: my ($l1,$f1) = split(/,/, $n1);
349: my ($l2,$f2) = split(/,/, $n2);
350:
351: # We don't bother to remove the leading/trailing whitespace from the
352: # firstname, unless the last names compare identical.
353:
354: if($l1 lt $l2) {
355: return -1;
356: }
357: if($l1 gt $l2) {
358: return 1;
359: }
360:
361: # Break the tie on the first name, but there are leading (possibly trailing
362: # whitespaces to get rid of first
363: #
364: $f1 =~ s/^\s+//; # Remove leading...
365: $f1 =~ s/\s+$//; # Trailing spaces from first 1...
366:
367: $f2 =~ s/^\s+//;
368: $f2 =~ s/\s+$//; # And the same for first 2...
369:
370: if($f1 lt $f2) {
371: return -1;
372: }
373: if($f1 gt $f2) {
374: return 1;
375: }
376:
377: # Must be the same name.
378:
379: return 0;
380: }
381:
382: sub latex_header_footer_remove {
383: my $text = shift;
384: $text =~ s/\\end{document}//;
385: $text =~ s/\\documentclass([^&]*)\\begin{document}//;
386: return $text;
387: }
388: #
389: # If necessary, encapsulate text inside
390: # a minipage env.
391: # necessity is determined by the problem_split param.
392: #
393: sub encapsulate_minipage {
394: my ($text) = @_;
395: if (!($env{'form.problem.split'} =~ /yes/i)) {
396: $text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}';
397: }
398: return $text;
399: }
400: #
401: # The NUMBER_TO_PRINT and SPLIT_PDFS
402: # variables interact, this sub looks at these two parameters
403: # and comes up with a final value for NUMBER_TO_PRINT which can be:
404: # all - if SPLIT_PDFS eq 'all'.
405: # 1 - if SPLIT_PDFS eq 'oneper'
406: # section - if SPLIT_PDFS eq 'sections'
407: # <unchanged> - if SPLIT_PDFS eq 'usenumber'
408: #
409: sub adjust_number_to_print {
410: my $helper = shift;
411:
412: my $split_pdf = $helper->{'VARS'}->{'SPLIT_PDFS'};
413:
414: if ($split_pdf eq 'all') {
415: $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 'all';
416: } elsif ($split_pdf eq 'oneper') {
417: $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 1;
418: } elsif ($split_pdf eq 'sections') {
419: $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 'section';
420: } elsif ($split_pdf eq 'usenumber') {
421: # Unmodified.
422: } else {
423: # Error!!!!
424:
425: croak "bad SPLIT_PDFS: $split_pdf in lonprintout::adjust_number_to_print";
426: }
427: }
428:
429: sub character_chart {
430: my $result = shift;
431: $result =~ s/&\#0?0?(7|9);//g;
432: $result =~ s/&\#0?(10|13);//g;
433: $result =~ s/&\#0?32;/ /g;
434: $result =~ s/&\#0?33;/!/g;
435: $result =~ s/&(\#0?34|quot);/\"/g;
436: $result =~ s/&\#0?35;/\\\#/g;
437: $result =~ s/&\#0?36;/\\\$/g;
438: $result =~ s/&\#0?37;/\\%/g;
439: $result =~ s/&(\#0?38|amp);/\\&/g;
440: $result =~ s/&\#(0?39|146);/\'/g;
441: $result =~ s/&\#0?40;/(/g;
442: $result =~ s/&\#0?41;/)/g;
443: $result =~ s/&\#0?42;/\*/g;
444: $result =~ s/&\#0?43;/\+/g;
445: $result =~ s/&\#(0?44|130);/,/g;
446: $result =~ s/&\#0?45;/-/g;
447: $result =~ s/&\#0?46;/\./g;
448: $result =~ s/&\#0?47;/\//g;
449: $result =~ s/&\#0?48;/0/g;
450: $result =~ s/&\#0?49;/1/g;
451: $result =~ s/&\#0?50;/2/g;
452: $result =~ s/&\#0?51;/3/g;
453: $result =~ s/&\#0?52;/4/g;
454: $result =~ s/&\#0?53;/5/g;
455: $result =~ s/&\#0?54;/6/g;
456: $result =~ s/&\#0?55;/7/g;
457: $result =~ s/&\#0?56;/8/g;
458: $result =~ s/&\#0?57;/9/g;
459: $result =~ s/&\#0?58;/:/g;
460: $result =~ s/&\#0?59;/;/g;
461: $result =~ s/&(\#0?60|lt|\#139);/\$<\$/g;
462: $result =~ s/&\#0?61;/\\ensuremath\{=\}/g;
463: $result =~ s/&(\#0?62|gt|\#155);/\\ensuremath\{>\}/g;
464: $result =~ s/&\#0?63;/\?/g;
465: $result =~ s/&\#0?65;/A/g;
466: $result =~ s/&\#0?66;/B/g;
467: $result =~ s/&\#0?67;/C/g;
468: $result =~ s/&\#0?68;/D/g;
469: $result =~ s/&\#0?69;/E/g;
470: $result =~ s/&\#0?70;/F/g;
471: $result =~ s/&\#0?71;/G/g;
472: $result =~ s/&\#0?72;/H/g;
473: $result =~ s/&\#0?73;/I/g;
474: $result =~ s/&\#0?74;/J/g;
475: $result =~ s/&\#0?75;/K/g;
476: $result =~ s/&\#0?76;/L/g;
477: $result =~ s/&\#0?77;/M/g;
478: $result =~ s/&\#0?78;/N/g;
479: $result =~ s/&\#0?79;/O/g;
480: $result =~ s/&\#0?80;/P/g;
481: $result =~ s/&\#0?81;/Q/g;
482: $result =~ s/&\#0?82;/R/g;
483: $result =~ s/&\#0?83;/S/g;
484: $result =~ s/&\#0?84;/T/g;
485: $result =~ s/&\#0?85;/U/g;
486: $result =~ s/&\#0?86;/V/g;
487: $result =~ s/&\#0?87;/W/g;
488: $result =~ s/&\#0?88;/X/g;
489: $result =~ s/&\#0?89;/Y/g;
490: $result =~ s/&\#0?90;/Z/g;
491: $result =~ s/&\#0?91;/[/g;
492: $result =~ s/&\#0?92;/\\ensuremath\{\\setminus\}/g;
493: $result =~ s/&\#0?93;/]/g;
494: $result =~ s/&\#(0?94|136);/\\ensuremath\{\\wedge\}/g;
495: $result =~ s/&\#(0?95|138|154);/\\underline{\\makebox[2mm]{\\strut}}/g;
496: $result =~ s/&\#(0?96|145);/\`/g;
497: $result =~ s/&\#0?97;/a/g;
498: $result =~ s/&\#0?98;/b/g;
499: $result =~ s/&\#0?99;/c/g;
500: $result =~ s/&\#100;/d/g;
501: $result =~ s/&\#101;/e/g;
502: $result =~ s/&\#102;/f/g;
503: $result =~ s/&\#103;/g/g;
504: $result =~ s/&\#104;/h/g;
505: $result =~ s/&\#105;/i/g;
506: $result =~ s/&\#106;/j/g;
507: $result =~ s/&\#107;/k/g;
508: $result =~ s/&\#108;/l/g;
509: $result =~ s/&\#109;/m/g;
510: $result =~ s/&\#110;/n/g;
511: $result =~ s/&\#111;/o/g;
512: $result =~ s/&\#112;/p/g;
513: $result =~ s/&\#113;/q/g;
514: $result =~ s/&\#114;/r/g;
515: $result =~ s/&\#115;/s/g;
516: $result =~ s/&\#116;/t/g;
517: $result =~ s/&\#117;/u/g;
518: $result =~ s/&\#118;/v/g;
519: $result =~ s/&\#119;/w/g;
520: $result =~ s/&\#120;/x/g;
521: $result =~ s/&\#121;/y/g;
522: $result =~ s/&\#122;/z/g;
523: $result =~ s/&\#123;/\\{/g;
524: $result =~ s/&\#124;/\|/g;
525: $result =~ s/&\#125;/\\}/g;
526: $result =~ s/&\#126;/\~/g;
527: $result =~ s/&\#131;/\\textflorin /g;
528: $result =~ s/&\#132;/\"/g;
529: $result =~ s/&\#133;/\\ensuremath\{\\ldots\}/g;
530: $result =~ s/&\#134;/\\ensuremath\{\\dagger\}/g;
531: $result =~ s/&\#135;/\\ensuremath\{\\ddagger\}/g;
532: $result =~ s/&\#137;/\\textperthousand /g;
533: $result =~ s/&\#140;/{\\OE}/g;
534: $result =~ s/&\#147;/\`\`/g;
535: $result =~ s/&\#148;/\'\'/g;
536: $result =~ s/&\#149;/\\ensuremath\{\\bullet\}/g;
537: $result =~ s/&(\#150|\#8211);/--/g;
538: $result =~ s/&\#151;/---/g;
539: $result =~ s/&\#152;/\\ensuremath\{\\sim\}/g;
540: $result =~ s/&\#153;/\\texttrademark /g;
541: $result =~ s/&\#156;/\\oe/g;
542: $result =~ s/&\#159;/\\\"Y/g;
543: $result =~ s/&(\#160|nbsp);/~/g;
544: $result =~ s/&(\#161|iexcl);/!\`/g;
545: $result =~ s/&(\#162|cent);/\\textcent /g;
546: $result =~ s/&(\#163|pound);/\\pounds /g;
547: $result =~ s/&(\#164|curren);/\\textcurrency /g;
548: $result =~ s/&(\#165|yen);/\\textyen /g;
549: $result =~ s/&(\#166|brvbar);/\\textbrokenbar /g;
550: $result =~ s/&(\#167|sect);/\\textsection /g;
551: $result =~ s/&(\#168|uml);/\\texthighdieresis /g;
552: $result =~ s/&(\#169|copy);/\\copyright /g;
553: $result =~ s/&(\#170|ordf);/\\textordfeminine /g;
554: $result =~ s/&(\#172|not);/\\ensuremath\{\\neg\}/g;
555: $result =~ s/&(\#173|shy);/ - /g;
556: $result =~ s/&(\#174|reg);/\\textregistered /g;
557: $result =~ s/&(\#175|macr);/\\ensuremath\{^{-}\}/g;
558: $result =~ s/&(\#176|deg);/\\ensuremath\{^{\\circ}\}/g;
559: $result =~ s/&(\#177|plusmn);/\\ensuremath\{\\pm\}/g;
560: $result =~ s/&(\#178|sup2);/\\ensuremath\{^2\}/g;
561: $result =~ s/&(\#179|sup3);/\\ensuremath\{^3\}/g;
562: $result =~ s/&(\#180|acute);/\\textacute /g;
563: $result =~ s/&(\#181|micro);/\\ensuremath\{\\mu\}/g;
564: $result =~ s/&(\#182|para);/\\P/g;
565: $result =~ s/&(\#183|middot);/\\ensuremath\{\\cdot\}/g;
566: $result =~ s/&(\#184|cedil);/\\c{\\strut}/g;
567: $result =~ s/&(\#185|sup1);/\\ensuremath\{^1\}/g;
568: $result =~ s/&(\#186|ordm);/\\textordmasculine /g;
569: $result =~ s/&(\#188|frac14);/\\textonequarter /g;
570: $result =~ s/&(\#189|frac12);/\\textonehalf /g;
571: $result =~ s/&(\#190|frac34);/\\textthreequarters /g;
572: $result =~ s/&(\#191|iquest);/?\`/g;
573: $result =~ s/&(\#192|Agrave);/\\\`{A}/g;
574: $result =~ s/&(\#193|Aacute);/\\\'{A}/g;
575: $result =~ s/&(\#194|Acirc);/\\^{A}/g;
576: $result =~ s/&(\#195|Atilde);/\\~{A}/g;
577: $result =~ s/&(\#196|Auml);/\\\"{A}/g;
578: $result =~ s/&(\#197|Aring);/{\\AA}/g;
579: $result =~ s/&(\#198|AElig);/{\\AE}/g;
580: $result =~ s/&(\#199|Ccedil);/\\c{c}/g;
581: $result =~ s/&(\#200|Egrave);/\\\`{E}/g;
582: $result =~ s/&(\#201|Eacute);/\\\'{E}/g;
583: $result =~ s/&(\#202|Ecirc);/\\^{E}/g;
584: $result =~ s/&(\#203|Euml);/\\\"{E}/g;
585: $result =~ s/&(\#204|Igrave);/\\\`{I}/g;
586: $result =~ s/&(\#205|Iacute);/\\\'{I}/g;
587: $result =~ s/&(\#206|Icirc);/\\^{I}/g;
588: $result =~ s/&(\#207|Iuml);/\\\"{I}/g;
589: $result =~ s/&(\#209|Ntilde);/\\~{N}/g;
590: $result =~ s/&(\#210|Ograve);/\\\`{O}/g;
591: $result =~ s/&(\#211|Oacute);/\\\'{O}/g;
592: $result =~ s/&(\#212|Ocirc);/\\^{O}/g;
593: $result =~ s/&(\#213|Otilde);/\\~{O}/g;
594: $result =~ s/&(\#214|Ouml);/\\\"{O}/g;
595: $result =~ s/&(\#215|times);/\\ensuremath\{\\times\}/g;
596: $result =~ s/&(\#216|Oslash);/{\\O}/g;
597: $result =~ s/&(\#217|Ugrave);/\\\`{U}/g;
598: $result =~ s/&(\#218|Uacute);/\\\'{U}/g;
599: $result =~ s/&(\#219|Ucirc);/\\^{U}/g;
600: $result =~ s/&(\#220|Uuml);/\\\"{U}/g;
601: $result =~ s/&(\#221|Yacute);/\\\'{Y}/g;
602: $result =~ s/&(\#223|szlig);/{\\ss}/g;
603: $result =~ s/&(\#224|agrave);/\\\`{a}/g;
604: $result =~ s/&(\#225|aacute);/\\\'{a}/g;
605: $result =~ s/&(\#226|acirc);/\\^{a}/g;
606: $result =~ s/&(\#227|atilde);/\\~{a}/g;
607: $result =~ s/&(\#228|auml);/\\\"{a}/g;
608: $result =~ s/&(\#229|aring);/{\\aa}/g;
609: $result =~ s/&(\#230|aelig);/{\\ae}/g;
610: $result =~ s/&(\#231|ccedil);/\\c{c}/g;
611: $result =~ s/&(\#232|egrave);/\\\`{e}/g;
612: $result =~ s/&(\#233|eacute);/\\\'{e}/g;
613: $result =~ s/&(\#234|ecirc);/\\^{e}/g;
614: $result =~ s/&(\#235|euml);/\\\"{e}/g;
615: $result =~ s/&(\#236|igrave);/\\\`{i}/g;
616: $result =~ s/&(\#237|iacute);/\\\'{i}/g;
617: $result =~ s/&(\#238|icirc);/\\^{i}/g;
618: $result =~ s/&(\#239|iuml);/\\\"{i}/g;
619: $result =~ s/&(\#240|eth);/\\ensuremath\{\\partial\}/g;
620: $result =~ s/&(\#241|ntilde);/\\~{n}/g;
621: $result =~ s/&(\#242|ograve);/\\\`{o}/g;
622: $result =~ s/&(\#243|oacute);/\\\'{o}/g;
623: $result =~ s/&(\#244|ocirc);/\\^{o}/g;
624: $result =~ s/&(\#245|otilde);/\\~{o}/g;
625: $result =~ s/&(\#246|ouml);/\\\"{o}/g;
626: $result =~ s/&(\#247|divide);/\\ensuremath\{\\div\}/g;
627: $result =~ s/&(\#248|oslash);/{\\o}/g;
628: $result =~ s/&(\#249|ugrave);/\\\`{u}/g;
629: $result =~ s/&(\#250|uacute);/\\\'{u}/g;
630: $result =~ s/&(\#251|ucirc);/\\^{u}/g;
631: $result =~ s/&(\#252|uuml);/\\\"{u}/g;
632: $result =~ s/&(\#253|yacute);/\\\'{y}/g;
633: $result =~ s/&(\#255|yuml);/\\\"{y}/g;
634: $result =~ s/&\#295;/\\ensuremath\{\\hbar\}/g;
635: $result =~ s/&\#952;/\\ensuremath\{\\theta\}/g;
636: #Greek Alphabet
637: $result =~ s/&(alpha|\#945);/\\ensuremath\{\\alpha\}/g;
638: $result =~ s/&(beta|\#946);/\\ensuremath\{\\beta\}/g;
639: $result =~ s/&(gamma|\#947);/\\ensuremath\{\\gamma\}/g;
640: $result =~ s/&(delta|\#948);/\\ensuremath\{\\delta\}/g;
641: $result =~ s/&(epsilon|\#949);/\\ensuremath\{\\epsilon\}/g;
642: $result =~ s/&(zeta|\#950);/\\ensuremath\{\\zeta\}/g;
643: $result =~ s/&(eta|\#951);/\\ensuremath\{\\eta\}/g;
644: $result =~ s/&(theta|\#952);/\\ensuremath\{\\theta\}/g;
645: $result =~ s/&(iota|\#953);/\\ensuremath\{\\iota\}/g;
646: $result =~ s/&(kappa|\#954);/\\ensuremath\{\\kappa\}/g;
647: $result =~ s/&(lambda|\#955);/\\ensuremath\{\\lambda\}/g;
648: $result =~ s/&(mu|\#956);/\\ensuremath\{\\mu\}/g;
649: $result =~ s/&(nu|\#957);/\\ensuremath\{\\nu\}/g;
650: $result =~ s/&(xi|\#958);/\\ensuremath\{\\xi\}/g;
651: $result =~ s/&(omicron|\#959);/o/g;
652: $result =~ s/&(pi|\#960);/\\ensuremath\{\\pi\}/g;
653: $result =~ s/&(rho|\#961);/\\ensuremath\{\\rho\}/g;
654: $result =~ s/&(sigma|\#963);/\\ensuremath\{\\sigma\}/g;
655: $result =~ s/&(tau|\#964);/\\ensuremath\{\\tau\}/g;
656: $result =~ s/&(upsilon|\#965);/\\ensuremath\{\\upsilon\}/g;
657: $result =~ s/&(phi|\#966);/\\ensuremath\{\\phi\}/g;
658: $result =~ s/&(chi|\#967);/\\ensuremath\{\\chi\}/g;
659: $result =~ s/&(psi|\#968);/\\ensuremath\{\\psi\}/g;
660: $result =~ s/&(omega|\#969);/\\ensuremath\{\\omega\}/g;
661: $result =~ s/&(thetasym|\#977);/\\ensuremath\{\\vartheta\}/g;
662: $result =~ s/&(piv|\#982);/\\ensuremath\{\\varpi\}/g;
663: $result =~ s/&(Alpha|\#913);/A/g;
664: $result =~ s/&(Beta|\#914);/B/g;
665: $result =~ s/&(Gamma|\#915);/\\ensuremath\{\\Gamma\}/g;
666: $result =~ s/&(Delta|\#916);/\\ensuremath\{\\Delta\}/g;
667: $result =~ s/&(Epsilon|\#917);/E/g;
668: $result =~ s/&(Zeta|\#918);/Z/g;
669: $result =~ s/&(Eta|\#919);/H/g;
670: $result =~ s/&(Theta|\#920);/\\ensuremath\{\\Theta\}/g;
671: $result =~ s/&(Iota|\#921);/I/g;
672: $result =~ s/&(Kappa|\#922);/K/g;
673: $result =~ s/&(Lambda|\#923);/\\ensuremath\{\\Lambda\}/g;
674: $result =~ s/&(Mu|\#924);/M/g;
675: $result =~ s/&(Nu|\#925);/N/g;
676: $result =~ s/&(Xi|\#926);/\\ensuremath\{\\Xi\}/g;
677: $result =~ s/&(Omicron|\#927);/O/g;
678: $result =~ s/&(Pi|\#928);/\\ensuremath\{\\Pi\}/g;
679: $result =~ s/&(Rho|\#929);/P/g;
680: $result =~ s/&(Sigma|\#931);/\\ensuremath\{\\Sigma\}/g;
681: $result =~ s/&(Tau|\#932);/T/g;
682: $result =~ s/&(Upsilon|\#933);/\\ensuremath\{\\Upsilon\}/g;
683: $result =~ s/&(Phi|\#934);/\\ensuremath\{\\Phi\}/g;
684: $result =~ s/&(Chi|\#935);/X/g;
685: $result =~ s/&(Psi|\#936);/\\ensuremath\{\\Psi\}/g;
686: $result =~ s/&(Omega|\#937);/\\ensuremath\{\\Omega\}/g;
687: #Arrows (extended HTML 4.01)
688: $result =~ s/&(larr|\#8592);/\\ensuremath\{\\leftarrow\}/g;
689: $result =~ s/&(uarr|\#8593);/\\ensuremath\{\\uparrow\}/g;
690: $result =~ s/&(rarr|\#8594);/\\ensuremath\{\\rightarrow\}/g;
691: $result =~ s/&(darr|\#8595);/\\ensuremath\{\\downarrow\}/g;
692: $result =~ s/&(harr|\#8596);/\\ensuremath\{\\leftrightarrow\}/g;
693: $result =~ s/&(lArr|\#8656);/\\ensuremath\{\\Leftarrow\}/g;
694: $result =~ s/&(uArr|\#8657);/\\ensuremath\{\\Uparrow\}/g;
695: $result =~ s/&(rArr|\#8658);/\\ensuremath\{\\Rightarrow\}/g;
696: $result =~ s/&(dArr|\#8659);/\\ensuremath\{\\Downarrow\}/g;
697: $result =~ s/&(hArr|\#8660);/\\ensuremath\{\\Leftrightarrow\}/g;
698: #Mathematical Operators (extended HTML 4.01)
699: $result =~ s/&(forall|\#8704);/\\ensuremath\{\\forall\}/g;
700: $result =~ s/&(part|\#8706);/\\ensuremath\{\\partial\}/g;
701: $result =~ s/&(exist|\#8707);/\\ensuremath\{\\exists\}/g;
702: $result =~ s/&(empty|\#8709);/\\ensuremath\{\\emptyset\}/g;
703: $result =~ s/&(nabla|\#8711);/\\ensuremath\{\\nabla\}/g;
704: $result =~ s/&(isin|\#8712);/\\ensuremath\{\\in\}/g;
705: $result =~ s/&(notin|\#8713);/\\ensuremath\{\\notin\}/g;
706: $result =~ s/&(ni|\#8715);/\\ensuremath\{\\ni\}/g;
707: $result =~ s/&(prod|\#8719);/\\ensuremath\{\\prod\}/g;
708: $result =~ s/&(sum|\#8721);/\\ensuremath\{\\sum\}/g;
709: $result =~ s/&(minus|\#8722);/\\ensuremath\{-\}/g;
710: $result =~ s/–/\\ensuremath\{-\}/g;
711: $result =~ s/&(lowast|\#8727);/\\ensuremath\{*\}/g;
712: $result =~ s/&(radic|\#8730);/\\ensuremath\{\\surd\}/g;
713: $result =~ s/&(prop|\#8733);/\\ensuremath\{\\propto\}/g;
714: $result =~ s/&(infin|\#8734);/\\ensuremath\{\\infty\}/g;
715: $result =~ s/&(ang|\#8736);/\\ensuremath\{\\angle\}/g;
716: $result =~ s/&(and|\#8743);/\\ensuremath\{\\wedge\}/g;
717: $result =~ s/&(or|\#8744);/\\ensuremath\{\\vee\}/g;
718: $result =~ s/&(cap|\#8745);/\\ensuremath\{\\cap\}/g;
719: $result =~ s/&(cup|\#8746);/\\ensuremath\{\\cup\}/g;
720: $result =~ s/&(int|\#8747);/\\ensuremath\{\\int\}/g;
721: $result =~ s/&(sim|\#8764);/\\ensuremath\{\\sim\}/g;
722: $result =~ s/&(cong|\#8773);/\\ensuremath\{\\cong\}/g;
723: $result =~ s/&(asymp|\#8776);/\\ensuremath\{\\approx\}/g;
724: $result =~ s/&(ne|\#8800);/\\ensuremath\{\\not=\}/g;
725: $result =~ s/&(equiv|\#8801);/\\ensuremath\{\\equiv\}/g;
726: $result =~ s/&(le|\#8804);/\\ensuremath\{\\leq\}/g;
727: $result =~ s/&(ge|\#8805);/\\ensuremath\{\\geq\}/g;
728: $result =~ s/&(sub|\#8834);/\\ensuremath\{\\subset\}/g;
729: $result =~ s/&(sup|\#8835);/\\ensuremath\{\\supset\}/g;
730: $result =~ s/&(nsub|\#8836);/\\ensuremath\{\\not\\subset\}/g;
731: $result =~ s/&(sube|\#8838);/\\ensuremath\{\\subseteq\}/g;
732: $result =~ s/&(supe|\#8839);/\\ensuremath\{\\supseteq\}/g;
733: $result =~ s/&(oplus|\#8853);/\\ensuremath\{\\oplus\}/g;
734: $result =~ s/&(otimes|\#8855);/\\ensuremath\{\\otimes\}/g;
735: $result =~ s/&(perp|\#8869);/\\ensuremath\{\\perp\}/g;
736: $result =~ s/&(sdot|\#8901);/\\ensuremath\{\\cdot\}/g;
737: #Geometric Shapes (extended HTML 4.01)
738: $result =~ s/&(loz|\#9674);/\\ensuremath\{\\Diamond\}/g;
739: #Miscellaneous Symbols (extended HTML 4.01)
740: $result =~ s/&(spades|\#9824);/\\ensuremath\{\\spadesuit\}/g;
741: $result =~ s/&(clubs|\#9827);/\\ensuremath\{\\clubsuit\}/g;
742: $result =~ s/&(hearts|\#9829);/\\ensuremath\{\\heartsuit\}/g;
743: $result =~ s/&(diams|\#9830);/\\ensuremath\{\\diamondsuit\}/g;
744: # Chemically useful 'things' contributed by Hon Kie (bug 4652).
745: $result =~ s/&\#8636;/\\ensuremath\{\\leftharpoonup\}/g;
746: $result =~ s/&\#8637;/\\ensuremath\{\\leftharpoondown\}/g;
747: $result =~ s/&\#8640;/\\ensuremath\{\\rightharpoonup\}/g;
748: $result =~ s/&\#8641;/\\ensuremath\{\\rightharpoondown\}/g;
749: $result =~ s/&\#8652;/\\ensuremath\{\\rightleftharpoons\}/g;
750: $result =~ s/&\#8605;/\\ensuremath\{\\leadsto\}/g;
751: $result =~ s/&\#8617;/\\ensuremath\{\\hookleftarrow\}/g;
752: $result =~ s/&\#8618;/\\ensuremath\{\\hookrightarrow\}/g;
753: $result =~ s/&\#8614;/\\ensuremath\{\\mapsto\}/g;
754: $result =~ s/&\#8599;/\\ensuremath\{\\nearrow\}/g;
755: $result =~ s/&\#8600;/\\ensuremath\{\\searrow\}/g;
756: $result =~ s/&\#8601;/\\ensuremath\{\\swarrow\}/g;
757: $result =~ s/&\#8598;/\\ensuremath\{\\nwarrow\}/g;
758:
759: # Left/right quotations:
760:
761: $result =~ s/&(ldquo|#8220);/\`\`/g;
762: $result =~ s/&(rdquo|#8221);/\'\'/g;
763:
764:
765: return $result;
766: }
767:
768:
769: #width, height, oddsidemargin, evensidemargin, topmargin
770: my %page_formats=
771: ('letter' => {
772: 'book' => {
773: '1' => [ '7.1 in','9.8 in', '-0.57 in','-0.57 in','0.275 in'],
774: '2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.275 in']
775: },
776: 'album' => {
777: '1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.55 in','0.394 in'],
778: '2' => [ '4.8 in', '6.8 in','-0.5 in', '-1.0 in','3.5 in']
779: },
780: },
781: 'legal' => {
782: 'book' => {
783: '1' => ['7.1 in','13 in',,'-0.57 in','-0.57 in','-0.5 in'],
784: '2' => ['3.66 in','13 in','-0.57 in','-0.57 in','-0.5 in']
785: },
786: 'album' => {
787: '1' => ['12 in','7.1 in',,'-0.57 in','-0.57 in','-0.5 in'],
788: '2' => ['6.0 in','7.1 in','-1 in','-1 in','5 in']
789: },
790: },
791: 'tabloid' => {
792: 'book' => {
793: '1' => ['9.8 in','16 in','-0.57 in','-0.57 in','-0.5 in'],
794: '2' => ['4.9 in','16 in','-0.57 in','-0.57 in','-0.5 in']
795: },
796: 'album' => {
797: '1' => ['16 in','9.8 in','-0.57 in','-0.57 in','-0.5 in'],
798: '2' => ['16 in','4.9 in','-0.57 in','-0.57 in','-0.5 in']
799: },
800: },
801: 'executive' => {
802: 'book' => {
803: '1' => ['6.8 in','9 in','-0.57 in','-0.57 in','1.2 in'],
804: '2' => ['3.1 in','9 in','-0.57 in','-0.57 in','1.2 in']
805: },
806: 'album' => {
807: '1' => [],
808: '2' => []
809: },
810: },
811: 'a2' => {
812: 'book' => {
813: '1' => [],
814: '2' => []
815: },
816: 'album' => {
817: '1' => [],
818: '2' => []
819: },
820: },
821: 'a3' => {
822: 'book' => {
823: '1' => [],
824: '2' => []
825: },
826: 'album' => {
827: '1' => [],
828: '2' => []
829: },
830: },
831: 'a4' => {
832: 'book' => {
833: '1' => ['17.6 cm','27.2 cm','-1.397 cm','-2.11 cm','-1.27 cm'],
834: '2' => [ '9.1 cm','27.2 cm','-1.397 cm','-2.11 cm','-1.27 cm']
835: },
836: 'album' => {
837: '1' => ['21.59 cm','19.558 cm','-1.397cm','-2.11 cm','0 cm'],
838: '2' => ['9.91 cm','19.558 cm','-1.397 cm','-2.11 cm','0 cm']
839: },
840: },
841: 'a5' => {
842: 'book' => {
843: '1' => [],
844: '2' => []
845: },
846: 'album' => {
847: '1' => [],
848: '2' => []
849: },
850: },
851: 'a6' => {
852: 'book' => {
853: '1' => [],
854: '2' => []
855: },
856: 'album' => {
857: '1' => [],
858: '2' => []
859: },
860: },
861: );
862:
863: sub page_format {
864: #
865: #Supported paper format: "Letter [8 1/2x11 in]", "Legal [8 1/2x14 in]",
866: # "Ledger/Tabloid [11x17 in]", "Executive [7 1/2x10 in]",
867: # "A2 [420x594 mm]", "A3 [297x420 mm]",
868: # "A4 [210x297 mm]", "A5 [148x210 mm]",
869: # "A6 [105x148 mm]"
870: #
871: my ($papersize,$layout,$numberofcolumns) = @_;
872: return @{$page_formats{$papersize}->{$layout}->{$numberofcolumns}};
873: }
874:
875:
876: sub get_name {
877: my ($uname,$udom)=@_;
878: if (!defined($uname)) { $uname=$env{'user.name'}; }
879: if (!defined($udom)) { $udom=$env{'user.domain'}; }
880: my $plainname=&Apache::loncommon::plainname($uname,$udom);
881: if ($plainname=~/^\s*$/) { $plainname=$uname.'@'.$udom; }
882: $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');
883: return $plainname;
884: }
885:
886: sub get_course {
887: my $courseidinfo;
888: if (defined($env{'request.course.id'})) {
889: $courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');
890: }
891: return $courseidinfo;
892: }
893:
894: sub page_format_transformation {
895: my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist,$selectionmade) = @_;
896: my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin);
897:
898: if ($selectionmade eq '4') {
899: if ($choice eq 'all_problems') {
900: $assignment='Problems from the Whole Course';
901: } else {
902: $assignment='Resources from the Whole Course';
903: }
904: } else {
905: $assignment=&Apache::lonxml::latex_special_symbols($assignment,'header');
906: }
907: ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin);
908:
909:
910: my $name = &get_name();
911: my $courseidinfo = &get_course();
912: if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
913: my $header_text = $parmhash{'print_header_format'};
914: $header_text = &format_page_header($textwidth, $header_text, $assignment,
915: $courseidinfo, $name);
916: my $topmargintoinsert = '';
917: if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';}
918: my $fancypagestatement='';
919: if ($numberofcolumns eq '2') {
920: $fancypagestatement="\\fancyhead{}\\fancyhead[LO]{$header_text}";
921: } else {
922: $fancypagestatement="\\rhead{}\\chead{}\\lhead{$header_text}";
923: }
924: if ($layout eq 'album') {
925: $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\n\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\n\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\n\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}\n /;
926: } elsif ($layout eq 'book') {
927: if ($choice ne 'All class print') {
928: $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\n\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\n\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\\pagestyle{fancy}$fancypagestatement\\begin{document}\n\\voffset=-0\.8 cm\\setcounter{page}{1}\n/;
929: } else {
930: $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /;
931: }
932: if ($papersize eq 'a4') {
933: $text =~ s/(\\begin{document})/$1\\special{papersize=210mm,297mm}/;
934: }
935: }
936: if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;}
937: if ($indexlist eq 'yes') {
938: $text=~s/(\\begin{document})/\\makeindex $1/;
939: $text=~s/(\\end{document})/\\strut\\\\\\strut\\printindex $1/;
940: }
941: return $text;
942: }
943:
944:
945: sub page_cleanup {
946: my $result = shift;
947:
948: $result =~ m/\\end{document}(\d*)$/;
949: my $number_of_columns = $1;
950: my $insert = '{';
951: for (my $id=1;$id<=$number_of_columns;$id++) { $insert .='l'; }
952: $insert .= '}';
953: $result =~ s/(\\begin{longtable})INSERTTHEHEADOFLONGTABLE\\endfirsthead\\endhead/$1$insert/g;
954: $result =~ s/&\s*REMOVETHEHEADOFLONGTABLE\\\\/\\\\/g;
955: return $result,$number_of_columns;
956: }
957:
958:
959: sub details_for_menu {
960: my ($helper)=@_;
961: my $postdata=$env{'form.postdata'};
962: if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; }
963: my $name_of_resource = &Apache::lonnet::gettitle($postdata);
964: my $symbolic = &Apache::lonnet::symbread($postdata);
965: return if ( $symbolic eq '');
966:
967: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic);
968: $map=&Apache::lonnet::clutter($map);
969: my $name_of_sequence = &Apache::lonnet::gettitle($map);
970: if ($name_of_sequence =~ /^\s*$/) {
971: $map =~ m|([^/]+)$|;
972: $name_of_sequence = $1;
973: }
974: my $name_of_map = &Apache::lonnet::gettitle($env{'request.course.uri'});
975: if ($name_of_map =~ /^\s*$/) {
976: $env{'request.course.uri'} =~ m|([^/]+)$|;
977: $name_of_map = $1;
978: }
979: return ($name_of_resource,$name_of_sequence,$name_of_map);
980: }
981:
982: sub copyright_line {
983: return '\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\vspace*{-2 mm}\newline\noindent{\tiny Printed from LON-CAPA\copyright MSU{\hfill} Licensed under GNU General Public License } ';
984: }
985: my $end_of_student = "\n".'\special{ps:ENDOFSTUDENTSTAMP}'."\n";
986:
987: sub latex_corrections {
988: my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_;
989: # $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
990: my $copyright = ©right_line();
991: if ($selectionmade eq '1' || $answer_mode eq 'only') {
992: $result =~ s/(\\end{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/;
993: } else {
994: $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/;
995: }
996: $result =~ s/\$number_of_columns/$number_of_columns/g;
997: $result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g;
998: $result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g;
999: #-- LaTeX corrections
1000: my $first_comment = index($result,'<!--',0);
1001: while ($first_comment != -1) {
1002: my $end_comment = index($result,'-->',$first_comment);
1003: substr($result,$first_comment,$end_comment-$first_comment+3) = '';
1004: $first_comment = index($result,'<!--',$first_comment);
1005: }
1006: $result =~ s/^\s+$//gm; #remove empty lines
1007: #removes more than one empty space
1008: $result =~ s|(\s\s+)|($1=~/[\n\r]/)?"\n":" "|ge;
1009: $result =~ s/\\\\\s*\\vskip/\\vskip/gm;
1010: $result =~ s/\\\\\s*\\noindent\s*(\\\\)+/\\\\\\noindent /g;
1011: $result =~ s/{\\par }\s*\\\\/\\\\/gm;
1012: $result =~ s/\\\\\s+\[/ \[/g;
1013: #conversion of html characters to LaTeX equivalents
1014: if ($result =~ m/&(\w+|#\d+);/) {
1015: $result = &character_chart($result);
1016: }
1017: $result =~ s/(\\end{tabular})\s*\\vskip 0 mm/$1/g;
1018: $result =~ s/(\\begin{enumerate})\s*\\noindent/$1/g;
1019: return $result;
1020: }
1021:
1022:
1023: sub index_table {
1024: my $currentURL = shift;
1025: my $insex_string='';
1026: $currentURL=~s/\.([^\/+])$/\.$1\.meta/;
1027: $insex_string=&Apache::lonnet::metadata($currentURL,'keywords');
1028: return $insex_string;
1029: }
1030:
1031:
1032: sub IndexCreation {
1033: my ($texversion,$currentURL)=@_;
1034: my @key_words=split(/,/,&index_table($currentURL));
1035: my $chunk='';
1036: my $st=index $texversion,'\addcontentsline{toc}{subsection}{';
1037: if ($st>0) {
1038: for (my $i=0;$i<3;$i++) {$st=(index $texversion,'}',$st+1);}
1039: $chunk=substr($texversion,0,$st+1);
1040: substr($texversion,0,$st+1)=' ';
1041: }
1042: foreach my $key_word (@key_words) {
1043: if ($key_word=~/\S+/) {
1044: $texversion=~s/\b($key_word)\b/$1 \\index{$key_word} /i;
1045: }
1046: }
1047: if ($st>0) {substr($texversion,0,1)=$chunk;}
1048: return $texversion;
1049: }
1050:
1051: sub print_latex_header {
1052: my $mode=shift;
1053: my $output='\documentclass[letterpaper,twoside]{article}\raggedbottom';
1054: if (($mode eq 'batchmode') || (!$perm{'pav'})) {
1055: $output.='\batchmode';
1056: }
1057: $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
1058: '\usepackage{multirow}'."\n".
1059: '\usepackage{longtable}\usepackage{textcomp}\usepackage{makeidx}'."\n".
1060: '\usepackage[dvips]{graphicx}\usepackage{epsfig}'."\n".
1061: '\usepackage{wrapfig}'.
1062: '\usepackage{picins}\usepackage{calc}'."\n".
1063: '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}'."\n".
1064: '\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}'."\n".
1065: '\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}'."\n".
1066: '\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}'."\n".
1067: '\setlength{\abovedisplayshortskip}{-0.04in}'."\n".
1068: '\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'."\n".
1069: '\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large'."\n".
1070: '\textbf{Index}} \newline \setlength{\rightmargin}{0in}'."\n".
1071: '\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}'."\n".
1072: '\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}'."\n".
1073: '\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}'."\n".
1074: '\setlength{\abovedisplayshortskip}{-0.04in}'."\n".
1075: '\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}\begin{document}'."\n";
1076: return $output;
1077: }
1078:
1079: sub path_to_problem {
1080: my ($urlp,$colwidth)=@_;
1081: $urlp=&Apache::lonnet::clutter($urlp);
1082:
1083: my $newurlp = '';
1084: $colwidth=~s/\s*mm\s*$//;
1085: #characters average about 2 mm in width
1086: if (length($urlp)*2 > $colwidth) {
1087: my @elements = split('/',$urlp);
1088: my $curlength=0;
1089: foreach my $element (@elements) {
1090: if ($element eq '') { next; }
1091: if ($curlength+(length($element)*2) > $colwidth) {
1092: $newurlp .= '|\vskip -1 mm \verb|';
1093: $curlength=length($element)*2;
1094: } else {
1095: $curlength+=length($element)*2;
1096: }
1097: $newurlp.='/'.$element;
1098: }
1099: } else {
1100: $newurlp=$urlp;
1101: }
1102: return '{\small\noindent\verb|'.$newurlp.'|\vskip 0 mm}';
1103: }
1104:
1105: sub recalcto_mm {
1106: my $textwidth=shift;
1107: my $LaTeXwidth;
1108: if ($textwidth=~/(-?\d+\.?\d*)\s*cm/) {
1109: $LaTeXwidth = $1*10;
1110: } elsif ($textwidth=~/(-?\d+\.?\d*)\s*mm/) {
1111: $LaTeXwidth = $1;
1112: } elsif ($textwidth=~/(-?\d+\.?\d*)\s*in/) {
1113: $LaTeXwidth = $1*25.4;
1114: }
1115: $LaTeXwidth.=' mm';
1116: return $LaTeXwidth;
1117: }
1118:
1119: sub get_textwidth {
1120: my ($helper,$LaTeXwidth)=@_;
1121: my $textwidth=$LaTeXwidth;
1122: if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
1123: $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
1124: $textwidth=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.
1125: $helper->{'VARS'}->{'pagesize.widthunit'});
1126: }
1127: return $textwidth;
1128: }
1129:
1130:
1131: sub unsupported {
1132: my ($currentURL,$mode,$symb)=@_;
1133: if ($mode ne '') {$mode='\\'.$mode}
1134: my $result.= &print_latex_header($mode);
1135: if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {
1136: $currentURL=~s|^(/adm/wrapper/)?ext/|http://|;
1137: my $title=&Apache::lonnet::gettitle($symb);
1138: $title = &Apache::lonxml::latex_special_symbols($title);
1139: $result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' ';
1140: } else {
1141: $result.=$currentURL;
1142: }
1143: $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}';
1144: return $result;
1145: }
1146:
1147:
1148: #
1149: # List of recently generated print files
1150: #
1151: sub recently_generated {
1152: my $r=shift;
1153: my $prtspool=$r->dir_config('lonPrtDir');
1154: my $zip_result;
1155: my $pdf_result;
1156: opendir(DIR,$prtspool);
1157:
1158: my @files =
1159: grep(/^$env{'user.name'}_$env{'user.domain'}_printout_(\d+)_.*\.(pdf|zip)$/,readdir(DIR));
1160: closedir(DIR);
1161:
1162: @files = sort {
1163: my ($actime) = (stat($prtspool.'/'.$a))[10];
1164: my ($bctime) = (stat($prtspool.'/'.$b))[10];
1165: return $bctime <=> $actime;
1166: } (@files);
1167:
1168: foreach my $filename (@files) {
1169: my ($ext) = ($filename =~ m/(pdf|zip)$/);
1170: my ($cdev,$cino,$cmode,$cnlink,
1171: $cuid,$cgid,$crdev,$csize,
1172: $catime,$cmtime,$cctime,
1173: $cblksize,$cblocks)=stat($prtspool.'/'.$filename);
1174: my $result="<a href='/prtspool/$filename'>".
1175: &mt('Generated [_1] ([_2] bytes)',
1176: &Apache::lonlocal::locallocaltime($cctime),$csize).
1177: '</a><br />';
1178: if ($ext eq 'pdf') { $pdf_result .= $result; }
1179: if ($ext eq 'zip') { $zip_result .= $result; }
1180: }
1181: if ($zip_result) {
1182: $r->print('<h4>'.&mt('Recently generated printout zip files')."</h4>\n"
1183: .$zip_result);
1184: }
1185: if ($pdf_result) {
1186: $r->print('<h4>'.&mt('Recently generated printouts')."</h4>\n"
1187: .$pdf_result);
1188: }
1189: }
1190:
1191: #
1192: # Retrieve the hash of page breaks.
1193: #
1194: # Inputs:
1195: # helper - reference to helper object.
1196: # Outputs
1197: # A reference to a page break hash.
1198: #
1199: #
1200: #use Data::Dumper;
1201: #sub dump_helper_vars {
1202: # my ($helper) = @_;
1203: # my $helpervars = Dumper($helper->{'VARS'});
1204: # &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars");
1205: #}
1206:
1207: sub get_page_breaks {
1208: my ($helper) = @_;
1209: my %page_breaks;
1210:
1211: foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) {
1212: $page_breaks{$break} = 1;
1213: }
1214: return %page_breaks;
1215: }
1216:
1217: # Output a sequence (recursively if neeed)
1218: # from construction space.
1219: # Parameters:
1220: # url = URL of the sequence to print.
1221: # helper - Reference to the helper hash.
1222: # form - Copy of the format hash.
1223: # LaTeXWidth
1224: # Returns:
1225: # Text to add to the printout.
1226: # NOTE if the first element of the outermost sequence
1227: # is itself a sequence, the outermost caller may need to
1228: # prefix the latex with the page headers stuff.
1229: #
1230: sub print_construction_sequence {
1231: my ($currentURL, $helper, %form, $LaTeXwidth) = @_;
1232: my $result;
1233: my $rndseed=time;
1234: if ($helper->{'VARS'}->{'curseed'}) {
1235: $rndseed=$helper->{'VARS'}->{'curseed'};
1236: }
1237: my $errtext=&LONCAPA::map::mapread($currentURL);
1238: #
1239: # These make this all support recursing for subsequences.
1240: #
1241: my @order = @LONCAPA::map::order;
1242: my @resources = @LONCAPA::map::resources;
1243: for (my $member=0;$member<=$#order;$member++) {
1244: $resources[$order[$member]]=~/^([^:]*):([^:]*):/;
1245: my $urlp=$2;
1246: if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {
1247: my $texversion='';
1248: if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
1249: $form{'problem_split'}=$parmhash{'problem_stream_switch'};
1250: $form{'suppress_tries'}=$parmhash{'suppress_tries'};
1251: $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
1252: $form{'rndseed'}=$rndseed;
1253: $resources_printed .=$urlp.':';
1254: $texversion=&Apache::lonnet::ssi($urlp,%form);
1255: }
1256: if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
1257: ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) &&
1258: ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) {
1259: # Don't permanently modify %$form...
1260: my %answerform = %form;
1261: $answerform{'grade_target'}='answer';
1262: $answerform{'answer_output_mode'}='tex';
1263: $answerform{'rndseed'}=$rndseed;
1264: $answerform{'problem_split'}=$parmhash{'problem_stream_switch'};
1265: if ($urlp=~/\/res\//) {$env{'request.state'}='published';}
1266: $resources_printed .= $urlp.':';
1267: my $answer=&Apache::lonnet::ssi($urlp,%answerform);
1268: if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
1269: $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
1270: } else {
1271: # If necessary, encapsulate answer in minipage:
1272:
1273: $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
1274: my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'});
1275: $title = &Apache::lonxml::latex_special_symbols($title);
1276: my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
1277: $body.=&path_to_problem($urlp,$LaTeXwidth);
1278: $body.='\vskip 1 mm '.$answer.'\end{document}';
1279: $body = &encapsulate_minipage($body);
1280: $texversion.=$body;
1281: }
1282: }
1283: $texversion = &latex_header_footer_remove($texversion);
1284:
1285: if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
1286: $texversion=&IndexCreation($texversion,$urlp);
1287: }
1288: if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') {
1289: $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;
1290: }
1291: $result.=$texversion;
1292:
1293: } elsif ($urlp=~/\.(sequence|page)$/) {
1294:
1295: # header:
1296:
1297: $result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent ';
1298:
1299: # IF sequence, recurse:
1300:
1301: if ($urlp =~ /\.sequence$/) {
1302: my $sequence_url = $urlp;
1303: my $domain = $env{'user.domain'}; # Constr. space only on local
1304: my $user = $env{'user.name'};
1305:
1306: $sequence_url =~ s/^\/res\/$domain/\/home/;
1307: $sequence_url =~ s/^(\/home\/$user)/$1\/public_html/;
1308: # $sequence_url =~ s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
1309: $result .= &print_construction_sequence($sequence_url,
1310: $helper, %form,
1311: $LaTeXwidth);
1312: }
1313: }
1314: }
1315: if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
1316: return $result;
1317: }
1318:
1319: sub output_data {
1320: my ($r,$helper,$rparmhash) = @_;
1321: my %parmhash = %$rparmhash;
1322: $resources_printed = '';
1323: my $do_postprocessing = 1;
1324: my $js = <<ENDPART;
1325: <script type="text/javascript">
1326: var editbrowser;
1327: function openbrowser(formname,elementname,only,omit) {
1328: var url = '/res/?';
1329: if (editbrowser == null) {
1330: url += 'launch=1&';
1331: }
1332: url += 'catalogmode=interactive&';
1333: url += 'mode=parmset&';
1334: url += 'form=' + formname + '&';
1335: if (only != null) {
1336: url += 'only=' + only + '&';
1337: }
1338: if (omit != null) {
1339: url += 'omit=' + omit + '&';
1340: }
1341: url += 'element=' + elementname + '';
1342: var title = 'Browser';
1343: var options = 'scrollbars=1,resizable=1,menubar=0';
1344: options += ',width=700,height=600';
1345: editbrowser = open(url,title,options,'1');
1346: editbrowser.focus();
1347: }
1348: </script>
1349: ENDPART
1350:
1351:
1352:
1353: my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js);
1354: my $msg = &mt('Please stand by while processing your print request, this may take some time ...');
1355:
1356: $r->print($start_page."\n<p>\n$msg\n</p>\n");
1357:
1358: # fetch the pagebreaks and store them in the course environment
1359: # The page breaks will be pulled into the hash %page_breaks which is
1360: # indexed by symb and contains 1's for each break.
1361:
1362: $env{'form.pagebreaks'} = $helper->{'VARS'}->{'FINISHPAGE'};
1363: $env{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'};
1364: &Apache::loncommon::store_course_settings('print',
1365: {'pagebreaks' => 'scalar',
1366: 'lastprinttype' => 'scalar'});
1367:
1368: my %page_breaks = &get_page_breaks($helper);
1369:
1370: my $format_from_helper = $helper->{'VARS'}->{'FORMAT'};
1371: my ($result,$selectionmade) = ('','');
1372: my $number_of_columns = 1; #used only for pages to determine the width of the cell
1373: my @temporary_array=split /\|/,$format_from_helper;
1374: my ($laystyle,$numberofcolumns,$papersize)=@temporary_array;
1375: if ($laystyle eq 'L') {
1376: $laystyle='album';
1377: } else {
1378: $laystyle='book';
1379: }
1380: my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
1381: my $assignment = $env{'form.assignment'};
1382: my $LaTeXwidth=&recalcto_mm($textwidth);
1383: my @print_array=();
1384: my @student_names=();
1385:
1386:
1387: # Common settings for the %form has:
1388: # In some cases these settings get overriddent by specific cases, but the
1389: # settings are common enough to make it worthwhile factoring them out
1390: # here.
1391: #
1392: my %form;
1393: $form{'grade_target'} = 'tex';
1394: $form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth);
1395:
1396: # If form.showallfoils is set, then request all foils be shown:
1397: # privilege will be enforced both by not allowing the
1398: # check box selecting this option to be presnt unless it's ok,
1399: # and by lonresponse's priv. check.
1400: # The if is here because lonresponse.pm only cares that
1401: # showallfoils is defined, not what the value is.
1402:
1403: if ($helper->{'VARS'}->{'showallfoils'} eq "1") {
1404: $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'};
1405: }
1406:
1407: if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
1408: &Apache::lonnet::appenv('construct.style' =>
1409: $helper->{'VARS'}->{'style_file'});
1410: } elsif ($env{'construct.style'}) {
1411: &Apache::lonnet::delenv('construct\\.style');
1412: }
1413:
1414:
1415: if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
1416: #-- single document - problem, page, html, xml, ...
1417: my ($currentURL,$cleanURL);
1418:
1419: if ($helper->{'VARS'}->{'construction'} ne '1') {
1420: #prints published resource
1421: $currentURL=$helper->{'VARS'}->{'postdata'};
1422: $cleanURL=&Apache::lonenc::check_decrypt($currentURL);
1423: } else {
1424:
1425: #prints resource from the construction space
1426: $currentURL='/'.$helper->{'VARS'}->{'filename'};
1427: if ($currentURL=~/([^?]+)/) {$currentURL=$1;}
1428: $cleanURL=$currentURL;
1429: }
1430: $selectionmade = 1;
1431: if ($cleanURL!~m|^/adm/|
1432: && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
1433: my $rndseed=time;
1434: my $texversion='';
1435: if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
1436: my %moreenv;
1437: $moreenv{'request.filename'}=$cleanURL;
1438: if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';}
1439: $form{'problem_split'}=$parmhash{'problem_stream_switch'};
1440: $form{'suppress_tries'}=$parmhash{'suppress_tries'};
1441: $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
1442: $form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
1443: $form{'print_annotations'}=$helper->{'VARS'}->{'PRINT_ANNOTATIONS'};
1444: if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') ||
1445: ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) {
1446: $form{'problem_split'}='yes';
1447: }
1448: if ($helper->{'VARS'}->{'curseed'}) {
1449: $rndseed=$helper->{'VARS'}->{'curseed'};
1450: }
1451: $form{'rndseed'}=$rndseed;
1452: &Apache::lonnet::appenv(%moreenv);
1453:
1454: &Apache::lonxml::clear_problem_counter();
1455:
1456: $resources_printed .= $currentURL.':';
1457: $texversion.=&Apache::lonnet::ssi($currentURL,%form);
1458:
1459: # Add annotations if required:
1460:
1461: &Apache::lonxml::clear_problem_counter();
1462:
1463: &Apache::lonnet::delenv('request.filename');
1464: }
1465: # current document with answers.. no need to encap in minipage
1466: # since there's only one answer.
1467:
1468: if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
1469: ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
1470: $form{'problem_split'}=$parmhash{'problem_stream_switch'};
1471: $form{'grade_target'}='answer';
1472: $form{'answer_output_mode'}='tex';
1473: $form{'rndseed'}=$rndseed;
1474: if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {
1475: $form{'problemtype'}='exam';
1476: }
1477: $resources_printed .= $currentURL.':';
1478: my $answer=&Apache::lonnet::ssi($currentURL,%form);
1479:
1480:
1481: if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
1482: $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
1483: } else {
1484: $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
1485: if ($helper->{'VARS'}->{'construction'} ne '1') {
1486: my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'});
1487: $title = &Apache::lonxml::latex_special_symbols($title);
1488: $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
1489: $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
1490: } else {
1491: $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm ';
1492: my $URLpath=$cleanURL;
1493: $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/;
1494: $texversion.=&path_to_problem($URLpath,$LaTeXwidth);
1495: }
1496: $texversion.='\vskip 1 mm '.$answer.'\end{document}';
1497: }
1498:
1499:
1500:
1501:
1502: }
1503: # Print annotations.
1504:
1505:
1506: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
1507: my $annotation .= &annotate($currentURL);
1508: $texversion =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/;
1509: }
1510:
1511:
1512: if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
1513: $texversion=&IndexCreation($texversion,$currentURL);
1514: }
1515: if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') {
1516: $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$currentURL| \\strut\\\\\\strut /;
1517:
1518: }
1519: $result .= $texversion;
1520: if ($currentURL=~m/\.page\s*$/) {
1521: ($result,$number_of_columns) = &page_cleanup($result);
1522: }
1523: } elsif ($cleanURL!~m|^/adm/|
1524: && $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') {
1525: #printing content of sequence from the construction space
1526: $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
1527: $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
1528: $result .= &print_construction_sequence($currentURL, $helper, %form,
1529: $LaTeXwidth);
1530: $result .= '\end{document}';
1531: if (!($result =~ /\\begin\{document\}/)) {
1532: $result = &print_latex_header() . $result;
1533: }
1534: # End construction space sequence.
1535: } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
1536: $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
1537: if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
1538: $resources_printed .= $currentURL.':';
1539: my $texversion=&Apache::lonnet::ssi($currentURL,%form);
1540: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
1541: my $annotation = &annotate($currentURL);
1542: $texversion =~ s/(\\end{document})/$annotation$1/;
1543: }
1544: $result .= $texversion;
1545: } elsif ($cleanURL =~/.tex$/) {
1546: # For this sort of print of a single LaTeX file,
1547: # We can just print the LaTeX file as it is uninterpreted in any way:
1548: #
1549:
1550: $result = &fetch_raw_resource($currentURL);
1551: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
1552: my $annotation = &annotate($currentURL);
1553: $result =~ s/(\\end{document})/$annotation$1/;
1554: }
1555:
1556: $do_postprocessing = 0; # Don't massage the result.
1557:
1558: } else {
1559: $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},
1560: $helper->{'VARS'}->{'symb'});
1561: }
1562: } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or
1563: ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
1564: ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or
1565: ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') or # BUGBUG
1566: ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) {
1567:
1568:
1569: #-- produce an output string
1570: if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
1571: $selectionmade = 2;
1572: } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
1573: $selectionmade = 3;
1574: } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
1575: $selectionmade = 4;
1576: } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') { #BUGBUG
1577: $selectionmade = 4;
1578: } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {
1579: $selectionmade = 7;
1580: }
1581: $form{'problem_split'}=$parmhash{'problem_stream_switch'};
1582: $form{'suppress_tries'}=$parmhash{'suppress_tries'};
1583: $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
1584: $form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
1585: $form{'print_annotations'} = $helper->{'VARS'}->{'PRINT_ANNOTATIONS'};
1586: if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') ||
1587: ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') ) {
1588: $form{'problem_split'}='yes';
1589: }
1590: my $flag_latex_header_remove = 'NO';
1591: my $flag_page_in_sequence = 'NO';
1592: my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
1593: my $prevassignment='';
1594:
1595: &Apache::lonxml::clear_problem_counter();
1596:
1597: my $pbreakresources = keys %page_breaks;
1598: for (my $i=0;$i<=$#master_seq;$i++) {
1599:
1600: # Note due to document structure, not allowed to put \newpage
1601: # prior to the first resource
1602:
1603: if (defined $page_breaks{$master_seq[$i]}) {
1604: if($i != 0) {
1605: $result.="\\newpage\n";
1606: }
1607: }
1608: my ($sequence,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
1609: $urlp=&Apache::lonnet::clutter($urlp);
1610: $form{'symb'}=$master_seq[$i];
1611:
1612: my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem
1613: if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
1614: if ($i==0) {$prevassignment=$assignment;}
1615: my $texversion='';
1616: if ($urlp!~m|^/adm/|
1617: && $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
1618: $resources_printed .= $urlp.':';
1619: &Apache::lonxml::remember_problem_counter();
1620: $texversion.=&Apache::lonnet::ssi($urlp,%form);
1621: if ($urlp=~/\.page$/) {
1622: ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
1623: if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;}
1624: $texversion =~ s/\\end{document}\d*/\\end{document}/;
1625: $flag_page_in_sequence = 'YES';
1626: }
1627:
1628: if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
1629: ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
1630: # Don't permanently pervert the %form hash
1631: my %answerform = %form;
1632: $answerform{'grade_target'}='answer';
1633: $answerform{'answer_output_mode'}='tex';
1634: $resources_printed .= $urlp.':';
1635:
1636: &Apache::lonxml::restore_problem_counter();
1637: my $answer=&Apache::lonnet::ssi($urlp,%answerform);
1638:
1639: if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
1640: $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
1641: } else {
1642: if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
1643: $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
1644: my $title = &Apache::lonnet::gettitle($master_seq[$i]);
1645: $title = &Apache::lonxml::latex_special_symbols($title);
1646: my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
1647: $body .= &path_to_problem ($urlp,$LaTeXwidth);
1648: $body .='\vskip 1 mm '.$answer;
1649: $body = &encapsulate_minipage($body);
1650: $texversion .= $body;
1651: } else {
1652: $texversion='';
1653: }
1654: }
1655:
1656: }
1657: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
1658: my $annotation .= &annotate($urlp);
1659: $texversion =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/;
1660: }
1661:
1662: if ($flag_latex_header_remove ne 'NO') {
1663: $texversion = &latex_header_footer_remove($texversion);
1664: } else {
1665: $texversion =~ s/\\end{document}//;
1666: }
1667: if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
1668: $texversion=&IndexCreation($texversion,$urlp);
1669: }
1670: if (($selectionmade == 4) and ($assignment ne $prevassignment)) {
1671: my $name = &get_name();
1672: my $courseidinfo = &get_course();
1673: if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
1674: $prevassignment=$assignment;
1675: my $header_text = $parmhash{'print_header_format'};
1676: $header_text = &format_page_header($textwidth, $header_text,
1677: $assignment,
1678: $courseidinfo,
1679: $name);
1680: if ($numberofcolumns eq '1') {
1681: $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$header_text.'}} \vskip 5 mm ';
1682: } else {
1683: $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$header_text.'}} \vskip 5 mm ';
1684: }
1685: }
1686: $result .= $texversion;
1687: $flag_latex_header_remove = 'YES';
1688: } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
1689: $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
1690: if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
1691: $resources_printed .= $urlp.':';
1692: my $texversion=&Apache::lonnet::ssi($urlp,%form);
1693: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
1694: my $annotation = &annotate($urlp);
1695: $texversion =~ s/(\\end{document)/$annotation$1/;
1696: }
1697:
1698: if ($flag_latex_header_remove ne 'NO') {
1699: $texversion = &latex_header_footer_remove($texversion);
1700: } else {
1701: $texversion =~ s/\\end{document}/\\vskip 0\.5mm\\noindent\\makebox\[\\textwidth\/\$number_of_columns\]\[b\]\{\\hrulefill\}/;
1702: }
1703: $result .= $texversion;
1704: $flag_latex_header_remove = 'YES';
1705: } else {
1706: $texversion=&unsupported($urlp,$helper->{'VARS'}->{'LATEX_TYPE'},
1707: $master_seq[$i]);
1708: if ($flag_latex_header_remove ne 'NO') {
1709: $texversion = &latex_header_footer_remove($texversion);
1710: } else {
1711: $texversion =~ s/\\end{document}//;
1712: }
1713: $result .= $texversion;
1714: $flag_latex_header_remove = 'YES';
1715: }
1716: if (&Apache::loncommon::connection_aborted($r)) { last; }
1717: }
1718: &Apache::lonxml::clear_problem_counter();
1719: if ($flag_page_in_sequence eq 'YES') {
1720: $result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;
1721: }
1722: $result .= '\end{document}';
1723: } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') ||
1724: ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')){
1725:
1726:
1727: #-- prints assignments for whole class or for selected students
1728: my $type;
1729: if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {
1730: $selectionmade=5;
1731: $type='problems';
1732: } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students') {
1733: $selectionmade=8;
1734: $type='resources';
1735: }
1736: my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'};
1737: # The normal sort order is by section then by students within the
1738: # section. If the helper var student_sort is 1, then the user has elected
1739: # to override this and output the students by name.
1740: # Each element of the students array is of the form:
1741: # username:domain:section:last, first:status
1742: #
1743: # Note that student sort is not compatible with printing
1744: # 1 section per pdf...so that setting overrides.
1745: #
1746: if (($helper->{'VARS'}->{'student_sort'} eq 1) &&
1747: ($helper->{'VARS'}->{'SPLIT_PDFS'} ne "sections")) {
1748: @students = sort compare_names @students;
1749: }
1750: &adjust_number_to_print($helper);
1751:
1752: if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0' ||
1753: $helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq 'all' ) {
1754: $helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1;
1755: }
1756: # If we are splitting on section boundaries, we need
1757: # to remember that in split_on_sections and
1758: # print all of the students in the list.
1759: #
1760: my $split_on_sections = 0;
1761: if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq 'section') {
1762: $split_on_sections = 1;
1763: $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = $#students+1;
1764: }
1765: my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
1766:
1767: #loop over students
1768: my $flag_latex_header_remove = 'NO';
1769: my %moreenv;
1770: $moreenv{'instructor_comments'}='hide';
1771: $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
1772: $moreenv{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
1773: $moreenv{'print_annotations'} = $helper->{'VARS'}->{'PRINT_ANNOTATIONS'};
1774: $moreenv{'problem_split'} = $parmhash{'problem_stream_switch'};
1775: $moreenv{'suppress_tries'} = $parmhash{'suppress_tries'};
1776: if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') ||
1777: ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) {
1778: $moreenv{'problem_split'}='yes';
1779: }
1780: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75');
1781: my $student_counter=-1;
1782: my $i = 0;
1783: my $last_section = (split(/:/,$students[0]))[2];
1784: foreach my $person (@students) {
1785:
1786: my $duefile="/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
1787: if (-e $duefile) {
1788: my $temp_file = Apache::File->new('>>'.$duefile);
1789: print $temp_file "1969\n";
1790: }
1791: $student_counter++;
1792: if ($split_on_sections) {
1793: my $this_section = (split(/:/,$person))[2];
1794: if ($this_section ne $last_section) {
1795: $i++;
1796: $last_section = $this_section;
1797: }
1798: } else {
1799: $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
1800: }
1801: my ($output,$fullname, $printed)=&print_resources($r,$helper,
1802: $person,$type,
1803: \%moreenv,\@master_seq,
1804: $flag_latex_header_remove,
1805: $LaTeXwidth);
1806: $resources_printed .= ":";
1807: $print_array[$i].=$output;
1808: $student_names[$i].=$person.':'.$fullname.'_END_';
1809: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname);
1810: $flag_latex_header_remove = 'YES';
1811: if (&Apache::loncommon::connection_aborted($r)) { last; }
1812: }
1813: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1814: $result .= $print_array[0].' \end{document}';
1815: } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') ||
1816: ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) {
1817: my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
1818: my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
1819: my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
1820: my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
1821: my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
1822: my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'};
1823: my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};
1824:
1825: my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
1826: open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
1827: my ($code_type,$code_length)=('letter',6);
1828: foreach my $line (<FH>) {
1829: my ($name,$type,$length) = (split(/:/,$line))[0,2,4];
1830: if ($name eq $code_option) {
1831: $code_length=$length;
1832: if ($type eq 'number') { $code_type = 'number'; }
1833: }
1834: }
1835: my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
1836: $moreenv{'problem_split'} = $parmhash{'problem_stream_switch'};
1837: $moreenv{'instructor_comments'}='hide';
1838: my $seed=time+($$<<16)+($$);
1839: my @allcodes;
1840: if ($old_name) {
1841: my %result=&Apache::lonnet::get('CODEs',
1842: [$old_name,"type\0$old_name"],
1843: $cdom,$cnum);
1844: $code_type=$result{"type\0$old_name"};
1845: @allcodes=split(',',$result{$old_name});
1846: $num_todo=scalar(@allcodes);
1847: } elsif ($selected_code) { # Selection value is always numeric.
1848: $num_todo = 1;
1849: @allcodes = ($selected_code);
1850: } elsif ($single_code) {
1851:
1852: $num_todo = 1; # Unconditionally one code to do.
1853: # If an alpha code have to convert to numbers so it can be
1854: # converted back to letters again :-)
1855: #
1856: if ($code_type ne 'number') {
1857: $single_code = &letters_to_num($single_code);
1858: }
1859: @allcodes = ($single_code);
1860: } else {
1861: my %allcodes;
1862: srand($seed);
1863: for (my $i=0;$i<$num_todo;$i++) {
1864: $moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,$code_length,
1865: $code_type);
1866: }
1867: if ($code_name) {
1868: &Apache::lonnet::put('CODEs',
1869: {
1870: $code_name =>join(',',keys(%allcodes)),
1871: "type\0$code_name" => $code_type
1872: },
1873: $cdom,$cnum);
1874: }
1875: @allcodes=keys(%allcodes);
1876: }
1877: my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
1878: my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});
1879: &adjust_number_to_print($helper);
1880: my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};
1881: if ($number_per_page eq '0' || $number_per_page eq 'all') {
1882: $number_per_page=$num_todo;
1883: }
1884: my $flag_latex_header_remove = 'NO';
1885: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline','75');
1886: my $count=0;
1887: foreach my $code (sort(@allcodes)) {
1888: my $file_num=int($count/$number_per_page);
1889: if ($code_type eq 'number') {
1890: $moreenv{'CODE'}=$code;
1891: } else {
1892: $moreenv{'CODE'}=&num_to_letters($code);
1893: }
1894: my ($output,$fullname, $printed)=
1895: &print_resources($r,$helper,'anonymous',$type,\%moreenv,
1896: \@master_seq,$flag_latex_header_remove,
1897: $LaTeXwidth);
1898: $resources_printed .= ":";
1899: $print_array[$file_num].=$output;
1900: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
1901: &mt('last assignment').' '.$fullname);
1902: $flag_latex_header_remove = 'YES';
1903: $count++;
1904: if (&Apache::loncommon::connection_aborted($r)) { last; }
1905: }
1906: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1907: $result .= $print_array[0].' \end{document}';
1908: } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {
1909: #prints selected problems from the subdirectory
1910: $selectionmade = 6;
1911: my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'};
1912: @list_of_files=sort @list_of_files;
1913: my $flag_latex_header_remove = 'NO';
1914: my $rndseed=time;
1915: if ($helper->{'VARS'}->{'curseed'}) {
1916: $rndseed=$helper->{'VARS'}->{'curseed'};
1917: }
1918: for (my $i=0;$i<=$#list_of_files;$i++) {
1919: my $urlp = $list_of_files[$i];
1920: $urlp=~s|//|/|;
1921: if ($urlp=~/\//) {
1922: $form{'problem_split'}=$parmhash{'problem_stream_switch'};
1923: $form{'rndseed'}=$rndseed;
1924: if ($urlp =~ m|/home/([^/]+)/public_html|) {
1925: $urlp =~ s|/home/([^/]*)/public_html|/~$1|;
1926: } else {
1927: $urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||;
1928: }
1929: $resources_printed .= $urlp.':';
1930: my $texversion=&Apache::lonnet::ssi($urlp,%form);
1931: if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
1932: ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
1933: # Don't permanently pervert %form:
1934: my %answerform = %form;
1935: $answerform{'grade_target'}='answer';
1936: $answerform{'answer_output_mode'}='tex';
1937: $answerform{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
1938: $answerform{'rndseed'}=$rndseed;
1939: $resources_printed .= $urlp.':';
1940: my $answer=&Apache::lonnet::ssi($urlp,%answerform);
1941: if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
1942: $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
1943: } else {
1944: $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
1945: if ($helper->{'VARS'}->{'construction'} ne '1') {
1946: $texversion.='\vskip 0 mm \noindent ';
1947: $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
1948: } else {
1949: $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm ';
1950: my $URLpath=$urlp;
1951: $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/;
1952: $texversion.=&path_to_problem ($URLpath,$LaTeXwidth);
1953: }
1954: $texversion.='\vskip 1 mm '.$answer.'\end{document}';
1955: }
1956: }
1957: #this chunck is responsible for printing the path to problem
1958: my $newurlp=$urlp;
1959: if ($newurlp=~/~/) {$newurlp=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;}
1960: $newurlp=&path_to_problem($newurlp,$LaTeXwidth);
1961: $texversion =~ s/(\\begin{minipage}{\\textwidth})/$1 $newurlp/;
1962: if ($flag_latex_header_remove ne 'NO') {
1963: $texversion = &latex_header_footer_remove($texversion);
1964: } else {
1965: $texversion =~ s/\\end{document}//;
1966: }
1967: if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
1968: $texversion=&IndexCreation($texversion,$urlp);
1969: }
1970: if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') {
1971: $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;
1972:
1973: }
1974: $result .= $texversion;
1975: }
1976: $flag_latex_header_remove = 'YES';
1977: }
1978: if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\typeout)/ RANDOM SEED IS $rndseed $1/;}
1979: $result .= '\end{document}';
1980: }
1981: #-------------------------------------------------------- corrections for the different page formats
1982:
1983: # Only post process if that has not been turned off e.g. by a raw latex resource.
1984:
1985: if ($do_postprocessing) {
1986: $result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade);
1987: $result = &latex_corrections($number_of_columns,$result,$selectionmade,
1988: $helper->{'VARS'}->{'ANSWER_TYPE'});
1989: #if ($numberofcolumns == 1) {
1990: $result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;
1991: $result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /;
1992: $result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;
1993: $result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;
1994: #}
1995: }
1996:
1997: #-- writing .tex file in prtspool
1998: my $temp_file;
1999: my $identifier = &Apache::loncommon::get_cgi_id();
2000: my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_$identifier.tex";
2001: if (!($#print_array>0)) {
2002: unless ($temp_file = Apache::File->new('>'.$filename)) {
2003: $r->log_error("Couldn't open $filename for output $!");
2004: return SERVER_ERROR;
2005: }
2006: print $temp_file $result;
2007: my $begin=index($result,'\begin{document}',0);
2008: my $inc=substr($result,0,$begin+16);
2009: } else {
2010: my $begin=index($result,'\begin{document}',0);
2011: my $inc=substr($result,0,$begin+16);
2012: for (my $i=0;$i<=$#print_array;$i++) {
2013: if ($i==0) {
2014: $print_array[$i]=$result;
2015: } else {
2016: $print_array[$i].='\end{document}';
2017: $print_array[$i] =
2018: &latex_corrections($number_of_columns,$print_array[$i],
2019: $selectionmade,
2020: $helper->{'VARS'}->{'ANSWER_TYPE'});
2021:
2022: my $anobegin=index($print_array[$i],'\setcounter{page}',0);
2023: substr($print_array[$i],0,$anobegin)='';
2024: $print_array[$i]=$inc.$print_array[$i];
2025: }
2026: my $temp_file;
2027: my $newfilename=$filename;
2028: my $num=$i+1;
2029: $newfilename =~s/\.tex$//;
2030: $newfilename=sprintf("%s_%03d.tex",$newfilename, $num);
2031: unless ($temp_file = Apache::File->new('>'.$newfilename)) {
2032: $r->log_error("Couldn't open $newfilename for output $!");
2033: return SERVER_ERROR;
2034: }
2035: print $temp_file $print_array[$i];
2036: }
2037: }
2038: my $student_names='';
2039: if ($#print_array>0) {
2040: for (my $i=0;$i<=$#print_array;$i++) {
2041: $student_names.=$student_names[$i].'_ENDPERSON_';
2042: }
2043: } else {
2044: if ($#student_names>-1) {
2045: $student_names=$student_names[0].'_ENDPERSON_';
2046: } else {
2047: my $fullname = &get_name($env{'user.name'},$env{'user.domain'});
2048: $student_names=join(':',$env{'user.name'},$env{'user.domain'},
2049: $env{'request.course.sec'},$fullname).
2050: '_ENDPERSON_'.'_END_';
2051: }
2052: }
2053:
2054: my $URLback=''; #link to original document
2055: if ($helper->{'VARS'}->{'construction'} eq '1') {
2056: #prints resource from the construction space
2057: $URLback='/'.$helper->{'VARS'}->{'filename'};
2058: if ($URLback=~/([^?]+)/) {
2059: $URLback=$1;
2060: $URLback=~s|^/~|/priv/|;
2061: }
2062: }
2063: # logic for now is too complex to trace if this has been defined
2064: # yet.
2065: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2066: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2067: &Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename,
2068: 'cgi.'.$identifier.'.layout' => $laystyle,
2069: 'cgi.'.$identifier.'.numcol' => $numberofcolumns,
2070: 'cgi.'.$identifier.'.paper' => $papersize,
2071: 'cgi.'.$identifier.'.selection' => $selectionmade,
2072: 'cgi.'.$identifier.'.tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
2073: 'cgi.'.$identifier.'.tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},
2074: 'cgi.'.$identifier.'.role' => $perm{'pav'},
2075: 'cgi.'.$identifier.'.numberoffiles' => $#print_array,
2076: 'cgi.'.$identifier.'.studentnames' => $student_names,
2077: 'cgi.'.$identifier.'.backref' => $URLback,);
2078: &Apache::lonnet::appenv("cgi.$identifier.user" => $env{'user.name'},
2079: "cgi.$identifier.domain" => $env{'user.domain'},
2080: "cgi.$identifier.courseid" => $cnum,
2081: "cgi.$identifier.coursedom" => $cdom,
2082: "cgi.$identifier.resources" => $resources_printed);
2083:
2084: my $end_page = &Apache::loncommon::end_page();
2085: $r->print(<<FINALEND);
2086: <br />
2087: <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier" />
2088: <a href="/cgi-bin/printout.pl?$identifier">Continue</a>
2089: $end_page
2090: FINALEND
2091: }
2092:
2093:
2094: sub get_CODE {
2095: my ($all_codes,$num,$seed,$size,$type)=@_;
2096: my $max='1'.'0'x$size;
2097: my $newcode;
2098: while(1) {
2099: $newcode=sprintf("%0".$size."d",int(rand($max)));
2100: if (!exists($$all_codes{$newcode})) {
2101: $$all_codes{$newcode}=1;
2102: if ($type eq 'number' ) {
2103: return $newcode;
2104: } else {
2105: return &num_to_letters($newcode);
2106: }
2107: }
2108: }
2109: }
2110:
2111: sub print_resources {
2112: my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header,
2113: $LaTeXwidth)=@_;
2114: my $current_output = '';
2115: my $printed = '';
2116: my ($username,$userdomain,$usersection) = split /:/,$person;
2117: my $fullname = &get_name($username,$userdomain);
2118: my $namepostfix = "\\\\"; # Both anon and not anon should get the same vspace.
2119: if ($person =~ 'anon') {
2120: $namepostfix .="Name: ";
2121: $fullname = "CODE - ".$moreenv->{'CODE'};
2122: }
2123: # Fullname may have special latex characters that need \ prefixing:
2124: #
2125:
2126: my $i = 0;
2127: #goes through all resources, checks if they are available for
2128: #current student, and produces output
2129:
2130: &Apache::lonxml::clear_problem_counter();
2131: my %page_breaks = &get_page_breaks($helper);
2132: my $columns_in_format = (split(/\|/,$helper->{'VARS'}->{'FORMAT'}))[1];
2133: #
2134: # end each student with a
2135: # Special that allows the post processor to even out the page
2136: # counts later. Nasty problem this... it would be really
2137: # nice to put the special in as a postscript comment
2138: # e.g. \special{ps:\ENDOFSTUDENTSTAMP} unfortunately,
2139: # The special gets passed the \ and dvips puts it in the output file
2140: # so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the
2141: # postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself.
2142: #
2143:
2144:
2145: foreach my $curresline (@{$master_seq}) {
2146: if (defined $page_breaks{$curresline}) {
2147: if($i != 0) {
2148: $current_output.= "\\newpage\n";
2149: }
2150: }
2151: $i++;
2152:
2153: if ( !($type eq 'problems' &&
2154: ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {
2155: my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
2156: if (&Apache::lonnet::allowed('bre',$res_url)) {
2157: if ($res_url!~m|^ext/|
2158: && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
2159: $printed .= $curresline.':';
2160:
2161: &Apache::lonxml::remember_problem_counter();
2162:
2163: my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
2164:
2165: if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
2166: ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
2167: # Use a copy of the hash so we don't pervert it on future loop passes.
2168: my %answerenv = %{$moreenv};
2169: $answerenv{'answer_output_mode'}='tex';
2170: $answerenv{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
2171:
2172: &Apache::lonxml::restore_problem_counter();
2173:
2174: my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$env{'request.course.id'},%answerenv);
2175:
2176: if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
2177: $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
2178: } else {
2179:
2180:
2181: my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
2182: my $title = &Apache::lonnet::gettitle($curresline);
2183: $title = &Apache::lonxml::latex_special_symbols($title);
2184: my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
2185: $body .=&path_to_problem($res_url,$LaTeXwidth);
2186: $body .='\vskip 1 mm '.$ansrendered;
2187: $body = &encapsulate_minipage($body);
2188: $rendered = $header.$body;
2189: }
2190: }
2191:
2192: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
2193: my $url = &Apache::lonnet::clutter($res_url);
2194: my $annotation = &annotate($url);
2195: $rendered =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/;
2196: }
2197: if ($remove_latex_header eq 'YES') {
2198: $rendered = &latex_header_footer_remove($rendered);
2199: } else {
2200: $rendered =~ s/\\end{document}//;
2201: }
2202: $current_output .= $rendered;
2203: } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
2204: $printed .= $curresline.':';
2205: my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
2206: if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
2207: my $url = &Apache::lonnet::clutter($res_url);
2208: my $annotation = &annotate($url);
2209: $annotation =~ s/(\\end{document})/$annotation$1/;
2210: }
2211: if ($remove_latex_header eq 'YES') {
2212: $rendered = &latex_header_footer_remove($rendered);
2213: } else {
2214: $rendered =~ s/\\end{document}//;
2215: }
2216: $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\strut \vskip 0 mm \strut ';
2217:
2218: } else {
2219: my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'},$curresline);
2220: if ($remove_latex_header ne 'NO') {
2221: $rendered = &latex_header_footer_remove($rendered);
2222: } else {
2223: $rendered =~ s/\\end{document}//;
2224: }
2225: $current_output .= $rendered;
2226: }
2227: }
2228: $remove_latex_header = 'YES';
2229: }
2230: if (&Apache::loncommon::connection_aborted($r)) { last; }
2231: }
2232: my $courseidinfo = &get_course();
2233: if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
2234: if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
2235: my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
2236: my $header_line =
2237: &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},
2238: $currentassignment, $courseidinfo, $fullname);
2239: my $header_start = ($columns_in_format == 1) ? '\lhead'
2240: : '\fancyhead[LO]';
2241: $header_line = $header_start.'{'.$header_line.'}';
2242:
2243: if ($current_output=~/\\documentclass/) {
2244: $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /;
2245: } else {
2246: my $blankpages =
2247: '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};
2248:
2249: $current_output = '\strut\vspace*{-6 mm}\\newline'.
2250: ©right_line().' \newpage '.$blankpages.$end_of_student.
2251: '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'.
2252: $header_line.$namepostfix.'} \vskip 5 mm '.$current_output;
2253: }
2254: #
2255: # Close the student bracketing.
2256: #
2257: return ($current_output,$fullname, $printed);
2258:
2259: }
2260:
2261: sub handler {
2262:
2263: my $r = shift;
2264:
2265: &init_perm();
2266:
2267:
2268:
2269: my $helper = printHelper($r);
2270: if (!ref($helper)) {
2271: return $helper;
2272: }
2273:
2274:
2275: %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
2276:
2277:
2278:
2279:
2280: # If a figure conversion queue file exists for this user.domain
2281: # we delete it since it can only be bad (if it were good, printout.pl
2282: # would have deleted it the last time around.
2283:
2284: my $conversion_queuefile = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
2285: if(-e $conversion_queuefile) {
2286: unlink $conversion_queuefile;
2287: }
2288: &output_data($r,$helper,\%parmhash);
2289: return OK;
2290: }
2291:
2292: use Apache::lonhelper;
2293:
2294: sub addMessage {
2295: my $text = shift;
2296: my $paramHash = Apache::lonhelper::getParamHash();
2297: $paramHash->{MESSAGE_TEXT} = $text;
2298: Apache::lonhelper::message->new();
2299: }
2300:
2301:
2302:
2303: sub init_perm {
2304: undef(%perm);
2305: $perm{'pav'}=&Apache::lonnet::allowed('pav',$env{'request.course.id'});
2306: if (!$perm{'pav'}) {
2307: $perm{'pav'}=&Apache::lonnet::allowed('pav',
2308: $env{'request.course.id'}.'/'.$env{'request.course.sec'});
2309: }
2310: $perm{'pfo'}=&Apache::lonnet::allowed('pfo',$env{'request.course.id'});
2311: if (!$perm{'pfo'}) {
2312: $perm{'pfo'}=&Apache::lonnet::allowed('pfo',
2313: $env{'request.course.id'}.'/'.$env{'request.course.sec'});
2314: }
2315: }
2316:
2317: sub get_randomly_ordered_warning {
2318: my ($helper,$map) = @_;
2319:
2320: my $message;
2321:
2322: my $postdata = $env{'form.postdata'} || $helper->{VARS}{'postdata'};
2323: my $navmap = Apache::lonnavmaps::navmap->new();
2324: my $res = $navmap->getResourceByUrl($map);
2325: if ($res) {
2326: my $func =
2327: sub { return ($_[0]->is_map() && $_[0]->randomorder); };
2328: my @matches = $navmap->retrieveResources($res, $func,1,1,1);
2329: if (@matches) {
2330: $message = "Some of the items below are in folders set to be randomly ordered. However, when printing the contents of these folders, they will be printed in the original order for all students, not the randomized order.";
2331: }
2332: }
2333: if ($message) {
2334: return '<message type="warning">'.$message.'</message>';
2335: }
2336: return;
2337: }
2338:
2339: sub printHelper {
2340: my $r = shift;
2341:
2342: if ($r->header_only) {
2343: if ($env{'browser.mathml'}) {
2344: &Apache::loncommon::content_type($r,'text/xml');
2345: } else {
2346: &Apache::loncommon::content_type($r,'text/html');
2347: }
2348: $r->send_http_header;
2349: return OK;
2350: }
2351:
2352: # Send header, nocache
2353: if ($env{'browser.mathml'}) {
2354: &Apache::loncommon::content_type($r,'text/xml');
2355: } else {
2356: &Apache::loncommon::content_type($r,'text/html');
2357: }
2358: &Apache::loncommon::no_cache($r);
2359: $r->send_http_header;
2360: $r->rflush();
2361:
2362: # Unfortunately, this helper is so complicated we have to
2363: # write it by hand
2364:
2365: Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING});
2366:
2367: my $helper = Apache::lonhelper::helper->new("Printing Helper");
2368: $helper->declareVar('symb');
2369: $helper->declareVar('postdata');
2370: $helper->declareVar('curseed');
2371: $helper->declareVar('probstatus');
2372: $helper->declareVar('filename');
2373: $helper->declareVar('construction');
2374: $helper->declareVar('assignment');
2375: $helper->declareVar('style_file');
2376: $helper->declareVar('student_sort');
2377: $helper->declareVar('FINISHPAGE');
2378: $helper->declareVar('PRINT_TYPE');
2379: $helper->declareVar("showallfoils");
2380: $helper->declareVar("STUDENTS");
2381:
2382: # The page breaks can get loaded initially from the course environment:
2383: # But we only do this in the initial state so that they are allowed to change.
2384: #
2385:
2386: # $helper->{VARS}->{FINISHPAGE} = '';
2387:
2388: &Apache::loncommon::restore_course_settings('print',
2389: {'pagebreaks' => 'scalar',
2390: 'lastprinttype' => 'scalar'});
2391:
2392: # This will persistently load in the data we want from the
2393: # very first screen.
2394:
2395: if($helper->{VARS}->{PRINT_TYPE} eq $env{'form.lastprinttype'}) {
2396: if (!defined ($env{"form.CURRENT_STATE"})) {
2397:
2398: $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'};
2399: } else {
2400: my $state = $env{"form.CURRENT_STATE"};
2401: if ($state eq "START") {
2402: $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'};
2403: }
2404: }
2405:
2406: }
2407:
2408:
2409: # Detect whether we're coming from construction space
2410: if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {
2411: $helper->{VARS}->{'filename'} = "~$1/$2";
2412: $helper->{VARS}->{'construction'} = 1;
2413: } else {
2414: if ($env{'form.postdata'}) {
2415: $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'});
2416: if ( $helper->{VARS}->{'symb'} eq '') {
2417: $helper->{VARS}->{'postdata'} = $env{'form.postdata'};
2418: }
2419: }
2420: if ($env{'form.symb'}) {
2421: $helper->{VARS}->{'symb'} = $env{'form.symb'};
2422: }
2423: if ($env{'form.url'}) {
2424: $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
2425: }
2426:
2427: }
2428:
2429: if ($env{'form.symb'}) {
2430: $helper->{VARS}->{'symb'} = $env{'form.symb'};
2431: }
2432: if ($env{'form.url'}) {
2433: $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
2434:
2435: }
2436: $helper->{VARS}->{'symb'}=
2437: &Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'});
2438: my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper);
2439: if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;}
2440:
2441:
2442: # Extract map
2443: my $symb = $helper->{VARS}->{'symb'};
2444: my ($map, $id, $url);
2445: my $subdir;
2446: my $is_published=0; # True when printing from resource space.
2447:
2448: # Get the resource name from construction space
2449: if ($helper->{VARS}->{'construction'}) {
2450: $resourceTitle = substr($helper->{VARS}->{'filename'},
2451: rindex($helper->{VARS}->{'filename'}, '/')+1);
2452: $subdir = substr($helper->{VARS}->{'filename'},
2453: 0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
2454: } else {
2455: if ($symb ne '') {
2456: ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
2457: $helper->{VARS}->{'postdata'} =
2458: &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
2459: } else {
2460: $url = $helper->{VARS}->{'postdata'};
2461: $is_published=1; # From resource space.
2462: }
2463: $url = &Apache::lonnet::clutter($url);
2464:
2465: if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
2466: my $postdata = $helper->{VARS}->{'postdata'};
2467: $resourceTitle = substr($postdata, rindex($postdata, '/') + 1);
2468: }
2469: $subdir = &Apache::lonnet::filelocation("", $url);
2470: }
2471: if (!$helper->{VARS}->{'curseed'} && $env{'form.curseed'}) {
2472: $helper->{VARS}->{'curseed'}=$env{'form.curseed'};
2473: }
2474: if (!$helper->{VARS}->{'probstatus'} && $env{'form.problemtype'}) {
2475: $helper->{VARS}->{'probstatus'}=$env{'form.problemstatus'};
2476: }
2477:
2478: my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
2479:
2480: Apache::lonhelper::registerHelperTags();
2481:
2482: # "Delete everything after the last slash."
2483: $subdir =~ s|/[^/]+$||;
2484:
2485: # What can be printed is a very dynamic decision based on
2486: # lots of factors. So we need to dynamically build this list.
2487: # To prevent security leaks, states are only added to the wizard
2488: # if they can be reached, which ensures manipulating the form input
2489: # won't allow anyone to reach states they shouldn't have permission
2490: # to reach.
2491:
2492: # printChoices is tracking the kind of printing the user can
2493: # do, and will be used in a choices construction later.
2494: # In the meantime we will be adding states and elements to
2495: # the helper by hand.
2496: my $printChoices = [];
2497: my $paramHash;
2498:
2499: if ($resourceTitle) {
2500: push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE'];
2501: }
2502:
2503: # Useful filter strings
2504: my $isProblem = '($res->is_problem()||$res->contains_problem) ';
2505: $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
2506: my $isProblemOrMap = '$res->is_problem() || $res->contains_problem() || $res->is_sequence()';
2507: my $isNotMap = '!$res->is_sequence()';
2508: $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
2509: my $isMap = '$res->is_map()';
2510: my $symbFilter = '$res->shown_symb()';
2511: my $urlValue = '$res->link()';
2512:
2513: $helper->declareVar('SEQUENCE');
2514:
2515: # If we're in a sequence...
2516:
2517: my $start_new_option;
2518: if ($perm{'pav'}) {
2519: $start_new_option =
2520: "<option text='".&mt('Start new page<br />before selected').
2521: "' variable='FINISHPAGE' />";
2522: }
2523:
2524: if (($helper->{'VARS'}->{'construction'} ne '1' ) &&
2525:
2526: $helper->{VARS}->{'postdata'} &&
2527: $helper->{VARS}->{'assignment'}) {
2528: # Allow problems from sequence
2529: push @{$printChoices}, [&mt('Selected <b>Problems</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS'];
2530: # Allow all resources from sequence
2531: push @{$printChoices}, [&mt('Selected <b>Resources</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
2532:
2533: my $helperFragment = <<HELPERFRAGMENT;
2534: <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
2535: <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
2536: closeallpages="1">
2537: <nextstate>PAGESIZE</nextstate>
2538: <filterfunc>return $isProblem;</filterfunc>
2539: <mapurl>$map</mapurl>
2540: <valuefunc>return $symbFilter;</valuefunc>
2541: $start_new_option
2542: </resource>
2543: </state>
2544:
2545: <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
2546: <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
2547: closeallpages="1">
2548: <nextstate>PAGESIZE</nextstate>
2549: <filterfunc>return $isNotMap;</filterfunc>
2550: <mapurl>$map</mapurl>
2551: <valuefunc>return $symbFilter;</valuefunc>
2552: $start_new_option
2553: </resource>
2554: </state>
2555: HELPERFRAGMENT
2556:
2557: &Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
2558: }
2559:
2560: # If the user has pfo (print for otheres) allow them to print all
2561: # problems and resources in the entier course, optionally for selected students
2562: if ($perm{'pfo'} && !$is_published &&
2563: ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) {
2564:
2565: push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b>'), 'all_problems', 'ALL_PROBLEMS'];
2566: push @{$printChoices}, [&mtn('Selected <b>Resources</b> from <b>entire course</b>'), 'all_resources', 'ALL_RESOURCES'];
2567: &Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);
2568: <state name="ALL_PROBLEMS" title="Select Problem(s) to print">
2569: <resource variable="RESOURCES" toponly='0' multichoice="1"
2570: suppressEmptySequences='0' addstatus="1" closeallpages="1">
2571: <nextstate>PAGESIZE</nextstate>
2572: <filterfunc>return $isProblemOrMap;</filterfunc>
2573: <choicefunc>return $isNotMap;</choicefunc>
2574: <valuefunc>return $symbFilter;</valuefunc>
2575: $start_new_option
2576: </resource>
2577: </state>
2578: <state name="ALL_RESOURCES" title="Select Resource(s) to print">
2579: <resource variable="RESOURCES" toponly='0' multichoice='1'
2580: suppressEmptySequences='0' addstatus='1' closeallpages='1'>
2581: <nextstate>PAGESIZE</nextstate>
2582: <filterfunc>return $isNotMap; </filterfunc>
2583: <valuefunc>return $symbFilter;</valuefunc>
2584: $start_new_option
2585: </resource>
2586: </state>
2587: ALL_PROBLEMS
2588:
2589: if ($helper->{VARS}->{'assignment'}) {
2590: push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected people</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS'];
2591: push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1'];
2592: }
2593:
2594: my $randomly_ordered_warning =
2595: &get_randomly_ordered_warning($helper,$map);
2596:
2597: # resource_selector will hold a few states that:
2598: # - Allow resources to be selected for printing.
2599: # - Determine pagination between assignments.
2600: # - Determine how many assignments should be bundled into a single PDF.
2601: # TODO:
2602: # Probably good to do things like separate this up into several vars, each
2603: # with one state, and use REGEXPs at inclusion time to set state names
2604: # and next states for better mix and match capability
2605: #
2606: my $resource_selector=<<RESOURCE_SELECTOR;
2607: <state name="SELECT_PROBLEMS" title="Select resources to print">
2608: $randomly_ordered_warning
2609:
2610: <nextstate>PRINT_FORMATTING</nextstate>
2611: <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
2612: <resource variable="RESOURCES" multichoice="1" addstatus="1"
2613: closeallpages="1">
2614: <filterfunc>return $isProblem;</filterfunc>
2615: <mapurl>$map</mapurl>
2616: <valuefunc>return $symbFilter;</valuefunc>
2617: $start_new_option
2618: </resource>
2619: </state>
2620: <state name="PRINT_FORMATTING" title="How should results be printed?">
2621: <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
2622: <choices variable="EMPTY_PAGES">
2623: <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
2624: <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
2625: <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
2626: <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
2627: </choices>
2628: <nextstate>PAGESIZE</nextstate>
2629: <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
2630: <choices variable="SPLIT_PDFS">
2631: <choice computer="all">All assignments in a single PDF file</choice>
2632: <choice computer="sections">Each PDF contains exactly one section</choice>
2633: <choice computer="oneper">Each PDF contains exactly one assignment</choice>
2634: <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
2635: Specify the number of assignments per PDF:</choice>
2636: </choices>
2637: </state>
2638: RESOURCE_SELECTOR
2639:
2640: &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
2641: <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
2642: <message><b>Select sorting order of printout</b> </message>
2643: <choices variable='student_sort'>
2644: <choice computer='0'>Sort by section then student</choice>
2645: <choice computer='1'>Sort by students across sections.</choice>
2646: </choices>
2647: <message><br /><hr /><br /> </message>
2648: <student multichoice='1' variable="STUDENTS" nextstate="SELECT_PROBLEMS" coursepersonnel="1"/>
2649: </state>
2650: $resource_selector
2651: CHOOSE_STUDENTS
2652:
2653: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2654: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2655: my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
2656: my $namechoice='<choice></choice>';
2657: foreach my $name (sort {uc($a) cmp uc($b)} @names) {
2658: if ($name =~ /^error: 2 /) { next; }
2659: if ($name =~ /^type\0/) { next; }
2660: $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';
2661: }
2662:
2663:
2664: my %code_values;
2665: my %codes_to_print;
2666: foreach my $key (@names) {
2667: %code_values = &Apache::grades::get_codes($key, $cdom, $cnum);
2668: foreach my $key (keys(%code_values)) {
2669: $codes_to_print{$key} = 1;
2670: }
2671: }
2672:
2673: my $code_selection;
2674: foreach my $code (sort {uc($a) cmp uc($b)} (keys(%codes_to_print))) {
2675: my $choice = $code;
2676: if ($code =~ /^[A-Z]+$/) { # Alpha code
2677: $choice = &letters_to_num($code);
2678: }
2679: push(@{$helper->{DATA}{ALL_CODE_CHOICES}},[$code,$choice]);
2680: }
2681: if (%codes_to_print) {
2682: $code_selection .='
2683: <message><b>Choose single CODE from list:</b></message>
2684: <message></td><td></message>
2685: <dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
2686: <choice></choice>
2687: <exec>
2688: push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}});
2689: </exec>
2690: </dropdown>
2691: <message></td></tr><tr><td></message>
2692: '.$/;
2693:
2694: }
2695:
2696:
2697: open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
2698: my $codechoice='';
2699: foreach my $line (<FH>) {
2700: my ($name,$description,$code_type,$code_length)=
2701: (split(/:/,$line))[0,1,2,4];
2702: if ($code_length > 0 &&
2703: $code_type =~/^(letter|number|-1)/) {
2704: $codechoice.='<choice computer="'.$name.'">'.$description.'</choice>';
2705: }
2706: }
2707: if ($codechoice eq '') {
2708: $codechoice='<choice computer="default">Default</choice>';
2709: }
2710: &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1);
2711: <state name="CHOOSE_ANON1" title="Specify CODEd Assignments">
2712: <nextstate>SELECT_PROBLEMS</nextstate>
2713: <message><h4>Fill out one of the forms below</h4></message>
2714: <message><br /><hr /> <br /></message>
2715: <message><h3>Generate new CODEd Assignments</h3></message>
2716: <message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message>
2717: <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5">
2718: <validator>
2719: if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
2720: !\$helper->{'VARS'}{'REUSE_OLD_CODES'} &&
2721: !\$helper->{'VARS'}{'SINGLE_CODE'} &&
2722: !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
2723: return "You need to specify the number of assignments to print";
2724: }
2725: return undef;
2726: </validator>
2727: </string>
2728: <message></td></tr><tr><td></message>
2729: <message><b>Names to save the CODEs under for later:</b></message>
2730: <message></td><td></message>
2731: <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
2732: <message></td></tr><tr><td></message>
2733: <message><b>Bubble sheet type:</b></message>
2734: <message></td><td></message>
2735: <dropdown variable="CODE_OPTION" multichoice="0" allowempty="0">
2736: $codechoice
2737: </dropdown>
2738: <message></td></tr><tr><td colspan="2"></td></tr><tr><td></message>
2739: <message></td></tr><tr><td></table></message>
2740: <message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message>
2741: <message><tr><td><b>Enter a CODE to print:</b></td><td></message>
2742: <string variable="SINGLE_CODE" size="10">
2743: <validator>
2744: if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} &&
2745: !\$helper->{'VARS'}{'REUSE_OLD_CODES'} &&
2746: !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
2747: return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},
2748: \$helper->{'VARS'}{'CODE_OPTION'});
2749: } else {
2750: return undef; # Other forces control us.
2751: }
2752: </validator>
2753: </string>
2754: <message></td></tr><tr><td></message>
2755: $code_selection
2756: <message></td></tr></table></message>
2757: <message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message>
2758: <message><b>Select saved CODEs:</b></message>
2759: <message></td><td></message>
2760: <dropdown variable="REUSE_OLD_CODES">
2761: $namechoice
2762: </dropdown>
2763: <message></td></tr></table></message>
2764: </state>
2765: $resource_selector
2766: CHOOSE_ANON1
2767:
2768:
2769: if ($helper->{VARS}->{'assignment'}) {
2770: push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected people</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1'];
2771: push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2'];
2772: }
2773:
2774:
2775: $resource_selector=<<RESOURCE_SELECTOR;
2776: <state name="SELECT_RESOURCES" title="Select Resources">
2777: $randomly_ordered_warning
2778:
2779: <nextstate>PRINT_FORMATTING</nextstate>
2780: <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
2781: <resource variable="RESOURCES" multichoice="1" addstatus="1"
2782: closeallpages="1">
2783: <filterfunc>return $isNotMap;</filterfunc>
2784: <mapurl>$map</mapurl>
2785: <valuefunc>return $symbFilter;</valuefunc>
2786: $start_new_option
2787: </resource>
2788: </state>
2789: <state name="PRINT_FORMATTING" title="Format of the print job">
2790: <nextstate>NUMBER_PER_PDF</nextstate>
2791: <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
2792: <choices variable="EMPTY_PAGES">
2793: <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
2794: <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
2795: <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
2796: <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
2797: </choices>
2798: <nextstate>PAGESIZE</nextstate>
2799: <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
2800: <choices variable="SPLIT_PDFS">
2801: <choice computer="all">All assignments in a single PDF file</choice>
2802: <choice computer="sections">Each PDF contains exactly one section</choice>
2803: <choice computer="oneper">Each PDF contains exactly one assignment</choice>
2804: <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
2805: Specify the number of assignments per PDF:</choice>
2806: </choices>
2807: </state>
2808: RESOURCE_SELECTOR
2809:
2810: &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
2811: <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
2812: <choices variable='student_sort'>
2813: <choice computer='0'>Sort by section then student</choice>
2814: <choice computer='1'>Sort by students across sections.</choice>
2815: </choices>
2816: <message><br /><hr /><br /></message>
2817: <student multichoice='1' variable="STUDENTS" nextstate="SELECT_RESOURCES" coursepersonnel="1" />
2818:
2819: </state>
2820: $resource_selector
2821: CHOOSE_STUDENTS1
2822:
2823: &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2);
2824: <state name="CHOOSE_ANON2" title="Select CODEd Assignments">
2825: <nextstate>SELECT_RESOURCES</nextstate>
2826: <message><h4>Fill out one of the forms below</h4></message>
2827: <message><br /><hr /> <br /></message>
2828: <message><h3>Generate new CODEd Assignments</h3></message>
2829: <message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message>
2830: <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5">
2831: <validator>
2832: if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
2833: !\$helper->{'VARS'}{'REUSE_OLD_CODES'} &&
2834: !\$helper->{'VARS'}{'SINGLE_CODE'} &&
2835: !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
2836: return "You need to specify the number of assignments to print";
2837: }
2838: return undef;
2839: </validator>
2840: </string>
2841: <message></td></tr><tr><td></message>
2842: <message><b>Names to save the CODEs under for later:</b></message>
2843: <message></td><td></message>
2844: <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
2845: <message></td></tr><tr><td></message>
2846: <message><b>Bubble sheet type:</b></message>
2847: <message></td><td></message>
2848: <dropdown variable="CODE_OPTION" multichoice="0" allowempty="0">
2849: $codechoice
2850: </dropdown>
2851: <message></td></tr><tr><td></table></message>
2852: <message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message>
2853: <message><tr><td><b>Enter a CODE to print:</b></td><td></message>
2854: <string variable="SINGLE_CODE" size="10">
2855: <validator>
2856: if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} &&
2857: !\$helper->{'VARS'}{'REUSE_OLD_CODES'} &&
2858: !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
2859: return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},
2860: \$helper->{'VARS'}{'CODE_OPTION'});
2861: } else {
2862: return undef; # Other forces control us.
2863: }
2864: </validator>
2865: </string>
2866: <message></td></tr><tr><td></message>
2867: $code_selection
2868: <message></td></tr></table></message>
2869: <message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message>
2870: <message><b>Select saved CODEs:</b></message>
2871: <message></td><td></message>
2872: <dropdown variable="REUSE_OLD_CODES">
2873: $namechoice
2874: </dropdown>
2875: <message></td></tr></table></message>
2876: </state>
2877: $resource_selector
2878: CHOOSE_ANON2
2879: }
2880:
2881: # FIXME: That RE should come from a library somewhere.
2882: if (($perm{'pav'}
2883: && $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'
2884: && (defined($helper->{'VARS'}->{'construction'})
2885: ||
2886: (&Apache::lonnet::allowed('bre',$subdir) eq 'F'
2887: &&
2888: $helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)
2889: ))
2890: && $helper->{VARS}->{'assignment'} eq ""
2891: ) {
2892:
2893: my $pretty_dir = &Apache::lonnet::hreflocation($subdir);
2894: push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$pretty_dir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
2895: my $xmlfrag = <<CHOOSE_FROM_SUBDIR;
2896: <state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$pretty_dir</small></b> to print">
2897:
2898: <files variable="FILES" multichoice='1'>
2899: <nextstate>PAGESIZE</nextstate>
2900: <filechoice>return '$subdir';</filechoice>
2901: CHOOSE_FROM_SUBDIR
2902:
2903: # this is broken up because I really want interpolation above,
2904: # and I really DON'T want it below
2905: $xmlfrag .= <<'CHOOSE_FROM_SUBDIR';
2906: <filefilter>return Apache::lonhelper::files::not_old_version($filename) &&
2907: $filename =~ m/\.(problem|exam|quiz|assess|survey|form|library)$/;
2908: </filefilter>
2909: </files>
2910: </state>
2911: CHOOSE_FROM_SUBDIR
2912: &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
2913: }
2914:
2915: # Allow the user to select any sequence in the course, feed it to
2916: # another resource selector for that sequence
2917: if (!$helper->{VARS}->{'construction'} && !$is_published) {
2918: push @$printChoices, [&mtn("Selected <b>Resources</b> from <b>selected folder</b> in course"),
2919: 'select_sequences', 'CHOOSE_SEQUENCE'];
2920: my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
2921: #Escape apostrophes and backslashes for Perl
2922: $escapedSequenceName =~ s/\\/\\\\/g;
2923: $escapedSequenceName =~ s/'/\\'/g;
2924: &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_FROM_ANY_SEQUENCE);
2925: <state name="CHOOSE_SEQUENCE" title="Select Sequence To Print From">
2926: <message>Select the sequence to print resources from:</message>
2927: <resource variable="SEQUENCE">
2928: <nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>
2929: <filterfunc>return \$res->is_sequence;</filterfunc>
2930: <valuefunc>return $urlValue;</valuefunc>
2931: <choicefunc>return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
2932: </choicefunc>
2933: </resource>
2934: </state>
2935: <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
2936: <message>(mark desired resources then click "next" button) <br /></message>
2937: <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
2938: closeallpages="1">
2939: <nextstate>PAGESIZE</nextstate>
2940: <filterfunc>return $isNotMap</filterfunc>
2941: <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>
2942: <valuefunc>return $symbFilter;</valuefunc>
2943: $start_new_option
2944: </resource>
2945: </state>
2946: CHOOSE_FROM_ANY_SEQUENCE
2947: }
2948:
2949: # Generate the first state, to select which resources get printed.
2950: Apache::lonhelper::state->new("START", "Select Printing Options:");
2951: $paramHash = Apache::lonhelper::getParamHash();
2952: $paramHash->{MESSAGE_TEXT} = "";
2953: Apache::lonhelper::message->new();
2954: $paramHash = Apache::lonhelper::getParamHash();
2955: $paramHash->{'variable'} = 'PRINT_TYPE';
2956: $paramHash->{CHOICES} = $printChoices;
2957: Apache::lonhelper::choices->new();
2958:
2959: my $startedTable = 0; # have we started an HTML table yet? (need
2960: # to close it later)
2961:
2962: if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or
2963: ($helper->{VARS}->{'construction'} eq '1')) {
2964: addMessage("<hr width='33%' /><table><tr><td align='right'>".
2965: '<label for="ANSWER_TYPE_forminput">'.
2966: &mt('Print').
2967: "</label>: </td><td>");
2968: $paramHash = Apache::lonhelper::getParamHash();
2969: $paramHash->{'variable'} = 'ANSWER_TYPE';
2970: $helper->declareVar('ANSWER_TYPE');
2971: $paramHash->{CHOICES} = [
2972: ['Without Answers', 'yes'],
2973: ['With Answers', 'no'],
2974: ['Only Answers', 'only']
2975: ];
2976: Apache::lonhelper::dropdown->new();
2977: addMessage("</td></tr>");
2978: $startedTable = 1;
2979: }
2980:
2981: if ($perm{'pav'}) {
2982: if (!$startedTable) {
2983: addMessage("<hr width='33%' /><table><tr><td align='right'>".
2984: '<label for="LATEX_TYPE_forminput">'.
2985: &mt('LaTeX mode').
2986: "</label>: </td><td>");
2987: $startedTable = 1;
2988: } else {
2989: addMessage("<tr><td align='right'>".
2990: '<label for="LATEX_TYPE_forminput">'.
2991: &mt('LaTeX mode').
2992: "</label>: </td><td>");
2993: }
2994: $paramHash = Apache::lonhelper::getParamHash();
2995: $paramHash->{'variable'} = 'LATEX_TYPE';
2996: $helper->declareVar('LATEX_TYPE');
2997: if ($helper->{VARS}->{'construction'} eq '1') {
2998: $paramHash->{CHOICES} = [
2999: ['standard LaTeX mode', 'standard'],
3000: ['LaTeX batchmode', 'batchmode'], ];
3001: } else {
3002: $paramHash->{CHOICES} = [
3003: ['LaTeX batchmode', 'batchmode'],
3004: ['standard LaTeX mode', 'standard'] ];
3005: }
3006: Apache::lonhelper::dropdown->new();
3007:
3008: addMessage("</td></tr><tr><td align='right'>".
3009: '<label for="TABLE_CONTENTS_forminput">'.
3010: &mt('Print Table of Contents').
3011: "</label>: </td><td>");
3012: $paramHash = Apache::lonhelper::getParamHash();
3013: $paramHash->{'variable'} = 'TABLE_CONTENTS';
3014: $helper->declareVar('TABLE_CONTENTS');
3015: $paramHash->{CHOICES} = [
3016: ['No', 'no'],
3017: ['Yes', 'yes'] ];
3018: Apache::lonhelper::dropdown->new();
3019: addMessage("</td></tr>");
3020:
3021: if (not $helper->{VARS}->{'construction'}) {
3022: addMessage("<tr><td align='right'>".
3023: '<label for="TABLE_INDEX_forminput">'.
3024: &mt('Print Index').
3025: "</label>: </td><td>");
3026: $paramHash = Apache::lonhelper::getParamHash();
3027: $paramHash->{'variable'} = 'TABLE_INDEX';
3028: $helper->declareVar('TABLE_INDEX');
3029: $paramHash->{CHOICES} = [
3030: ['No', 'no'],
3031: ['Yes', 'yes'] ];
3032: Apache::lonhelper::dropdown->new();
3033: addMessage("</td></tr>");
3034: addMessage("<tr><td align='right'>".
3035: '<label for="PRINT_DISCUSSIONS_forminput">'.
3036: &mt('Print Discussions').
3037: "</label>: </td><td>");
3038: $paramHash = Apache::lonhelper::getParamHash();
3039: $paramHash->{'variable'} = 'PRINT_DISCUSSIONS';
3040: $helper->declareVar('PRINT_DISCUSSIONS');
3041: $paramHash->{CHOICES} = [
3042: ['No', 'no'],
3043: ['Yes', 'yes'] ];
3044: Apache::lonhelper::dropdown->new();
3045: addMessage("</td></tr>");
3046:
3047: # Prompt for printing annotations too.
3048:
3049: addMessage("<tr><td align='right'>".
3050: '<label for="PRINT_ANNOTATIONS_forminput">'.
3051: &mt('Print Annotations').
3052: "</label>:</td><td>");
3053: $paramHash = Apache::lonhelper::getParamHash();
3054: $paramHash->{'variable'} = "PRINT_ANNOTATIONS";
3055: $helper->declareVar("PRINT_ANNOTATIONS");
3056: $paramHash->{CHOICES} = [
3057: ['No', 'no'],
3058: ['Yes', 'yes']];
3059: Apache::lonhelper::dropdown->new();
3060: addMessage("</td></tr>");
3061:
3062: addMessage("<tr><td align = 'right'> </td><td>");
3063: $paramHash = Apache::lonhelper::getParamHash();
3064: $paramHash->{'multichoice'} = "true";
3065: $paramHash->{'allowempty'} = "true";
3066: $paramHash->{'variable'} = "showallfoils";
3067: $paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];
3068: Apache::lonhelper::choices->new();
3069: addMessage("</td></tr>");
3070: }
3071:
3072: if ($helper->{'VARS'}->{'construction'}) {
3073: my $stylevalue='$Apache::lonnet::env{"construct.style"}';
3074: my $randseedtext=&mt("Use random seed");
3075: my $stylefiletext=&mt("Use style file");
3076: my $selectfiletext=&mt("Select style file");
3077:
3078: my $xmlfrag .= <<"RNDSEED";
3079: <message><tr><td align='right'>
3080: <label for="curseed_forminput">$randseedtext</label>:
3081: </td><td></message>
3082: <string variable="curseed" size="15" maxlength="15">
3083: <defaultvalue>
3084: return $helper->{VARS}->{'curseed'};
3085: </defaultvalue>
3086: </string>
3087: <message></td></tr><tr><td align="right">
3088: <label for="style_file">$stylefiletext</label>:
3089: </td><td></message>
3090: <string variable="style_file" size="40">
3091: <defaultvalue>
3092: return $stylevalue;
3093: </defaultvalue>
3094: </string><message> <a href="javascript:openbrowser('helpform','style_file_forminput','sty')">$selectfiletext</a> </td></tr><tr><td></td><td align="left"></message>
3095: <choices allowempty="1" multichoice="true" variable="showallfoils">
3096: <choice computer="1">Show all foils</choice>
3097: </choices>
3098: <message></td></tr></message>
3099: RNDSEED
3100: &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
3101:
3102:
3103: addMessage("<tr><td>Problem Type:</td><td>");
3104: $paramHash = &Apache::lonhelper::getParamHash();
3105: $paramHash->{'variable'} = 'probstatus'; # Already declared:
3106: #
3107: # Initial value from construction space:
3108: #
3109: if (!$helper->{VARS}->{'probstatus'} && $env{'form.problemtype'}) {
3110: $helper->{VARS}->{'probstatus'} = $env{'form.problemtype'}; # initial value
3111: }
3112: $paramHash->{CHOICES} = [
3113: ['Homework problem', 'problem'],
3114: ['Exam Problem', 'exam'],
3115: ['Survey question', 'survey']];
3116: Apache::lonhelper::dropdown->new();
3117: addMessage("</td></tr>");
3118:
3119: }
3120: }
3121:
3122:
3123:
3124:
3125: if ($startedTable) {
3126: addMessage("</table>");
3127: }
3128:
3129: Apache::lonprintout::page_format_state->new("FORMAT");
3130:
3131: # Generate the PAGESIZE state which will offer the user the margin
3132: # choices if they select one column
3133: Apache::lonhelper::state->new("PAGESIZE", "Set Margins");
3134: Apache::lonprintout::page_size_state->new('pagesize', 'FORMAT', 'FINAL');
3135:
3136:
3137: $helper->process();
3138:
3139:
3140: # MANUAL BAILOUT CONDITION:
3141: # If we're in the "final" state, bailout and return to handler
3142: if ($helper->{STATE} eq 'FINAL') {
3143: return $helper;
3144: }
3145:
3146: $r->print($helper->display());
3147: if ($helper->{STATE} eq 'START') {
3148: &recently_generated($r);
3149: }
3150: &Apache::lonhelper::unregisterHelperTags();
3151:
3152: return OK;
3153: }
3154:
3155:
3156: 1;
3157:
3158: package Apache::lonprintout::page_format_state;
3159:
3160: =pod
3161:
3162: =head1 Helper element: page_format_state
3163:
3164: See lonhelper.pm documentation for discussion of the helper framework.
3165:
3166: Apache::lonprintout::page_format_state is an element that gives the
3167: user an opportunity to select the page layout they wish to print
3168: with: Number of columns, portrait/landscape, and paper size. If you
3169: want to change the paper size choices, change the @paperSize array
3170: contents in this package.
3171:
3172: page_format_state is always directly invoked in lonprintout.pm, so there
3173: is no tag interface. You actually pass parameters to the constructor.
3174:
3175: =over 4
3176:
3177: =item * B<new>(varName): varName is where the print information will be stored in the format FIXME.
3178:
3179: =back
3180:
3181: =cut
3182:
3183: use Apache::lonhelper;
3184:
3185: no strict;
3186: @ISA = ("Apache::lonhelper::element");
3187: use strict;
3188: use Apache::lonlocal;
3189: use Apache::lonnet;
3190:
3191: my $maxColumns = 2;
3192: # it'd be nice if these all worked
3193: #my @paperSize = ("letter [8 1/2x11 in]", "legal [8 1/2x14 in]",
3194: # "tabloid (ledger) [11x17 in]", "executive [7 1/2x10 in]",
3195: # "a2 [420x594 mm]", "a3 [297x420 mm]", "a4 [210x297 mm]",
3196: # "a5 [148x210 mm]", "a6 [105x148 mm]" );
3197: my @paperSize = ("letter [8 1/2x11 in]", "legal [8 1/2x14 in]",
3198: "a4 [210x297 mm]");
3199:
3200: # Tentative format: Orientation (L = Landscape, P = portrait) | Colnum |
3201: # Paper type
3202:
3203: sub new {
3204: my $self = Apache::lonhelper::element->new();
3205:
3206: shift;
3207:
3208: $self->{'variable'} = shift;
3209: my $helper = Apache::lonhelper::getHelper();
3210: $helper->declareVar($self->{'variable'});
3211: bless($self);
3212: return $self;
3213: }
3214:
3215: sub render {
3216: my $self = shift;
3217: my $helper = Apache::lonhelper::getHelper();
3218: my $result = '';
3219: my $var = $self->{'variable'};
3220: my $PageLayout=&mt('Page layout');
3221: my $NumberOfColumns=&mt('Number of columns');
3222: my $PaperType=&mt('Paper type');
3223: my $landscape=&mt('Landscape');
3224: my $portrait=&mt('Portrait');
3225: $result .= <<STATEHTML;
3226:
3227: <hr width="33%" />
3228: <table cellpadding="3">
3229: <tr>
3230: <td align="center"><b>$PageLayout</b></td>
3231: <td align="center"><b>$NumberOfColumns</b></td>
3232: <td align="center"><b>$PaperType</b></td>
3233: </tr>
3234: <tr>
3235: <td>
3236: <label><input type="radio" name="${var}.layout" value="L" /> $landscape </label><br />
3237: <label><input type="radio" name="${var}.layout" value="P" checked='1' /> $portrait </label>
3238: </td>
3239: <td align="center">
3240: <select name="${var}.cols">
3241: STATEHTML
3242:
3243: my $i;
3244: for ($i = 1; $i <= $maxColumns; $i++) {
3245: if ($i == 2) {
3246: $result .= "<option value='$i' selected>$i</option>\n";
3247: } else {
3248: $result .= "<option value='$i'>$i</option>\n";
3249: }
3250: }
3251:
3252: $result .= "</select></td><td>\n";
3253: $result .= "<select name='${var}.paper'>\n";
3254:
3255: my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
3256: my $DefaultPaperSize=lc($parmhash{'default_paper_size'});
3257: $DefaultPaperSize=~s/\s//g;
3258: if ($DefaultPaperSize eq '') {$DefaultPaperSize='letter';}
3259: $i = 0;
3260: foreach (@paperSize) {
3261: $_=~/(\w+)/;
3262: my $papersize=$1;
3263: if ($paperSize[$i]=~/$DefaultPaperSize/) {
3264: $result .= "<option selected value='$papersize'>" . $paperSize[$i] . "</option>\n";
3265: } else {
3266: $result .= "<option value='$papersize'>" . $paperSize[$i] . "</option>\n";
3267: }
3268: $i++;
3269: }
3270: $result .= "</select></td></tr></table>";
3271: return $result;
3272: }
3273:
3274: sub postprocess {
3275: my $self = shift;
3276:
3277: my $var = $self->{'variable'};
3278: my $helper = Apache::lonhelper->getHelper();
3279: $helper->{VARS}->{$var} =
3280: $env{"form.$var.layout"} . '|' . $env{"form.$var.cols"} . '|' .
3281: $env{"form.$var.paper"};
3282: return 1;
3283: }
3284:
3285: 1;
3286:
3287: package Apache::lonprintout::page_size_state;
3288:
3289: =pod
3290:
3291: =head1 Helper element: page_size_state
3292:
3293: See lonhelper.pm documentation for discussion of the helper framework.
3294:
3295: Apache::lonprintout::page_size_state is an element that gives the
3296: user the opportunity to further refine the page settings if they
3297: select a single-column page.
3298:
3299: page_size_state is always directly invoked in lonprintout.pm, so there
3300: is no tag interface. You actually pass parameters to the constructor.
3301:
3302: =over 4
3303:
3304: =item * B<new>(varName): varName is where the print information will be stored in the format FIXME.
3305:
3306: =back
3307:
3308: =cut
3309:
3310: use Apache::lonhelper;
3311: use Apache::lonnet;
3312: no strict;
3313: @ISA = ("Apache::lonhelper::element");
3314: use strict;
3315:
3316:
3317:
3318: sub new {
3319: my $self = Apache::lonhelper::element->new();
3320:
3321: shift; # disturbs me (probably prevents subclassing) but works (drops
3322: # package descriptor)... - Jeremy
3323:
3324: $self->{'variable'} = shift;
3325: my $helper = Apache::lonhelper::getHelper();
3326: $helper->declareVar($self->{'variable'});
3327:
3328: # The variable name of the format element, so we can look into
3329: # $helper->{VARS} to figure out whether the columns are one or two
3330: $self->{'formatvar'} = shift;
3331:
3332:
3333: $self->{NEXTSTATE} = shift;
3334: bless($self);
3335:
3336: return $self;
3337: }
3338:
3339: sub render {
3340: my $self = shift;
3341: my $helper = Apache::lonhelper::getHelper();
3342: my $result = '';
3343: my $var = $self->{'variable'};
3344:
3345:
3346:
3347: if (defined $self->{ERROR_MSG}) {
3348: $result .= '<br /><span class="LC_error">' . $self->{ERROR_MSG} . '</span><br />';
3349: }
3350:
3351: my $format = $helper->{VARS}->{$self->{'formatvar'}};
3352:
3353: # Use format to get sensible defaults for the margins:
3354:
3355:
3356: my ($laystyle, $cols, $papersize) = split(/\|/, $format);
3357: ($papersize) = split(/ /, $papersize);
3358:
3359:
3360: if ($laystyle eq 'L') {
3361: $laystyle = 'album';
3362: } else {
3363: $laystyle = 'book';
3364: }
3365:
3366:
3367: my %size;
3368: ($size{'width_and_units'},
3369: $size{'height_and_units'},
3370: $size{'margin_and_units'})=
3371: &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
3372:
3373: foreach my $dimension ('width','height','margin') {
3374: ($size{$dimension},$size{$dimension.'_unit'}) =
3375: split(/ +/, $size{$dimension.'_and_units'},2);
3376:
3377: foreach my $unit ('cm','in') {
3378: $size{$dimension.'_options'} .= '<option ';
3379: if ($size{$dimension.'_unit'} eq $unit) {
3380: $size{$dimension.'_options'} .= 'selected="selected" ';
3381: }
3382: $size{$dimension.'_options'} .= '>'.$unit.'</option>';
3383: }
3384: }
3385:
3386: # Adjust margin for LaTeX margin: .. requires units == cm or in.
3387:
3388: if ($size{'margin_unit'} eq 'in') {
3389: $size{'margin'} += 1;
3390: } else {
3391: $size{'margin'} += 2.54;
3392: }
3393: my %text = ('format' => 'How should each column be formatted?',
3394: 'width' => 'Width:',
3395: 'height' => 'Height:',
3396: 'margin' => 'Left Margin:',);
3397: %text = &Apache::lonlocal::texthash(%text);
3398:
3399: $result .= <<ELEMENTHTML;
3400:
3401: <p>$text{'format'}</p>
3402:
3403: <table cellpadding='3'>
3404: <tr>
3405: <td align='right'><b>$text{'width'}</b></td>
3406: <td align='left'><input type='text' name='$var.width' value="$size{'width'}" size='4' /></td>
3407: <td align='left'>
3408: <select name='$var.widthunit'>
3409: $size{'width_options'}
3410: </select>
3411: </td>
3412: </tr>
3413: <tr>
3414: <td align='right'><b>$text{'height'}</b></td>
3415: <td align='left'><input type='text' name="$var.height" value="$size{'height'}" size='4' /></td>
3416: <td align='left'>
3417: <select name='$var.heightunit'>
3418: $size{'height_options'}
3419: </select>
3420: </td>
3421: </tr>
3422: <tr>
3423: <td align='right'><b>$text{'margin'}</b></td>
3424: <td align='left'><input type='text' name='$var.lmargin' value="$size{'margin'}" size='4' /></td>
3425: <td align='left'>
3426: <select name='$var.lmarginunit'>
3427: $size{'margin_options'}
3428: </select>
3429: </td>
3430: </tr>
3431: </table>
3432:
3433: <!--<p>Hint: Some instructors like to leave scratch space for the student by
3434: making the width much smaller than the width of the page.</p>-->
3435:
3436: ELEMENTHTML
3437:
3438: return $result;
3439: }
3440:
3441:
3442: sub preprocess {
3443: my $self = shift;
3444: my $helper = Apache::lonhelper::getHelper();
3445:
3446: my $format = $helper->{VARS}->{$self->{'formatvar'}};
3447:
3448: # If the user does not have 'pav' privilege, set default widths and
3449: # on to the next state right away.
3450: #
3451: if (!$perm{'pav'}) {
3452: my $var = $self->{'variable'};
3453: my $format = $helper->{VARS}->{$self->{'formatvar'}};
3454:
3455: my ($laystyle, $cols, $papersize) = split(/\|/, $format);
3456: ($papersize) = split(/ /, $papersize);
3457:
3458:
3459: if ($laystyle eq 'L') {
3460: $laystyle = 'album';
3461: } else {
3462: $laystyle = 'book';
3463: }
3464: # Figure out some good defaults for the print out and set them:
3465:
3466: my %size;
3467: ($size{'width'},
3468: $size{'height'},
3469: $size{'lmargin'})=
3470: &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
3471:
3472: foreach my $dim ('width', 'height', 'lmargin') {
3473: my ($value, $units) = split(/ /, $size{$dim});
3474:
3475: $helper->{VARS}->{"$var.".$dim} = $value;
3476: $helper->{VARS}->{"$var.".$dim.'unit'} = $units;
3477:
3478: }
3479:
3480:
3481: # Transition to the next state
3482:
3483: $helper->changeState($self->{NEXTSTATE});
3484: }
3485:
3486: return 1;
3487: }
3488:
3489: sub postprocess {
3490: my $self = shift;
3491:
3492: my $var = $self->{'variable'};
3493: my $helper = Apache::lonhelper->getHelper();
3494: my $width = $helper->{VARS}->{$var .'.width'} = $env{"form.${var}.width"};
3495: my $height = $helper->{VARS}->{$var .'.height'} = $env{"form.${var}.height"};
3496: my $lmargin = $helper->{VARS}->{$var .'.lmargin'} = $env{"form.${var}.lmargin"};
3497: $helper->{VARS}->{$var .'.widthunit'} = $env{"form.${var}.widthunit"};
3498: $helper->{VARS}->{$var .'.heightunit'} = $env{"form.${var}.heightunit"};
3499: $helper->{VARS}->{$var .'.lmarginunit'} = $env{"form.${var}.lmarginunit"};
3500:
3501: my $error = '';
3502:
3503: # /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed
3504: # by an optional period, followed by digits, ending the string
3505:
3506: if ($width !~ /^-?[0-9]*(\.[0-9]*)?$/) {
3507: $error .= "Invalid width; please type only a number.<br />\n";
3508: }
3509: if ($height !~ /^-?[0-9]*(\.[0-9]*)?$/) {
3510: $error .= "Invalid height; please type only a number.<br />\n";
3511: }
3512: if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) {
3513: $error .= "Invalid left margin; please type only a number.<br />\n";
3514: } else {
3515: # Adjust for LaTeX 1.0 inch margin:
3516:
3517: if ($env{"form.${var}.lmarginunit"} eq "in") {
3518: $helper->{VARS}->{$var.'.lmargin'} = $lmargin - 1;
3519: } else {
3520: $helper->{VARS}->{$var.'.lmargin'} = $lmargin - 2.54;
3521: }
3522: }
3523:
3524: if (!$error) {
3525: Apache::lonhelper::getHelper()->changeState($self->{NEXTSTATE});
3526: return 1;
3527: } else {
3528: $self->{ERROR_MSG} = $error;
3529: return 0;
3530: }
3531: }
3532:
3533:
3534:
3535: __END__
3536:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>