marcusgreen / moodle-qtype_wordselect

langHighlight words by clicking e.g. select all nouns in this sentence

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined Offset on line 284 in question.php

dustinbrisebois opened this issue · comments

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:

$summary .= " " . $allwords[substr($index, 1)]->get_without_delim() . " ";

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.

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?

would you email me at marcusgreen at mailbox.org

@marcusgreen were you able to sort this out?

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.
daf2e64
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.