LLMS_Grades::get_grade( obj $post, obj $student, bool $use_cache = true )

Main grade getter function Uses caching by default and can bypass cache when requested


Description Description


Parameters Parameters

$post

(obj) (Required) LLMS_Post_Model

$student

(obj) (Required) LLMS_Student

$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

	public function get_grade( $post, $student, $use_cache = true ) {

		$post = llms_get_post( $post );
		$student = llms_get_student( $student );

		$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, $use_cache );

			// 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 );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.24.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: