| 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$ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Instructor/PGProblemEditor.pm,v 1.21 2003/12/09 01:12:31 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. |
| … | |
… | |
| 116 | my $problemPath = $templateDirectory; |
116 | my $problemPath = $templateDirectory; |
| 117 | my $problem_record = undef; |
117 | my $problem_record = undef; |
| 118 | # FIXME there is a discrepancy in the way that the problems are found. |
118 | # FIXME there is a discrepancy in the way that the problems are found. |
| 119 | # FIXME more error checking is needed in case the problem doesn't exist. |
119 | # FIXME more error checking is needed in case the problem doesn't exist. |
| 120 | if (defined($problemNumber) and $problemNumber) { |
120 | if (defined($problemNumber) and $problemNumber) { |
| 121 | $problem_record = $db->getMergedProblem($effectiveUserName, $setName, $problemNumber); |
121 | $problem_record = $db->getMergedProblem($effectiveUserName, $setName, $problemNumber); # checked |
| 122 | # If there is no global_user defined problem, (i.e. the sets haven't been assigned yet), |
122 | # If there is no global_user defined problem, (i.e. the sets haven't been assigned yet), |
| 123 | # look for a global version of the problem. |
123 | # look for a global version of the problem. |
| 124 | $problem_record = $db->getGlobalProblem($setName, $problemNumber) unless defined($problem_record); |
124 | $problem_record = $db->getGlobalProblem($setName, $problemNumber) unless defined($problem_record); # checked |
| 125 | # bail if no problem is found |
125 | # bail if no problem is found |
| 126 | die "Cannot find a problem record for set $setName / problem $problemNumber" |
126 | die "Cannot find a problem record for set $setName / problem $problemNumber" |
| 127 | unless defined($problem_record); |
127 | unless defined($problem_record); |
| 128 | $problemPath .= '/'.$problem_record->source_file; |
128 | $problemPath .= '/'.$problem_record->source_file; |
| 129 | $self->{file_type} = 'problem'; |
129 | $self->{file_type} = 'problem'; |
| 130 | } elsif (defined($problemNumber) and $problemNumber==0) { # we are editing a header file |
130 | } elsif (defined($problemNumber) and $problemNumber==0) { # we are editing a header file |
| 131 | my $set_record = $db->getMergedSet($effectiveUserName, $setName); |
131 | my $set_record = $db->getMergedSet($effectiveUserName, $setName); # checked |
| 132 | die "Cannot find a set record for set $setName" unless defined($set_record); |
132 | die "Cannot find a set record for set $setName" unless defined($set_record); |
| 133 | $problemPath .= '/'.$set_record->set_header; |
133 | $problemPath .= '/'.$set_record->set_header; |
| 134 | $self->{file_type} = 'set_header'; |
134 | $self->{file_type} = 'set_header'; |
| 135 | } |
135 | } |
| 136 | |
136 | |
| … | |
… | |
| 269 | # test area |
269 | # test area |
| 270 | my $r = $self->{r}; |
270 | my $r = $self->{r}; |
| 271 | my $db = $self->{db}; |
271 | my $db = $self->{db}; |
| 272 | my $ce = $self->{ce}; |
272 | my $ce = $self->{ce}; |
| 273 | my $user = $r->param('user'); |
273 | my $user = $r->param('user'); |
| 274 | my $key = $db->getKey($user)->key(); |
274 | |
| 275 | |
275 | |
| 276 | |
276 | |
| 277 | ################ |
277 | ################ |
| 278 | # Gathering info |
278 | # Gathering info |
| 279 | # What is needed |
279 | # What is needed |