• Resolved alealealeale1234

    (@alealealeale1234)


    Hello everyone.

    Everything worked correctly with the quizzes until today when, suddenly, the same error appeared on all the pages containing a quiz.


    Warning: Invalid argument supplied for foreach() in /home/customer/www/francesefacile.it/public_html/wp-content/plugins/quiz-master-next/php/classes/class-qsm-questions.php on line 536

    Does it depends on the plugin itself or maybe you can suggest me some different explanation?

    Thanks for your time.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @alealealeale1234

    I need to discuss this with my development team. Hopefully, I will get back to you with the solution.

    Regards,
    Sumit

    Thread Starter alealealeale1234

    (@alealealeale1234)

    Hi Sumit, thank you for your support.

    It may be helpfull to know that when creating new quizzes the same problem doesn’t occur.

    However, it occurs for all the quizzes that I created before a couple of days ago.

    Regards,
    Alessandro

    Hi Alessandro,

    As per your comment and the error message it’s showing because it’s not getting question categories. we have checked the function create_terms_tree, these functions provide a questions categories list So for replicating this issue we have tested multiple conditions like

    condition 1: Created new categories and assign them to quiz questions then delete categories
    condition 2: assign multiple categories and subcategories to questions and then delete categories
    condition 3: created categories and assigned categories to multiple questions and then delete questions and categories

    we can’t replicate this issue but we have added if condition before foreach loop for skipping the loop if categories do not exist

    so you can replace function in the file

    /home/customer/www/francesefacile.it/public_html/wp-content/plugins/quiz-master-next/php/classes/class-qsm-questions.php

    on line 534

    updated function code

    `/**
    * Create tree structure of terms.
    *
    * @since 7.2.1
    */
    public static function create_terms_tree( &$list, $parent ) {
    $taxTree = array();
    if ( is_array($parent) ) {
    foreach ( $parent as $ind => $val ) {
    if ( isset( $list[ $val->term_id ] ) ) {
    $val->children = self::create_terms_tree( $list, $list[ $val->term_id ] );
    }
    $taxTree[] = $val;
    }
    }
    return $taxTree;
    }

    Let me know if you need more help.

    Regards,
    sumit

    Thread Starter alealealeale1234

    (@alealealeale1234)

    Hello Sumit,

    I’d like to thank you for your quick and effective support, really appreciated.

    The code you provided me with actually works.

    It appears that all the previously created quizzes just lost their category at some point, apparently for no reason.

    I’ll probably categorize them again one by one if I can’t think of something quicker, even if this will take some time.

    Thanks again for your help.

    My best,
    Alessandro

    Hi Alessandro,

    Thank you so much for your kind words. Please let me know if you need more help in the future.

    Regards,
    sumit

    Hi Alessandro,

    This issue is fixed in the latest QSM version 8.0.1. Please check and let me know if you need more help.

    Regards,
    sumit

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Warning: Invalid argument supplied for foreach()’ is closed to new replies.