예제 #1
0
 /**
  * Service endpoint for data web service.
  * Determines whether one-time or temporal data is requested
  * and returns the data in JSON format
  *
  */
 public function data($user, $project_id, $redcap_url, $id, $fields)
 {
     if (in_array($project_id, array_keys(Constants::$pidfiles))) {
         // Instantiate new ConfigDAO to hold information from configuration file
         $config = new ConfigDAO(Constants::$pidfiles[$project_id]);
         $configarr = $config->getConfiguration();
         // Pass this information into the dictionary to return the
         // items of interest from the dictionary
         $dict = new FieldDictionary($project_id, $id, $fields, $configarr[$project_id]);
         $configdict = $dict->getDictionary();
         // Get the JSON for these fields
         $a = $this->getJSON($configdict);
         return $a;
     } else {
         throw new Exception("Sorry, your project is unsupported by DDP at this time.");
     }
 }
예제 #2
0
<?php

/*
 * Tests correctness of metadata web service.
 */
while (!file_exists('utils')) {
    chdir('..');
}
include_once 'utils/db_connect.php';
include_once 'utils/constants.php';
include_once 'exceptions/unsupportedprojectexception.php';
include_once 'fields/redcapfieldformatter.php';
include_once 'dao/ConfigDAO.php';
include_once 'fields/field_dict.php';
$project_id = "1073";
$meta = array();
// Instantiate new ConfigDAO to hold information from configuration file
$config = new ConfigDAO(Constants::$pidfiles[$project_id]);
$configarr = $config->getConfiguration();
foreach ($configarr as $key => $value) {
    foreach ($value as $k => $v) {
        $meta[] = $v;
    }
}
echo json_encode($meta);