LLMS_Grades::get_grade( WP_Post|int $post_id, LLMS_Student $student, bool $use_cache = true )

Main grade getter function


Description Description

Uses caching by default and can bypass cache when requested


Top ↑

Parameters Parameters

$post_id

(WP_Post|int) (Required) An instance of WP_Post or a WP Post ID.

$student

(LLMS_Student) (Required) A LLMS_Student object.

$use_cache

(bool) (Optional) when true, retrieves from cache if available

Default value: true


Top ↑

Return Return

(float|null)


Top ↑

Source Source

File: includes/class-llms-grades.php

			$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' ) )
			);

		}

		return apply_filters( 'llms_get_grade', $grade, $post, $student );

	}

	/**
	 * Retrieve a grade from the wp_cache
	 *
	 * @param    LLMS_Post_Model $post    A LLMS_Post_Model object.
	 * @param    LLMS_Student    $student A LLMS_Student object.
	 * @return   mixed             grade as a float
	 *                             null if there's no grade for the post
	 *                             false if the grade wasn't found in the cache


Top ↑

Changelog Changelog

Changelog
Version Description
4.4.4 Don't pass the $use_cache parameter to the calculate_grade() method.
3.24.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.