llms_update_3160_update_quiz_to_lesson_rels()

Ensure quizzes backreference their parent lessons


Return Return

(void)


Top ↑

Source Source

File: includes/functions/updates/llms-functions-updates-3160.php

function llms_update_3160_update_quiz_to_lesson_rels() {

	if ( 'complete' !== get_transient( 'llms_update_3160_update_attempt_question_data' ) ) {
		return true;
	}

	global $wpdb;
	$ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_llms_quiz_enabled' AND meta_value = 'yes'" );

	foreach ( $ids as $id ) {

		$lesson = llms_get_post( $id );
		if ( $lesson ) {
			$quiz_id = $lesson->get( 'quiz' );
			if ( $quiz_id ) {
				$quiz = llms_get_post( $quiz_id );
				$quiz->set( 'lesson_id', $id );
			}
		}
	}

}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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