[system] / branches / gage_dev / webwork2 / lib / WeBWorK / ContentGenerator / Problem.pm Repository:
ViewVC logotype

Diff of /branches/gage_dev/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm

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

Revision 1016 Revision 2446
1################################################################################ 1################################################################################
2# WeBWorK mod_perl (c) 2000-2002 WeBWorK Project 2# WeBWorK Online Homework Delivery System
3# $Id$ 3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.152 2004/07/06 16:12:09 sh002i Exp $
5#
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
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.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the
14# Artistic License for more details.
4################################################################################ 15################################################################################
5 16
6package WeBWorK::ContentGenerator::Problem; 17package WeBWorK::ContentGenerator::Problem;
7use base qw(WeBWorK::ContentGenerator); 18use base qw(WeBWorK::ContentGenerator);
8 19
9=head1 NAME 20=head1 NAME
10 21
11WeBWorK::ContentGenerator::Problem - Allow a student to interact with a problem. 22WeBWorK::ContentGenerator::Problem - Allow a student to interact with a problem.
12 23
13=cut 24=cut
14 25
15use strict; 26use strict;
16use warnings; 27use warnings;
17use CGI qw(); 28use CGI qw();
18use File::Path qw(rmtree); 29use File::Path qw(rmtree);
19use File::Temp qw(tempdir);
20use WeBWorK::Form; 30use WeBWorK::Form;
21use WeBWorK::PG; 31use WeBWorK::PG;
32use WeBWorK::PG::ImageGenerator;
22use WeBWorK::PG::IO; 33use WeBWorK::PG::IO;
23use WeBWorK::Utils qw(writeLog encodeAnswers decodeAnswers ref2string); 34use WeBWorK::Utils qw(writeLog writeCourseLog encodeAnswers decodeAnswers ref2string makeTempDirectory);
24use WeBWorK::DB::Utils qw(global2user user2global findDefaults); 35use WeBWorK::DB::Utils qw(global2user user2global findDefaults);
36use WeBWorK::Timing;
37
38use WeBWorK::Utils::Tasks qw(fake_set fake_problem);
25 39
26############################################################ 40############################################################
27# 41#
28# user 42# user
29# effectiveUser 43# effectiveUser
30# key 44# key
31# 45#
32# displayMode 46# editMode
47# sourceFilePath - path to file to be editted
48# problemSeed - problem seed for editted problem
49#
50# displayMode - type of display (ie formatted, images, asciimath, etc)
51#
33# showOldAnswers 52# showOldAnswers
34# showCorrectAnswers 53# showCorrectAnswers
35# showHints 54# showHints
36# showSolutions 55# showSolutions
37# 56#
40# redisplay - name of the "Redisplay Problem" button 59# redisplay - name of the "Redisplay Problem" button
41# submitAnswers - name of "Submit Answers" button 60# submitAnswers - name of "Submit Answers" button
42# checkAnswers - name of the "Check Answers" button 61# checkAnswers - name of the "Check Answers" button
43# previewAnswers - name of the "Preview Answers" button 62# previewAnswers - name of the "Preview Answers" button
44# 63#
64# success - success message (from PGProblemEditor)
65# failure - failure message (from PGProblemEditor)
66#
45############################################################ 67############################################################
46 68
69
47sub pre_header_initialize { 70sub pre_header_initialize {
48 my ($self, $setName, $problemNumber) = @_; 71 my ($self) = @_;
49 my $r = $self->{r}; 72 my $r = $self->r;
50 my $courseEnv = $self->{ce}; 73 my $ce = $r->ce;
51 my $db = $self->{db}; 74 my $db = $r->db;
75 my $authz = $r->authz;
76 my $urlpath = $r->urlpath;
77
78 my $setName = $urlpath->arg("setID");
79 my $problemNumber = $r->urlpath->arg("problemID");
52 my $userName = $r->param('user'); 80 my $userName = $r->param('user');
53 my $effectiveUserName = $r->param('effectiveUser'); 81 my $effectiveUserName = $r->param('effectiveUser');
82 my $key = $r->param('key');
54 83
55 my $user = $db->getUser($userName); 84 my $user = $db->getUser($userName); # checked
85 die "record for user $userName (real user) does not exist."
86 unless defined $user;
87
56 my $effectiveUser = $db->getUser($effectiveUserName); 88 my $effectiveUser = $db->getUser($effectiveUserName); # checked
89 die "record for user $effectiveUserName (effective user) does not exist."
90 unless defined $effectiveUser;
91
92 my $PermissionLevel = $db->getPermissionLevel($userName); # checked
93 die "permission level record for user $userName does not exist (but the user does? odd...)"
94 unless defined $PermissionLevel;
95 my $permissionLevel = $PermissionLevel->permission;
96
97 # obtain the merged set for $effectiveUser
98 my $set = $db->getMergedSet($effectiveUserName, $setName); # checked
99
100 # obtain the merged problem for $effectiveUser
101 my $problem = $db->getMergedProblem($effectiveUserName, $setName, $problemNumber); # checked
57 102
58 # obtain the effective user set, or if that is not yet defined obtain global set 103 my $editMode = $r->param("editMode");
59 my $set = $db->getGlobalUserSet($effectiveUserName, $setName); 104
105 if ($authz->hasPermissions($userName, "modify_problem_sets")) {
106 # professors are allowed to fabricate sets and problems not
107 # assigned to them (or anyone). this allows them to use the
108 # editor to
109
110 # if that is not yet defined obtain the global set, convert
111 # it to a user set, and add fake user data
60 unless (defined $set) { 112 unless (defined $set) {
61 my $userSetClass = $courseEnv->{dbLayout}->{set_user}->{record}; 113 my $userSetClass = $db->{set_user}->{record};
62 $set = global2user($userSetClass, $db->getGlobalSet($setName)); 114 my $globalSet = $db->getGlobalSet($setName); # checked
115 # if the global set doesn't exist either, bail!
116 if(not defined $globalSet) {
117 $set = fake_set($db);
118 } else {
119 $set = global2user($userSetClass, $globalSet);
63 $set->psvn('000'); 120 $set->psvn(0);
121
122 # FIXME: This is a temporary fix to fill in the database
123 # We want the published field to contain either 1 or 0 so if it has not been set to 0, default to 1
124 # this will fill in all the empty fields but not change anything that has been specifically set to 1 or 0
125 $globalSet->published("1") unless $globalSet->published eq "0";
126 $db->putGlobalSet($globalSet);
127 }
64 } 128 }
65 my $psvn = $set->psvn(); 129
66 130 # if that is not yet defined obtain the global problem,
67 # obtain the effective user problem, or if that is not yet defined obtain global problem 131 # convert it to a user problem, and add fake user data
68 my $problem = $db->getGlobalUserProblem($effectiveUserName, $setName, $problemNumber);
69 unless (defined $problem) { 132 unless (defined $problem) {
70 my $userProblemClass = $courseEnv->{dbLayout}->{problem_user}->{record}; 133 my $userProblemClass = $db->{problem_user}->{record};
71 $problem = global2user($userProblemClass, $db->getGlobalProblem($setName,$problemNumber)); 134 my $globalProblem = $db->getGlobalProblem($setName, $problemNumber); # checked
72 135 # if the global problem doesn't exist either, bail!
73# $problem->max_attempts(-1); # default is infinite number of attempts 136 if(not defined $globalProblem) {
74# $problem->value; 137 my $sourceFilePath = $r->param("sourceFilePath");
138 # These are problems from setmaker. If declared invalid, they won't come up
139 $self->{invalidProblem} = $self->{invalidSet} = 1 unless defined $sourceFilePath;
140# die "Problem $problemNumber in set $setName does not exist" unless defined $sourceFilePath;
141 $problem = fake_problem($db);
142 $problem->problem_id(1);
143 $problem->source_file($sourceFilePath);
144 $problem->user_id($effectiveUserName);
145 } else {
146 $problem = global2user($userProblemClass, $globalProblem);
147 $problem->user_id($effectiveUserName);
75# $problem->problem_seed; 148 $problem->problem_seed(0);
76# $problem->source_file;
77 $problem->user_id($userName); # is this the right value for this unassigned problem? FIXME
78 $problem->status(0); 149 $problem->status(0);
79 $problem->attempted(0); 150 $problem->attempted(0);
151 $problem->last_answer("");
80 $problem->num_correct(0); 152 $problem->num_correct(0);
81 $problem->num_incorrect(0); 153 $problem->num_incorrect(0);
82 $problem->last_answer(' '); 154 }
83 } 155 }
84 #$problem = $db->getGlobalProblem($setName, $problemNumber) unless defined($problem); 156
85 # FIXME 157 # now we're sure we have valid UserSet and UserProblem objects
86 # a better solution at this point would be to take set and problem, convert them to global_user type 158 # yay!
87 # so that they have the right methods. 159
88 # Stuff the local copy of $set and $problem with default data where it won't have been defined 160 # now deal with possible editor overrides:
89 # Make sure that nothing bad is stored back in the database. 161
90 # It would be nice to store lastAnswer somewhere -- perhaps that could be done as a special case. 162 # if the caller is asking to override the source file, and
163 # editMode calls for a temporary file, do so
164 my $sourceFilePath = $r->param("sourceFilePath");
165 if (defined $sourceFilePath and
166 (not defined $editMode or $editMode eq "temporaryFile")) {
167 $problem->source_file($sourceFilePath);
168 }
169
170 # if the problem does not have a source file or no source file has been passed in
171 # then this is really an invalid problem (probably from a bad URL)
172 $self->{invalidProblem} = not (defined $sourceFilePath or $problem->source_file);
173
174 # if the caller is asking to override the problem seed, do so
175 my $problemSeed = $r->param("problemSeed");
176 if (defined $problemSeed) {
177 $problem->problem_seed($problemSeed);
178 }
179
180 my $publishedClass = ($set->published) ? "Published" : "Unpublished";
181 my $publishedText = ($set->published) ? "visible to students." : "hidden from students.";
182 $self->addmessage(CGI::p("This set is " . CGI::font({class=>$publishedClass}, $publishedText)));
183 } else {
91 184
92 185 # students can't view problems not assigned to them
93 # This supplies a psvn if $set doesn't have it. Unfortunately the problem is called on to provide 186
94 # data in many places and it might not even have methods defined. 187 # A set is valid if it exists and if it is either published or the user is privileged.
95 188 $self->{invalidSet} = ((grep /^$setName/, $db->listUserSets($effectiveUserName)) == 0)
96 # global sets will not have a defined psvn 189 || not defined $set
97# my $psvn; 190 || !($set->published || $authz->hasPermissions($userName, "view_unpublished_sets"));
98# if ($set->can('psvn') ) { 191 $self->{invalidProblem} = ((grep /^$problemNumber/, $db->listUserProblems($effectiveUserName, $setName)) == 0)
99# $psvn = $set->psvn(); 192 || not defined $problem
100# } else { # we are viewing an unassigned problem set, psvn's are irrelevant 193 || !($set->published || $authz->hasPermissions($userName, "view_unpublished_sets"));
101# $psvn = '0000'; 194
102# } 195 $self->addbadmessage(CGI::p("This problem will not count towards your grade.")) if $problem and not $problem->value and not $self->{invalidProblem};
103 196 }
104 my $permissionLevel = $db->getPermissionLevel($userName)->permission(); 197
105
106 $self->{userName} = $userName; 198 $self->{userName} = $userName;
199 $self->{effectiveUserName} = $effectiveUserName;
107 $self->{user} = $user; 200 $self->{user} = $user;
108 $self->{effectiveUser} = $effectiveUser; 201 $self->{effectiveUser} = $effectiveUser;
109 $self->{set} = $set;
110 $self->{problem} = $problem;
111 $self->{permissionLevel} = $permissionLevel; 202 $self->{permissionLevel} = $permissionLevel;
203 $self->{set} = $set;
204 $self->{problem} = $problem;
205 $self->{editMode} = $editMode;
112 206
113 ##### form processing ##### 207 ##### form processing #####
114 208
115 # set options from form fields (see comment at top of file for names) 209 # set options from form fields (see comment at top of file for names)
116 my $displayMode = $r->param("displayMode") || $courseEnv->{pg}->{options}->{displayMode}; 210 my $displayMode = $r->param("displayMode") || $ce->{pg}->{options}->{displayMode};
117 my $redisplay = $r->param("redisplay"); 211 my $redisplay = $r->param("redisplay");
118 my $submitAnswers = $r->param("submitAnswers"); 212 my $submitAnswers = $r->param("submitAnswers");
119 my $checkAnswers = $r->param("checkAnswers"); 213 my $checkAnswers = $r->param("checkAnswers");
120 my $previewAnswers = $r->param("previewAnswers"); 214 my $previewAnswers = $r->param("previewAnswers");
121 215
122 # fields which may be defined when using Problem Editor
123 my $override_seed = ($permissionLevel>=10) ? $r->param('problemSeed') : undef;
124 my $override_problem_source = ($permissionLevel>=10) ? $r->param('sourceFilePath') : undef;
125 my $editMode = undef;
126 my $submit_button = $r->param('submit_button');
127 if ( defined($submit_button ) ) {
128 $editMode = "temporaryFile" if $submit_button eq 'Refresh';
129 $editMode = 'savedFile' if $submit_button eq 'Save';
130 }
131
132 #override using the source file data from the form field
133 $problem->source_file($override_problem_source) if defined($override_problem_source);
134 $problem->problem_seed($override_seed) if defined($override_seed);
135
136 # store path to source file for title.
137 $self->{problem_source_name} = $problem->source_file;
138 $self->{edit_mode} = $editMode;
139# $self->{current_problem_source} = (defined($override_problem_source) ) ?
140# $override_problem_source :
141# $problem->source_file;
142 # coerce form fields into CGI::Vars format
143 my $formFields = { WeBWorK::Form->new_from_paramable($r)->Vars }; 216 my $formFields = { WeBWorK::Form->new_from_paramable($r)->Vars };
144 217
145 $self->{displayMode} = $displayMode; 218 $self->{displayMode} = $displayMode;
146 $self->{redisplay} = $redisplay; 219 $self->{redisplay} = $redisplay;
147 $self->{submitAnswers} = $submitAnswers; 220 $self->{submitAnswers} = $submitAnswers;
148 $self->{checkAnswers} = $checkAnswers; 221 $self->{checkAnswers} = $checkAnswers;
149 $self->{previewAnswers} = $previewAnswers; 222 $self->{previewAnswers} = $previewAnswers;
150 $self->{formFields} = $formFields; 223 $self->{formFields} = $formFields;
151
152 224
225 # get result and send to message
226 my $success = $r->param("sucess");
227 my $failure = $r->param("failure");
228 $self->addbadmessage(CGI::p($failure)) if $failure;
229 $self->addgoodmessage(CGI::p($success)) if $success;
230
231 # now that we've set all the necessary variables quit out if the set or problem is invalid
232 return if $self->{invalidSet} || $self->{invalidProblem};
233
153 ##### permissions ##### 234 ##### permissions #####
154 235
155 # are we allowed to view this problem? 236 # are we allowed to view this problem?
156 $self->{isOpen} = time >= $set->open_date || $permissionLevel > 0; 237 $self->{isOpen} = time >= $set->open_date || $authz->hasPermissions($userName, "view_unopened_sets");
157 return unless $self->{isOpen}; 238 return unless $self->{isOpen};
158 239
159 # what does the user want to do? 240 # what does the user want to do?
160 my %want = ( 241 my %want = (
161 showOldAnswers => $r->param("showOldAnswers") || $courseEnv->{pg}->{options}->{showOldAnswers}, 242 showOldAnswers => $r->param("showOldAnswers") || $ce->{pg}->{options}->{showOldAnswers},
162 showCorrectAnswers => $r->param("showCorrectAnswers") || $courseEnv->{pg}->{options}->{showCorrectAnswers}, 243 showCorrectAnswers => $r->param("showCorrectAnswers") || $ce->{pg}->{options}->{showCorrectAnswers},
163 showHints => $r->param("showHints") || $courseEnv->{pg}->{options}->{showHints}, 244 showHints => $r->param("showHints") || $ce->{pg}->{options}->{showHints},
164 showSolutions => $r->param("showSolutions") || $courseEnv->{pg}->{options}->{showSolutions}, 245 showSolutions => $r->param("showSolutions") || $ce->{pg}->{options}->{showSolutions},
165 recordAnswers => $submitAnswers, 246 recordAnswers => $submitAnswers,
166 checkAnswers => $checkAnswers, 247 checkAnswers => $checkAnswers,
167 ); 248 );
168 249
169 # are certain options enforced? 250 # are certain options enforced?
183 showHints => 1, 264 showHints => 1,
184 showSolutions => canShowSolutions($permissionLevel, $set->answer_date), 265 showSolutions => canShowSolutions($permissionLevel, $set->answer_date),
185 recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date, 266 recordAnswers => canRecordAnswers($permissionLevel, $set->open_date, $set->due_date,
186 $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1), 267 $problem->max_attempts, $problem->num_correct + $problem->num_incorrect + 1),
187 # attempts=num_correct+num_incorrect+1, as this happens before updating $problem 268 # attempts=num_correct+num_incorrect+1, as this happens before updating $problem
188 checkAnswers => canCheckAnswers($permissionLevel, $set->answer_date), 269 checkAnswers => canCheckAnswers($permissionLevel, $set->due_date),
270 );
271
272 # more complicated logic for showing check answer button:
273 # checkAnswers button shows up after due date -- once a student can't record anymore
274 # checkAnswers button always shows up when an instructor or TA is acting
275 # as someone else (the $user and $effectiveUserName aren't the same).
276 $can{checkAnswers} = (
277 # $can{recordAnswers} will be false if the due date has passed OR the
278 # student has used up all of her attempts
279 ($can{checkAnswers} and not $can{recordAnswers})
280 or
281 (
282 # FIXME: this is not the right way to check for this.
283 # also, canCheckAnswers() will show this button if the permission
284 # level is positive, which is always true when an instructor is
285 # acting as a student
286 defined($userName)
287 and
288 defined($effectiveUserName)
289 and
290 ($userName ne $effectiveUserName)
291 )
292 );
293
294 # more complicated logic for showing "submit answer" button:
295 # We hide the submit answer button if someone is acting as a student
296 # This prevents errors where you accidently submit the answer for a student
297 # Not sure whether this a feature or a bug
298 $can{recordAnswers} = (
299 $can{recordAnswers}
300 and not
301 (
302 # FIXME: this is not the right way to check for this.
303 defined($userName)
304 and
305 defined($effectiveUserName)
306 and
307 ($userName ne $effectiveUserName)
308 )
189 ); 309 );
190 310
191 # final values for options 311 # final values for options
192 my %will; 312 my %will;
193 foreach (keys %must) { 313 foreach (keys %must) {
194 $will{$_} = $can{$_} && ($want{$_} || $must{$_}); 314 $will{$_} = $can{$_} && ($want{$_} || $must{$_});
195 } 315 }
196 316
197 ##### sticky answers ##### 317 ##### sticky answers #####
198 318
199 if (not $submitAnswers and $will{showOldAnswers}) { 319 if (not ($submitAnswers or $previewAnswers or $checkAnswers) and $will{showOldAnswers}) {
200 # do this only if new answers are NOT being submitted 320 # do this only if new answers are NOT being submitted
201 my %oldAnswers = decodeAnswers($problem->last_answer); 321 my %oldAnswers = decodeAnswers($problem->last_answer);
202 $formFields->{$_} = $oldAnswers{$_} foreach keys %oldAnswers; 322 $formFields->{$_} = $oldAnswers{$_} foreach keys %oldAnswers;
203 } 323 }
204 324
205 ##### translation ##### 325 ##### translation #####
206 326
327 $WeBWorK::timer->continue("begin pg processing") if defined($WeBWorK::timer);
207 my $pg = WeBWorK::PG->new( 328 my $pg = WeBWorK::PG->new(
208 $courseEnv, 329 $ce,
209 $effectiveUser, 330 $effectiveUser,
210 $r->param('key'), 331 $key,
211 $set, 332 $set,
212 $problem, 333 $problem,
213 $psvn, 334 $set->psvn, # FIXME: this field should be removed
214 $formFields, 335 $formFields,
215 { # translation options 336 { # translation options
216 displayMode => $displayMode, 337 displayMode => $displayMode,
217 override_seed => $override_seed,
218 override_problem_source =>$override_problem_source,
219 showHints => $will{showHints}, 338 showHints => $will{showHints},
220 showSolutions => $will{showSolutions}, 339 showSolutions => $will{showSolutions},
221 refreshMath2img => $will{showHints} || $will{showSolutions}, 340 refreshMath2img => $will{showHints} || $will{showSolutions},
222 processAnswers => 1, 341 processAnswers => 1,
223 }, 342 },
224 ); 343 );
225 344
345 $WeBWorK::timer->continue("end pg processing") if defined($WeBWorK::timer);
226 ##### fix hint/solution options ##### 346 ##### fix hint/solution options #####
227 347
228 $can{showHints} &&= $pg->{flags}->{hintExists}; 348 $can{showHints} &&= $pg->{flags}->{hintExists}
349 &&= $pg->{flags}->{showHintLimit}<=$pg->{state}->{num_of_incorrect_ans};
229 $can{showSolutions} &&= $pg->{flags}->{solutionExists}; 350 $can{showSolutions} &&= $pg->{flags}->{solutionExists};
230 351
231 ##### store fields ##### 352 ##### store fields #####
232 353
233 $self->{want} = \%want; 354 $self->{want} = \%want;
234 $self->{must} = \%must; 355 $self->{must} = \%must;
235 $self->{can} = \%can; 356 $self->{can} = \%can;
236 $self->{will} = \%will; 357 $self->{will} = \%will;
237
238 $self->{pg} = $pg; 358 $self->{pg} = $pg;
239}
240
241sub if_warnings($$) {
242 my ($self, $arg) = @_;
243 return 0 unless $self->{isOpen};
244 return $self->{pg}->{warnings} ne "";
245} 359}
246 360
247sub if_errors($$) { 361sub if_errors($$) {
248 my ($self, $arg) = @_; 362 my ($self, $arg) = @_;
249 return 0 unless $self->{isOpen}; 363
364 if ($self->{isOpen}) {
250 return $self->{pg}->{flags}->{error_flag}; 365 return $self->{pg}->{flags}->{error_flag} ? $arg : !$arg;
366 } else {
367 return !$arg;
368 }
251} 369}
252 370
253sub head { 371sub head {
254 my $self = shift; 372 my ($self) = @_;
373
255 return "" unless $self->{isOpen}; 374 return "" unless $self->{isOpen};
256 return $self->{pg}->{head_text} if $self->{pg}->{head_text}; 375 return $self->{pg}->{head_text} if $self->{pg}->{head_text};
257} 376}
258 377
259sub path { 378sub options {
260 my $self = shift; 379 my ($self) = @_;
261 my $args = $_[-1];
262 my $setName = $self->{set}->set_id;
263 my $problemNumber = $self->{problem}->problem_id;
264 380
265 my $ce = $self->{ce}; 381 return "" if $self->{invalidProblem};
266 my $root = $ce->{webworkURLs}->{root}; 382 my $sourceFilePathfield = '';
267 my $courseName = $ce->{courseName}; 383 if($self->r->param("sourceFilePath")) {
268 return $self->pathMacro($args, 384 $sourceFilePathfield = CGI::hidden(-name => "sourceFilePath",
269 "Home" => "$root", 385 -value => $self->r->param("sourceFilePath"));
270 $courseName => "$root/$courseName", 386 }
271 $setName => "$root/$courseName/$setName", 387
272 "Problem $problemNumber" => "", 388 return join("",
389 CGI::start_form("POST", $self->{r}->uri),
390 $self->hidden_authen_fields,
391 $sourceFilePathfield,
392 CGI::hr(),
393 CGI::start_div({class=>"viewOptions"}),
394 $self->viewOptions(),
395 CGI::end_div(),
396 CGI::end_form()
273 ); 397 );
274} 398}
275 399
276sub siblings { 400sub siblings {
277 my $self = shift; 401 my ($self) = @_;
402 my $r = $self->r;
403 my $db = $r->db;
404 my $urlpath = $r->urlpath;
405
406 # can't show sibling problems if the set is invalid
407 return "" if $self->{invalidSet};
408
409 my $courseID = $urlpath->arg("courseID");
278 my $setName = $self->{set}->set_id; 410 my $setID = $self->{set}->set_id;
279 my $problemNumber = $self->{problem}->problem_id;
280
281 my $ce = $self->{ce};
282 my $db = $self->{db};
283 my $root = $ce->{webworkURLs}->{root};
284 my $courseName = $ce->{courseName};
285
286 print CGI::strong("Problems"), CGI::br();
287
288 my $effectiveUser = $self->{r}->param("effectiveUser"); 411 my $eUserID = $r->param("effectiveUser");
289 my @problems; 412 my @problemIDs = sort { $a <=> $b } $db->listUserProblems($eUserID, $setID);
290 push @problems, $db->getGlobalUserProblem($effectiveUser, $setName, $_) 413
291 foreach ($db->listUserProblems($effectiveUser, $setName)); 414 print CGI::start_ul({class=>"LinksMenu"});
292 foreach my $problem (sort { $a->problem_id <=> $b->problem_id } @problems) { 415 print CGI::start_li();
293 print CGI::a({-href=>"$root/$courseName/$setName/".$problem->problem_id."/?" 416 print CGI::span({style=>"font-size:larger"}, "Problems");
294 . $self->url_authen_args . "&displayMode=" . $self->{displayMode}}, 417 print CGI::start_ul();
295 "Problem ".$problem->problem_id), CGI::br(); 418
419 foreach my $problemID (@problemIDs) {
420 my $problemPage = $urlpath->newFromModule("WeBWorK::ContentGenerator::Problem",
421 courseID => $courseID, setID => $setID, problemID => $problemID);
422 print CGI::li(CGI::a({href=>$self->systemLink($problemPage, params=>{displayMode => $self->{displayMode}})}, "Problem $problemID"));
296 } 423 }
424
425 print CGI::end_ul();
426 print CGI::end_li();
427 print CGI::end_ul();
428
429 return "";
297} 430}
298 431
299sub nav { 432sub nav {
300 my $self = shift; 433 my ($self, $args) = @_;
301 my $args = $_[-1];
302 my $setName = $self->{set}->set_id;
303 my $problemNumber = $self->{problem}->problem_id;
304
305 my $ce = $self->{ce}; 434 my $r = $self->r;
306 my $db = $self->{db}; 435 my $db = $r->db;
307 my $root = $ce->{webworkURLs}->{root}; 436 my $urlpath = $r->urlpath;
308 my $courseName = $ce->{courseName};
309 437
310 my $wwdb = $self->{wwdb}; 438 my $courseID = $urlpath->arg("courseID");
439 my $setID = $self->{set}->set_id if !($self->{invalidSet});
440 my $problemID = $self->{problem}->problem_id if !($self->{invalidProblem});
311 my $effectiveUser = $self->{r}->param("effectiveUser"); 441 my $eUserID = $r->param("effectiveUser");
442
443 my ($prevID, $nextID);
444
445 if (!$self->{invalidProblem}) {
446 my @problemIDs = $db->listUserProblems($eUserID, $setID);
447 foreach my $id (@problemIDs) {
448 $prevID = $id if $id < $problemID
449 and (not defined $prevID or $id > $prevID);
450 $nextID = $id if $id > $problemID
451 and (not defined $nextID or $id < $nextID);
452 }
453 }
454
455 my @links;
456
457 if ($prevID) {
458 my $prevPage = $urlpath->newFromModule(__PACKAGE__,
459 courseID => $courseID, setID => $setID, problemID => $prevID);
460 push @links, "Previous Problem", $r->location . $prevPage->path, "navPrev";
461 } else {
462 push @links, "Previous Problem", "", "navPrev";
463 }
464
465 push @links, "Problem List", $r->location . $urlpath->parent->path, "navProbList";
466
467 if ($nextID) {
468 my $nextPage = $urlpath->newFromModule(__PACKAGE__,
469 courseID => $courseID, setID => $setID, problemID => $nextID);
470 push @links, "Next Problem", $r->location . $nextPage->path, "navNext";
471 } else {
472 push @links, "Next Problem", "", "navNext";
473 }
474
312 my $tail = "&displayMode=".$self->{displayMode}; 475 my $tail = "&displayMode=".$self->{displayMode};
313
314 my @links = ("Problem List" , "$root/$courseName/$setName", "navProbList");
315
316 my $prevProblem = $db->getGlobalUserProblem($effectiveUser, $setName, $problemNumber-1);
317 my $nextProblem = $db->getGlobalUserProblem($effectiveUser, $setName, $problemNumber+1);
318 unshift @links, "Previous Problem" , ($prevProblem
319 ? "$root/$courseName/$setName/".$prevProblem->problem_id
320 : "") , "navPrev";
321 push @links, "Next Problem" , ($nextProblem
322 ? "$root/$courseName/$setName/".$nextProblem->problem_id
323 : "") , "navNext";
324
325 return $self->navMacro($args, $tail, @links); 476 return $self->navMacro($args, $tail, @links);
326} 477}
327 478
328sub title { 479sub title {
329 my $self = shift; 480 my ($self) = @_;
330 my $setName = $self->{set}->set_id; 481
482 # using the url arguments won't break if the set/problem are invalid
483 my $setID = $self->r->urlpath->arg("setID");
484 my $problemID = $self->r->urlpath->arg("problemID");
331 485
332 my $file_action; 486 return "$setID : $problemID";
333 my $edit_mode = $self->{edit_mode};
334 if ( not defined($edit_mode) ) {
335 $file_action = '';
336 } elsif ( $edit_mode eq 'temporaryFile') {
337 $file_action .= 'Editing temporary file : '. CGI::br() . $self->{problem_source_name};
338 } elsif ( $edit_mode eq 'savedFile' ){
339 $file_action .= 'Problem saved to : '. CGI::br() . $self->{problem_source_name};
340 }
341 my $problemNumber = $self->{problem}->problem_id . " : " . $file_action;
342
343 return "$setName : Problem $problemNumber";
344} 487}
345 488
346sub body { 489sub body {
347 my $self = shift; 490 my $self = shift;
491 my $r = $self->r;
492 my $ce = $r->ce;
493 my $db = $r->db;
494 my $authz = $r->authz;
495 my $urlpath = $r->urlpath;
496 my $user = $r->param('user');
497
498 if ($self->{invalidSet}) {
499 return CGI::div({class=>"ResultsWithError"},
500 CGI::p("The selected problem set (" . $urlpath->arg("setID") . ") is not a valid set for " . $r->param("effectiveUser") . "."));
501 }
348 502
349 return CGI::p(CGI::font({-color=>"red"}, "This problem is not available because the problem set that contains it is not yet open.")) 503 if ($self->{invalidProblem}) {
504 return CGI::div({class=>"ResultsWithError"},
505 CGI::p("The selected problem (" . $urlpath->arg("problemID") . ") is not a valid problem for set " . $self->{set}->set_id . "."));
506 }
507
350 unless $self->{isOpen}; 508 unless ($self->{isOpen}) {
351 509 return CGI::div({class=>"ResultsWithError"},
510 CGI::p("This problem is not available because the problem set that contains it is not yet open."));
511 }
352 # unpack some useful variables 512 # unpack some useful variables
353 my $r = $self->{r};
354 my $db = $self->{db};
355 my $set = $self->{set}; 513 my $set = $self->{set};
356 my $problem = $self->{problem}; 514 my $problem = $self->{problem};
515 my $editMode = $self->{editMode};
357 my $permissionLevel = $self->{permissionLevel}; 516 my $permissionLevel = $self->{permissionLevel};
358 my $submitAnswers = $self->{submitAnswers}; 517 my $submitAnswers = $self->{submitAnswers};
359 my $checkAnswers = $self->{checkAnswers}; 518 my $checkAnswers = $self->{checkAnswers};
360 my $previewAnswers = $self->{previewAnswers}; 519 my $previewAnswers = $self->{previewAnswers};
361 my %want = %{ $self->{want} }; 520 my %want = %{ $self->{want} };
362 my %can = %{ $self->{can} }; 521 my %can = %{ $self->{can} };
363 my %must = %{ $self->{must} }; 522 my %must = %{ $self->{must} };
364 my %will = %{ $self->{will} }; 523 my %will = %{ $self->{will} };
365 my $pg = $self->{pg}; 524 my $pg = $self->{pg};
366 525
526 my $courseName = $urlpath->arg("courseID");
527
528 my $editorLink = "";
529 # if we are here without a real problem set, carry that through
530 my $forced_field = [];
531 $forced_field = ['sourceFilePath' => $r->param("sourceFilePath")] if
532 ($set->set_id eq 'Undefined_Set');
533 if ($authz->hasPermissions($user, "modify_problem_sets")) {
534 my $editorPage = $urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::PGProblemEditor",
535 courseID => $courseName, setID => $set->set_id, problemID => $problem->problem_id);
536 my $editorURL = $self->systemLink($editorPage, params=>$forced_field);
537 $editorLink = CGI::a({href=>$editorURL}, "Edit this problem");
538 }
539
367 ##### translation errors? ##### 540 ##### translation errors? #####
368 541
369 if ($pg->{flags}->{error_flag}) { 542 if ($pg->{flags}->{error_flag}) {
370 return $self->errorOutput($pg->{errors}, $pg->{body_text}); 543 print $self->errorOutput($pg->{errors}, $pg->{body_text});
544 print $editorLink;
545 return "";
371 } 546 }
372 547
373 ##### answer processing ##### 548 ##### answer processing #####
374 549 $WeBWorK::timer->continue("begin answer processing") if defined($WeBWorK::timer);
375 # if answers were submitted: 550 # if answers were submitted:
551 my $scoreRecordedMessage;
552 my $pureProblem;
376 if ($submitAnswers) { 553 if ($submitAnswers) {
377 # get a "pure" (unmerged) UserProblem to modify 554 # get a "pure" (unmerged) UserProblem to modify
378 # this will be undefined if the problem has not been assigned to this user 555 # this will be undefined if the problem has not been assigned to this user
379 my $pureProblem = $db->getUserProblem($problem->user_id, $problem->set_id, $problem->problem_id); 556 $pureProblem = $db->getUserProblem($problem->user_id, $problem->set_id, $problem->problem_id); # checked
557 if (defined $pureProblem) {
380 # store answers in DB for sticky answers 558 # store answers in DB for sticky answers
381 my %answersToStore; 559 my %answersToStore;
382 my %answerHash = %{ $pg->{answers} }; 560 my %answerHash = %{ $pg->{answers} };
383 $answersToStore{$_} = $answerHash{$_}->{original_student_ans} 561 $answersToStore{$_} = $self->{formFields}->{$_} #$answerHash{$_}->{original_student_ans} -- this may have been modified for fields with multiple values. Don't use it!!
384 foreach (keys %answerHash); 562 foreach (keys %answerHash);
563
564 # There may be some more answers to store -- one which are auxiliary entries to a primary answer. Evaluating
565 # matrices works in this way, only the first answer triggers an answer evaluator, the rest are just inputs
566 # however we need to store them. Fortunately they are still in the input form.
567 my @extra_answer_names = @{ $pg->{flags}->{KEPT_EXTRA_ANSWERS}};
568 $answersToStore{$_} = $self->{formFields}->{$_} foreach (@extra_answer_names);
569
570 # Now let's encode these answers to store them -- append the extra answers to the end of answer entry order
571 my @answer_order = (@{$pg->{flags}->{ANSWER_ENTRY_ORDER}}, @extra_answer_names);
385 my $answerString = encodeAnswers(%answersToStore, 572 my $answerString = encodeAnswers(%answersToStore,
386 @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }); 573 @answer_order);
387 574
575 # store last answer to database
388 $problem->last_answer($answerString); 576 $problem->last_answer($answerString);
389 # if $pureProblem is defined ( there is a user ) then record the last answer.
390 # FIXME (we're assuming that not being able to get a pure problem is enough to determine
391 # whether or not the problem database needs to be updated. This should be thought through
392 # more carefully to be sure.
393 if ( defined($pureProblem) ) {
394 $pureProblem->last_answer($answerString); 577 $pureProblem->last_answer($answerString);
395 $db->putUserProblem($pureProblem); 578 $db->putUserProblem($pureProblem);
396 #die "pureProblem = ", defined($pureProblem);
397 579
398
399 # store state in DB if it makes sense 580 # store state in DB if it makes sense
400 if ($will{recordAnswers}) { 581 if ($will{recordAnswers}) {
401 $problem->status($pg->{state}->{recorded_score}); 582 $problem->status($pg->{state}->{recorded_score});
402 $problem->attempted(1); 583 $problem->attempted(1);
403 $problem->num_correct($pg->{state}->{num_of_correct_ans}); 584 $problem->num_correct($pg->{state}->{num_of_correct_ans});
404 $problem->num_incorrect($pg->{state}->{num_of_incorrect_ans}); 585 $problem->num_incorrect($pg->{state}->{num_of_incorrect_ans});
405 $pureProblem->status($pg->{state}->{recorded_score}); 586 $pureProblem->status($pg->{state}->{recorded_score});
406 $pureProblem->attempted(1); 587 $pureProblem->attempted(1);
407 $pureProblem->num_correct($pg->{state}->{num_of_correct_ans}); 588 $pureProblem->num_correct($pg->{state}->{num_of_correct_ans});
408 $pureProblem->num_incorrect($pg->{state}->{num_of_incorrect_ans}); 589 $pureProblem->num_incorrect($pg->{state}->{num_of_incorrect_ans});
409 $db->putUserProblem($pureProblem); 590 if ($db->putUserProblem($pureProblem)) {
591 $scoreRecordedMessage = "Your score was recorded.";
592 } else {
593 $scoreRecordedMessage = "Your score was not recorded because there was a failure in storing the problem record to the database.";
594 }
410 # write to the transaction log, just to make sure 595 # write to the transaction log, just to make sure
411 writeLog($self->{ce}, "transaction", 596 writeLog($self->{ce}, "transaction",
412 $problem->problem_id."\t". 597 $problem->problem_id."\t".
413 $problem->set_id."\t". 598 $problem->set_id."\t".
414 $problem->user_id."\t". 599 $problem->user_id."\t".
420 $pureProblem->attempted."\t". 605 $pureProblem->attempted."\t".
421 $pureProblem->last_answer."\t". 606 $pureProblem->last_answer."\t".
422 $pureProblem->num_correct."\t". 607 $pureProblem->num_correct."\t".
423 $pureProblem->num_incorrect 608 $pureProblem->num_incorrect
424 ); 609 );
610 } else {
611 if (time < $set->open_date or time > $set->due_date) {
612 $scoreRecordedMessage = "Your score was not recorded because this problem set is closed.";
613 } else {
614 $scoreRecordedMessage = "Your score was not recorded.";
615 }
425 } 616 }
617 } else {
618 $scoreRecordedMessage = "Your score was not recorded because this problem has not been built for you.";
426 } 619 }
427 } 620 }
621
428 # logging student answers 622 # logging student answers
429 my $pastAnswerLog = undef; 623
430 if (defined( $self->{ce}->{webworkFiles}->{logs}->{'pastAnswerList'} )) { 624 my $answer_log = $self->{ce}->{courseFiles}->{logs}->{'answer_log'};
431 625 if ( defined($answer_log ) and defined($pureProblem)) {
432 $pastAnswerLog = $self->{ce}->{webworkFiles}->{logs}->{'pastAnswerList'}; 626 if ($submitAnswers ) {
433
434 if ($submitAnswers and defined($pastAnswerLog) ) {
435 my $answerString = ""; 627 my $answerString = "";
436 my %answerHash = %{ $pg->{answers} }; 628 my %answerHash = %{ $pg->{answers} };
437 $answerString = $answerString . $answerHash{$_}->{original_student_ans}."\t" 629 # FIXME this is the line 552 error. make sure original student ans is defined.
630 # The fact that it is not defined is probably due to an error in some answer evaluator.
631 # But I think it is useful to suppress this error message in the log.
438 foreach (sort keys %answerHash); 632 foreach (sort keys %answerHash) {
633 my $student_ans = $answerHash{$_}->{original_student_ans} ||'';
634 $answerString .= $student_ans."\t"
635 }
439 $answerString = '' unless defined($answerString); # insure string is defined. 636 $answerString = '' unless defined($answerString); # insure string is defined.
440 writeLog($self->{ce}, "pastAnswerList", 637 writeCourseLog($self->{ce}, "answer_log",
638 join("",
441 '|'.$problem->user_id. 639 '|', $problem->user_id,
442 '|'.$problem->set_id. 640 '|', $problem->set_id,
443 '|'.$problem->problem_id.'|'."\t". 641 '|', $problem->problem_id,
642 '|',"\t",
444 time()."\t". 643 time(),"\t",
445 $answerString, 644 $answerString,
446 645 ),
447 ); 646 );
448 647
449 } 648 }
450
451 } 649 }
452 # end logging student answers 650
651 $WeBWorK::timer->continue("end answer processing") if defined($WeBWorK::timer);
453 652
454 ##### output ##### 653 ##### output #####
654
455 print CGI::start_div({class=>"problemHeader"}); 655 print CGI::start_div({class=>"problemHeader"});
656
657 # custom message for editor
658 if ($authz->hasPermissions($user, "modify_problem_sets") and defined $editMode) {
659 if ($editMode eq "temporaryFile") {
660 print CGI::p(CGI::i("Editing temporary file: ", $problem->source_file));
661 } elsif ($editMode eq "savedFile") {
662 # taken care of in the initialization phase
663 }
664 }
665
456 # attempt summary 666 # attempt summary
457 if ($submitAnswers or $will{showCorrectAnswers}) { 667 #FIXME -- the following is a kludge: if showPartialCorrectAnswers is negative don't show anything.
668 # until after the due date
669 # do I need to check $will{showCorrectAnswers} to make preflight work??
670 if (($pg->{flags}->{showPartialCorrectAnswers}>= 0 and $submitAnswers) ) {
458 # print this if user submitted answers OR requested correct answers 671 # print this if user submitted answers OR requested correct answers
672
459 print $self->attemptResults($pg, $submitAnswers, 673 print $self->attemptResults($pg, 1,
460 $will{showCorrectAnswers}, 674 $will{showCorrectAnswers},
461 $pg->{flags}->{showPartialCorrectAnswers}, 1, 1); 675 $pg->{flags}->{showPartialCorrectAnswers}, 1, 1);
462 } elsif ($checkAnswers) { 676 } elsif ($checkAnswers) {
463 # print this if user previewed answers 677 # print this if user previewed answers
678 print CGI::div({class=>'ResultsWithError'},"ANSWERS ONLY CHECKED -- ",CGI::br(),"ANSWERS NOT RECORDED", CGI::br() );
464 print $self->attemptResults($pg, 1, 0, 1, 1, 1); 679 print $self->attemptResults($pg, 1, $will{showCorrectAnswers}, 1, 1, 1);
465 # show attempt answers 680 # show attempt answers
466 # don't show correct answers 681 # show correct answers if asked
467 # show attempt results (correctness) 682 # show attempt results (correctness)
468 # don't show attempt previews 683 # show attempt previews
469 } elsif ($previewAnswers) { 684 } elsif ($previewAnswers) {
470 # print this if user previewed answers 685 # print this if user previewed answers
471 print $self->attemptResults($pg, 1, 0, 0, 0, 1); 686 print CGI::div({class=>'ResultsWithError'},"PREVIEW ONLY -- NOT RECORDED"),CGI::br(),$self->attemptResults($pg, 1, 0, 0, 0, 1);
472 # show attempt answers 687 # show attempt answers
473 # don't show correct answers 688 # don't show correct answers
474 # don't show attempt results (correctness) 689 # don't show attempt results (correctness)
475 # show attempt previews 690 # show attempt previews
476 } 691 }
477 692
478 print CGI::end_div(); 693 print CGI::end_div();
479 694
480 print CGI::start_div({class=>"problem"}); 695 print CGI::start_div({class=>"problem"});
481 #print CGI::hr(); 696
482 # main form 697 # main form
483 print 698 print
484 CGI::startform("POST", $r->uri), 699 CGI::startform("POST", $r->uri),
485 $self->hidden_authen_fields, 700 $self->hidden_authen_fields,
486 CGI::p($pg->{body_text}), 701 CGI::p($pg->{body_text}),
487 CGI::p($pg->{result}->{msg} ? CGI::b("Note: ") : "", CGI::i($pg->{result}->{msg})), 702 CGI::p($pg->{result}->{msg} ? CGI::b("Note: ") : "", CGI::i($pg->{result}->{msg})),
488 CGI::p( 703 CGI::p(
704 ($can{showCorrectAnswers}
705 ? CGI::checkbox(
706 -name => "showCorrectAnswers",
707 -checked => $will{showCorrectAnswers},
708 -label => "Show correct answers",
709 ) ." "
710 : "" ),
711 ($can{showHints}
712 ? '<div style="color:red">'. CGI::checkbox(
713 -name => "showHints",
714 -checked => $will{showHints},
715 -label => "Show Hints",
716 ) . "</div> "
717 : " " ),
718 ($can{showSolutions}
719 ? CGI::checkbox(
720 -name => "showSolutions",
721 -checked => $will{showSolutions},
722 -label => "Show Solutions",
723 ) . " "
724 : " " ),CGI::br(),
725 CGI::submit(-name=>"previewAnswers",
726 -label=>"Preview Answers"),
489 ($can{recordAnswers} 727 ($can{recordAnswers}
490 ? CGI::submit(-name=>"submitAnswers", 728 ? CGI::submit(-name=>"submitAnswers",
491 -label=>"Submit Answers") 729 -label=>"Submit Answers")
492 : ""), 730 : ""),
493 ($can{checkAnswers} 731 ( $can{checkAnswers}
494 ? CGI::submit(-name=>"checkAnswers", 732 ? CGI::submit(-name=>"checkAnswers",
495 -label=>"Check Answers") 733 -label=>"Check Answers")
496 : ""), 734 : ""),
497 CGI::submit(-name=>"previewAnswers",
498 -label=>"Preview Answers"),
499 ); 735 );
500 print CGI::end_div(); 736 print CGI::end_div();
501 737
502 print CGI::start_div({class=>"scoreSummary"}); 738 print CGI::start_div({class=>"scoreSummary"});
739
503 # score summary 740 # score summary
504 my $attempts = $problem->num_correct + $problem->num_incorrect; 741 my $attempts = $problem->num_correct + $problem->num_incorrect;
505 my $attemptsNoun = $attempts != 1 ? "times" : "time"; 742 my $attemptsNoun = $attempts != 1 ? "times" : "time";
506 my $lastScore = int ($problem->status * 100) . "%"; 743 my $lastScore = sprintf("%.0f%%", $problem->status * 100); # Round to whole number
507 my ($attemptsLeft, $attemptsLeftNoun); 744 my ($attemptsLeft, $attemptsLeftNoun);
508 if ($problem->max_attempts == -1) { 745 if ($problem->max_attempts == -1) {
509 # unlimited attempts 746 # unlimited attempts
510 $attemptsLeft = "unlimited"; 747 $attemptsLeft = "unlimited";
511 $attemptsLeftNoun = "attempts"; 748 $attemptsLeftNoun = "attempts";
517 my $setClosed = 0; 754 my $setClosed = 0;
518 my $setClosedMessage; 755 my $setClosedMessage;
519 if (time < $set->open_date or time > $set->due_date) { 756 if (time < $set->open_date or time > $set->due_date) {
520 $setClosed = 1; 757 $setClosed = 1;
521 $setClosedMessage = "This problem set is closed."; 758 $setClosedMessage = "This problem set is closed.";
522 if ($permissionLevel > 0) { 759 if ($authz->hasPermissions($user, "view_answers")) {
523 $setClosedMessage .= " Since you are a privileged user, additional attempts will be recorded."; 760 $setClosedMessage .= " However, since you are a privileged user, additional attempts will be recorded.";
524 } else { 761 } else {
525 $setClosedMessage .= " Additional attempts will not be recorded."; 762 $setClosedMessage .= " Additional attempts will not be recorded.";
526 } 763 }
527 } 764 }
765
766 my $notCountedMessage = ($problem->value) ? "" : "(This problem will not count towards your grade.)";
528 print CGI::p( 767 print CGI::p(
768 $submitAnswers ? $scoreRecordedMessage . CGI::br() : "",
529 "You have attempted this problem $attempts $attemptsNoun.", CGI::br(), 769 "You have attempted this problem $attempts $attemptsNoun.", CGI::br(),
530 $problem->attempted 770 $problem->attempted
531 ? "Your recorded score is $lastScore." . CGI::br() 771 ? "Your recorded score is $lastScore. $notCountedMessage" . CGI::br()
532 : "", 772 : "",
533 $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining." 773 $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining."
534 ); 774 );
535 print CGI::end_div(); 775 print CGI::end_div();
536# print CGI::hr(), CGI::start_div({class=>"viewOptions"}); 776
537# print $self->viewOptions(),CGI::end_div(),
538# save state for viewOptions 777 # save state for viewOptions
539 print CGI::hidden(-name => "showOldAnswers", 778 print CGI::hidden(
779 -name => "showOldAnswers",
540 -value => $will{showOldAnswers}, 780 -value => $will{showOldAnswers}
541 ), 781 ),
542 CGI::hidden(-name => "showCorrectAnswers", 782
543 -value => $will{showCorrectAnswers}, 783 CGI::hidden(
544 ), 784 -name => "displayMode",
545 CGI::hidden(-name => "showHints",
546 -value => $will{showHints},
547 ),
548 CGI::hidden(-name => "showSolutions",
549 -value => $will{showSolutions},
550 ),
551 CGI::hidden(-name => "displayMode",
552 -value => $self->{displayMode} 785 -value => $self->{displayMode}
553 ); 786 );
787 print( CGI::hidden(
788 -name => 'editMode',
789 -value => $self->{editMode},
790 )
791 ) if defined($self->{editMode}) and $self->{editMode} eq 'temporaryFile';
792 print( CGI::hidden(
793 -name => 'sourceFilePath',
794 -value => $self->{problem}->{source_file}
795 )) if defined($self->{problem}->{source_file});
796
797 print( CGI::hidden(
798 -name => 'problemSeed',
799 -value => $r->param("problemSeed")
800 )) if defined($r->param("problemSeed"));
801
802 # end of main form
554 print CGI::endform(); 803 print CGI::endform();
555 804
556 print CGI::start_div({class=>"problemFooter"}); 805 print CGI::start_div({class=>"problemFooter"});
557 # feedback form
558 my $ce = $self->{ce};
559 my $root = $ce->{webworkURLs}->{root};
560 my $courseName = $ce->{courseName};
561 my $feedbackURL = "$root/$courseName/feedback/";
562 806
563 # arguments for answer inspection button 807 ## arguments for answer inspection button
564 my $prof_url = $ce->{webworkURLs}->{oldProf}; 808 #my $prof_url = $ce->{webworkURLs}->{oldProf};
809 #my $webworkURL = $ce->{webworkURLs}->{root};
565 my $cgi_url = $prof_url; 810 #my $cgi_url = $prof_url;
566 $cgi_url=~ s|/[^/]*$||; # clip profLogin.pl 811 #$cgi_url=~ s|/[^/]*$||; # clip profLogin.pl
567 my $authen_args = $self->url_authen_args(); 812 #my $authen_args = $self->url_authen_args();
568 my $showPastAnswersURL = "$cgi_url/showPastAnswers.pl"; 813 #my $showPastAnswersURL = "$webworkURL/$courseName/instructor/show_answers/";
569 814
570 815 my $pastAnswersPage = $urlpath->newFromModule("WeBWorK::ContentGenerator::Instructor::ShowAnswers",
571 print CGI::end_div(); 816 courseID => $courseName);
572 print CGI::start_div(); 817 my $showPastAnswersURL = $self->systemLink($pastAnswersPage, authen => 0); # no authen info for form action
818
573 # print answer inspection button 819 # print answer inspection button
574 if ($self->{permissionLevel} >0) { 820 if ($authz->hasPermissions($user, "view_answers")) {
575
576
577 print "\n", 821 print "\n",
578 CGI::start_form(-method=>"POST",-action=>$showPastAnswersURL,-target=>"information"),"\n", 822 CGI::start_form(-method=>"POST",-action=>$showPastAnswersURL,-target=>"information"),"\n",
579 $self->hidden_authen_fields,"\n", 823 $self->hidden_authen_fields,"\n",
580 CGI::hidden(-name => 'course', -value=>$courseName), "\n", 824 CGI::hidden(-name => 'courseID', -value=>$courseName), "\n",
581 CGI::hidden(-name => 'probNum', -value=>$problem->problem_id), "\n", 825 CGI::hidden(-name => 'problemID', -value=>$problem->problem_id), "\n",
582 CGI::hidden(-name => 'setNum', -value=>$problem->set_id), "\n", 826 CGI::hidden(-name => 'setID', -value=>$problem->set_id), "\n",
583 CGI::hidden(-name => 'User', -value=>$problem->user_id), "\n", 827 CGI::hidden(-name => 'studentUser', -value=>$problem->user_id), "\n",
584 CGI::p( {-align=>"left"}, 828 CGI::p( {-align=>"left"},
585 CGI::submit(-name => 'action', -value=>'Show Past Answers') 829 CGI::submit(-name => 'action', -value=>'Show Past Answers')
586 ), "\n", 830 ), "\n",
587 CGI::endform(); 831 CGI::endform();
832 }
588 833
834 # feedback form url
835 my $feedbackPage = $urlpath->newFromModule("WeBWorK::ContentGenerator::Feedback",
836 courseID => $courseName);
837 my $feedbackURL = $self->systemLink($feedbackPage, authen => 0); # no authen info for form action
589 838
590
591 } #print feedback form 839 #print feedback form
592
593
594 print 840 print
595 CGI::start_form(-method=>"POST", -action=>$feedbackURL),"\n", 841 CGI::start_form(-method=>"POST", -action=>$feedbackURL),"\n",
596 $self->hidden_authen_fields,"\n", 842 $self->hidden_authen_fields,"\n",
597 CGI::hidden("module", __PACKAGE__),"\n", 843 CGI::hidden("module", __PACKAGE__),"\n",
598 CGI::hidden("set", $set->set_id),"\n", 844 CGI::hidden("set", $set->set_id),"\n",
601 CGI::hidden("showOldAnswers", $will{showOldAnswers}),"\n", 847 CGI::hidden("showOldAnswers", $will{showOldAnswers}),"\n",
602 CGI::hidden("showCorrectAnswers", $will{showCorrectAnswers}),"\n", 848 CGI::hidden("showCorrectAnswers", $will{showCorrectAnswers}),"\n",
603 CGI::hidden("showHints", $will{showHints}),"\n", 849 CGI::hidden("showHints", $will{showHints}),"\n",
604 CGI::hidden("showSolutions", $will{showSolutions}),"\n", 850 CGI::hidden("showSolutions", $will{showSolutions}),"\n",
605 CGI::p({-align=>"left"}, 851 CGI::p({-align=>"left"},
606 CGI::submit(-name=>"feedbackForm", -label=>"Contact instructor") 852 CGI::submit(-name=>"feedbackForm", -label=>"Email instructor")
607 ), 853 ),
608 CGI::endform(),"\n"; 854 CGI::endform(),"\n";
609 855
610 # FIXME print editor link 856 # FIXME print editor link
611 # print editor link if the user is an instructor AND the file is not in temporary editing mode 857 print $editorLink; #empty unless it is appropriate to have an editor link.
612 if ($self->{permissionLevel}>=10 and ( (not defined($self->{edit_mode})) or $self->{edit_mode} eq 'savedFile') ) {
613 print CGI::a({-href=>"/webwork/$courseName/instructor/pgProblemEditor/".$set->set_id.
614 '/'.$problem->problem_id.'?'.$self->url_authen_args},'Edit this problem');
615 }
616 858
617 print CGI::end_div(); 859 print CGI::end_div();
618
619 # end answer inspection button
620 # warning output
621 if ($pg->{warnings} ne "") {
622 print CGI::hr(), $self->warningOutput($pg->{warnings});
623 }
624 860
625 # debugging stuff 861 # debugging stuff
626 if (0) { 862 if (0) {
627 print 863 print
628 CGI::hr(), 864 CGI::hr(),
642 return ""; 878 return "";
643} 879}
644 880
645##### output utilities ##### 881##### output utilities #####
646 882
647sub attemptResults($$$$$$) { 883sub attemptResults {
648 my $self = shift; 884 my $self = shift;
649 my $pg = shift; 885 my $pg = shift;
650 my $showAttemptAnswers = shift; 886 my $showAttemptAnswers = shift;
651 my $showCorrectAnswers = shift; 887 my $showCorrectAnswers = shift;
652 my $showAttemptResults = $showAttemptAnswers && shift; 888 my $showAttemptResults = $showAttemptAnswers && shift;
653 my $showSummary = shift; 889 my $showSummary = shift;
654 my $showAttemptPreview = shift || 0; 890 my $showAttemptPreview = shift || 0;
891
892 my $ce = $self->r->ce;
893
655 my $problemResult = $pg->{result}; # the overall result of the problem 894 my $problemResult = $pg->{result}; # the overall result of the problem
656 my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; 895 my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} };
657 896
658 my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames; 897 my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames;
659 898
899 my $basename = "equation-" . $self->{set}->psvn. "." . $self->{problem}->problem_id . "-preview";
900
901 # to make grabbing these options easier, we'll pull them out now...
902 my %imagesModeOptions = %{$ce->{pg}->{displayModeOptions}->{images}};
903
904 my $imgGen = WeBWorK::PG::ImageGenerator->new(
905 tempDir => $ce->{webworkDirs}->{tmp},
906 latex => $ce->{externalPrograms}->{latex},
907 dvipng => $ce->{externalPrograms}->{dvipng},
908 useCache => 1,
909 cacheDir => $ce->{webworkDirs}->{equationCache},
910 cacheURL => $ce->{webworkURLs}->{equationCache},
911 cacheDB => $ce->{webworkFiles}->{equationCacheDB},
912 dvipng_align => $imagesModeOptions{dvipng_align},
913 dvipng_depth_db => $imagesModeOptions{dvipng_depth_db},
914 );
915
916 my $header;
660 my $header = CGI::th("Part"); 917 #$header .= CGI::th("Part");
661 $header .= $showAttemptAnswers ? CGI::th("Entered") : ""; 918 $header .= $showAttemptAnswers ? CGI::th("Entered") : "";
662 $header .= $showAttemptPreview ? CGI::th("Answer Preview") : ""; 919 $header .= $showAttemptPreview ? CGI::th("Answer Preview") : "";
663 $header .= $showCorrectAnswers ? CGI::th("Correct") : ""; 920 $header .= $showCorrectAnswers ? CGI::th("Correct") : "";
664 $header .= $showAttemptResults ? CGI::th("Result") : ""; 921 $header .= $showAttemptResults ? CGI::th("Result") : "";
665 $header .= $showMessages ? CGI::th("messages") : ""; 922 $header .= $showMessages ? CGI::th("Messages") : "";
666 my @tableRows = ( $header ); 923 my @tableRows = ( $header );
667 my $numCorrect; 924 my $numCorrect = 0;
668 foreach my $name (@answerNames) { 925 foreach my $name (@answerNames) {
669 my $answerResult = $pg->{answers}->{$name}; 926 my $answerResult = $pg->{answers}->{$name};
670 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans 927 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans
671 my $preview = ($showAttemptPreview 928 my $preview = ($showAttemptPreview
672 ? $self->previewAnswer($answerResult) 929 ? $self->previewAnswer($answerResult, $imgGen)
673 : ""); 930 : "");
674 my $correctAnswer = $answerResult->{correct_ans}; 931 my $correctAnswer = $answerResult->{correct_ans};
675 my $answerScore = $answerResult->{score}; 932 my $answerScore = $answerResult->{score};
676 my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; 933 my $answerMessage = $showMessages ? $answerResult->{ans_message} : "";
677 934 #FIXME --Can we be sure that $answerScore is an integer-- could the problem give partial credit?
678 $numCorrect += $answerScore > 0; 935 $numCorrect += $answerScore > 0;
679 my $resultString = $answerScore ? "correct" : "incorrect"; 936 my $resultString = $answerScore == 1 ? "correct" : "incorrect";
680 937
681 # get rid of the goofy prefix on the answer names (supposedly, the format 938 # get rid of the goofy prefix on the answer names (supposedly, the format
682 # of the answer names is changeable. this only fixes it for "AnSwEr" 939 # of the answer names is changeable. this only fixes it for "AnSwEr"
683 $name =~ s/^AnSwEr//; 940 #$name =~ s/^AnSwEr//;
684 941
942 my $row;
685 my $row = CGI::td($name); 943 #$row .= CGI::td($name);
686 $row .= $showAttemptAnswers ? CGI::td($studentAnswer) : ""; 944 $row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : "";
687 $row .= $showAttemptPreview ? CGI::td($preview) : ""; 945 $row .= $showAttemptPreview ? CGI::td($self->nbsp($preview)) : "";
688 $row .= $showCorrectAnswers ? CGI::td($correctAnswer) : ""; 946 $row .= $showCorrectAnswers ? CGI::td($self->nbsp($correctAnswer)) : "";
689 $row .= $showAttemptResults ? CGI::td($resultString) : ""; 947 $row .= $showAttemptResults ? CGI::td($self->nbsp($resultString)) : "";
690 $row .= $answerMessage ? CGI::td($answerMessage) : ""; 948 $row .= $showMessages ? CGI::td($self->nbsp($answerMessage)) : "";
691 push @tableRows, $row; 949 push @tableRows, $row;
692 } 950 }
693 951
952 # render equation images
953 $imgGen->render(refresh => 1);
954
694 my $numIncorrectNoun = scalar @answerNames == 1 ? "question" : "questions"; 955# my $numIncorrectNoun = scalar @answerNames == 1 ? "question" : "questions";
695 my $scorePercent = int ($problemResult->{score} * 100) . "\%"; 956 my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100);
957# FIXME -- I left the old code in in case we have to back out.
696 my $summary = "On this attempt, you answered $numCorrect out of " 958# my $summary = "On this attempt, you answered $numCorrect out of "
697 . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent."; 959# . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent.";
698 return CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) . ($showSummary ? CGI::p($summary) : ""); 960 my $summary = "";
961 if (scalar @answerNames == 1) {
962 if ($numCorrect == scalar @answerNames) {
963 $summary .= CGI::div({class=>"ResultsWithoutError"},"The above answer is correct.");
964 } else {
965 $summary .= CGI::div({class=>"ResultsWithError"},"The above answer is NOT correct.");
966 }
967 } else {
968 if ($numCorrect == scalar @answerNames) {
969 $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the above answers are correct.");
970 } else {
971 $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the above answers is NOT correct.");
972 }
973 }
974
975 return
976 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows))
977 . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : "");
699} 978}
700 979
980#sub nbsp {
981# my $str = shift;
982# ($str =~/\S/) ? $str : '&nbsp;' ; # returns non-breaking space for empty strings
983# # tricky cases: $str =0;
984# # $str is a complex number
985#}
986
701sub viewOptions($) { 987sub viewOptions {
702 my $self = shift; 988 my ($self) = @_;
989 my $ce = $self->r->ce;
990
991 # don't show options if we don't have anything to show
992 return if $self->{invalidSet} or $self->{invalidProblem};
993 return unless $self->{isOpen};
994
703 my $displayMode = $self->{displayMode}; 995 my $displayMode = $self->{displayMode};
704 my %must = %{ $self->{must} }; 996 my %must = %{ $self->{must} };
705 my %can = %{ $self->{can} }; 997 my %can = %{ $self->{can} };
706 my %will = %{ $self->{will} }; 998 my %will = %{ $self->{will} };
707 999
711 CGI::checkbox( 1003 CGI::checkbox(
712 -name => "showOldAnswers", 1004 -name => "showOldAnswers",
713 -checked => $will{showOldAnswers}, 1005 -checked => $will{showOldAnswers},
714 -label => "Saved answers", 1006 -label => "Saved answers",
715 ), "&nbsp;&nbsp;".CGI::br(); 1007 ), "&nbsp;&nbsp;".CGI::br();
716 $can{showCorrectAnswers} and $optionLine .= join "", 1008
717 CGI::checkbox(
718 -name => "showCorrectAnswers",
719 -checked => $will{showCorrectAnswers},
720 -label => "Correct answers",
721 ), "&nbsp;&nbsp;".CGI::br();
722 $can{showHints} and $optionLine .= join "",
723 CGI::checkbox(
724 -name => "showHints",
725 -checked => $will{showHints},
726 -label => "Hints",
727 ), "&nbsp;&nbsp;".CGI::br();
728 $can{showSolutions} and $optionLine .= join "",
729 CGI::checkbox(
730 -name => "showSolutions",
731 -checked => $will{showSolutions},
732 -label => "Solutions",
733 ), "&nbsp;&nbsp;".CGI::br();
734 $optionLine and $optionLine .= join "", CGI::br(); 1009 $optionLine and $optionLine .= join "", CGI::br();
735 1010
736 return CGI::div({-style=>"border: thin groove; padding: 1ex; margin: 2ex align: left"}, 1011 my %display_modes = %{WeBWorK::PG::DISPLAY_MODES()};
1012 my @active_modes = grep { exists $display_modes{$_} }
1013 @{$ce->{pg}->{displayModes}};
1014 my $modeLine = (scalar(@active_modes)>1) ?
737 "View&nbsp;equations&nbsp;as:&nbsp;&nbsp;&nbsp;&nbsp;".CGI::br(), 1015 "View&nbsp;equations&nbsp;as:&nbsp;&nbsp;&nbsp;&nbsp;".CGI::br().
738 CGI::radio_group( 1016 CGI::radio_group(
739 -name => "displayMode", 1017 -name => "displayMode",
740 -values => ['plainText', 'formattedText', 'images'], 1018 -values => \@active_modes,
741 -default => $displayMode, 1019 -default => $displayMode,
742 -linebreak=>'true', 1020 -linebreak=>'true',
743 -labels => { 1021 -labels => {
744 plainText => "plain", 1022 plainText => "plain",
745 formattedText => "formatted", 1023 formattedText => "formatted",
746 images => "images", 1024 images => "images",
1025 jsMath => "jsMath",
1026 asciimath => "asciimath",
747 } 1027 },
748 ), CGI::br(),CGI::hr(), 1028 ). CGI::br().CGI::hr() : '';
1029
1030 return CGI::div({-style=>"border: thin groove; padding: 1ex; margin: 2ex align: left"},
1031 $modeLine,
749 $optionLine, 1032 $optionLine,
750 CGI::submit(-name=>"redisplay", -label=>"Save Options"), 1033 CGI::submit(-name=>"redisplay", -label=>"Apply Options"),
751 ); 1034 );
752} 1035}
753 1036
754sub previewAnswer($$) { 1037sub previewAnswer {
755 my ($self, $answerResult) = @_; 1038 my ($self, $answerResult, $imgGen) = @_;
756 my $ce = $self->{ce}; 1039 my $ce = $self->r->ce;
757 my $effectiveUser = $self->{effectiveUser}; 1040 my $effectiveUser = $self->{effectiveUser};
758 my $set = $self->{set}; 1041 my $set = $self->{set};
759 my $problem = $self->{problem}; 1042 my $problem = $self->{problem};
760 my $displayMode = $self->{displayMode}; 1043 my $displayMode = $self->{displayMode};
761 1044
764 # so we'll just deal with each case explicitly here. there's some code 1047 # so we'll just deal with each case explicitly here. there's some code
765 # duplication that can be dealt with later by abstracting out tth/dvipng/etc. 1048 # duplication that can be dealt with later by abstracting out tth/dvipng/etc.
766 1049
767 my $tex = $answerResult->{preview_latex_string}; 1050 my $tex = $answerResult->{preview_latex_string};
768 1051
769 return "" if $tex eq ""; 1052 return "" unless defined $tex and $tex ne "";
770 1053
771 if ($displayMode eq "plainText") { 1054 if ($displayMode eq "plainText") {
772 return $tex; 1055 return $tex;
773 } elsif ($displayMode eq "formattedText") { 1056 } elsif ($displayMode eq "formattedText") {
774 my $tthCommand = $ce->{externalPrograms}->{tth} 1057 my $tthCommand = $ce->{externalPrograms}->{tth}
781 if ($?) { 1064 if ($?) {
782 return "<b>[tth failed: $? $@]</b>"; 1065 return "<b>[tth failed: $? $@]</b>";
783 } 1066 }
784 return $result; 1067 return $result;
785 } elsif ($displayMode eq "images") { 1068 } elsif ($displayMode eq "images") {
786 # how are we going to name this? 1069 $imgGen->add($tex);
787 my $targetPathCommon = "/m2i/" 1070 } elsif ($displayMode eq "jsMath") {
788 . $effectiveUser->user_id . "." 1071
789 . $set->set_id . "." 1072 return '<DIV CLASS="math">'.$tex.'</DIV>' ;
790 . $problem->problem_id . "." 1073
791 . $answerResult->{ans_name} . ".png"; 1074
792 1075
793 # figure out where to put things 1076
794 my $wd = tempdir("webwork-dvipng-XXXXXXXX", DIR => $ce->{courseDirs}->{html_temp});
795 my $latex = $ce->{externalPrograms}->{latex};
796 my $dvipng = $ce->{externalPrograms}->{dvipng};
797 my $targetPath = $ce->{courseDirs}->{html_temp} . $targetPathCommon;
798 # should use surePathToTmpFile, but we have to
799 # isolate it from the problem enivronment first
800 my $targetURL = $ce->{courseURLs}->{html_temp} . $targetPathCommon;
801
802 # call dvipng to generate a preview
803 dvipng($wd, $latex, $dvipng, $tex, $targetPath);
804 rmtree($wd, 0, 0);
805 if (-e $targetPath) {
806 return "<img src=\"$targetURL\" alt=\"$tex\" />";
807 } else {
808 return "<b>[math2img failed]</b>";
809 }
810 } 1077 }
811} 1078}
812
813sub options {
814 my $self=shift;
815 my $out;
816 $out .=join("",
817 CGI::startform("POST", $self->{r}->uri),
818 $self->hidden_authen_fields,
819 CGI::hr(),
820 CGI::start_div({class=>"viewOptions"}),
821 $self->viewOptions(),CGI::end_div(),
822 );
823return $out;
824
825}
826##### logging subroutine ####
827
828
829 1079
830##### permission queries ##### 1080##### permission queries #####
831 1081
832# this stuff should be abstracted out into the permissions system 1082# this stuff should be abstracted out into the permissions system
833# however, the permission system only knows about things in the 1083# however, the permission system only knows about things in the
834# course environment and the username. hmmm... 1084# course environment and the username. hmmm...
835 1085
836# also, i should fix these so that they have a consistent calling 1086# also, i should fix these so that they have a consistent calling
837# format -- perhaps: 1087# format -- perhaps:
838# canPERM($courseEnv, $user, $set, $problem, $permissionLevel) 1088# canPERM($ce, $user, $set, $problem, $permissionLevel)
839 1089
840sub canShowCorrectAnswers($$) { 1090sub canShowCorrectAnswers($$) {
841 my ($permissionLevel, $answerDate) = @_; 1091 my ($permissionLevel, $answerDate) = @_;
842 return $permissionLevel > 0 || time > $answerDate; 1092 return $permissionLevel > 0 || time > $answerDate;
843} 1093}
855 my $recordAnswers = $permHigh || ($timeOK && $attemptsOK); 1105 my $recordAnswers = $permHigh || ($timeOK && $attemptsOK);
856 return $recordAnswers; 1106 return $recordAnswers;
857} 1107}
858 1108
859sub canCheckAnswers($$) { 1109sub canCheckAnswers($$) {
860 my ($permissionLevel, $answerDate) = @_; 1110 my ($permissionLevel, $dueDate) = @_;
861 my $permHigh = $permissionLevel > 0; 1111 my $permHigh = $permissionLevel > 0;
862 my $timeOK = time >= $answerDate; 1112 my $timeOK = time >= $dueDate;
863 my $recordAnswers = $permHigh || $timeOK; 1113 my $recordAnswers = $permHigh || $timeOK;
864 return $recordAnswers; 1114 return $recordAnswers;
865} 1115}
866 1116
867sub mustRecordAnswers($) { 1117sub mustRecordAnswers($) {
868 my ($permissionLevel) = @_; 1118 my ($permissionLevel) = @_;
869 return $permissionLevel == 0; 1119 return $permissionLevel == 0;
870} 1120}
871
8721; 11211;

Legend:
Removed from v.1016  
changed lines
  Added in v.2446

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9