| … | |
… | |
| 192 | " the loadMacros() statement in the problem template.<p>" . |
192 | " the loadMacros() statement in the problem template.<p>" . |
| 193 | " The externalTTHPath variable |$main::externalTTHPath| was\n". |
193 | " The externalTTHPath variable |$main::externalTTHPath| was\n". |
| 194 | " not defined which usually indicates the problem above.<br>\n"; |
194 | " not defined which usually indicates the problem above.<br>\n"; |
| 195 | |
195 | |
| 196 | } |
196 | } |
| 197 | warn "running load macros"; |
197 | # warn "running load macros"; |
| 198 | while (@files) { |
198 | while (@files) { |
| 199 | $fileName = shift @files; |
199 | $fileName = shift @files; |
| 200 | next if ($fileName =~ /^PG.pl$/) ; # the PG.pl macro package is already loaded. |
200 | next if ($fileName =~ /^PG.pl$/) ; # the PG.pl macro package is already loaded. |
| 201 | |
201 | |
| 202 | my $macro_file_name = $fileName; |
202 | my $macro_file_name = $fileName; |
| … | |
… | |
| 216 | # be the same. |
216 | # be the same. |
| 217 | ############################################################################### |
217 | ############################################################################### |
| 218 | |
218 | |
| 219 | local($temp::rf_init_subroutine); |
219 | local($temp::rf_init_subroutine); |
| 220 | eval qq{ \$temp::rf_init_subroutine = \\&main::$init_subroutine_name;}; |
220 | eval qq{ \$temp::rf_init_subroutine = \\&main::$init_subroutine_name;}; |
| 221 | warn "loadMacros: defining \$temp::rf_init_subroutine",$temp::rf_init_subroutine; |
221 | #warn "loadMacros: defining \$temp::rf_init_subroutine",$temp::rf_init_subroutine; |
| 222 | |
222 | |
| 223 | $macro_file_loaded = defined($temp::rf_init_subroutine) && defined( &{$temp::rf_init_subroutine} ); |
223 | $macro_file_loaded = defined($temp::rf_init_subroutine) && defined( &{$temp::rf_init_subroutine} ); |
| 224 | |
224 | |
| 225 | # macros are searched for first in the $macroDirectory of the course |
225 | # macros are searched for first in the $macroDirectory of the course |
| 226 | # and then in the webwork $courseScripts directory. |
226 | # and then in the webwork $courseScripts directory. |
| 227 | unless ($macro_file_loaded) { |
227 | unless ($macro_file_loaded) { |
| 228 | print STDERR "loadMacros: loading macro file $fileName\n"; |
228 | #print STDERR "loadMacros: loading macro file $fileName\n"; |
| 229 | if (-r "${main::macroDirectory}$fileName") { |
229 | if (-r "${main::macroDirectory}$fileName") { |
| 230 | compile_file("${main::macroDirectory}$fileName"); |
230 | compile_file("${main::macroDirectory}$fileName"); |
| 231 | |
231 | |
| 232 | } elsif (-r "${main::courseScriptsDirectory}$fileName" ) { |
232 | } elsif (-r "${main::courseScriptsDirectory}$fileName" ) { |
| 233 | compile_file("${main::courseScriptsDirectory}$fileName"); |
233 | compile_file("${main::courseScriptsDirectory}$fileName"); |
| … | |
… | |
| 235 | die "Can't locate macro file via path: |${main::macroDirectory}$fileName| or |${main::courseScriptsDirectory}$fileName|"; |
235 | die "Can't locate macro file via path: |${main::macroDirectory}$fileName| or |${main::courseScriptsDirectory}$fileName|"; |
| 236 | } |
236 | } |
| 237 | } |
237 | } |
| 238 | # Try again to define the initialization subroutine. |
238 | # Try again to define the initialization subroutine. |
| 239 | eval qq{ \$temp::rf_init_subroutine = \\&main::$init_subroutine_name;}; |
239 | eval qq{ \$temp::rf_init_subroutine = \\&main::$init_subroutine_name;}; |
| 240 | warn "loadMacros: defining \$temp::rf_init_subroutine",$temp::rf_init_subroutine; |
240 | #warn "loadMacros: defining \$temp::rf_init_subroutine",$temp::rf_init_subroutine; |
| 241 | |
241 | |
| 242 | if ( defined($temp::rf_init_subroutine) and defined( &{$temp::rf_init_subroutine} ) ) { |
242 | if ( defined($temp::rf_init_subroutine) and defined( &{$temp::rf_init_subroutine} ) ) { |
| 243 | #print " &$init_subroutine_name defined = ", $macro_file_loaded,"\n"; |
243 | #print " &$init_subroutine_name defined = ", $macro_file_loaded,"\n"; |
| 244 | &{$temp::rf_init_subroutine}(); #initialize file |
244 | &{$temp::rf_init_subroutine}(); #initialize file |
| 245 | #print "initializing $init_subroutine_name\n"; |
245 | #print "initializing $init_subroutine_name\n"; |