PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Randomize order of choices prevents form display on Twenty Eleven theme

  1. If I turn this on for any question the entire form does not display on output page. Page title displays but entry-content div is blank.

    Posted 10 years ago on Monday May 13, 2013 | Permalink
  2. An ugly hack via jQuery for those who might encounter this issue and need something in place before the next beta or prod version comes out with a bug fix.

    BIG GIANT DISCLAIMER:

    • Change the selector .randomizer to whatever CSS class your form has or be more specific. In my case I already have a lot of questions that adding a class on each question wasn't viable.
    • This JS also rules out any questions with only 2 options to leave True/False in original sort order.
    $('form.idealien_randomizer .gquiz-field ul').each(function(){
               // get current ul
               var $ul = $(this);
               // get array of list items in current ul
               var $liArr = $ul.children('li');
                if ($liArr.length > "2") {
               // sort array of list items in current ul randomly
               $liArr.sort(function(a,b){
                     // Get a random number between 0 and 10
                     var temp = parseInt( Math.random()*10 );
                     // Get 1 or 0, whether temp is odd or even
                     var isOddOrEven = temp%2;
                     // Get +1 or -1, whether temp greater or smaller than 5
                     var isPosOrNeg = temp>5 ? 1 : -1;
                     // Return -1, 0, or +1
                     return( isOddOrEven*isPosOrNeg );
               })
               // append list items to ul
               .appendTo($ul);
               }
         });

    For GF team - Something around lines 557 - 570 of gravityformsquiz/quiz.php appears to be the source of issue based purely on commenting blocks out for basic debug.

    Posted 10 years ago on Monday May 13, 2013 | Permalink