Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/WeBWorK/AchievementEvaluator.pm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ sub checkForAchievements {
# $pg->{result} reflects the current submission, $pg->{state} holds the best result
# close the unlimited achievement points loophole by only using the current result!
$problem->status($pg->{result}->{score});
$problem->sub_status($pg->{state}->{sub_recorded_score});
$problem->attempted(1);
$problem->num_correct($pg->{state}->{num_of_correct_ans});
$problem->num_incorrect($pg->{state}->{num_of_incorrect_ans});
Expand Down
15 changes: 11 additions & 4 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1456,11 +1456,17 @@ sub body {

# next, store the state in the database if that makes sense
if ($submitAnswers && $will{recordAnswers}) {
$problems[$i]->status(wwRound(2,$pg_results[$i]->{state}->{recorded_score}));
# Reduced scoring adjustments
my $new_score = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::compute_reduced_score(
$self, $pureProblem, $set, $pg_results[$i]->{state}->{recorded_score});

$problems[$i]->status(wwRound(2,$new_score));
$problems[$i]->sub_status($pg_results[$i]->{state}->{recorded_score});
$problems[$i]->attempted(1);
$problems[$i]->num_correct($pg_results[$i]->{state}->{num_of_correct_ans});
$problems[$i]->num_incorrect($pg_results[$i]->{state}->{num_of_incorrect_ans});
$pureProblem->status(wwRound(2,$pg_results[$i]->{state}->{recorded_score}));
$pureProblem->status(wwRound(2,$new_score));
$pureProblem->sub_status($pg_results[$i]->{state}->{recorded_score});
$pureProblem->attempted(1);
$pureProblem->num_correct($pg_results[$i]->{state}->{num_of_correct_ans});
$pureProblem->num_incorrect($pg_results[$i]->{state}->{num_of_incorrect_ans});
Expand Down Expand Up @@ -1746,8 +1752,9 @@ sub body {
my $pScore = 0;
my $numParts = 0;
if (ref($pg)) { # then we have a pg object
###
$pScore = $pg->{state}->{recorded_score};
# Reduced scoring adjustments
$pScore = WeBWorK::ContentGenerator::ProblemUtil::ProblemUtil::compute_reduced_score(
$self, $problems[$i], $set, $pg->{state}->{recorded_score});
$probStatus[$i] = $pScore;
$numParts = 1;
###
Expand Down
41 changes: 37 additions & 4 deletions lib/WeBWorK/ContentGenerator/ProblemUtil/ProblemUtil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ sub process_and_log_answer{

# store state in DB if it makes sense
if ($will{recordAnswers}) {
$problem->status($pg->{state}->{recorded_score});
$problem->sub_status($pg->{state}->{sub_recorded_score});
# Reduced scoring adjustments
my $new_score = compute_reduced_score($self, $problem, $set, $pg->{state}->{recorded_score});

$problem->status($new_score);
$problem->sub_status($pg->{state}->{recorded_score});
$problem->attempted(1);
$problem->num_correct($pg->{state}->{num_of_correct_ans});
$problem->num_incorrect($pg->{state}->{num_of_incorrect_ans});
$pureProblem->status($pg->{state}->{recorded_score});
$pureProblem->sub_status($pg->{state}->{sub_recorded_score});
$pureProblem->status($new_score);
$pureProblem->sub_status($pg->{state}->{recorded_score});
$pureProblem->attempted(1);
$pureProblem->num_correct($pg->{state}->{num_of_correct_ans});
$pureProblem->num_incorrect($pg->{state}->{num_of_incorrect_ans});
Expand Down Expand Up @@ -675,4 +678,34 @@ Comment: $comment
return "";
}

# Determines if a set is in the reduced scoring period and applies
# the reduced scoring adjustment to the portion of the score earned
# during the reduced scoring period.
sub compute_reduced_score {
my ($self, $problem, $set, $new_status) = @_;

my $r = $self->r;
my $reducedScoringEnabled = $r->{ce}->{pg}{ansEvalDefaults}{enableReducedScoring};
my $reducedScoringValue = $r->{ce}->{pg}{ansEvalDefaults}{reducedScoringValue};

# If no adjustments need to be applied, return the full score.
if (! $reducedScoringEnabled
|| ! $set->enable_reduced_scoring
|| ! $set->reduced_scoring_date
|| $set->reduced_scoring_date == $set->due_date
|| time < $set->reduced_scoring_date
|| $reducedScoringValue == 1
) {
return $new_status;
}

# Invert the reduced scoring computation to get the portion of the
# grade earned before the reduced scoring date, then return the
# adjusted score by applying the reduced scoring adjustment to the
# portion done after the reduced scoring date.
my $pre_reduced_score = $problem->sub_status - ($problem->sub_status
- $problem->status) / (1 - $reducedScoringValue);
return $pre_reduced_score + $reducedScoringValue * ($new_status - $pre_reduced_score);
}

1;
4 changes: 2 additions & 2 deletions lib/WeBWorK/DB/Record/UserProblem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ BEGIN {
# periodic re-randomization number of attempts for the current seed
prCount => {type => "INT"},
problem_seed => { type=>"INT" },
status => { type=>"FLOAT" },
status => { type=>"FLOAT" }, # The adjusted problem score
attempted => { type=>"INT" },
last_answer => { type=>"TEXT" },
num_correct => { type=>"INT" },
num_incorrect => { type=>"INT" },
att_to_open_children => { type=>"INT" },
counts_parent_grade => { type=>"INT" },
sub_status => { type=>"FLOAT" }, # A subsidiary status used to implement the reduced scoring period
sub_status => { type=>"FLOAT" }, # The raw problem score before any adjustments
# a field for flags which need to be set
flags => { type=>"TEXT" },
);
Expand Down
3 changes: 1 addition & 2 deletions lib/WeBWorK/PG/Local.pm
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ EOF
#warn "PG: retrieving the problem state and giving it to the translator\n";

$translator->rh_problem_state({
recorded_score => $problem->status,
sub_recorded_score => $problem->sub_status,
recorded_score => $problem->sub_status, # using sub_status since it is the raw score.
num_of_correct_ans => $problem->num_correct,
num_of_incorrect_ans => $problem->num_incorrect,
});
Expand Down
3 changes: 1 addition & 2 deletions lib/WeBWorK/PG/Remote.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ EOF
extra_packages_to_load => [ @extra_packages_to_load ],
envir => $envir,
problem_state => {
recorded_score => $problem->status,
sub_recorded_score => $problem->sub_status,
recorded_score => $problem->sub_status, # Using sub_status since it is the raw score.
num_of_correct_ans => $problem->num_correct,
num_of_incorrect_ans => $problem->num_incorrect,
},
Expand Down