LLMS_Controller_Admin_Quiz_Attempts::maybe_run_actions()

Run actions on form submission


Return Return

(void)


Top ↑

Source Source

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

	public function maybe_run_actions() {

		if ( ! llms_verify_nonce( '_llms_quiz_attempt_nonce', 'llms_quiz_attempt_actions', 'POST' ) ) {
			return;
		}

		if ( isset( $_POST['llms_quiz_attempt_action'] ) && isset( $_POST['llms_attempt_id'] ) ) {

			$action  = llms_filter_input( INPUT_POST, 'llms_quiz_attempt_action' );
			$attempt = new LLMS_Quiz_Attempt( absint( $_POST['llms_attempt_id'] ) );

			if ( ! current_user_can( 'edit_post', $attempt->get( 'quiz_id' ) ) ) {
				return;
			}

			if ( 'llms_attempt_delete' === $action ) {
				$url = add_query_arg(
					array(
						'page'    => 'llms-reporting',
						'tab'     => 'quizzes',
						'quiz_id' => $attempt->get( 'quiz_id' ),
						'stab'    => 'attempts',
					),
					admin_url( 'admin.php' )
				);
				$attempt->delete();
				wp_safe_redirect( $url );
				exit();
			} elseif ( 'llms_attempt_grade' === $action && ( isset( $_POST['remarks'] ) || isset( $_POST['points'] ) ) ) {
				$this->save_grade( $attempt );
			}
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.9.0 Stop using deprecated FILTER_SANITIZE_STRING.
4.4.4 Made sure to exit after redirecting on attempt deletion.
3.35.0 Sanitize $_POST data.
3.16.9 Unknown.
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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