Quiz question relationships cleared on every change

Created on 31 December 2014, over 9 years ago
Updated 27 July 2024, about 1 month ago

Whenever Quiz questions are updated, existing quiz_question_relationship entities are being deleted rather than updated, and new relationship entities are created in its place. This appears to occur even if only minor things like weights are being changed.

function quiz_set_questions($quiz, $questions, $set_new_revision = FALSE) {
  if ($set_new_revision) {
    // Create a new Quiz VID, even if nothing changed.
    $quiz->revision = 1;

    node_save($quiz);
  }

  // Clear the existing relationships for this version.
  db_delete('quiz_node_relationship')
    ->condition('parent_nid', $quiz->nid)
    ->condition('parent_vid', $quiz->vid)
    ->execute();

It would be more logical if the overview on node/%node/quiz/questions operated directly on the relationship entities, rather than the question entities. This would allow for targetted updating of only relationships which have actually changed and would update those relationships rather than creating new ones.

I'm having some trouble deciphering the logic in quiz_set_questions and the related quiz_update_quiz_question_relationship, the latter of which seems to aim to simply copy over existing relationships to new entities connected to a new node->vid, but first creates new entities, then right after updates them again with values that could've been inserted in the first place.

πŸ› Bug report
Status

Postponed: needs info

Version

5.0

Component

Code - Quiz core

Created by

πŸ‡³πŸ‡±Netherlands FreekVR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024