In a selection voting, Randomize answers order is checked and users can select maximum 2 out of 5 choices.
If a user checks 3 choices, an error is raised: 3 choices were selected but only 2 are allowed (as expected).

The problem is that the order of answers is changed/randomized, but the checked fields remain the same, resulting in other selections than originally choosen.

IMO randomize should not occur in case an error is raised, leaving the answer and checks as they were.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kayceedub’s picture

This problem actually runs deeper and its actually a pretty serious problem. It looks like the only thing that is being randomized is the display text for the choices. The actual values are still listed as non-randomized, which is why the above poster is seeing the problem above.

When you submit the ballot, what is actually submitted are votes for the non-randomized choices that would've appeared if the display text/labels for the checkboxes were not randomized. Does that make sense?

Robert_T’s picture

Title: Randomize shufles choices on error » Randomize shuffles choices incorrectly
Version: 6.x-1.7 » 6.x-1.x-dev
Priority: Normal » Major

This is a bug in the /modes/selection module, a component of decisions, within function decisions_selection_voting_form(). The checkboxes' labels are randomized, but the checkboxes' values are always output in numeric order (1,2,3,...). This is due to the use of the $node->choice array index instead of the $node->choice[index]['vote_offset'] in the $list array used for $form['choice']['#options'].

The solution is a small modification to /modes/selection.module. The code below begins at line 219 of the 2011-Feb-25 version of 6.x-1.x-dev.

    //Approval/multiple-choice voting.
    else {
      foreach ($node->choice as $i => $choice) {
        //----- delete or comment out these two lines -----
        //if ($choice['label']) {
        //  $list[$i] = check_plain($choice['label']);
        //----- end delete -----
        //----- add these two lines -----
        if (!empty($choice['label']) && !empty($choice['vote_offset'])) {
          $list[$choice['vote_offset']] = check_plain($choice['label']);
        //----- end addition -----
        }
      }
travisjbennett’s picture

(Follow)

travisjbennett’s picture

(retracted)

travisjbennett’s picture

Looks like this change fixed the issue with radio buttons (THANK YOU!), but we're still only half way there.

1-click forms, or forms with checkboxes (used when the voter isn't limited to only one selection) still have this issue. The code for that is right above the area Robert_T fixed, but I'm having some trouble figuring out how to make a similar change.

I'm using version module 6.x-1.7.