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

608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
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.