Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Controller_Admin_Quiz_Attempts::save_grade( LLMS_Quiz_Attempt $attempt )

Saves changes to a quiz


Parameters Parameters

$attempt

(LLMS_Quiz_Attempt) (Required) Quiz attempt instance.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.admin.quiz.attempts.php

				$quiz_id = llms_filter_input( INPUT_POST, 'llms_quiz_id' );

				if ( ! current_user_can( 'edit_post', $quiz_id ) ) {
					return;
				}

				$resumable_attempts = $this->get_resumable_attempts( $quiz_id );

				foreach ( $resumable_attempts as $attempt_id ) {
					$attempt = new LLMS_Quiz_Attempt( $attempt_id );
					$attempt->set( 'can_be_resumed', false );
					$attempt->save();

					$attempt->end();
				}
			}
		}
	}

	/**
	 * Get resumable attempts for a quiz.
	 *
	 * @since 7.8.0
	 *
	 * @param int $quiz_id Quiz ID.
	 */
	public function get_resumable_attempts( $quiz_id ) {

		// Query to get all resumable attempts.
		$query = new LLMS_Query_Quiz_Attempt(
			array(
				'quiz_id'        => $quiz_id,
				'can_be_resumed' => true,
				'status'         => 'incomplete',
			)
		);

		return wp_list_pluck( $query->get_results(), 'id' );
	}

	/**

Top ↑

Changelog Changelog

Changelog
Version Description
4.4.4 Use strict type comparisons where needed.
3.35.0 Sanitize $_POST data.
3.30.3 Strip slashes on remarks.
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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