| 1 |
<?php |
<?php |
| 2 |
// $Id: randomizer.module,v 1.4 2006/11/06 22:01:03 deekayen Exp $ |
// $Id: randomizer.module,v 1.5 2007/03/06 21:20:21 deekayen Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 21 |
* @return string |
* @return string |
| 22 |
*/ |
*/ |
| 23 |
function randomizer_help($section = 'admin/help#randomizer') { |
function randomizer_help($section = 'admin/help#randomizer') { |
|
$output = ''; |
|
|
|
|
| 24 |
switch ($section) { |
switch ($section) { |
| 25 |
case 'admin/help#randomizer': |
case 'admin/help#randomizer': |
| 26 |
return t('<p>This module is designed to assist researchers and students who want an easy way to perform random sampling or assign participants to experimental conditions.</p>'); |
return t('<p>This module is designed to assist researchers and students who want an easy way to perform random sampling or assign participants to experimental conditions.</p>'); |
| 83 |
* |
* |
| 84 |
* @return array |
* @return array |
| 85 |
*/ |
*/ |
| 86 |
function randomizer_menu($may_cache) { |
function randomizer_menu() { |
| 87 |
$items = array(); |
$items = array(); |
| 88 |
if ($may_cache) { |
$items['randomizer'] = array( |
| 89 |
$items[] = array('path' => 'randomizer', |
'title' => 'Randomizer', |
| 90 |
'title' => t('randomizer'), |
'page callback' => 'drupal_get_form', |
| 91 |
'callback' => 'randomizer_page', |
'page arguments' => array('randomizer_page'), |
| 92 |
'callback_arguments' => array($_POST), |
'access callback' => 'user_access', |
| 93 |
'access' => user_access('access randomizer'), |
'access arguments' => array('access randomizer'), |
| 94 |
'type' => MENU_SUGGESTED_ITEM); |
'type' => MENU_SUGGESTED_ITEM |
| 95 |
$items[] = array( |
); |
| 96 |
'path' => 'admin/settings/randomizer', |
$items['admin/settings/randomizer'] = array( |
| 97 |
'title' => t('Randomizer'), |
'title' => 'Randomizer', |
| 98 |
'description' => t('Set bounds for list generation.'), |
'description' => 'Set bounds for list generation.', |
| 99 |
'callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 100 |
'callback arguments' => 'randomizer_admin_settings', |
'page arguments' => array('randomizer_admin_settings'), |
| 101 |
'access' => user_access('administer site configuration'), |
'access callback' => 'user_access', |
| 102 |
'type' => MENU_NORMAL_ITEM |
'access arguments' => array('administer site configuration'), |
| 103 |
); |
'type' => MENU_NORMAL_ITEM |
| 104 |
} |
); |
| 105 |
return $items; |
return $items; |
| 106 |
} |
} |
| 107 |
|
|
| 115 |
*/ |
*/ |
| 116 |
function randomizer_page() { |
function randomizer_page() { |
| 117 |
$form = array(); |
$form = array(); |
| 118 |
|
$error = false; |
| 119 |
|
|
| 120 |
if(isset($_POST['op'])) { |
if (isset($_POST['op'])) { |
| 121 |
if (!is_numeric($_POST['randomizer_sets'])) { |
if (!is_numeric($_POST['randomizer_sets'])) { |
| 122 |
$error = true; |
$error = true; |
| 123 |
form_set_error('randomizer_sets', t('The entered sets of numbers must be numeric.')); |
form_set_error('randomizer_sets', t('The entered sets of numbers must be numeric.')); |
| 166 |
unset($tmp); |
unset($tmp); |
| 167 |
} |
} |
| 168 |
|
|
|
$form = array(); |
|
|
|
|
| 169 |
$_POST['randomizer_range_from'] = (int)$_POST['randomizer_range_from']; |
$_POST['randomizer_range_from'] = (int)$_POST['randomizer_range_from']; |
| 170 |
$_POST['randomizer_range_to'] = (int)$_POST['randomizer_range_to']; |
$_POST['randomizer_range_to'] = (int)$_POST['randomizer_range_to']; |
| 171 |
|
|
| 196 |
} |
} |
| 197 |
} |
} |
| 198 |
|
|
| 199 |
return drupal_get_form('randomizer_form', $form); |
return array_merge($form, randomizer_form()); |
| 200 |
} |
} |
| 201 |
|
|
| 202 |
/** |
/** |