When I want to delete a multichoice content I get this error:

Notice: Undefined property: MultichoiceQuestion::$rid in MultichoiceQuestion->delete() (line 313 of /home/user/public_html/sites/all/modules/quiz/question_types/multichoice/multichoice.classes.inc).

I use quiz-alpha-2 ;)
Thanks for help!

Comments

Maks’s picture

Have the same problem.

jwjoshuawalker’s picture

Version: 7.x-4.0-alpha2 » 7.x-4.0-alpha4
Category: support » bug

Same here, I get that error and this one below it:

PDOException: SQLSTATE[22012]: Division by zero: 1365 Division by 0: UPDATE {quiz_node_results} SET score=ROUND( 100 * ( SELECT COALESCE (SUM(a.points_awarded), 0) FROM {quiz_node_results_answers} a WHERE a.result_id = {quiz_node_results}.result_id ) / ( SELECT max_score FROM {quiz_node_properties} qnp WHERE qnp.vid = {quiz_node_results}.vid ) ) WHERE (vid IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2)) ; Array ( [:db_condition_placeholder_0] => 4 [:db_condition_placeholder_1] => 8 [:db_condition_placeholder_2] => ) in quiz_update_max_score_properties() (line 2606 of .../sites/all/modules/quiz/quiz.module).

jwjoshuawalker’s picture

Update on this:

Reverting to the first revision of my Quiz let me delete some, but not all questions.

Deleting the quiz entirely allowed me to delete the questions.

burt.lo’s picture

This bug is still present in 7.x-alpha9. I consistently get this when deleting a multiple choice question.

julianmancera’s picture

Hi

I confirm the issue, it seems that the object rid is not part of the QuizQuestion class but part of the QuizQuestionResponse class. So it seems a reference problem. I think that the only condition that should match is the node id as here we are trying to delete the multichoice question, so it should delete all the results:

Line 313

    $query = db_query('SELECT id FROM {quiz_multichoice_user_answers} WHERE question_nid = :nid ', array(':nid' => $this->node->nid));

And for the version condition it shouldn't match the rid as we are deleting all the quiz version answers.

Line 310

    $query = db_query('SELECT id FROM {quiz_multichoice_user_answers} WHERE question_nid = :nid AND question_vid = :vid', array(':nid' => $this->node->nid, ':vid' => $this->node->vid));

Julian Mancera

julianmancera’s picture

I also confirm the problem on #2 once the above is implemented, I think that during the delete process the script should look for the scores that sum 0 and remove them

SELECT FROM {quiz_node_properties} qnp WHERE qnp.vid = {quiz_node_results}.vid

Julian Mancera

chiko.mukwenha’s picture

This problem is real against alpha9

@julianmancera, is that the patch you are suggesting?

paalj’s picture

I have created the patch described in #5.

#2 is covered here: http://drupal.org/node/1728390

paalj’s picture

Status: Active » Needs review
sivaji_ganesh_jojodae’s picture

Status: Needs review » Fixed

Issue fixed. Including the division by zero exception. Thanks for reporting and sharing the patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

just a simple edit

  • Commit f672da4 on 7.x-4.x, 7.x-5.x by sivaji:
    Issue #1537814 by paalj | krysty2k9: Fixed Delete content multichoice...

  • Commit f672da4 on 7.x-4.x, 7.x-5.x, quiz-pages by sivaji:
    Issue #1537814 by paalj | krysty2k9: Fixed Delete content multichoice...

  • Commit f672da4 on 7.x-4.x, 7.x-5.x, quiz-pages, 2269219 by sivaji:
    Issue #1537814 by paalj | krysty2k9: Fixed Delete content multichoice...

  • Commit f672da4 on 7.x-4.x, 7.x-5.x, 2269219 by sivaji:
    Issue #1537814 by paalj | krysty2k9: Fixed Delete content multichoice...