From: Sam H. v. a. <we...@ma...> - 2005-09-22 18:45:32
|
Log Message: ----------- restrict dates to < 10 years in the future -- see bug #829. Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator/Instructor: ProblemSetList.pm ProblemSetDetail.pm Revision Data ------------- Index: ProblemSetDetail.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm -u -r1.20 -r1.21 --- lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm +++ lib/WeBWorK/ContentGenerator/Instructor/ProblemSetDetail.pm @@ -604,12 +604,29 @@ $error = $r->param('submit_changes'); } + # make sure the dates are not more than 10 years in the future + my $curr_time = time; + my $seconds_per_year = 31_556_926; + my $cutoff = $curr_time + $seconds_per_year*10; + if ($open_date > $cutoff) { + $self->addbadmessage("Error: open date cannot be more than 10 years from now in set $setID"); + $error = $r->param('submit_changes'); + } + if ($due_date > $cutoff) { + $self->addbadmessage("Error: due date cannot be more than 10 years from now in set $setID"); + $error = $r->param('submit_changes'); + } + if ($answer_date > $cutoff) { + $self->addbadmessage("Error: answer date cannot be more than 10 years from now in set $setID"); + $error = $r->param('submit_changes'); + } + + if ($error) { $self->addbadmessage("No changes were saved!"); } } - - + if (defined $r->param('submit_changes') && !$error) { #my $setRecord = $db->getGlobalSet($setID); # already fetched above --sam Index: ProblemSetList.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm,v retrieving revision 1.85 retrieving revision 1.86 diff -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm -Llib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm -u -r1.85 -r1.86 --- lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm +++ lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm @@ -1213,7 +1213,7 @@ my @visibleSetIDs = @{ $self->{visibleSetIDs} }; foreach my $setID (@visibleSetIDs) { my $Set = $db->getGlobalSet($setID); # checked -# FIXME: we may not want to die on bad sets, they're not as bad as bad users + # FIXME: we may not want to die on bad sets, they're not as bad as bad users die "record for visible set $setID not found" unless $Set; foreach my $field ($Set->NONKEYFIELDS()) { @@ -1226,20 +1226,27 @@ } } } - - ################################################### + + # make sure the dates are not more than 10 years in the future + my $curr_time = time; + my $seconds_per_year = 31_556_926; + my $cutoff = $curr_time + $seconds_per_year*10; + return CGI::div({class=>'ResultsWithError'}, "Error: open date cannot be more than 10 years from now in set $setID") + if $Set->open_date > $cutoff; + return CGI::div({class=>'ResultsWithError'}, "Error: due date cannot be more than 10 years from now in set $setID") + if $Set->due_date > $cutoff; + return CGI::div({class=>'ResultsWithError'}, "Error: answer date cannot be more than 10 years from now in set $setID") + if $Set->answer_date > $cutoff; + # Check that the open, due and answer dates are in increasing order. # Bail if this is not correct. - ################################################### if ($Set->open_date > $Set->due_date) { return CGI::div({class=>'ResultsWithError'}, "Error: Due date must come after open date in set $setID"); } if ($Set->due_date > $Set->answer_date) { return CGI::div({class=>'ResultsWithError'}, "Error: Answer date must come after due date in set $setID"); } - ################################################### - # End date check section. - ################################################### + $db->putGlobalSet($Set); } |