marcusgreen / moodle-qtype_wordselect

langHighlight words by clicking e.g. select all nouns in this sentence
2 stars 10 forks source link

Undefined Offset on line 284 in question.php #15

Closed dustinbrisebois closed 4 years ago

dustinbrisebois commented 5 years ago

Notice: Undefined offset: 26 in /var/www/data/pvschools/public_html/moodle/question/type/wordselect/question.php on line 286 Exception - Call to a member function get_without_delim() on null

As per line: https://github.com/marcusgreen/moodle-qtype_wordselect/blob/37f509bec713566578df164a1111e403d4b4b946/question.php#L284

Should be something more similar to this:

if (isset($allwords[substr($index, 1)])) {
          $summary .= " " . $allwords[substr($index, 1)]->get_without_delim() . " ";
} else {
          return '';
}

Where the assumption that the item exists in the array - if it doesn't it faults out.

marcusgreen commented 5 years ago

Thanks Dustin, Can you tell me how to reproduce this so that when I update the code I can include an automated test for it?

marcusgreen commented 5 years ago

would you email me at marcusgreen at mailbox.org

dustinbrisebois commented 5 years ago

@marcusgreen were you able to sort this out?

marcusgreen commented 5 years ago

Hi Dustin I was never able to reproduce this but I have just done a commit which I think is a slightly more concise version of your suggestion just in case. Please correct me if you think it doesn't do what you expect. https://github.com/marcusgreen/moodle-qtype_wordselect/commit/daf2e6401db65c92a0c51f06bf4a274369061021 I am currently working on a branch that will support the mobile app so this will get pushed to the plugins database as part of that release.