continue; } // skip padding if (strtolower($row['Item']) === '*newsession*') { continue; } // skip multisession markers foreach ($trialTypeColumns as $postNumber => $column) { // check all trial levels $thisTrialType = strtolower($row[$column]); // which trial is being used at this level (e.g, Study, Test, etc.) if (isset($notTrials[$thisTrialType])) { // skip turned off trials (off, no, n/a, '') continue; } $trialFiles = getTrialTypeFiles($thisTrialType); $trialTypes[$thisTrialType]['files'] = $trialFiles; $trialTypes[$thisTrialType]['levels'][$postNumber] = true; // make note what levels each trial type are used at (e.g., Study is a regular AND a Post 1 trial) if ($trialFiles === false) { $procName = pathinfo($_FILES->proc_files . '/' . $_SESSION['Condition']['Procedure'], PATHINFO_FILENAME); $errors['Count']++; $errors['Details'][] = 'The trial type ' . $row[$column] . ' for row ' . $i . ' in ' . 'the procedure file ' . $procName . ' has no folder in ' . 'either the "' . $_FILES->custom_trial_types . '" folder or ' . 'the "' . $_FILES->trial_types . '" folder.'; } } } unset($procedure); ##### END Error Checking Code ################################################# ############################################################################### #### Preparing The Experiment ################################################# ###############################################################################
/** * Finds all trial types and their files * @return array */ function getAllTrialTypeFiles() { global $_PATH; $trialTypes = array(); $trialTypeDirs = array($_PATH->get('Custom Trial Types'), $_PATH->get('Trial Types')); foreach ($trialTypeDirs as $dir) { $dirScan = scandir($dir); foreach ($dirScan as $entry) { $type = strtolower(trim($entry)); if (isset($trialTypes[$type])) { continue; } // dont override custom trial types, found first $files = getTrialTypeFiles($type); if ($files !== false) { $trialTypes[strtolower($entry)] = $files; } } } return $trialTypes; }