I just encountered a bug with the multiple choice question. When adding more than one alternative answer to some questions on some quizzes, the alternative counter doesn't update. So, if I start with 2 alternatives, when I click the Add More button once, I get Alternative 3. When I click it again, I still get Alternative 3. When I save the question, the last Alternative 3 is saved, and the others disappear. Along with this behavior, an error is thrown: "Illegal choice 321-653 in The 10 latest Quiz nodes this question isn't a member of element.".
I have traced it back to the handling of adding additional alternatives to a multiple choice question when adding a question from the "Create new Question" dialog when editing a quiz.
The error involves populating the value of the "Add to Quiz" list of quizzes. Populating the list happens in the getNodeForm function of quiz_question.core.inc. When loading the page the first time, the 10 latest quiz nodes are added to the list as well as the quiz that you are editing if it isn't in the ten latest. When the "Add more alternatives" button is clicked, the element is rendered correct, and then getNodeForm is called again. When it's called this time, there is no value for $_GET['quiz_nid'], which prevents the quiz node you are working with to not be added to the list of nodes to appear on the "Add to Quiz" list. When you click the "Add more alternatives" button is clicked again, an error is thrown when rendering the element because the value for Add to Quiz doesn't match any of the available options.
The solution seems to be that the quiz_nid needs to be stored in a different way: $_GET values are not carried through on ajax form updates. I'll post a patch once I develop one. Until then, I am going to increase the Default Number of Alternatives so that this particular set of circumstances isn't triggered.
Let me know if my explanation isn't clear. Thanks!
Comments
Comment #1
falcon commentedI think the main problem here is that the D7 ajax api isn't beeing used. Instead we're using the D6 approach/hack. We need to convert to the D7 way.
Comment #2
antoinetooley commentedhave you had any joy making this patch? im getting this error too.
Cheers!
Comment #3
vlad074 commentedMay be it will help to find the solution. I have found, that on the clean system everything works propertly. But if the CKEditor is enabled - the ajax error comes up.
In my situation helps the following: the CKEditor module temporarily disabling or switching text fields of multiple choice question (question text, and text alternatives - all fields on the page) in Plain Text mode.
If you have installed a WYSEWYG - maybe you should pay attention to it.
D7
Comment #4
mendu.sriram commentedError when adding more alternatives to multiple choice question
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /aspire1/system/ajax
StatusText: OK
ResponseText:
Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0
[{"command":"settings","settings":{"basePath":"\/aspire1\/","pathPrefix":"","ajaxPageState":{"theme":"nexus","theme_token":"0dixcjm2WNaoWwOmyxIDYJdCEcCD-u-GxzSizOzhJW0"},"jcarousel":{"ajaxPath":"\/aspire1\/jcarousel\/ajax\/views"},"overlay":{"paths":{"admin":"node\/*\/access\nnode\/*\/edit\nnode\/*\/delete\nnode\/*\/revisions\nnode\/*\/revisions\/*\/revert\nnode\/*\/revisions\/*\/delete\nnode\/add\nnode\/add\/*\noverlay\/dismiss-message\nnode\/*\/questions\nuser\/*\/shortcuts\nadmin\nadmin\/*\nbatch\ntaxonomy\/term\/*\/edit\nuser\/*\/cancel\nuser\/*\/edit\nuser\/*\/edit\/*","non_admin":"admin\/structure\/block\/demo\/*\nadmin\/reports\/status\/php"},"pathPrefixes":[],"ajaxCallback":"overlay-ajax"},"ckeditor":{"input_formats":{"filtered_html":{"customConfig":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckeditor.config.js?","defaultLanguage":"en","toolbar":"[\n [\u0027Source\u0027],\n [\u0027Cut\u0027,\u0027Copy\u0027,\u0027Paste\u0027,\u0027PasteText\u0027,\u0027PasteFromWord\u0027,\u0027-\u0027,\u0027SpellChecker\u0027,\u0027Scayt\u0027],\n [\u0027Undo\u0027,\u0027Redo\u0027,\u0027Find\u0027,\u0027Replace\u0027,\u0027-\u0027,\u0027SelectAll\u0027],\n [\u0027EnhancedImage\u0027,\u0027ImageButton\u0027,\u0027Flash\u0027,\u0027Table\u0027,\u0027HorizontalRule\u0027,\u0027Smiley\u0027,\u0027SpecialChar\u0027],\n [\u0027Maximize\u0027,\u0027ShowBlocks\u0027],\n \u0027\/\u0027,\n [\u0027Format\u0027],\n [\u0027Bold\u0027,\u0027Italic\u0027,\u0027Underline\u0027,\u0027Strike\u0027,\u0027-\u0027,\u0027Subscript\u0027,\u0027Superscript\u0027,\u0027-\u0027,\u0027RemoveFormat\u0027],\n [\u0027NumberedList\u0027,\u0027BulletedList\u0027,\u0027-\u0027,\u0027Outdent\u0027,\u0027Indent\u0027,\u0027Blockquote\u0027],\n [\u0027JustifyLeft\u0027,\u0027JustifyCenter\u0027,\u0027JustifyRight\u0027,\u0027JustifyBlock\u0027,\u0027-\u0027,\u0027BidiLtr\u0027,\u0027BidiRtl\u0027],\n [\u0027Link\u0027,\u0027Unlink\u0027,\u0027Anchor\u0027]\n]","enterMode":1,"shiftEnterMode":2,"toolbarStartupExpanded":true,"width":"100%","skin":"moono","format_tags":"p;div;pre;address;h1;h2;h3;h4;h5;h6","show_toggle":"t","ss":"2","loadPlugins":{"ckeditor_image":{"name":"enhanced_image","desc":"CKEditor Image - Enhanced Image plugin","path":"\/aspire1\/sites\/all\/modules\/ckeditor_image\/plugins\/enhanced_image\/","default":"t","buttons":{"EnhancedImage":{"label":"Enhanced Image","icon":"images\/image.png"}}},"drupalbreaks":{"name":"drupalbreaks","desc":"Plugin for inserting Drupal teaser and page breaks.","path":"\/aspire1\/sites\/all\/modules\/ckeditor\/plugins\/drupalbreaks\/","buttons":{"DrupalBreak":{"label":"DrupalBreak","icon":"images\/drupalbreak.png"}},"default":"t"},"tableresize":{"name":"tableresize","desc":"Table Resize plugin. See \u003Ca href=\u0022http:\/\/ckeditor.com\/addon\/tableresize\u0022\u003Eaddon page\u003C\/a\u003E for more details.","path":"\/\/cdn.ckeditor.com\/4.4.0\/full-all\/plugins\/tableresize\/","buttons":false,"default":"t"}},"entities":false,"entities_greek":false,"entities_latin":false,"scayt_autoStartup":true,"stylesCombo_stylesSet":"drupal:\/aspire1\/sites\/all\/modules\/ckeditor\/ckeditor.styles.js","contentsCss":["\/aspire1\/sites\/all\/modules\/ckeditor\/css\/ckeditor.css?n","\/\/cdn.ckeditor.com\/4.4.0\/full-all\/contents.css?n"]},"full_html":{"customConfig":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckeditor.config.js?","defaultLanguage":"en","toolbar":"[\n [\u0027Format\u0027,\u0027Bold\u0027,\u0027Italic\u0027,\u0027-\u0027,\u0027NumberedList\u0027,\u0027BulletedList\u0027,\u0027-\u0027,\u0027Link\u0027,\u0027Unlink\u0027,\u0027Image\u0027]\n]","enterMode":1,"shiftEnterMode":2,"toolbarStartupExpanded":true,"width":"100%","skin":"moono","format_tags":"p;div;pre;address;h1;h2;h3;h4;h5;h6","show_toggle":"t","ss":"2","loadPlugins":{"ckeditor_image":{"name":"enhanced_image","desc":"CKEditor Image - Enhanced Image plugin","path":"\/aspire1\/sites\/all\/modules\/ckeditor_image\/plugins\/enhanced_image\/","default":"t","buttons":{"EnhancedImage":{"label":"Enhanced Image","icon":"images\/image.png"}}},"drupalbreaks":{"name":"drupalbreaks","desc":"Plugin for inserting Drupal teaser and page breaks.","path":"\/aspire1\/sites\/all\/modules\/ckeditor\/plugins\/drupalbreaks\/","buttons":{"DrupalBreak":{"label":"DrupalBreak","icon":"images\/drupalbreak.png"}},"default":"t"},"tableresize":{"name":"tableresize","desc":"Table Resize plugin. See \u003Ca href=\u0022http:\/\/ckeditor.com\/addon\/tableresize\u0022\u003Eaddon page\u003C\/a\u003E for more details.","path":"\/\/cdn.ckeditor.com\/4.4.0\/full-all\/plugins\/tableresize\/","buttons":false,"default":"t"}},"entities":false,"entities_greek":false,"entities_latin":false,"scayt_autoStartup":true,"filebrowserBrowseUrl":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckfinder\/ckfinder.html?id=Full","filebrowserImageBrowseUrl":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckfinder\/ckfinder.html?Type=Images\u0026id=Full","filebrowserFlashBrowseUrl":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckfinder\/ckfinder.html?Type=Flash\u0026id=Full","filebrowserUploadUrl":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckfinder\/core\/connector\/php\/connector.php?command=QuickUpload\u0026type=Files\u0026id=Full","filebrowserImageUploadUrl":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckfinder\/core\/connector\/php\/connector.php?command=QuickUpload\u0026type=Images\u0026id=Full","filebrowserFlashUploadUrl":"\/aspire1\/sites\/all\/modules\/ckeditor\/ckfinder\/core\/connector\/php\/connector.php?command=QuickUpload\u0026type=Flash\u0026id=Full","stylesCombo_stylesSet":"drupal:\/aspire1\/sites\/all\/modules\/ckeditor\/ckeditor.styles.js","contentsCss":["\/aspire1\/sites\/all\/modules\/ckeditor\/css\/ckeditor.css?n","\/\/cdn.ckeditor.com\/4.4.0\/full-all\/contents.css?n"]}},"plugins":[],"textarea_default_format":{"edit-alternatives-3-answer-value":"filtered_html","edit-alternatives-3-feedback-if-chosen-value":"filtered_html","edit-alternatives-3-feedback-if-not-chosen-value":"filtered_html"},"module_path":"\/aspire1\/sites\/all\/modules\/ckeditor","editor_path":"\/\/cdn.ckeditor.com\/4.4.0\/full-all\/","ajaxToken":"_vEgpHkRxPt17nCKUGprY0yIQHAlA7AWcr_gvd9YTOU","xss_url":"\/aspire1\/ckeditor\/xss","theme":["nexus","nexus","nexus"],"elements":{"edit-alternatives-3-answer-value":"filtered_html","edit-alternatives-3-feedback-if-chosen-value":"filtered_html","edit-alternatives-3-feedback-if-not-chosen-value":"filtered_html"},"autostart":{"edit-alternatives-3-answer-value":true,"edit-alternatives-3-feedback-if-chosen-value":true,"edit-alternatives-3-feedback-if-not-chosen-value":true}}},"merge":true},{"command":"insert","method":null,"selector":null,"data":"\u003Cfieldset class=\u0022collapsible form-wrapper\u0022 id=\u0022edit-alternatives-3\u0022\u003E\u003Clegend\u003E\u003Cspan class=\u0022fieldset-legend\u0022\u003EAlternative 4\u003C\/span\u003E\u003C\/legend\u003E\u003Cdiv class=\u0022fieldset-wrapper\u0022\u003E\u003Ctable class=\u0022sticky-enabled\u0022\u003E\n \u003Cthead\u003E\u003Ctr\u003E\u003Cth\u003ECorrect\u003C\/th\u003E\u003Cth\u003EAlternative 4\u003C\/th\u003E \u003C\/tr\u003E\u003C\/thead\u003E\n\u003Ctbody\u003E\n \u003Ctr class=\u0022odd\u0022\u003E\u003Ctd\u003E\u003Cdiv class=\u0022form-item form-type-checkbox form-item-alternatives-3-correct\u0022\u003E\n \u003Cinput onchange=\u0022Multichoice.refreshScores(this, 0)\u0022 type=\u0022checkbox\u0022 id=\u0022edit-alternatives-3-correct\u0022 name=\u0022alternatives[3][correct]\u0022 value=\u00221\u0022 class=\u0022form-checkbox\u0022 \/\u003E\n\u003C\/div\u003E\n\u003C\/td\u003E\u003Ctd\u003E\u003Cdiv class=\u0022text-format-wrapper\u0022\u003E\u003Cdiv class=\u0022form-item form-type-textarea form-item-alternatives-3-answer-value\u0022\u003E\n \u003Clabel for=\u0022edit-alternatives-3-answer-value\u0022\u003EAlternative 4 \u003C\/label\u003E\n \u003Cdiv class=\u0022form-textarea-wrapper resizable\u0022\u003E\u003Ctextarea class=\u0022ckeditor-mod form-textarea\u0022 id=\u0022edit-alternatives-3-answer-value\u0022 name=\u0022alternatives[3][answer][value]\u0022 cols=\u002260\u0022 rows=\u00223\u0022\u003E\u003C\/textarea\u003E\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Ca class=\u0022ckeditor_links\u0022 style=\u0022display:none\u0022 href=\u0022javascript:void(0);\u0022 onclick=\u0022javascript:Drupal.ckeditorToggle([\u0027edit-alternatives-3-answer-value\u0027],\u0027Switch to plain text editor\u0027,\u0027Switch to rich text editor\u0027);\u0022 id=\u0022switch_edit-alternatives-3-answer-value\u0022\u003ESwitch to plain text editor\u003C\/a\u003E\u003Cfieldset class=\u0022filter-wrapper form-wrapper\u0022 id=\u0022edit-alternatives-3-answer-format\u0022\u003E\u003Cdiv class=\u0022fieldset-wrapper\u0022\u003E\u003Cdiv class=\u0022filter-help form-wrapper\u0022 id=\u0022edit-alternatives-3-answer-format-help\u0022\u003E\u003Cp\u003E\u003Ca href=\u0022\/aspire1\/filter\/tips\u0022 target=\u0022_blank\u0022\u003EMore information about text formats\u003C\/a\u003E\u003C\/p\u003E\u003C\/div\u003E\u003Cdiv class=\u0022form-item form-type-select form-item-alternatives-3-answer-format\u0022\u003E\n \u003Clabel for=\u0022edit-alternatives-3-answer-format--2\u0022\u003EText format \u003C\/label\u003E\n \u003Cselect class=\u0022filter-list form-select\u0022 id=\u0022edit-alternatives-3-answer-format--2\u0022 name=\u0022alternatives[3][answer][format]\u0022\u003E\u003Coption value=\u0022filtered_html\u0022 selected=\u0022selected\u0022\u003EFiltered HTML\u003C\/option\u003E\u003Coption value=\u0022full_html\u0022\u003EFull HTML\u003C\/option\u003E\u003Coption value=\u0022plain_text\u0022\u003EPlain text\u003C\/option\u003E\u003C\/select\u003E\n\u003C\
Comment #5
djdevinSee #2541722: ajax_html_ids (primary culprit) in large forms causes max_input_vars to be exceeded for a solution (Drupal core).