/** Returns relation id's per experiment as an array. */
 public function get_relation_ids_by_experiment($experiment_id, $relation_type, $reversed = FALSE)
 {
     $this->db->where('relation', $relation_type);
     $this->db->where($reversed ? 'rel_exp_id' : 'experiment_id', $experiment_id);
     $relations = $this->db->get('relation')->result();
     return get_object_ids($relations, $reversed ? 'experiment_id' : 'rel_exp_id');
 }
 /** Returns all participations that have been confirmed, but no other action has been taken */
 public function get_confirmed_participations($experiments = array())
 {
     if ($experiments) {
         $this->db->where_in('experiment_id', get_object_ids($experiments));
     }
     $this->db->where(array('confirmed' => 1, 'cancelled' => 0, 'noshow' => 0, 'completed' => 0));
     return $this->db->get('participation')->result();
 }
    public function table_by_experiment($experiment_id = NULL, $weeks_ahead = WEEKS_AHEAD)
    {
        $experiment = $this->experimentModel->get_experiment_by_id($experiment_id);
        $participants = $this->participantModel->find_participants($experiment, $weeks_ahead);
        $participant_ids = get_object_ids($participants);
        $this->datatables->select('CONCAT(firstname, " ", lastname) AS p, dateofbirth, dateofbirth as age, dyslexicparent, multilingual, phone,
			lastcalled, participant.id AS id', FALSE);
        $this->datatables->from('participant');
        // Don't split this in two lines, see https://github.com/EllisLab/CodeIgniter/pull/759
        $this->datatables->join('participation', 'participation.participant_id = participant.id AND participation.experiment_id = ' . $experiment_id, 'left');
        if (empty($participant_ids)) {
            $this->datatables->where('participant.id', 0);
        } else {
            $this->datatables->where('participant.id IN (' . implode(',', $participant_ids) . ')');
        }
        $this->datatables->edit_column('p', '$1', 'participant_get_link_by_id(id)');
        $this->datatables->edit_column('dateofbirth', '$1', 'dob(dateofbirth)');
        $this->datatables->edit_column('age', '$1', 'age_in_months_and_days(age)');
        $this->datatables->edit_column('dyslexicparent', '$1', 'img_tick(dyslexicparent)');
        $this->datatables->edit_column('multilingual', '$1', 'img_tick(multilingual)');
        $this->datatables->edit_column('lastcalled', '$1', 'last_called(id, ' . $experiment_id . ')');
        $this->datatables->edit_column('id', '$1', 'participant_call_actions(id, ' . $experiment_id . ', ' . $weeks_ahead . ')');
        echo $this->datatables->generate();
    }
 /** Returns all experiment id's for a leader */
 public function get_experiment_ids_by_leader($user_id)
 {
     $leaders = $this->get_leaders_by_user($user_id);
     return get_object_ids($leaders, 'experiment_id');
 }
 public function table_without_leader()
 {
     $experiment_ids = get_object_ids($this->leaderModel->get_experiments_without_leaders());
     if ($experiment_ids) {
         $this->datatables->where('id IN (' . implode(',', $experiment_ids) . ')');
     } else {
         $this->datatables->where('id IN (NULL)');
     }
     $this->table();
 }
 /** Returns all experiments with these locations */
 public function get_experiments_by_locations($location_ids)
 {
     $this->db->where_in('location_id', $location_ids);
     return get_object_ids($this->db->get('experiment')->result());
 }
 /** Returns the total score (an array) for a testcat per participant */
 public function total_score_per_testinvite($testcat_id)
 {
     // If a testCat has children, select the scores of its children
     $testcat_ids = $testcat_id;
     if ($this->has_children($testcat_id)) {
         $testcat_ids = get_object_ids($this->get_children($testcat_id));
     }
     $this->db->select('testinvite_id');
     $this->db->select_sum('score');
     $this->db->select_max('date');
     $this->db->where_in('testcat_id', $testcat_ids);
     $this->db->group_by('testinvite_id');
     return $this->db->get('score')->result();
 }
 function testcat_score_boxplot($testcat_id)
 {
     $CI =& get_instance();
     $scores = $CI->scoreModel->get_scores_by_testcat($testcat_id);
     $score_array = get_object_ids($scores, 'score');
     return '<div class="boxplot">' . implode(',', $score_array) . '</div>';
 }
 public function table_by_experiment($experiment_id)
 {
     $participant_ids = get_object_ids($this->experimentModel->get_participants_by_experiment($experiment_id, TRUE));
     if (empty($participant_ids)) {
         $this->datatables->where('participant.id', 0);
     } else {
         $this->datatables->where('participant.id IN (' . implode(',', $participant_ids) . ')');
     }
     $this->table();
 }
Exemple #10
0
 private function get_testcat_ids($test_code)
 {
     $test = $this->testModel->get_test_by_code($test_code);
     $testcats = $this->testCatModel->get_testcats_by_test($test->id, TRUE);
     return get_object_ids($testcats);
 }