studentquiz / moodle-mod_studentquiz

Moodle-Plugin
GNU General Public License v3.0
38 stars 38 forks source link

Fix incorrect syntax error #417

Closed vuvanhieu143 closed 2 years ago

vuvanhieu143 commented 2 years ago

Hi @timhunt , Look like I make a mistake when I fix code checker error(change or to ||). || does not allow to using the same variable for two side but OR allow it. Could you please help me to review the changes?

Many thanks

timhunt commented 2 years ago

Yes, definitely more readable to move the assignment out of the if.

(For info the issue is not with whether using the value is allowed. It is just operator precidence. So.

$x = f() or $x->property means ($x = f()) or $x->property

but

$x = f() || $x->property means $x = (f() || $x->property)

which is why that does not work. However, the fix you did is better than just adding brackets to the old code.