Fix for "Match question throws PHP error if one or more options have not been selected "

Signed-off-by: Joseph Rézeau <moodle@rezeau.org>
MDL-39488 Lesson Module: Fixed PHP error matching question,
if one or more options have not been selected.
MDL-39488 Lesson Module: Improve code performance