Skip to content

Saving of cached values for grades doesn't match cache miss check #3116

@brianhogg

Description

@brianhogg

Reproduction Steps

  1. Install and activate Redis Object Cache plugin (or any persistent object cache)
  2. Enroll a student in a course that has a lesson with a quiz assigned
  3. Complete the quiz as the student (score does not matter, e.g. 90%)
  4. Navigate to the student's grades view (My Grades, Admin Reporting, or Group
    Reporting)
  5. Observe: Overall Grade shows 0%, lesson Grade column shows a dash
  6. Verify in wp_lifterlms_quiz_attempts that the quiz attempt exists with the correct grade
    and status='pass'

Expected Behavior

Overall Grade displays 90%, lesson Grade column displays 90%.

Actual Behavior

Overall Grade displays 0%, lesson Grade column displays N/A (dash).

Full report on HS-272958

Tech Notes

We are saving the overall grade as '' (empty string) in model.llms.quiz.attempt.php

$this->get_student()->set( 'overall_grade', '' );
and as null if there's no quiz attempt in class-llms-grades.php but then comparing to false to see if we need to re-calculate
$grade = $use_cache ? $this->get_grade_from_cache( $post, $student ) : false;
// Grade not found in cache or we're not using the cache.
if ( false === $grade ) {
$grade = $this->calculate_grade( $post, $student );
// Store in the cache.
wp_cache_set(
sprintf( '%d_grade', $post->get( 'id' ) ),
$grade,
sprintf( 'student_%d', $student->get( 'id' ) )
);
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Review in Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions