[system] / branches / rel-2-2-dev / webwork2 / lib / WeBWorK / ContentGenerator / Problem.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-2-dev/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm

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

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

Legend:
Removed from v.992  
changed lines
  Added in v.2349

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9