We get the warning message in the title when opening the question with the our own defined admin/teacher role (not with the student role, not with the superuser/root role)

Question XML:

<question type="check">
<text>In the pressing step K<sub>2</sub>S<sub>2</sub>O<sub>5</sub> is added, which forms SO<sub>2</sub>. 
Why do you want to have SO<sub>2</sub> in your product?</text>
<hint>Go to the [node:2980 link=next question;].</hint>
<option><choice>To avoid the growth of unwanted bacteria and yeasts</choice></option>
<option><choice>To promote the extraction of components from the skins into the juice</choice></option>
<option><choice>To increase the body and mouth feel of a wine</choice></option>
<option><choice>To obtain more free-run juice</choice></option>
<option><choice>To avoid chemical and enzymatic oxidation</choice></option>
</question>

Relevant code:

/**
 * Helper function to determine the value for a checkboxes form element.
 *
 * @param $form
 *   The form element whose value is being populated.
 * @param $edit
 *   The incoming POST data to populate the form element. If this is FALSE,
 *   the element's default value should be returned.
 * @return
 *   The data that will appear in the $form_state['values'] collection
 *   for this element. Return nothing to use the default.
 */
function form_type_checkboxes_value($form, $edit = FALSE) {
  if ($edit === FALSE) {
    $value = array();
    $form += array('#default_value' => array());
    foreach ($form['#default_value'] as $key) {
      $value[$key] = 1;
    }
    return $value;
  }
  elseif (!isset($edit)) {
    return array();
  }
}

Relevant URL:
http://fch.wmmrc.nl/content/food-fermentation-post-test/sulphite

Comments

jvdkolk’s picture

Status: Active » Closed (fixed)

Tested again: Problem seemed to have solved itself :).

pureh2o’s picture

Dag,

I get a similar or the same error:
"Invalid argument supplied for foreach() in form_type_checkboxes_value() (line 2390 of /home/xxxx/public_html/includes/form.inc)."

only for the check type of questions and with reference to this line from form.inc
foreach ($element['#default_value'] as $key) {

So maybe there are some other conditions to be met for the bug to be reproduced.

I'm using the 7.x-2.5 version

Happy to help if you need more info from my side.

jvdkolk’s picture

Version: 6.x-2.x-dev » 7.x-2.5
Status: Closed (fixed) » Needs review

Hi!

Could you post your XML giving this warning in 7.x-2.5?

Best regards,
Koos

pureh2o’s picture

Hi,

I can't reproduce it anymore. 3 days ago I would get it for each and every edit and view, and I did clean the cache...

I'm sure I haven't changed anything on that closedquestion since then.

I have created a new closed question with the same XML and cannot reproduce it still.

The source XML was the one in the sample lessons (you see it's useful to have a baseline):

<question type="check">
    <text>
        <p>Which cities are in The Netherlands?</p>
    </text>
    <hint mintries="1">Your answer is not entirely correct yet.</hint>
    <hint mintries="3">One option is really wrong.</hint>
    <correct>Well done. 
    </correct>
    <option correct="1">
        <choice>Amsterdam 
        </choice>
        <feedback>Yep, good pick. 
        </feedback>
        <feedbackunselected>You have not selected option "Amsterdam". 
        </feedbackunselected>
        <feedbackunselected mintries="2">You have not selected option "Amsterdam" after two tries. 
        </feedbackunselected>
    </option>
    <option correct="-1">
        <choice>Willemstad 
        </choice>
        <feedback>Willemstad on Curaçao is part of the Netherlands but not in the Netherlands. Selecting it or not selecting it makes no difference. 
        </feedback>
    </option>
    <option correct="1">
        <choice>Delft 
        </choice>
        <feedback>Yep, Delft is in The Netherlands 
        </feedback>
    </option>
    <option correct="0">
        <choice>Paris 
        </choice>
        <feedback>Nope, Paris is in France. 
        </feedback>
    </option>
</question>

Bedankt
P.S. Could you please look at the closed issues where I posted new findings (e.g. the issue with the options inlinefeedback)

jvdkolk’s picture

Status: Needs review » Closed (cannot reproduce)