Here's what I did to reproduce:

  1. Create some questions
  2. Create a new quiz
  3. Add questions to the quiz + save
  4. Edit the quiz and update some information, for instance the result comments
  5. Result: In the manage questions screen, no questions are assigned

All other options are pretty much untouched, especially did I not touch the revision-related options.

Update:
It seems that this behavior does not happen all the time. I have yet to find out when it happens and if it is related to certain types of questions being added to the quiz.

CommentFileSizeAuthor
#10 quiz_questions_unassigned.patch711 bytesjoel_osc

Comments

edboost’s picture

I'm getting the same thing. I went back to the quiz to delete the pass/fail text (and just rely on Results text) and when I saved, all question were unassigned.

I'm only using MC questions, if that helps.

ludo.r’s picture

Same here, when I edit the quiz, all questions are unassigned.

I'm only using Multiple choice questions.

ludo.r’s picture

Version: 7.x-4.0-alpha2 » 7.x-4.0-alpha4
dkliewer’s picture

Priority: Normal » Major

Any news on this? This bug makes the module useless. Even changing a word in the quiz description removes all questions!

isaac.niebeling’s picture

I'm seeing the same issue with multiple choice questions and quiz directions.

isaac.niebeling’s picture

So I did a little investigating in the database, and it looks like the parent_vid isn't getting updated when the quiz node is saved after adding a new question. Manually updating that in the DB fixes the questions not showing up. Haven't looked at the code yet, but that might give some direction to others.

joel_osc’s picture

I have a db that this happens on a particular quiz the first time I edit it - luckily I have a backup so I can restore and recreate the problem every time. If I just edit the quiz and select the field 'Allow jumping' in 'Taking options' and select save, the questions will get removed from the quiz. I think the problem happens around line 733 in the quiz.module:

 if ($node->revision) {
    // Insert a new row in the quiz_node_properties table.
    $old_auto = isset($node->auto_created);
    $node->auto_created = TRUE;
    $old_vid = $node->vid;
    quiz_insert($node);
    if (!$old_auto) {
      unset($node->auto_created);
    }

    // Create new quiz-question relation entries in the quiz_node_relationship
    // table.
    quiz_update_quiz_question_relationship($old_vid, $node->vid, $node->nid);

For some reason only the first time I save the quiz after restoring the database $node->revision is set to 1 so quiz_update_quiz_question_relationship is called with the parametres (277,277,112) where 277 is the vid of node.

I don't know this code too well but I believe a possible fix is to change the above segment to:

 if ($node->revision) {
    // Insert a new row in the quiz_node_properties table.
    $old_auto = isset($node->auto_created);
    $node->auto_created = TRUE;
    //$old_vid = $node->old_vid;
    quiz_insert($node);
    if (!$old_auto) {
      unset($node->auto_created);
    }

    // Create new quiz-question relation entries in the quiz_node_relationship
    // table.
    quiz_update_quiz_question_relationship($node->old_vid, $node->vid, $node->nid);
  }

I tested it and it seems to work, but again I don't really know if this change will have other ramifications.

amagdy’s picture

I'll test your comment

amagdy’s picture

it is working .. nice :)
create a patch for it

joel_osc’s picture

Status: Active » Needs review
StatusFileSize
new711 bytes

Thanks for testing. Here is a patch...

bonobo’s picture

FWIW, I checked out the latest dev branch after seeing this commit: http://drupalcode.org/project/quiz.git/commit/1d920a9

Note the commit message:

Fix problem with questions dissapearing when quiz is updated 7.x-4.x

And, the issue did not appear.

This did *not* look at either the comment in 7, or the related patch in 10.

amagdy’s picture

yes, but if you check the diff .. it is the same fix :)
gj joel_liquidcms

thememex’s picture

Same behavior with a MC only quiz on 7.x-4.0-alpha4. The patch in #10 seems to solve this issue.

Thanks @joel_liquidcms

drewbe121212’s picture

I seem to still be experiencing this issue when 0 results have been logged for a specific quiz. Can anyone else confirm this or replicate it?

- Created Questions
- Created Quiz
- Attached Questions to Quiz

- Edit Quiz *questions disappear*

- Re-attach questions to Quiz
- Start and/or complete the quiz
- Edit Quiz *questions are retained correctly*

- Delete result record from table quiz_node_results on the current quiz/revision
- Edit Quiz *questions disappear*

Edit: Just as a FYI, I have applied the single page quiz patch, so it would be nice to at least see if others are experiencing the same issue or if it is something single page did to this.

drewbe121212’s picture

Ok. It looks like my issue was still coming from a bug in the code during the update_quiz_relationships call. Posted a patch on the issue: #1301584: Saving questions to a quiz gives a fatal error

klausi’s picture

Status: Needs review » Needs work

Patch does not apply, see http://drupal.org/node/707484

falcon’s picture

Status: Needs work » Closed (fixed)

This issue was fixed quite some time ago. We just haven't made a new release yet...

falcon’s picture

Issue summary: View changes

add update in the descrription