Ejemplo n.º 1
0
 /**
  *
  * @return array data to be serialized
  */
 public function getData()
 {
     $data = array();
     if ($this->isChild()) {
         $data['parent'] = $this->_parent->getExperimentID();
     }
     if ($this->isMultiVar()) {
         $data['children'] = array_keys($this->_children);
     }
     $data['weightings'] = $this->getWeightings();
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * GetTreatmentID
  *
  * @param Scenario_Experiment $exp
  * @param string $treatmentname
  * @return int primary key (int) of the treatment in question
  */
 protected function GetTreatmentID(Scenario_Experiment $exp, $treatmentname)
 {
     $query = $this->getDbAdapter()->select()->from($this->treatmentsTable)->where('experiment_id = ?', $exp->getRowID())->where('name = ?', $treatmentname);
     $result = $this->getDbAdapter()->fetchRow($query);
     if ($result !== null) {
         return $result['id'];
     }
     return null;
 }
Ejemplo n.º 3
0
 /**
  * Add a treatment
  *
  * @param Scenario_Experiment $exp
  * @param string $treatmentname
  * @return bool Whether the operation was successful
  */
 protected function AddTreatment(Scenario_Experiment $exp, $treatmentname)
 {
     if (!is_string($treatmentname)) {
         /**
          * @see Scenario_Data_Exception
          */
         require_once 'Scenario/Data/Exception.php';
         throw new Scenario_Data_Exception('Treatment name must be a string.');
     }
     $sql = 'INSERT INTO `' . $this->treatmentsTable . '` (name,experiment_id) VALUES (?,?)';
     $result = $this->prepare($sql, array($treatmentname, $exp->getRowID()));
     return $result;
 }
Ejemplo n.º 4
0
 /**
  *
  * @param Scenario_Experiment $experiment
  * @return array 
  */
 private function _treatmentMatrix(Scenario_Experiment $experiment)
 {
     if ($experiment->isMultiVar()) {
         $tmp = array();
         foreach ($experiment->getChildren() as $cxp) {
             /* @var $cxp Scenario_Experiment */
             $tmp[$cxp->getExperimentID()] = array_keys($experiment->getWeightings());
         }
         if (count($tmp) == 0) {
             return array();
         }
         ksort($tmp);
         $out = array();
         foreach ($tmp[0] as $val) {
             $out[] = array($val);
         }
         if (count($tmp) == 1) {
             return $out;
         }
         for ($i = 1; $i < count($order); $i++) {
             $old = $out;
             $out = array();
             foreach ($tmp[$i] as $right) {
                 foreach ($old as $left) {
                     $out[] = array_merge($left, array($right));
                 }
             }
         }
         return $out;
     } else {
         $tmp = array_keys($experiment->getWeightings());
         $out = array();
         foreach ($tmp as $k) {
             $out[] = array($k);
         }
         return $out;
     }
 }