Index: webform.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/webform/webform.module,v
retrieving revision 1.124.2.95
diff -u -p -r1.124.2.95 webform.module
--- webform.module	27 Feb 2009 22:35:15 -0000	1.124.2.95
+++ webform.module	16 Apr 2009 21:49:46 -0000
@@ -2387,6 +2387,21 @@ function _webform_components_tree_sort($
 }
 
 /**
+ * Utility function to shuffle an array while preserving key-value pairs.
+ */
+function _webform_shuffle(&$array) {
+  // First shuffle the array keys, then use them as the basis for ordering
+  // the options.
+  $aux = array();
+  $keys = array_keys($array);
+  shuffle($keys);
+  foreach ($keys as $key) {
+    $aux[$key] = $array[$key];
+  }
+  $array = $aux;
+}
+
+/**
  * Load all necessary component.inc files into memory.
  */
 function webform_load_components($return_all = FALSE, $reset = FALSE) {
Index: components/grid.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/webform/components/grid.inc,v
retrieving revision 1.3.2.18
diff -u -p -r1.3.2.18 grid.inc
--- components/grid.inc	4 Mar 2009 05:05:12 -0000	1.3.2.18
+++ components/grid.inc	16 Apr 2009 21:49:46 -0000
@@ -90,26 +90,10 @@ function _webform_render_grid($component
   $options = _webform_grid_options($component['extra']['options']);
 
   if ($component['extra']['optrand'] && $random) {
-    // This maneuver shuffles the array keys, then uses them as
-    // the basis for ordering the options.
-    $aux = array();
-    $keys = array_keys($options);
-    shuffle($keys);
-    foreach ($keys as $key) {
-      $aux[$key] = $options[$key];
-      unset($options[$key]);
-    }
-    $options = $aux;
+    _webform_shuffle($options);
   }
   if ($component['extra']['qrand'] && $random) {
-    $aux = array();
-    $keys = array_keys($questions);
-    shuffle($keys);
-    foreach ($keys as $key) {
-      $aux[$key] = $questions[$key];
-      unset($questions[$key]);
-    }
-    $questions = $aux;
+    _webform_shuffle($questions);
   }
   foreach ($questions as $question) {
     if ($question != '') {
Index: components/select.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/webform/components/select.inc,v
retrieving revision 1.22.2.29
diff -u -p -r1.22.2.29 select.inc
--- components/select.inc	4 Mar 2009 05:05:11 -0000	1.22.2.29
+++ components/select.inc	16 Apr 2009 21:49:46 -0000
@@ -23,6 +23,7 @@ function _webform_defaults_select() {
       'email' => 0,
       'multiple' => NULL,
       'aslist' => NULL,
+      'optrand' => 0,
       'description' => '',
     ),
   );
@@ -73,6 +74,12 @@ function _webform_edit_select($currfield
     '#default_value' => $currfield['extra']['aslist'],
     '#description' => t('Check this option if you want the select component to be of listbox type instead of radiobuttons or checkboxes.'),
   );
+  $edit_fields['extra']['optrand'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Randomize Options'),
+    '#default_value' => $currfield['extra']['optrand'],
+    '#description' => t('Randomizes the order of the options when they are displayed in the form.'),
+  );
   $edit_fields['extra']['email'] = array(
     '#type' => 'checkbox',
     '#title' => t('E-mail a submission copy'),
@@ -134,10 +141,14 @@ function _webform_edit_validate_select($
  * @param $component
  *   An array of information describing the component, directly correlating to
  *   the webform_component database schema.
+ * @param $random
+ *   A boolean which can be set to FALSE to prevent the options in the form
+ *   item from being displayed in a random order, even when the component is
+ *   set to allow randomization.
  * @return
  *   An array of a form item to be displayed on the client-side webform.
  */
-function _webform_render_select($component) {
+function _webform_render_select($component, $random = TRUE) {
   $form_item = array(
     '#title'         => $component['name'],
     '#required'      => $component['mandatory'],
@@ -147,9 +158,13 @@ function _webform_render_select($compone
     '#suffix'        => '</div>',
   );
 
-  // Convert the user-entered options list into an array.
+  // Convert the user-entered options list into an array, and randomize it if
+  // requested.
   $default_value = _webform_filter_values($component['value'], NULL, NULL, FALSE);
   $options = _webform_select_options($component['extra']['items'], $component['extra']['aslist'] !== 'Y');
+  if ($component['extra']['optrand'] && $random) {
+    _webform_shuffle($options);
+  }
 
   if ($component['extra']['aslist'] === 'Y' && $component['extra']['multiple'] !== 'Y') {
     $options = array('' => t('select...')) + $options;
@@ -231,7 +246,7 @@ function webform_expand_checkboxes($elem
  *   Textual output formatted for human reading.
  */
 function _webform_submission_display_select($data, $component, $enabled = FALSE) {
-  $form_item = _webform_render_select($component);
+  $form_item = _webform_render_select($component, FALSE);
   if ($component['extra']['multiple'] === 'Y') {
     // Set the value as an array.
     $form_item['#default_value'] = array();
