$val = 'default'; } ?> <input type="text" form="shuffleFile" name="zoom" value="<?php echo $val; ?> " class="zoomInput" hidden/> <!-- Jquery puts modified zoom value here and it is submitted when shuffle button is pressed--> <span id="zoomVal" class="hidden"><?php echo $val; ?> </span> <!-- keeps the zoom value most recently submitted --> <form id="shuffleFile" action="" method="get"></form> <!-- the form that submits the selctions made on this page --> <?php if ($store['loc'] !== '' && inString('.csv', $store['loc']) == true) { $before = GetFromFile($store['loc']); // grab file to shuffle $timer = microtime(true); // start a timer $after = multiLevelShuffle($before); // run basic shuffles $after = shuffle2dArray($after); // run advanced shuffles $timer = microtime(true) - $timer; // calculate difference since start $timer = round($timer * 1000000, 0); // multiply by 1,000,000 and round $tableTimer = microtime(true); // show the before shuffling version echo '<div class="before"><div id="RF"><h2>Before</h2>'; display2dArray($before);
the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> */ require 'Code/initiateCollector.php'; // reset session so it doesn't contain any information from a previous login attempt session_destroy(); $_SESSION = array(); // load and sort conditions $Conditions = GetFromFile($_PATH->get('Conditions'), false); $conditionNumbers = array(); foreach ($Conditions as $cond) { if ($cond['Condition Description'][0] === '#') { continue; } if (isset($conditionNumbers[$cond['Number']])) { exit('Error: Multiple Conditions use the same number. Please check your "' . $_PATH->conditions . '" file and make sure each number in the "Number" column is unique.'); } else { $conditionNumbers[$cond['Number']] = true; if (!file_exists($_PATH->get('Stimuli Dir') . '/' . $cond['Stimuli'])) { exit('Error: The stimuli file "' . $cond['Stimuli'] . '" could not be found in the ' . $_PATH->get('Stimuli Dir') . ' folder, for Condition ' . $cond['Number'] . ': ' . $cond['Condition Description'] . '. Either rename a file to "' . $cond['Stimuli'] . '" or change this entry in the "' . $_PATH->get('Conditions') . '" file to match an existing file.'); } if (!file_exists($_PATH->get('Procedure Dir') . '/' . $cond['Procedure'])) { exit('Error: The procedure file "' . $cond['Procedure'] . '" could not be found in the ' . $_PATH->get('Procedure Dir') . ' folder, for Condition ' . $cond['Number'] . ': ' . $cond['Condition Description'] . '. Either rename a file to "' . $cond['Procedure'] . '" or change this entry in the "' . $_PATH->get('Conditions') . '" file to match an existing file.'); }
$column = null; } unset($column); foreach (array_keys($allColumnsNeeded) as $column) { $errors = keyCheck($proc, $column, $errors, $_SESSION['Condition']['Procedure']); } include 'shuffleFunctions.php'; #### Create $_SESSION['Trials'] #### Load all Stimuli and Procedure info for this participant's condition then combine to create the experiment // load stimuli for this condition then block shuffle $cleanStimuli = GetFromFile($_FILES->stim_files . '/' . $_SESSION['Condition']['Stimuli']); $stimuli = multiLevelShuffle($cleanStimuli); $stimuli = shuffle2dArray($stimuli, $_CONFIG->stop_at_login); $_SESSION['Stimuli'] = $stimuli; // load and block shuffle procedure for this condition $cleanProcedure = GetFromFile($_FILES->proc_files . '/' . $_SESSION['Condition']['Procedure']); $addColumns = array('Text'); foreach ($addColumns as $add) { foreach ($trialTypeColumns as $number => $colName) { // check all trial type levels we found if ($number == 0) { $prefix = ''; } else { $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);
<?php require 'initiateCollector.php'; $trialTypes = getAllTrialTypeFiles(); if (!isset($_SESSION['Trial Tester']) or isset($_POST['resetSession'])) { $_SESSION = array(); $_SESSION['Trial Tester'] = true; } elseif (isset($_POST['LoadStimFile'])) { $_SESSION['Stimuli'] = GetFromFile($_PATH->stimuli_dir . '/' . $_POST['StimuliFile']); $redirect = true; } elseif (isset($_POST['Procedure_Trial_Type'])) { $redirect = true; $posts = array(); foreach ($_POST as $name => $val) { $name = explode('_', htmlspecialchars_decode($name)); $category = array_shift($name); $name = implode('_', $name); if ($category === 'Stimuli' or $category === 'Procedure') { if (is_array($val)) { foreach ($val as &$v) { $v = trim(htmlspecialchars_decode($v)); } unset($v); $val = implode('|~|', $val); } else { $val = trim(htmlspecialchars_decode($val)); } $posts[$category][$name] = $val; } } $trialType = $posts['Procedure']['Trial_Type'];
// check all files // set correct delimiter and skip IP log file if (inString('.txt', $file)) { $delimiter = "\t"; } elseif (inString('.csv', $file)) { $delimiter = ','; } else { continue; } if ($file == $ipFilename) { // skip reading IP file continue; } $current = array(); // clear data from current file before loading next one $current = GetFromFile($folder . $file, false, $delimiter); // read a file presumably containing workers if (!isset($current[0]['WorkerId'])) { // skip files without a 'WorkerID' column $skipped[] = $file; // keep track of which files we've skipped } else { $checked[] = $folder . $file; // keep track of which files we've checked foreach ($current as $worker) { if (!in_array($worker['WorkerId'], $uniques)) { $uniques[] = trim(strtolower($worker['WorkerId'])); } } } }
$column = null; } unset($column); foreach (array_keys($allColumnsNeeded) as $column) { $errors = keyCheck($proc, $column, $errors, $_SESSION['Condition']['Procedure']); } include $_PATH->get('Shuffle Functions'); #### Create $_SESSION['Trials'] #### Load all Stimuli and Procedure info for this participant's condition then combine to create the experiment // load stimuli for this condition then block shuffle $cleanStimuli = GetFromFile($_PATH->get('Stimuli')); $stimuli = multiLevelShuffle($cleanStimuli); $stimuli = shuffle2dArray($stimuli, $_CONFIG->stop_at_login); $_SESSION['Stimuli'] = $stimuli; // load and block shuffle procedure for this condition $cleanProcedure = GetFromFile($_PATH->get('Procedure')); $addColumns = array('Text'); foreach ($addColumns as $add) { foreach ($trialTypeColumns as $number => $colName) { // check all trial type levels we found if ($number == 0) { $prefix = ''; } else { $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);
foreach ($extraFiles as $fileName) { foreach ($extraFileMeta as $category => $fileMeta) { if (strpos($fileName, $fileMeta['fileName']) !== false) { $extraFileMeta[$category]['files'][] = $fileName; } } } unset($allExtraFiles, $extraFiles); // inside each extra file, match each row (or rows, for final questions) with its ID in $IDs // while we are here, get the column options for the menu foreach ($extraFileMeta as $category => $fileMeta) { if (!isset($fileMeta['files'])) { continue; } foreach ($fileMeta['files'] as $fileName) { $data = GetFromFile("{$path}/{$fileName}", false); $d = getFirstLine("{$path}/{$fileName}", $testHeader, true); if ($d === false) { continue; } $file = fopen("{$path}/{$fileName}", "r"); $keys = fgetcsv($file, 0, $d); if ($category !== 'Final_Questions') { $extraFileMeta[$category]['Columns'] += array_flip($keys); } while (($line = fgetcsv($file, 0, $d)) !== false) { $row = array_combine_safely($keys, $line); if (!isset($IDs[$row['ID']])) { continue; } // if we don't have output from this person, we don't use any of their data
<?php /* Collector A program for running experiments on the web Copyright 2012-2015 Mikey Garcia & Nate Kornell */ require 'initiateCollector.php'; // if this is the first time on FinalQuestions.php then load questions from file if (isset($_SESSION['FinalQs']) == false) { $fQ = GetFromFile($_PATH->get('Final Questions')); // loop that deletes trailing empty positions from $fQ array for ($i = count($fQ) - 1; $i > 0; $i--) { if ($fQ[$i] == null) { unset($fQ[$i]); } else { break; } } $_SESSION['FinalQs'] = $fQ; $_SESSION['FQpos'] = 2; } // setting up aliases (makes all later code easier to read) $allFQs =& $_SESSION['FinalQs']; $pos =& $_SESSION['FQpos']; $FQ =& $allFQs[$pos]; // all info about current final question $Q = $FQ['Question']; // the question on this trial $type = trim(strtolower($FQ['Type'])); // type of question to display for this trial (i.e, likert, text, radio, checkbox) $options = array();