[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 3376 Revision 3377
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.174 2005/07/05 18:56:07 sh002i Exp $ 4# $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.173 2005/07/05 18:20:24 sh002i Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
83# Subroutines to determine if a user "can" perform an action. Each subroutine is 83# Subroutines to determine if a user "can" perform an action. Each subroutine is
84# called with the following arguments: 84# called with the following arguments:
85# 85#
86# ($self, $User, $EffectiveUser, $Set, $Problem) 86# ($self, $User, $EffectiveUser, $Set, $Problem)
87 87
88# Note that significant parts of the "can" methods are lifted into the
89# GatewayQuiz module. It isn't direct, however, because of the necessity
90# of dealing with versioning there.
91
88sub can_showOldAnswers { 92sub can_showOldAnswers {
89 #my ($self, $User, $EffectiveUser, $Set, $Problem) = @_; 93 #my ($self, $User, $EffectiveUser, $Set, $Problem) = @_;
90 94
91 return 1; 95 return 1;
92} 96}
171sub between { my $t = time; return $t > $_[0] && $t < $_[1] } 175sub between { my $t = time; return $t > $_[0] && $t < $_[1] }
172 176
173################################################################################ 177################################################################################
174# output utilities 178# output utilities
175################################################################################ 179################################################################################
180
181# Note: the substance of attemptResults is lifted into GatewayQuiz.pm,
182# with some changes to the output format
176 183
177sub attemptResults { 184sub attemptResults {
178 my $self = shift; 185 my $self = shift;
179 my $pg = shift; 186 my $pg = shift;
180 my $showAttemptAnswers = shift; 187 my $showAttemptAnswers = shift;
275 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) 282 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows))
276 . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : ""); 283 . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : "");
277} 284}
278 285
279 286
287# Note: previewAnswer is lifted into GatewayQuiz.pm
288
280sub previewAnswer { 289sub previewAnswer {
281 my ($self, $answerResult, $imgGen, $tthPreambleCache) = @_; 290 my ($self, $answerResult, $imgGen, $tthPreambleCache) = @_;
282 my $ce = $self->r->ce; 291 my $ce = $self->r->ce;
283 my $effectiveUser = $self->{effectiveUser}; 292 my $effectiveUser = $self->{effectiveUser};
284 my $set = $self->{set}; 293 my $set = $self->{set};
368 unless defined $effectiveUser; 377 unless defined $effectiveUser;
369 378
370 # obtain the merged set for $effectiveUser 379 # obtain the merged set for $effectiveUser
371 my $set = $db->getMergedSet($effectiveUserName, $setName); # checked 380 my $set = $db->getMergedSet($effectiveUserName, $setName); # checked
372 381
382# gateway check here: we want to be sure that someone isn't trying to take
383# a GatewayQuiz through the regular problem/homework mechanism, thereby
384# circumventing the versioning, time limits, etc.
385 die('Invalid access attempt: the Problem ContentGenerator was called ' .
386 'for a GatewayQuiz assignment.')
387 if ( defined($set) && defined( $set->assignment_type() ) &&
388 $set->assignment_type() =~ /gateway/ );
389
373 # Database fix (in case of undefined published values) 390 # Database fix (in case of undefined published values)
374 # this is only necessary because some people keep holding to ww1.9 which did not have a published field 391 # this is only necessary because some people keep holding to ww1.9 which did not have a published field
375 # make sure published is set to 0 or 1 392 # make sure published is set to 0 or 1
376 if ( $set and $set->published ne "0" and $set->published ne "1") { 393 if ( $set and $set->published ne "0" and $set->published ne "1") {
377 my $globalSet = $db->getGlobalSet($set->set_id); 394 my $globalSet = $db->getGlobalSet($set->set_id);
385 402
386 # obtain the merged problem for $effectiveUser 403 # obtain the merged problem for $effectiveUser
387 my $problem = $db->getMergedProblem($effectiveUserName, $setName, $problemNumber); # checked 404 my $problem = $db->getMergedProblem($effectiveUserName, $setName, $problemNumber); # checked
388 405
389 my $editMode = $r->param("editMode"); 406 my $editMode = $r->param("editMode");
390 407
391 if ($authz->hasPermissions($userName, "modify_problem_sets")) { 408 if ($authz->hasPermissions($userName, "modify_problem_sets")) {
392 # professors are allowed to fabricate sets and problems not 409 # professors are allowed to fabricate sets and problems not
393 # assigned to them (or anyone). this allows them to use the 410 # assigned to them (or anyone). this allows them to use the
394 # editor to 411 # editor to
395 412
460 } 477 }
461 478
462 my $publishedClass = ($set->published) ? "Published" : "Unpublished"; 479 my $publishedClass = ($set->published) ? "Published" : "Unpublished";
463 my $publishedText = ($set->published) ? "visible to students." : "hidden from students."; 480 my $publishedText = ($set->published) ? "visible to students." : "hidden from students.";
464 $self->addmessage(CGI::p("This set is " . CGI::font({class=>$publishedClass}, $publishedText))); 481 $self->addmessage(CGI::p("This set is " . CGI::font({class=>$publishedClass}, $publishedText)));
465 } else { 482
466 483 # test for additional set validity if it's not already invalid
484 } else {
467 # A set is valid if it exists and if it is either published or the user is privileged. 485 # A set is valid if it exists and if it is either published or the user is privileged.
468 $self->{invalidSet} = !(defined $set and ($set->published || $authz->hasPermissions($userName, "view_unpublished_sets"))); 486 $self->{invalidSet} = !(defined $set and ($set->published || $authz->hasPermissions($userName, "view_unpublished_sets")));
469 $self->{invalidProblem} = !(defined $problem and ($set->published || $authz->hasPermissions($userName, "view_unpublished_sets"))); 487 $self->{invalidProblem} = !(defined $problem and ($set->published || $authz->hasPermissions($userName, "view_unpublished_sets")));
470 488
471 $self->addbadmessage(CGI::p("This problem will not count towards your grade.")) if $problem and not $problem->value and not $self->{invalidProblem}; 489 $self->addbadmessage(CGI::p("This problem will not count towards your grade.")) if $problem and not $problem->value and not $self->{invalidProblem};

Legend:
Removed from v.3376  
changed lines
  Added in v.3377

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9