/** Specifies the content of a page with the contents for a specific participant */ public function participant($participant_id) { $participant = $this->participantModel->get_participant_by_id($participant_id); // Check validity of participant if (empty($participant)) { $data['error'] = sprintf(lang('not_authorized')); $this->load->view('templates/error', $data); return; } create_impediment_table(); $data['ajax_source'] = 'impediment/table/0/' . $participant_id; $data['page_title'] = sprintf(lang('impediments_for'), name($participant)); $this->load->view('templates/header', $data); $this->load->view('templates/list_view', $data); $this->load->view('templates/footer'); }
/** * * Shows the page for calling a participant * @param integer $participant_id * @param integer $experiment_id * @param integer $weeks_ahead */ public function call($participant_id, $experiment_id, $weeks_ahead = WEEKS_AHEAD) { // Retrieve entities $participant = $this->participantModel->get_participant_by_id($participant_id); $experiment = $this->experimentModel->get_experiment_by_id($experiment_id); // Check current user is caller for experiment if (!$this->callerModel->is_caller_for_experiment(current_user_id(), $experiment_id)) { $data['error'] = sprintf(lang('not_caller'), $experiment->name); $this->load->view('templates/error', $data); return; } // Check current participant is callable for experiment if (!in_array($participant, $this->participantModel->find_participants($experiment, $weeks_ahead))) { $data['error'] = sprintf(lang('not_callable_for'), name($participant), $experiment->name); $this->load->view('templates/error', $data); return; } // Check current participant is not being called if ($this->participationModel->is_locked_participant($participant_id, $experiment_id)) { $data['error'] = sprintf(lang('in_conversation'), name($participant)); $this->load->view('templates/error', $data); return; } // Retrieve links $comments = $this->commentModel->get_comments_by_participant($participant_id); $impediments = $this->impedimentModel->get_impediments_by_participant($participant_id); $experiments = $this->experimentModel->get_experiments_by_participant($participant_id); $participations = $this->participationModel->get_participations_by_experiment($experiment_id); $leaders = $this->leaderModel->get_leader_users_by_experiments($experiment_id); $first_visit = count($this->participationModel->get_participations_by_participant($participant_id, TRUE)) == 0; // Retrieve or create participation record $participation = $this->participationModel->get_participation($experiment_id, $participant_id); if ($participation) { $participation_id = $participation->id; } else { $participation_id = $this->participationModel->create_participation($experiment, $participant); $participation = $this->participationModel->get_participation_by_id($participation_id); } // Find the previous call (if is exists) $previous_call = $this->callModel->last_call($participation_id); // Lock the participation record $this->participationModel->lock($participation_id); // Create call record $call_id = $this->callModel->create_call($participation_id); // Find possible combined experiment, first check combinations $combinations = $this->relationModel->get_relation_ids_by_experiment($experiment->id, RelationType::Combination); $comb_exp = $combinations ? $this->experimentModel->get_experiment_by_id($combinations[0]) : FALSE; if (!$comb_exp) { // Then check prerequisites $prereqs = $this->relationModel->get_relation_ids_by_experiment($experiment->id, RelationType::Prerequisite); $comb_exp = $prereqs ? $this->experimentModel->get_experiment_by_id($prereqs[0]) : FALSE; } // Check if participation to combined experiment already exists $comb_part = $comb_exp ? $this->participationModel->get_participation($comb_exp->id, $participant_id) : FALSE; if ($comb_part) { $comb_exp = FALSE; } $comb_leaders = $comb_exp ? $this->leaderModel->get_leader_users_by_experiments($comb_exp->id) : array(); // Create page data $data = get_min_max_days($participant, $experiment); $data['participant'] = $participant; $data['experiment'] = $experiment; $data['participation'] = $participation; $data['participation_id'] = $participation_id; $data['leaders'] = leader_options($leaders); $data['call_id'] = $call_id; $data['previous_call'] = $previous_call; $data['comment_size'] = count($comments); $data['impediment_table'] = create_impediment_table($impediments); $data['impediment_size'] = count($impediments); $data['last_experiment'] = $this->participantModel->last_experiment($participant_id); $data['last_called'] = $this->participantModel->last_called($participant_id); $data['nr_participations'] = count($participations); $data['verify_languages'] = language_check($participant); $data['verify_dyslexia'] = dyslexia_check($participant); $data['first_visit'] = $first_visit; $data['combination_exp'] = $comb_exp; $data['combination_leaders'] = leader_options($comb_leaders); $data['page_title'] = sprintf(lang('call_participant'), name($participant)); $this->load->view('templates/header', $data); $this->load->view('participation_call', $data); $this->load->view('templates/footer'); }
create_dyslexia_table('dyslexia'); $dyslexia['id'] = 'dyslexia'; $dyslexia['ajax_source'] = 'dyslexia/table_by_participant/' . $participant->id; $this->load->view('templates/list_view', $dyslexia); } echo '</div>'; } ?> <!-- Impediments --> <?php echo heading(lang('impediments') . ' (' . $impediment_size . ')', 3); ?> <div> <?php create_impediment_table('impediments'); $impediments['id'] = 'impediments'; $impediments['ajax_source'] = 'impediment/table/1/' . $participant->id; echo $this->load->view('templates/list_view', $impediments); echo $this->load->view('impediment_add_view', $impediments); ?> </div> <!-- Comments --> <?php echo heading(lang('comments') . ' (' . $comment_size . ')', 3); ?> <div> <?php create_comment_table('comments'); $comments['id'] = 'comments';