$prefix = 'Post' . ' ' . $number . ' '; } $column = $prefix . $add; addColumn($cleanProcedure, $column); // this will only add columns if they don't already exist; nothing is overwritten } } $procedure = multiLevelShuffle($cleanProcedure); $procedure = shuffle2dArray($procedure, $_CONFIG->stop_at_login); $_SESSION['Procedure'] = $procedure; // Load entire experiment into $Trials[1-X] where X is the number of trials $Trials = array(0 => 0); $procedureLength = count($procedure); for ($count = 2; $count < $procedureLength; $count++) { // $Trials[$count-1] = makeTrial($procedure[$count]['Item']); $items = rangeToArray($procedure[$count]['Item']); $stim = array(); foreach ($items as $item) { if (isset($stimuli[$item]) and is_array($stimuli[$item])) { foreach ($stimuli[$item] as $column => $value) { $stim[$column][] = $value; } } } if ($stim === array()) { foreach ($stimuli[2] as $column => $value) { $stim[$column][] = ''; } } foreach ($stim as $column => $valueArray) { $Trials[$count - 1]['Stimuli'][$column] = implode('|', $valueArray);
foreach ($theseButtons as $thisButton) { if ($thisButton === '') { continue; } if ($thisButton[0] === '$') { $sep = strrpos($thisButton, '['); if ($sep === false) { $col = substr($thisButton, 1); $index = $item; } else { $col = substr($thisButton, 1, $sep - 1); $index = substr($thisButton, $sep + 1, strrpos($thisButton, ']') - $sep - 1); } $col = strtolower(trim($col)); if (isset($stimCols[$col])) { $index = rangeToArray($index); foreach ($index as $i) { $newButtons[] = $_SESSION['Stimuli'][$i][$stimCols[$col]]; } } else { $newButtons[] = $thisButton; // so we can see which button is being outputted as $bad button [2o3nri... $trialFail = true; echo '<h3>Buttons incorrectly defined. For dynamic buttons, please use a dollar sign, followed by the column name, followed by a space, followed by a number or range, like <strong>$cue[2::8]</strong></h3>'; } } else { $newButtons[] = $thisButton; } } if ($shuffleThese) { shuffle($newButtons);
foreach ($columns as $column => $default) { if (!isset($row[$column])) { $row[$column] = $default; } } } } unset($row); $_SESSION['Trials'] = array(); $i = 0; foreach ($_SESSION['Procedure'] as $procRow) { if ($procRow === 0) { continue; } ++$i; $items = rangeToArray($procRow['Item']); $stim = array(); foreach ($items as $item) { if (isset($_SESSION['Stimuli'][$item])) { foreach ($_SESSION['Stimuli'][$item] as $column => $value) { $stim[$column][] = $value; } } } if ($stim === array()) { foreach ($_SESSION['Stimuli'][2] as $column => $unused) { $stim[$column] = 'n/a'; } } else { foreach ($stim as &$values) { $values = implode('|', $values);
// // If you put a range (2 entries separated by two colons '::'), the // scale will start from the first entry, and end at the second. // Both number ranges (-3::3) and alphabetical ranges (a::f) // are fine. You can also define the step size using a # sign // after the range (e.g., 0::1#.5). // // You can also combine ranges using commas, such as "1::3,a::c". // Using these, its possible to have duplicate entries, so // something like "1,1,1,1::4" is possible. If you want to set // the step size for multiple ranges, please enter the step size // after each range, like "1::3#.1, a::g # 2, 7::9 #.5" if (!isset($settings) or $settings === '') { $settings = '1::7'; } $likertOptions = rangeToArray($settings); $texts = explode('|', $text); $question = array_shift($texts); $labelWidth = floor(1000 / max(1, count($texts))) / 10; $optionWidth = floor(1000 / count($likertOptions)) / 10; ?> <style> .likertArea { text-align: center; } .likertQuestion { margin: 0 0 30px 0; font-size: 1.3em; } .likertLabels { display: table; margin: 10px 0; color: #666; width: 100%; } .likertLabel { display: table-cell; padding: 8px; vertical-align: bottom; width: <?php echo $labelWidth; ?>