From: jj v. a. <we...@ma...> - 2005-08-24 20:21:29
|
Log Message: ----------- Make it so that by default, practice users don't see saved answers. That can be controlled in global.conf.dist. Also, default to not showing saved answers after the due date. In all cases, the Apply options button can adjust what you want. Also fixed a bug with showOldAnswers related to '', 0, and undef being similar in perl. Modified Files: -------------- webwork-modperl/conf: global.conf.dist webwork-modperl/lib/WeBWorK/ContentGenerator: Problem.pm Revision Data ------------- Index: global.conf.dist =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/conf/global.conf.dist,v retrieving revision 1.129 retrieving revision 1.130 diff -Lconf/global.conf.dist -Lconf/global.conf.dist -u -r1.129 -r1.130 --- conf/global.conf.dist +++ conf/global.conf.dist @@ -514,6 +514,7 @@ show_correct_answers_before_answer_date => $ta, show_solutions_before_answer_date => $ta, avoid_recording_answers => $ta, + can_show_old_answers_by_default => $student, check_answers_before_open_date => $ta, check_answers_after_open_date_with_attempts => $ta, check_answers_after_open_date_without_attempts => $guest, Index: Problem.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v retrieving revision 1.180 retrieving revision 1.181 diff -Llib/WeBWorK/ContentGenerator/Problem.pm -Llib/WeBWorK/ContentGenerator/Problem.pm -u -r1.180 -r1.181 --- lib/WeBWorK/ContentGenerator/Problem.pm +++ lib/WeBWorK/ContentGenerator/Problem.pm @@ -174,6 +174,16 @@ sub after { return time >= $_[0] } sub between { my $t = time; return $t > $_[0] && $t < $_[1] } +# Reset the default in some cases +sub set_showOldAnswers_default { + my ($self, $ce, $userName, $authz, $set) = @_; + # this person should always default to 0 + $ce->{pg}->{options}->{showOldAnswers} = 0 + unless ($authz->hasPermissions($userName, "can_show_old_answers_by_default")); + # we are after the due date, so default to not showing it + $ce->{pg}->{options}->{showOldAnswers} = 0 if after($set->{due_date}); +} + ################################################################################ # output utilities ################################################################################ @@ -389,6 +399,8 @@ # obtain the merged set for $effectiveUser my $set = $db->getMergedSet($effectiveUserName, $setName); # checked + $self->set_showOldAnswers_default($ce, $userName, $authz, $set); + # gateway check here: we want to be sure that someone isn't trying to take # a GatewayQuiz through the regular problem/homework mechanism, thereby # circumventing the versioning, time limits, etc. @@ -543,8 +555,10 @@ # there is no way to override this. Probably this is ok for the last three options, but it was definitely not ok for showing # saved answers which is normally on, but you want to be able to turn it off! This section should be moved to ContentGenerator # so that you can set these options anywhere. We also need mechanisms for making them sticky. + # Note: ProblemSet and ProblemSets might set showOldAnswers to '', which + # needs to be treated as if it is not set. my %want = ( - showOldAnswers => defined($r->param("showOldAnswers")) ? $r->param("showOldAnswers") : $ce->{pg}->{options}->{showOldAnswers}, + showOldAnswers => (defined($r->param("showOldAnswers")) and $r->param("showOldAnswers") ne '') ? $r->param("showOldAnswers") : $ce->{pg}->{options}->{showOldAnswers}, showCorrectAnswers => $r->param("showCorrectAnswers") || $ce->{pg}->{options}->{showCorrectAnswers}, showHints => $r->param("showHints") || $ce->{pg}->{options}->{showHints}, showSolutions => $r->param("showSolutions") || $ce->{pg}->{options}->{showSolutions}, |