[system] / trunk / pg / macros / PG.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PG.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5268 Revision 5269
1################################################################################ 1################################################################################
2# WeBWorK Program Generation Language 2# WeBWorK Program Generation Language
3# Copyright � 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright � 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork2/lib/WeBWorK.pm,v 1.97 2007/06/29 19:54:19 sh002i Exp $ 4# $CVSHeader: pg/macros/PG.pl,v 1.31 2007/07/13 22:43:22 sh002i Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
735 } else { 735 } else {
736 return %pg_answers_hash; 736 return %pg_answers_hash;
737 } 737 }
738} 738}
739 739
740=item includePGproblem($filePath)
741
742 includePGproblem($filePath);
743
744 Essentially runs the pg problem specified by $filePath, which is
745 a path relative to the top of the templates directory. The output
746 of that problem appears in the given problem.
747
748=cut
749
750sub includePGproblem {
751 my $filePath = shift;
752 my %save_envir = %main::envir;
753 my $fullfilePath = $main::envir{templateDirectory}.$filePath;
754 my $r_string = read_whole_problem_file($fullfilePath);
755 if (ref($r_string) eq 'SCALAR') {
756 $r_string = $$r_string;
757 }
758
759 # The problem calling this should provide DOCUMENT and ENDDOCUMENT,
760 # so we remove them from the included file.
761 $r_string=~ s/^\s*(END)?DOCUMENT(\(\s*\));?//gm;
762
763 # Reset the problem path so that static images can be found via
764 # their relative paths.
765 eval('$main::envir{probFileName} = $filePath');
766 eval('$main::envir{fileName} = $filePath');
767 includePGtext($r_string);
768 # Reset the environment to what it is before.
769 %main::envir = %save_envir;
770}
771
772
740=back 773=back
741 774
742=head1 SEE ALSO 775=head1 SEE ALSO
743 776
744L<PGbasicmacros.pl>, L<PGanswermacros.pl>. 777L<PGbasicmacros.pl>, L<PGanswermacros.pl>.

Legend:
Removed from v.5268  
changed lines
  Added in v.5269

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9