studentquiz / moodle-mod_studentquiz

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

Error on delete_orphaned_questions schedulded task execution #438

Open cmichenaud opened 1 year ago

cmichenaud commented 1 year ago

Hi,

On my Moodle 4.1.1 server, I noticed errors in the schedulded tasks log report about studentquiz plugin (V5.1.0 - 2022122200) and more precisely on delete_orphaned_questions task. Maybe is there typing mistake in the sql query ? Here is the debug message :

Unknown column 'sq.state' in 'where clause'
SELECT q.*, sqq.id as studentquizquestionid
                       FROM mdl_studentquiz_question sqq
                       JOIN mdl_question_references qr ON qr.itemid = sqq.id
                            AND qr.component = 'mod_studentquiz'
                            AND qr.questionarea = 'studentquiz_question'
                       JOIN mdl_question_bank_entries qbe ON qr.questionbankentryid = qbe.id
                       JOIN mdl_question_versions qv ON qv.questionbankentryid = qr.questionbankentryid
                       JOIN mdl_question q ON qv.questionid = q.id
                      WHERE sq.state = 0 AND ? - q.timemodified > 0
                   ORDER BY q.questionid ASC

And the backtrace :

Backtrace:
* line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
* line 1278 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
* line 64 of /mod/studentquiz/classes/task/delete_orphaned_questions.php: call to mysqli_native_moodle_database->get_records_sql()
* line 259 of /lib/cronlib.php: call to mod_studentquiz\task\delete_orphaned_questions->execute()
* line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
* line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
* line 178 of /admin/cli/cron.php: call to cron_run()

Thanks in advance for your feedback.

vuvanhieu143 commented 1 year ago

Thank you for your report @cmichenaud ,I will take a look at this issue