Saving a new revision of a question attached to a quiz fails to save some data

Created on 21 March 2014, over 10 years ago
Updated 26 July 2024, about 1 month ago

Problem/Motivation

When saving a Quiz Question that is currently used in one or more Quizzes, and the administrator has decided to create a new revision of that Question, a confirmation screen is displayed which asks what to do with the Quizes. The 3 options here are to update the Quiz, update and unpublish the Quiz, or do nothing.

The problem is that no matter what option is selected, the new revision of the Question is missing some of the altered data. A new revision is created, and some data is saved, but some is not.

The issue stems from the fact that when the Question node is saved, the QuizQuestion->save(); function is called which uses a custom save routine ($this->saveNodeProperties($is_new);) and saves some but not all of the node data. At this point if we are not creating a new revision the function completes and the normal Drupal node save operations take place and all the data is saved.

If a new revision is being created then we are immediately redirected to the confirmation screen where we can choose what to do with the parent Quiz. The redirection exits the function immediately and prevents the normal Drupal node save from completing.

One of the fields which fails to save in this scenario is the node body. There will be others which may vary depending on the Question type.

Proposed resolution

The fix for this issue is to stop using drupal_goto for the redirection, and override the destination parameter instead.

Additionally I altered the redirection destination to preserve any previous destination that may have been set. For example, if you edited the Question from the Manage Questions tab of a Quiz, after saving the question and choosing a Quiz update option, you will be redirected back to the Manage Questions tab.

πŸ› Bug report
Status

Needs review

Version

4.0

Component

Code - Quiz core

Created by

πŸ‡³πŸ‡ΏNew Zealand scott.whittaker

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