Skip to content

Conversation

@srobotta
Copy link

We have a quiz backup containing mtf questions in a random question using the plugin in version 2025031900.
During the restore on a 5.2dev Moodle with your latest version from master, I get an error by using a property on false.

$question->options->rows = $DB->get_records('qtype_mtf_rows',
                array('questionid' => $question->id),
                'number ASC', '*', 0, $question->options->numberofrows);

is the code in question where $question->options is false. This is because the query $DB->get_record('qtype_mtf_options', array('questionid' => $question->id)); returns no results.

Besides that, the question options that are possibly fetched in parent::get_question_options($question); two lines above would be overwritten there.
I changed the code by

  1. keeping the original question->options.
  2. trying to fetch specific options for this single question
  3. if there are no specific options, use the defaults.
  4. Merge the specific mtf options for that question with any other options.

I also made two little corrections, using a define and dropping the unused index variable in a loop.

@srobotta srobotta force-pushed the import-error-not-defined branch from 83b0827 to 9605b3b Compare October 25, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant