-
-
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
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,86 @@ sub new ($class) { | |
| }, $class; | ||
| } | ||
|
|
||
| sub can_use($self, $set, $records) { | ||
| sub can_use ($self, $set, $records) { | ||
| return $set->assignment_type eq 'default' | ||
| && (after($set->due_date) || ($set->reduced_scoring_date && after($set->reduced_scoring_date))); | ||
| && (after($set->due_date) || ($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); | ||
| $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 ($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; | ||
| } else { | ||
| return $c->maketext( | ||
| 'This assignment has been reopened and will now close on [_1]. ', | ||
| $c->formatDateTime($set->due_date, $c->ce->{studentDateDisplayFormat}) | ||
| ) . $rerandomizeMessage; | ||
| } | ||
| } | ||
|
Comment on lines
+85
to
99
Contributor
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.
Contributor
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. Unsure if that gets tricky or there should be a conditional to check if it should be added or not so the translated strings don't have extra space in them in the case
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.
Is it a problem to have an extra space at the end of a string to be translated?
Contributor
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. My understanding is not all languages are right to left, so just appending the string to the end may not be appropriate for some translations. In terms of the html, an extra space won't matter, but what happens if a translation doesn't understand that space is important and leaves it off. Putting the translated string as a positional argument inside the maketext call makes the use of the space clearer and allows positioning the statement in the string appropriately for the translation. There are various places thought out the code that a string is translated and then added as a positional argument in future translations to join things together. I think this should probably do the same. I think the space thing is very minor and probably won't matter if the positional argument is empty.
Contributor
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. Others may have a better knowledge, what you did may be okay, I just feel it isn't. I think a positional argument is better than string concatenation. I'm unsure if there is a better approach to avoid having to write lots of cases like you have been doing in most of this.
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. It is always best to give as much as possible together for translations. However, generally concatenations of two sentences can be done. Usually the bidirectional algorithm will make it work even for right to left languages. However, the space should be inserted between the translations and not inside of one of them. The translator may not add that space in the translation, and even if they do may not put it in the correct place, not knowing that it is going to be concatenated with another translation. Perhaps making it a positional argument inside another translation is better though. |
||
|
|
||
| 1; | ||
Uh oh!
There was an error while loading. Please reload this page.