/** * Initialize all of the class variables and things required from the * REQUEST. * * @return none, but as a side-effect modifies class */ function initialize() { ob_start('ob_gzhandler'); $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize(); $this->caller =& NDB_Caller::singleton(); $this->caller->setDataEntryType('Direct'); if (empty($_REQUEST['key'])) { throw new Exception("Missing parameter", 403); } $this->key = $_REQUEST['key']; $DB = Database::singleton(); $this->TestName = $DB->pselectOne("SELECT Test_name FROM participant_accounts\n WHERE OneTimePassword=:key AND Status <> 'Complete'", array('key' => $this->key)); $this->CommentID = $DB->pselectOne("SELECT CommentID FROM participant_accounts \n WHERE OneTimePassword=:key AND Status <> 'Complete'", array('key' => $this->key)); $this->NumPages = $DB->pselectOne("SELECT COUNT(*) FROM instrument_subtests WHERE Test_name=:TN", array('TN' => $this->TestName)); if (empty($this->TestName) && empty($this->CommentID)) { throw new Exception("Data has already been submitted.", 403); } $pageNum = null; if (!empty($_REQUEST['pageNum'])) { $pageNum = $_REQUEST['pageNum']; } if ($pageNum === 'finalpage') { $this->Subtest = 'finalpage'; } else { $this->Subtest = $DB->pselectOne("SELECT Subtest_name\n FROM instrument_subtests\n WHERE Test_name=:TN AND Order_number=:PN", array('TN' => $this->TestName, 'PN' => $pageNum)); } $totalPages = $DB->pselectOne("SELECT COUNT(*)+1 from instrument_subtests WHERE Test_name=:TN", array('TN' => $this->TestName)); $this->NextPageNum = $this->getNextPageNum($pageNum); $this->PrevPageNum = $this->getPrevPageNum($pageNum); $this->CommentID = $this->getCommentID(); $this->tpl_data = array('nextpage' => $this->NextPageNum, 'prevpage' => $this->PrevPageNum, 'pageNum' => $pageNum ? $pageNum + 1 : 1, 'totalPages' => $totalPages, 'key' => $this->key); }
function setUp() { $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize(); $this->DB = Database::singleton(); $this->DB->setFakeTableData("test_names", array(array('ID' => 1, 'Test_name' => 'ActiveTestByAge', 'Full_name' => 'Active Test 1', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 2, 'Test_name' => 'ActiveTestByAge2', 'Full_name' => 'Active Test 2', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 3, 'Test_name' => 'InactiveTest', 'Full_name' => 'Inactive Test 1', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 4, 'Test_name' => 'ActiveTestByVisit', 'Full_name' => 'Active Test by Visit 1', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 5, 'Test_name' => 'ActiveTestByVisit2', 'Full_name' => 'Active Test by Visit 2', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 6, 'Test_name' => 'ActiveTestByFirstVisit', 'Full_name' => 'Active Test by First Visit 2', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 7, 'Test_name' => 'ActiveTestByNotFirstVisit', 'Full_name' => 'Active Test by Not First Visit 2', 'Sub_group' => 1, 'IsDirectEntry' => 0))); $this->DB->setFakeTableData("test_battery", array(array('ID' => 1, 'Test_name' => 'ActiveTestByAge', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => null, 'firstVisit' => null), array('ID' => 2, 'Test_name' => 'ActiveTestByAge2', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => '1', 'firstVisit' => null), array('ID' => 3, 'Test_name' => 'InactiveTest', 'AgeMinDays' => 0, 'AgeMaxDays' => 0, 'Active' => 'N', 'Stage' => 'Visit', 'SubprojectID' => 2, 'Visit_label' => 'V01', 'CenterID' => '1', 'firstVisit' => null), array('ID' => 4, 'Test_name' => 'ActiveTestByVisit', 'AgeMinDays' => 0, 'AgeMaxDays' => 0, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 2, 'Visit_label' => 'V01', 'CenterID' => null, 'firstVisit' => null), array('ID' => 5, 'Test_name' => 'ActiveTestByVisit2', 'AgeMinDays' => 0, 'AgeMaxDays' => 0, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 2, 'Visit_label' => 'V01', 'CenterID' => '1', 'firstVisit' => null), array('ID' => 6, 'Test_name' => 'ActiveTestByFirstVisit', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => '1', 'firstVisit' => 'Y'), array('ID' => 7, 'Test_name' => 'ActiveTestByNotFirstVisit', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => '1', 'firstVisit' => 'N'))); }
function testSetFakeData() { $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize(); $DB = Database::singleton(); $DB->setFakeTableData("Config", array(0 => array('ID' => 99999, 'ConfigID' => '123456', 'Value' => 'FKE1234'))); $allCandidates = $DB->pselect("SELECT * FROM Config", array()); $this->assertEquals($allCandidates, array(0 => array('ID' => 99999, 'ConfigID' => 123456, 'Value' => 'FKE1234'))); }
/** * Validates the data which was passed in the request. * * @param string $method The HTTP method of the request * @param array $data The array-encode JSON posted to * the URL. */ function __construct($method, $data = array()) { $this->AllowedMethods = array('POST'); $this->RequestData = $data; if (!in_array($method, $this->AllowedMethods)) { $this->header("HTTP/1.1 405 Method Not Allowed"); $this->header("Allow: " . join(", ", $this->AllowedMethods)); $this->safeExit(0); } $client = new \NDB_Client(); // Bypass session handling because we're trying to authenticate a session $client->makeCommandLine(); $client->initialize(__DIR__ . "/../../../project/config.xml"); $this->HTTPMethod = $method; $this->handleRequest(); }
<?php /** * User: Stella * Date: 15-08-15 * * Project Statistics - Updating Counts From Each LORIS */ set_include_path(get_include_path() . ":../php/libraries:"); require_once __DIR__ . "/../vendor/autoload.php"; $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize('../project/config.xml'); $db =& Database::singleton(); $config = NDB_Config::singleton(); $date = date("m_d_Y"); $output_file = "project_statistics_{$date}.csv"; $fp = fopen($output_file, 'w'); echo "PROJECT STATISTICS SCRIPT - {$date}\n\n"; echo "Data can be found in {$output_file}.\n\n"; $headers = array('Project', 'Number of Scanning - Visits', 'Number of Sites', 'Variable Count', 'Number of instruments', 'total number of visits (for all candidates)', 'number of candidates', 'GB of imaging data (raw and processed)', '# of scans'); $counter = 0; // Where project's statistics will be stored $project_statistics = array(); // Project name $projectname = $config->getSetting('title'); // Number of Scanning - Visits $number_scanning_visits = $db->pselect("select count(*) from session where Scan_done='Y'", array()); // Number of Sites $number_sites = $db->pselect("select count(*) from psc WHERE CenterID <>1", array()); // Variable Count
* php data_dictionary_builder.php * * PHP Version 5 * * @category Behavioural * @package Main * @author Loris Team <*****@*****.**> * @license Loris License * @link https://github.com/aces/Loris */ set_include_path(get_include_path() . ":../project/libraries:../php/libraries:"); require_once __DIR__ . "/../vendor/autoload.php"; $configFile = "../project/config.xml"; $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize($configFile); $DB = Database::singleton(); // define which configuration file we're using for this installation //Get the entries we already have in the DB getColumns("Select Name, ParameterTypeID from parameter_type", $DB, $parameter_types); //Delete in the parameter_type table relating to //parameter_type_category.Type = 'Instrument', without affecting other entries. //get parameter_type_category.Type ='Instrument' ParamenterTypeCategoryIDs getColumn("SELECT ParameterTypeCategoryID\n FROM parameter_type_category\n WHERE Type = 'Instrument'", $DB, $instrumentParameterTypeCategoryIDs); $instrumentParameterTypeCategoryIDString = implode(', ', $instrumentParameterTypeCategoryIDs); //get all 'Instrument' ParameterTypeIDs getColumn("SELECT ParameterTypeID\n FROM parameter_type_category_rel\n WHERE ParameterTypeCategoryID\n IN ({$instrumentParameterTypeCategoryIDString})", $DB, $instrumentParameterTypeIDs); $instrumentParameterTypeIDString = implode(', ', $instrumentParameterTypeIDs); //delete all 'Instrument' entries from parameter_type_category_rel $DB->run("DELETE FROM parameter_type_category_rel\n WHERE ParameterTypeID in ({$instrumentParameterTypeIDString})"); //delete all 'Instrument' entries from parameter_type_category
<?php /** * inititalize */ set_include_path(get_include_path() . ":../php/libraries:"); require_once __DIR__ . "/../vendor/autoload.php"; require_once "NDB_Client.class.inc"; require_once "NDB_Config.class.inc"; require_once "Utility.class.inc"; require_once "NDB_BVL_Instrument.class.inc"; $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize("../project/config.xml"); $config = NDB_Config::singleton(); $db =& Database::singleton(); if (PEAR::isError($db)) { fwrite(STDERR, "Could not connect to database: " . $db->getMessage()); return false; } $database = $config->getSetting('database'); // This was required when there was incorrect html in the fields, but now we // can just populate empty ones without deleting old ones //$db->select("SELECT TABLE_NAME FROM information_schema.columns WHERE TABLE_SCHEMA='$database[database]' AND COLUMN_NAME='Candidate_Age'", $tables); //foreach($tables as $table) { //print "Emptying $table[TABLE_NAME]\n"; //$db->run("UPDATE $table[TABLE_NAME] SET Candidate_Age=NULL"); /* $t = $table['TABLE_NAME']; $db->select("SELECT i.CommentID, i.Date_taken, c.DoB FROM $t i JOIN flag f USING(CommentID)
<?php /* This is used by the stats page to get the list of scorable columns for an * instrument via AJAX. It's used so that ScatterPlot-SVG.php can be run for * any scorable in an instrument, dynamically */ ini_set('default_charset', 'utf-8'); require_once "Database.class.inc"; require_once 'NDB_Config.class.inc'; require_once 'NDB_Client.class.inc'; $config =& NDB_Config::singleton(); $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize(); require_once "Utility.class.inc"; $cols = Utility::getScoreColsForInstrument($_REQUEST['instrument']); if (strrpos($_REQUEST['instrument'], "_proband") === false) { print "Candidate_Age\n"; } foreach ($cols as $val) { print "{$val}\n"; }
<?php $user =& User::singleton(); if (!$user->hasPermission('dataquery_view')) { header("HTTP/1.1 403 Forbidden"); exit; } require_once __DIR__ . '/../../../vendor/autoload.php'; $client = new NDB_Client(); $client->makeCommandLine(); $client->initialize(__DIR__ . "/../../../project/config.xml"); $cdb = CouchDB::singleton(); $category = $_REQUEST['category']; $results = $cdb->queryView("DQG-2.0", "datadictionary", array("reduce" => "false", "startkey" => "[\"{$category}\"]", "endkey" => "[\"{$category}\", \"ZZZZZZZZ\"]")); print json_encode($results);
* @link https://www.github.com/aces/Loris/ */ if (isset($_SERVER['HTTP_ORIGIN'])) { header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']); header("Access-Control-Allow-Credentials: true"); } set_include_path(get_include_path() . ":../project/libraries:../php/libraries:"); require_once __DIR__ . "/../vendor/autoload.php"; ini_set('default_charset', 'utf-8'); ob_start('ob_gzhandler'); // Create an output buffer to capture console output, separately from the // gzip handler. ob_start(); // load the client $client = new NDB_Client(); if ($client->initialize() == false) { return false; } // require additional libraries $TestName = isset($_REQUEST['test_name']) ? $_REQUEST['test_name'] : 'dashboard'; $subtest = isset($_REQUEST['subtest']) ? $_REQUEST['subtest'] : ''; // make local instances of objects $config =& NDB_Config::singleton(); //-------------------------------------------------- /** * Extracts a parameter from request in a safe way, * and sets the $tpl_data to said request. If request does * not contain parameter, will set the smarty variable to * empty * * @param string $param The $_REQUEST parameter to convert to a smarty variable