Moodle

Possible undefined variable in questiontype 'match'

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: 2.0
  • Fix Version/s: None
  • Component/s: Questions
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE

Description

Note in the following code from question/type/match/questiontype.php that the variable $match_ans can be undefined at line 631 if the test at line 623 fails. Should be a suitable else for the if at 623.

//Get the match_sub from backup_ids (for the answer)
623 if ($match_answer_id) { // only recode answer if not 0, not answered yet
624 if (!$match_ans = backup_getid($restore->backup_unique_code,"question_match_sub",$match_answer_id)) { 625 echo 'Could not recode answer in question_match_sub '.$match_answer_id.'<br />'; 626 }
627 }
628
629 if ($match_que) {
630 //If the question hasn't response, it must be 0
631 if (!$match_ans and $match_answer_id == 0) { 632 $match_ans->new_id = 0; 633 }

Issue Links

Activity

Hide
Mary Parke added a comment -

Am not sure if this is the right place, but this is the only tracker that had this exact match on query:
"Could not recode answer in question_match_sub"

We're receiving this line of code as multiple errors in the quiz module when restoring a 1.8.2+ backup w/user data to a 1.9.1 version of Moodle.
Any ideas - or could you point me in the right direction?

Many thanks!

  • Mary
Show
Mary Parke added a comment - Am not sure if this is the right place, but this is the only tracker that had this exact match on query: "Could not recode answer in question_match_sub" We're receiving this line of code as multiple errors in the quiz module when restoring a 1.8.2+ backup w/user data to a 1.9.1 version of Moodle. Any ideas - or could you point me in the right direction? Many thanks!
  • Mary
Hide
Mary Parke added a comment -

I have a restore log with these errors in case it would help troubleshoot this....

Show
Mary Parke added a comment - I have a restore log with these errors in case it would help troubleshoot this....
Hide
Howard Miller added a comment -

Well, this report is specifically about what happens when the first "if" fails,, your problem is what happens if the first succeeds and the second fails.

Either way, the code carries on without solving the problem that $match_ans has not been defined and is needed.

Show
Howard Miller added a comment - Well, this report is specifically about what happens when the first "if" fails,, your problem is what happens if the first succeeds and the second fails. Either way, the code carries on without solving the problem that $match_ans has not been defined and is needed.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: