• Resolved joeyblack

    (@joeyblack)


    Hello,

    I’m trying to display all quizzes of all courses on some custom page.

    https://www.screencast.com/t/cgZBIiEb

    I’m using the following strategy:

    function get_all_quizzes( $user ) {
        $courses = $user->get( 'courses' );
        // here I collect all quizzes
        return $quizzes;
    }
    

    I faced a memory issue when the total questions in all quizzes reached 1,000. I discovered that it is because $user->get( ‘courses’ ) tries to prepare all questions and all answers for all quizzes.

    What is an alternative strategy to get all quizzes list?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Phong

    (@loquocphong)

    Hi,

    You can try use this sql query

    SELECT 
        q.ID, q.post_title, q.post_type, c.post_author
    FROM
        lptest.wp_posts q
            INNER JOIN
        lptest.wp_learnpress_section_items si ON q.ID = si.item_id
            AND item_type = 'lp_quiz'
            INNER JOIN
    	wp_learnpress_sections s ON s.section_id=si.section_id
    		INNER JOIN
        wp_posts c ON c.ID=s.section_course_id
    WHERE
        q.post_status = 'publish'
            AND q.post_type = 'lp_quiz'
            AND c.post_status = 'publish'
            AND c.post_type = 'lp_course'
            AND c.post_author = 3
    Thread Starter joeyblack

    (@joeyblack)

    Thank you.

    Though I didn’t experiment yet to compare with the native function which is a bit complex, I’m afraid.

    The topic can be closed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get all quizzes list?’ is closed to new replies.