ndunand / moodle-qtype_matrix

Source code of https://moodle.org/plugins/qtype_matrix
2 stars 10 forks source link

Deleting of questions not possible #37

Closed sehomer closed 7 years ago

sehomer commented 7 years ago

Hello,

deleting Matrix questions and deleting courses containing Matrix questions is not possible.

Debug Info: Debug info: ERROR: syntax error at or near "data" LINE 2: data, steps, attempts ^ DELETE data, steps, attempts FROM mdl_question_attempt_step_data data JOIN mdl_question_attempt_steps steps ON steps.id = data.attemptstepid JOIN mdl_question_attempts attempts ON attempts.id = steps.questionattemptid WHERE attempts.questionid = 97139 [array ( )] Error code: dmlwriteexception

Stack trace: line 482 of /lib/dml/moodle_database.php: dml_write_exception thrown line 250 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end() line 718 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end() line 136 of /question/type/matrix/libs/question_matrix_store.php: call to pgsql_native_moodle_database->execute() line 60 of /question/type/matrix/questiontype.php: call to question_matrix_store->delete_question() line 82 of /question/type/matrix/questiontype.php: call to qtype_matrix->delete_question_options() line 365 of /lib/questionlib.php: call to qtype_matrix->delete_question() line 869 of /question/classes/bank/view.php: call to question_delete_question() line 40 of /question/edit.php: call to core_question\bank\view->process_actions()

Any hints or tips appreciated. Best regards Sehomer

ndunand commented 7 years ago

Hello,

This seems to be due to the fact that the data name is a reserved word in PostgreSQL. My bad...

Could you try and replace data with qasd in question/type/matrix/libs/question_matrix_store.php in lines 127-131 (see here).

If you can confirm this fixes your issue, I'll release an update asap.

sehomer commented 7 years ago

Hello,

thanks for the quick reply. It did not fix my issue. I changed data to qasd:

Debug info: ERROR: syntax error at or near "qasd" LINE 2: qasd, steps, attempts ^ DELETE qasd, steps, attempts FROM mdl_question_attempt_step_data qasd JOIN mdl_question_attempt_steps steps ON steps.id = qasd.attemptstepid JOIN mdl_question_attempts attempts ON attempts.id = steps.questionattemptid WHERE attempts.questionid = 97139 [array ( )] Error code: dmlwriteexception

ndunand commented 7 years ago

Hello,

Thanks for reporting back. Indeed the syntax itself is not usable in PostgreSQL, this is a MySQLism.

Just remove this whole statement (lines 125-136), it is obsolete and will be removed.

sehomer commented 7 years ago

Hello,

it fixed the issue, thank you very much.

Best regards

ndunand commented 7 years ago

Thanks, commited this as d250c411b213496212476f4d69ca77aed22c8dca, releasing now on Moodle.org.