| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm,v 1.29 2004/05/06 21:53:41 jj Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm,v 1.32 2004/05/08 19:35:21 jj 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. |
| … | |
… | |
| 25 | =cut |
25 | =cut |
| 26 | |
26 | |
| 27 | use strict; |
27 | use strict; |
| 28 | use warnings; |
28 | use warnings; |
| 29 | use CGI qw(); |
29 | use CGI qw(); |
| 30 | use WeBWorK::Utils qw(readFile); |
30 | use WeBWorK::Utils qw(readFile surePathToFile); |
| 31 | use Apache::Constants qw(:common REDIRECT); |
31 | use Apache::Constants qw(:common REDIRECT); |
| 32 | use HTML::Entities; |
32 | use HTML::Entities; |
| 33 | use WeBWorK::Utils::Tasks qw(fake_set fake_problem); |
33 | use WeBWorK::Utils::Tasks qw(fake_set fake_problem); |
| 34 | |
34 | |
| 35 | ########################################################### |
35 | ########################################################### |
| … | |
… | |
| 432 | |
432 | |
| 433 | # FIXME set a local state rather continue to call on the submit button. |
433 | # FIXME set a local state rather continue to call on the submit button. |
| 434 | if (defined $submit_button and $submit_button eq 'Save as' and defined $currentSourceFilePath and -e $currentSourceFilePath) { |
434 | if (defined $submit_button and $submit_button eq 'Save as' and defined $currentSourceFilePath and -e $currentSourceFilePath) { |
| 435 | warn "File $currentSourceFilePath exists. File not saved."; |
435 | warn "File $currentSourceFilePath exists. File not saved."; |
| 436 | } else { |
436 | } else { |
|
|
437 | # make sure any missing directories are created |
|
|
438 | $currentSourceFilePath = WeBWorK::Utils::surePathToFile($ce->{courseDirs}->{templates},$currentSourceFilePath); |
| 437 | eval { |
439 | eval { |
| 438 | local *OUTPUTFILE; |
440 | local *OUTPUTFILE; |
| 439 | open OUTPUTFILE, ">", $currentSourceFilePath |
441 | open OUTPUTFILE, ">", $currentSourceFilePath |
| 440 | or die "Failed to open $currentSourceFilePath"; |
442 | or die "Failed to open $currentSourceFilePath"; |
| 441 | print OUTPUTFILE $problemContents; |
443 | print OUTPUTFILE $problemContents; |