-
-
Notifications
You must be signed in to change notification settings - Fork 170
Fix Resurrect Achievement Items #2938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: WeBWorK-2.21
Are you sure you want to change the base?
Changes from all commits
7d7fd79
68f98e2
2a4996a
1ccb538
34bfbe6
fa2fa2f
f7a5a94
447cecb
25c9dc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,48 +16,94 @@ sub new ($class) { | |
| }, $class; | ||
| } | ||
|
|
||
| sub can_use ($self, $set, $records) { | ||
| sub can_use ($self, $set, $records, $c) { | ||
| return $set->assignment_type eq 'default' | ||
| && (after($set->due_date) || ($set->reduced_scoring_date && after($set->reduced_scoring_date))); | ||
| && ( | ||
| after($set->due_date) | ||
| || ($c->ce->{pg}{ansEvalDefaults}{enableReducedScoring} | ||
| && $set->enable_reduced_scoring | ||
| && after($set->reduced_scoring_date)) | ||
| ); | ||
| } | ||
|
|
||
| sub print_form ($self, $set, $records, $c) { | ||
| return $c->tag('p', | ||
| $c->maketext('Reopen this homework assignment for the next 24 hours. All problems will be rerandomized.')); | ||
| if (after($set->due_date)) { | ||
| return $c->tag( | ||
| 'p', | ||
| $c->maketext( | ||
| 'Reopen this homework assignment for the next 24 hours. All problems will be rerandomized.') | ||
| ); | ||
| } else { | ||
| if (after($set->due_date - ONE_DAY)) { | ||
| return $c->tag('p', | ||
| $c->maketext('Reopen this homework assignment for full credit for the next 24 hours. ')); | ||
| } else { | ||
| return $c->tag( | ||
| 'p', | ||
| $c->maketext( | ||
| 'Reopen this homework assignment for full credit for the next 24 hours. After 24 hours ' | ||
| . 'any progress will revert to counting for [_1]% of the value until [_2].', | ||
| $c->ce->{pg}{ansEvalDefaults}{reducedScoringValue} * 100, | ||
| $c->formatDateTime($set->due_date, $c->ce->{studentDateDisplayFormat}) | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| sub use_item ($self, $set, $records, $c) { | ||
| my $db = $c->db; | ||
| my $userSet = $db->getUserSet($set->user_id, $set->set_id); | ||
|
|
||
| # Change the seed for all of the problems since the set is currently closed. | ||
| my %userProblems = | ||
| map { $_->problem_id => $_ } $db->getUserProblemsWhere({ user_id => $set->user_id, set_id => $set->set_id }); | ||
| for my $problem (@$records) { | ||
| my $userProblem = $userProblems{ $problem->problem_id }; | ||
| $userProblem->problem_seed($userProblem->problem_seed % 2**31 + 1); | ||
| $problem->problem_seed($userProblem->problem_seed); | ||
| $db->putUserProblem($userProblem); | ||
| my $db = $c->db; | ||
| my $userSet = $db->getUserSet($set->user_id, $set->set_id); | ||
| my $rerandomizeMessage = ''; | ||
|
|
||
| # Change the seed for all of the problems if the set is currently closed. | ||
| if (after($set->due_date)) { | ||
| my %userProblems = | ||
| map { $_->problem_id => $_ } | ||
| $db->getUserProblemsWhere({ user_id => $set->user_id, set_id => $set->set_id }); | ||
| for my $problem (@$records) { | ||
| my $userProblem = $userProblems{ $problem->problem_id }; | ||
| $userProblem->problem_seed($userProblem->problem_seed % 2**31 + 1); | ||
| $problem->problem_seed($userProblem->problem_seed); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this re-randomization should only occur if it is also past the answer date. Is there any need for this if the answer date has not passed?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the case where there are limited attempts allowed on a problem a student could check their answers as many times as they want to find the correct answers, and then resurrect the set and enter the correct answers using only one attempt.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, I forgot about the fact that once the set is closed the student can still use the "Check Answers" button, and thus can do what you say. |
||
| $db->putUserProblem($userProblem); | ||
| } | ||
| $rerandomizeMessage = $c->maketext('Problems have been rerandomized.'); | ||
| } | ||
|
|
||
| # Add time to the reduced scoring date if it was defined in the first place | ||
| if ($set->reduced_scoring_date) { | ||
| $set->reduced_scoring_date(time + ONE_DAY); | ||
| $userSet->reduced_scoring_date($set->reduced_scoring_date); | ||
| } | ||
| # Add time to the close date | ||
| $set->due_date(time + ONE_DAY); | ||
| $userSet->due_date($set->due_date); | ||
| # This may require also extending the answer date. | ||
| if ($set->due_date > $set->answer_date) { | ||
| $set->answer_date($set->due_date); | ||
| $userSet->answer_date($set->answer_date); | ||
| # Add time to the close date if necessary | ||
| if (after($set->due_date - ONE_DAY)) { | ||
| $set->due_date(time + ONE_DAY); | ||
| $userSet->due_date($set->due_date); | ||
| # This may require also extending the answer date. | ||
| if ($set->due_date > $set->answer_date) { | ||
| $set->answer_date($set->due_date); | ||
| $userSet->answer_date($set->answer_date); | ||
| } | ||
| } | ||
| $db->putUserSet($userSet); | ||
|
|
||
| return $c->maketext( | ||
| 'This assignment has been reopened and will now close on [_1]. Problems have been rerandomized.', | ||
| $c->formatDateTime($set->due_date, $c->ce->{studentDateDisplayFormat})); | ||
| if ($c->ce->{pg}{ansEvalDefaults}{enableReducedScoring} | ||
| && $set->enable_reduced_scoring | ||
| && ($set->reduced_scoring_date != $set->due_date)) | ||
| { | ||
| return $c->maketext( | ||
| 'This assignment has been reopened and is due on [_1]. After that date any work ' | ||
| . 'completed will count for [_2]% of its value until [_3].', | ||
| $c->formatDateTime($set->reduced_scoring_date, $c->ce->{studentDateDisplayFormat}), | ||
| $c->ce->{pg}{ansEvalDefaults}{reducedScoringValue} * 100, | ||
| $c->formatDateTime($set->due_date, $c->ce->{studentDateDisplayFormat}) | ||
| ) . ($rerandomizeMessage ? " $rerandomizeMessage" : ''); | ||
| } else { | ||
| return $c->maketext( | ||
| 'This assignment has been reopened and will now close on [_1].', | ||
| $c->formatDateTime($set->due_date, $c->ce->{studentDateDisplayFormat}) | ||
| ) . ($rerandomizeMessage ? " $rerandomizeMessage" : ''); | ||
| } | ||
| } | ||
|
|
||
| 1; | ||
Uh oh!
There was an error while loading. Please reload this page.