Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I could not load scale question node and zero the nid and set is_new to save as new node. The scale questions would not be properly linked. The problem appears to be that when saving the scale question node saveAnswerCollection() expects the scale answers to be available at $node->alternativeX. However, getNodeProperties() did not properly load these values. The fix appears to be...
Replace lines 318-320 of scale.classes.inc
foreach ($res as $res_o) {
$props[] = $res_o;
}
with this
/*** saveAnswerCollection() expects this to be 'alternativeX', so add the extra fields onto the node ***/
$x=0;
foreach ($res as $res_o) {
$props[] = $res_o;
$props['alternative'.$x] = $res_o->answer;
++$x;
}
Agree? Also any ideas if there might be similar problems with other question types?
Comments
Comment #2
djdevinThis was fixed in #2819869: Programmatic save of scale question removes alternatives
Comment #3
webservant316 CreditAttribution: webservant316 commentedJust noting that the link above to the duplicate issue only offers a patch for Quiz 5, but the solution suggested in this post work in my use case for Quiz 4.
Comment #4
webservant316 CreditAttribution: webservant316 commentedUpgraded to 7.x-4.0-rc7 and manually patched as indicated in the original post. Any chance of getting this fix into Quiz 4?