error when duplicating question

error when duplicating question

Joseph Rézeau發表於
Number of replies: 2
Core developers的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片 Translators的相片

Starting with Moodle 3.6, questions can have an ID number (which must be unique within a given category). This results in a bug when duplicating a question with an ID if the user forgets to give the duplicated question a different ID. I would have reported this in the tracker, but I've lost touch with it for a few years. I hope the info below will be useful for someone to create a bug report.

My original question had an ID number = 99.

Error writing to database

Debug info: Duplicate entry '2-99' for key 'mdl_ques_catidn_uix'
INSERT INTO mdl_question

etc.

Stack trace:

  • line 489 of \lib\dml\moodle_database.php: dml_write_exception thrown
  • line 1329 of \lib\dml\mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1375 of \lib\dml\mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
  • line 372 of \question\type\questiontypebase.php: call to mysqli_native_moodle_database->insert_record()
  • line 273 of \question\question.php: call to question_type->save_question()

 

評比平均分數: -
In reply to Joseph Rézeau

Re: error when duplicating question

Tim Hunt發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 Plugin developers的相片

I suppose that, like with the question name, what we should do is to automatically alter the idnumber for the duplicate, or automatically blank it.

If you can re-discover your tracker login, please create an improvement request there.