From 4ea45b67e7d7974f55f564bd0c60d7340decd8a3 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Fri, 16 Aug 2024 12:30:43 -0600 Subject: [PATCH 1/2] Also set sub_status when giving credit with achievement items. This ensures that the progress bar reflects they have 'earned' full credit on the problems. --- lib/WeBWorK/AchievementItems/FullCreditProb.pm | 3 ++- lib/WeBWorK/AchievementItems/FullCreditSet.pm | 3 ++- lib/WeBWorK/AchievementItems/HalfCreditProb.pm | 10 ++++------ lib/WeBWorK/AchievementItems/HalfCreditSet.pm | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/WeBWorK/AchievementItems/FullCreditProb.pm b/lib/WeBWorK/AchievementItems/FullCreditProb.pm index 331392b58b..3bb8b38758 100644 --- a/lib/WeBWorK/AchievementItems/FullCreditProb.pm +++ b/lib/WeBWorK/AchievementItems/FullCreditProb.pm @@ -100,8 +100,9 @@ sub use_item ($self, $userName, $c) { my $problem = $db->getUserProblem($userName, $setID, $problemID); return 'There was an error accessing that problem.' unless $problem; - # Set the status of the problem to one. + # Set the status and sub_status of the problem to one. $problem->status(1); + $problem->sub_status(1); $db->putUserProblem($problem); $globalData->{ $self->{id} }--; diff --git a/lib/WeBWorK/AchievementItems/FullCreditSet.pm b/lib/WeBWorK/AchievementItems/FullCreditSet.pm index 9cdee6960e..b29469c69f 100644 --- a/lib/WeBWorK/AchievementItems/FullCreditSet.pm +++ b/lib/WeBWorK/AchievementItems/FullCreditSet.pm @@ -72,8 +72,9 @@ sub use_item ($self, $userName, $c) { for my $probID (@probIDs) { my $problem = $db->getUserProblem($userName, $setID, $probID); - # Set status to 1. + # Set status and sub_status to 1. $problem->status(1); + $problem->sub_status(1); $db->putUserProblem($problem); } diff --git a/lib/WeBWorK/AchievementItems/HalfCreditProb.pm b/lib/WeBWorK/AchievementItems/HalfCreditProb.pm index 9edc79cf30..a1fd4abc5e 100644 --- a/lib/WeBWorK/AchievementItems/HalfCreditProb.pm +++ b/lib/WeBWorK/AchievementItems/HalfCreditProb.pm @@ -101,12 +101,10 @@ sub use_item ($self, $userName, $c) { return 'There was an error accessing that problem.' unless $problem; # Add .5 to grade with max of 1 - - if ($problem->status < .5) { - $problem->status($problem->status + .5); - } else { - $problem->status(1); - } + my $new_status = $problem->status + 0.5; + $new_status = 1 if $new_status > 1; + $problem->status($new_status); + $problem->sub_status($new_status); $db->putUserProblem($problem); diff --git a/lib/WeBWorK/AchievementItems/HalfCreditSet.pm b/lib/WeBWorK/AchievementItems/HalfCreditSet.pm index 4bcf203dae..cb28635a5a 100644 --- a/lib/WeBWorK/AchievementItems/HalfCreditSet.pm +++ b/lib/WeBWorK/AchievementItems/HalfCreditSet.pm @@ -73,11 +73,11 @@ sub use_item ($self, $userName, $c) { my $problem = $db->getUserProblem($userName, $setID, $probID); # Add .5 to grade with max of 1. - if ($problem->status < .5) { - $problem->status($problem->status + .5); - } else { - $problem->status(1); - } + my $new_status = $problem->status + 0.5; + $new_status = 1 if $new_status > 1; + $problem->status($new_status); + $problem->sub_status($new_status); + $db->putUserProblem($problem); } From 592eb2cb336f8b4d0ee430def71532e38ca3ffe1 Mon Sep 17 00:00:00 2001 From: Jaimos Skriletz Date: Fri, 16 Aug 2024 19:05:28 -0600 Subject: [PATCH 2/2] Update description of Half Credit achievement items. 'Gives half credit' seems ambiguous, for it could mean set the score to 50% instead of increase the score by 50%. This updates the description to indicate the score is increased to a maximum of 100%. --- lib/WeBWorK/AchievementItems/HalfCreditProb.pm | 4 ++-- lib/WeBWorK/AchievementItems/HalfCreditSet.pm | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/WeBWorK/AchievementItems/HalfCreditProb.pm b/lib/WeBWorK/AchievementItems/HalfCreditProb.pm index a1fd4abc5e..748ce57619 100644 --- a/lib/WeBWorK/AchievementItems/HalfCreditProb.pm +++ b/lib/WeBWorK/AchievementItems/HalfCreditProb.pm @@ -28,7 +28,7 @@ sub new ($class) { return bless { id => 'HalfCreditProb', name => x('Lesser Rod of Revelation'), - description => x('Gives half credit on a single homework problem.') + description => x('Increases the score of a single problem by 50%, to a maximum of 100%.') }, $class; } @@ -60,7 +60,7 @@ sub print_form ($self, $sets, $setProblemIds, $c) { $c->tag( 'p', $c->maketext( - 'Please choose the set name and problem number of the question which should be given half credit.') + 'Please choose the assignment name and problem number of the question to add half credit to.') ), WeBWorK::AchievementItems::form_popup_menu_row( $c, diff --git a/lib/WeBWorK/AchievementItems/HalfCreditSet.pm b/lib/WeBWorK/AchievementItems/HalfCreditSet.pm index cb28635a5a..ba01a455bd 100644 --- a/lib/WeBWorK/AchievementItems/HalfCreditSet.pm +++ b/lib/WeBWorK/AchievementItems/HalfCreditSet.pm @@ -26,7 +26,7 @@ sub new ($class) { return bless { id => 'HalfCreditSet', name => x('Lesser Tome of Enlightenment'), - description => x('Gives half credit on every problem in a set.') + description => x('Increases the score of every problem in an assignment by 50%, to a maximum of 100%.') }, $class; } @@ -41,7 +41,9 @@ sub print_form ($self, $sets, $setProblemIds, $c) { return unless @openSets; return $c->c( - $c->tag('p', $c->maketext('Please choose the set for which all problems should have half credit added.')), + $c->tag( + 'p', $c->maketext('Please choose the assignment for which all problems should have half credit added.') + ), WeBWorK::AchievementItems::form_popup_menu_row( $c, id => 'hcs_set_id',