studentquiz / moodle-mod_studentquiz

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

Drag&Drop pictures work only in Preview in v4.7.0 #427

Closed ksteitz closed 1 year ago

ksteitz commented 1 year ago

We encounter a bug using Drag&Drop on image (qtype_ddimageortext). The image shows only in preview; when starting the quiz it cannot be loaded:

Stack trace:

line 2719 of /lib/filelib.php: Error thrown
line 507 of /mod/studentquiz/lib.php: call to send_stored_file()
line 2213 of /lib/questionlib.php: call to mod_studentquiz_question_pluginfile()
line 43 of /question/type/ddimageortext/lib.php: call to question_pluginfile()
line 5218 of /lib/filelib.php: call to qtype_ddimageortext_pluginfile()
line 44 of /pluginfile.php: call to file_pluginfile()

There are different picture-paths used in preview and during quiz, e.g. /pluginfile.php/1639588/qtype_ddimageortext/bgimage/1637069/1/6088163/picturename.png (preview and picture correctly loaded) vs. /pluginfile.php/1639588/qtype_ddimageortext/bgimage/1637070/2/6088163/picturename.png (just above error when starting quiz).

Plugin-Version: v4.7.0 (2022052400) Moodle 3.11.11 Database: PostgreSQL 13.8

Any ideas to fix that issue? Thanks a lot!

jojoob commented 1 year ago

Just stumbled over the same issue. The bug is caused by a flawed variable assignment within this if-statement. I just wonder how that ever worked? Maybe an older PHP version interpreted this syntax differently.

It is fixed in v5.0.0 by commit 7af298d82a5dd3d487caed80c50039f29e5b5662.

jojoob commented 1 year ago

@timhunt I propose to backport commit 7af298d82a5dd3d487caed80c50039f29e5b5662 to v4.7 and release a v4.7.1.

timhunt commented 1 year ago

Yes. I need to releave a 5.0.1 when our current testing is complete.

jojoob commented 1 year ago

5.0.1? Will it be compatible with Moodle 3.9 to 3.11? If not, a 4.7.1 would be nice. :)

ksteitz commented 1 year ago

Thanks a lot for the finding Johannes! I already tested the fixed lib.php succesfully on our testing system using v4.7 in Moodle 3.11.11. So there should be definitely a Plugin-version supporting Moodle 3.9 to 3.11!

Thanks for your work once more, Tim!

kind regards Klaus

jojoob commented 1 year ago

@ksteitz Meanwhile I just cherry-picked to mentioned commit on top of the MOODLE_3X_STABLE branch (v4.7.0) without changing the version.php: rzhtwberlin/moodle-mod_studentquiz/tree/fork/MOODLE_3X_STABLE. Since this is just a simple code change you are safe to apply the patched plugin to your Moodle installation without triggering an upgrade.

ksteitz commented 1 year ago

Thanks Johannes, seme here. I just applyed the patch on our productive system today in the morning; works fine. Nevertheless a 4.7.1 version would be of help, to avoid such manual changes for future updates.