/php/lib/export_manager/component/survey_excel_percentage_exporter.class.php
PHP | 569 lines | 407 code | 130 blank | 32 comment | 20 complexity | 3e5c928c082d8baeddc887aa9dd9afd5 MD5 | raw file
- <?php
- namespace application\survey;
-
- use repository\content_object\survey\SurveyAnalyzer;
-
- use repository\content_object\survey\SurveyTemplateUser;
-
- use repository\content_object\survey\SurveyContextRelUser;
-
- use repository\content_object\survey\SurveyContextDataManager;
-
- use repository\content_object\survey\SurveyContext;
-
- use repository\content_object\survey_multiple_choice_question\SurveyMultipleChoiceQuestion;
- use repository\content_object\survey_matrix_question\SurveyMatrixQuestion;
-
- use tracking\Tracker;
- use reporting\ReportingData;
- use group\GroupDataManager;
-
- use common\libraries\AndCondition;
- use common\libraries\EqualityCondition;
- use common\libraries\InCondition;
- use common\libraries\Translation;
- use common\libraries\Utilities;
- use common\libraries\Request;
- use common\libraries\Path;
-
- use PHPExcel;
- use PHPExcel_Style_Alignment;
- use PHPExcel_IOFactory;
-
- ini_set("memory_limit", "-1");
- ini_set("max_execution_time", "0");
-
- require_once Path :: get_plugin_path() . 'phpexcel/PHPExcel.php';
-
- class SurveyExportManagerSurveyExcelPercentageExporterComponent extends SurveyExportManager
- {
-
- const COUNT = 'count';
- const TOTAL = 'total';
- const NOT_STARTED_PARTICIPANTS = 'not_started_participants';
- const STARTED_PARTICIPANTS = 'started_participants';
- const ALL_PARTICIPANTS = 'all_participants';
- const NOT_STARTED_PARTICIPANT_COUNT = 'not_started_participant_count';
- const STARTED_PARTICIPANT_COUNT = 'started_participant_count';
- const ALL_PARTICIPANT_COUNT = 'all_participant_count';
- const CONTEXTS = 'groups';
- const CONTEXT_NAME = 'group_name';
- const CONTEXT_DESCRIPTION = 'group_description';
- const INDIVIDUAL_USERS = 'individual_users';
- const USERS = 'users';
- const PARTICIPATION_GRADE = 'participation_grade';
- const SURVEYS = 'surveys';
- const SURVEY_NAME = 'survey_name';
- const SURVEY_DESCRIPTION = 'survey_description';
- const SURVEY_COUNT = 'survey_count';
- const REPORTING_DATA = 'reporting_data';
- const DATA_NAME = 'data_name';
- const DATA_DESCRIPTION = 'data_description';
- const DATA_GROUP = 'data_group';
-
- private $participants;
- private $surveys;
-
- /**
- * Runs this component and displays its output.
- */
-
- function run()
- {
- $id = Request :: get(SurveyManager :: PARAM_PUBLICATION_ID);
-
- // if (! is_array($ids))
- // {
- // $ids = array($ids);
- // }
- $this->create_participants($id);
-
- $this->render_data();
-
- }
-
- public function render_data()
- {
- $excel = new PHPExcel();
-
- $worksheet = $excel->getSheet(0)->setTitle('Algemeen');
- $this->render_summary_data($worksheet);
-
- $complex_questions = $this->get_questions();
- $worksheet_index = 1;
-
- foreach ($complex_questions as $complex_question_id => $complex_question)
- {
-
- $question = $complex_question->get_ref_object();
- $title = Utilities :: truncate_string(trim(strip_tags($question->get_title())), 15, true, '');
- $worksheet = $excel->createSheet($worksheet_index)->setTitle($title);
- $worksheet = $excel->getSheet($worksheet_index);
- $page_reporting_data = $this->create_page_reporting_data($complex_question, $question);
- $this->render_page_data($worksheet, $page_reporting_data);
- $worksheet_index ++;
- }
-
- exit();
-
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="' . 'survey_export' . '.xlsx"');
- header('Cache-Control: max-age=0');
- $objWriter = PHPExcel_IOFactory :: createWriter($excel, 'Excel2007');
- return $objWriter->save('php://output');
- }
-
- private function get_questions()
- {
-
- $page_questions = array();
- $surveys = $this->surveys;
-
- foreach ($surveys as $survey)
- {
- $complex_questions = $survey->get_complex_questions();
- }
-
- return $complex_questions;
-
- }
-
- private function render_summary_data($worksheet)
- {
-
- $column = 1;
- $row = 3;
-
- $worksheet->getColumnDimensionByColumn($column)->setWidth(20);
- $worksheet->getColumnDimensionByColumn($column + 1)->setWidth(20);
- $worksheet->getColumnDimensionByColumn($column + 2)->setWidth(20);
- $worksheet->getColumnDimensionByColumn($column + 3)->setWidth(20);
- $worksheet->getColumnDimensionByColumn($column + 4)->setWidth(5);
- $worksheet->getColumnDimensionByColumn($column + 5)->setWidth(200);
-
- $surveys = $this->participants[self :: SURVEYS];
-
- $worksheet->setCellValueByColumnAndRow($column, $row, Translation :: get('SurveyName'));
- $worksheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, Translation :: get('SurveyDescription'));
- $worksheet->getStyleByColumnAndRow($column + 1, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column + 1, $row)->getFont()->setBold(true);
- $row ++;
-
- foreach ($surveys as $survey)
- {
- $title = $survey[self :: SURVEY_NAME];
- $worksheet->setCellValueByColumnAndRow($column, $row, $title);
- $this->wrap_text($worksheet, $column, $row);
- $description = $survey[self :: SURVEY_DESCRIPTION];
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, $description);
- $this->wrap_text($worksheet, $column, $row);
- $row ++;
- }
-
- $row = $row + 2;
- $all_participants = $this->participants[self :: ALL_PARTICIPANT_COUNT];
- $worksheet->setCellValueByColumnAndRow($column, $row, 'Aantal participanten');
- $worksheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
-
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, $all_participants);
- $row ++;
- $started = $this->participants[self :: STARTED_PARTICIPANT_COUNT];
- $worksheet->setCellValueByColumnAndRow($column, $row, 'Deelgenomen');
- $worksheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
-
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, $started);
- $row ++;
- $not_started = $this->participants[self :: NOT_STARTED_PARTICIPANT_COUNT];
- $worksheet->setCellValueByColumnAndRow($column, $row, 'Niet deelgenomen');
- $worksheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
-
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, $not_started);
- $row ++;
- $participatie = $this->participants[self :: PARTICIPATION_GRADE];
- $worksheet->setCellValueByColumnAndRow($column, $row, 'Participatigraad (%)');
- $worksheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
-
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, $participatie);
- $row = $row + 2;
-
- $worksheet->setCellValueByColumnAndRow($column, $row, 'Aantal participanten');
- $worksheet->getStyleByColumnAndRow($column, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $row)->getFont()->setBold(true);
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, 'Deelgenomen');
- $worksheet->getStyleByColumnAndRow($column + 1, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column + 1, $row)->getFont()->setBold(true);
- $worksheet->setCellValueByColumnAndRow($column + 2, $row, 'Niet deelgenomen');
- $worksheet->getStyleByColumnAndRow($column + 2, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column + 2, $row)->getFont()->setBold(true);
- $worksheet->setCellValueByColumnAndRow($column + 3, $row, 'Participatie (%)');
- $worksheet->getStyleByColumnAndRow($column + 3, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column + 3, $row)->getFont()->setBold(true);
- $worksheet->setCellValueByColumnAndRow($column + 5, $row, 'Groepen');
- $worksheet->getStyleByColumnAndRow($column + 5, $row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column + 5, $row)->getFont()->setBold(true);
-
- $row = $row + 2;
-
- $groups = $this->participants[self :: GROUPS];
-
- foreach ($groups as $group_id => $group)
- {
- // $name = $this->participants[self :: GROUPS][$group_id][self :: GROUP_NAME];
-
-
- $all_participant_count = $group[self :: ALL_PARTICIPANT_COUNT];
- $worksheet->setCellValueByColumnAndRow($column, $row, $all_participant_count);
-
- $started_participant_count = $group[self :: STARTED_PARTICIPANT_COUNT];
- $worksheet->setCellValueByColumnAndRow($column + 1, $row, $started_participant_count);
-
- $not_started_participant_count = $group[self :: NOT_STARTED_PARTICIPANT_COUNT];
- $worksheet->setCellValueByColumnAndRow($column + 2, $row, $not_started_participant_count);
-
- $participatie = $group[self :: PARTICIPATION_GRADE];
- $worksheet->setCellValueByColumnAndRow($column + 3, $row, $participatie);
-
- $description = $group[self :: GROUP_DESCRIPTION];
- $worksheet->setCellValueByColumnAndRow($column + 5, $row, $description);
- $row ++;
- }
-
- }
-
- private function render_page_data($worksheet, $data)
- {
-
- $column = 0;
- $block_row = 0;
-
- $worksheet->getColumnDimensionByColumn($column)->setWidth(50);
- $column_count = 1;
- while ($column_count < 7)
- {
- $worksheet->getColumnDimensionByColumn($column + $column_count)->setWidth(15);
- $column_count ++;
- }
-
- if (is_array($data))
- {
-
- foreach ($data as $block_data)
- {
-
- $column = 0;
- $block_row = $block_row + 2;
-
- $participant_group = $block_data[self :: DATA_GROUP];
- $participant_count = $block_data[self :: STARTED_PARTICIPANT_COUNT];
- $block_title = trim(html_entity_decode(strip_tags($block_data[self :: DATA_NAME])));
- $block_description = trim(html_entity_decode(strip_tags($block_data[self :: DATA_DESCRIPTION])));
- $block_content_data = $block_data[self :: REPORTING_DATA];
-
- $worksheet->setCellValueByColumnAndRow($column, $block_row, $participant_group);
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getFont()->setBold(true);
- $this->wrap_text($worksheet, $column, $block_row);
-
- $block_row ++;
- $worksheet->setCellValueByColumnAndRow($column, $block_row, 'Deelnemers');
- $worksheet->setCellValueByColumnAndRow($column + 1, $block_row, $participant_count);
- $worksheet->getStyleByColumnAndRow($column + 1, $block_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column + 1, $block_row)->getFont()->setBold(true);
-
- $block_row = $block_row + 2;
-
- $worksheet->setCellValueByColumnAndRow($column, $block_row, $block_title);
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getFont()->setBold(true);
- $this->wrap_text($worksheet, $column, $block_row);
-
- if ($block_description != '')
- {
- $block_row ++;
- $worksheet->setCellValueByColumnAndRow($column, $block_row, $block_description);
- $this->wrap_text($worksheet, $column, $block_row);
- $block_row ++;
- }
-
- $block_row ++;
-
- foreach ($block_content_data->get_rows() as $row_id => $row_name)
- {
- // dump($row_name);
- $column ++;
- $worksheet->getColumnDimensionByColumn($column)->setAutoSize(true);
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_CENTER);
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getFont()->setBold(true);
- $worksheet->setCellValueByColumnAndRow($column, $block_row, $this->transcode_string($row_name));
- $this->wrap_text($worksheet, $column, $block_row);
-
- }
-
- $block_row ++;
-
- $row_count = count($block_content_data->get_rows());
- $category_count = count($block_content_data->get_categories());
-
- $categrory_row_index = 1;
-
- // dump('row count: ' . $row_count);
- // dump('cat count: ' . $category_count);
-
-
- foreach ($block_content_data->get_categories() as $category_id => $category_name)
- {
- $column = 0;
-
- $worksheet->setCellValueByColumnAndRow($column, $block_row, $this->transcode_string($category_name));
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_LEFT);
- $this->wrap_text($worksheet, $column, $block_row);
-
- // dump('category row index: ' . $categrory_row_index);
- // dump('cat row: ' . $block_row);
- //
-
-
- if ($categrory_row_index == $category_count && $category_count != 1)
- {
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getFont()->setBold(true);
- }
-
- $row_index = 1;
- // dump('row index: ' . $row_index);
-
-
- foreach ($block_content_data->get_rows() as $row_id => $row_name)
- {
- $column ++;
- $value = $block_content_data->get_data_category_row($category_id, $row_id);
- $worksheet->setCellValueByColumnAndRow($column, $block_row, $this->transcode_string($value));
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment :: HORIZONTAL_CENTER);
- // dump('row index: ' . $row_index);
- // dump('row: ' . $block_row);
-
-
- if ($row_index == $row_count && $row_count != 1)
- {
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getFont()->setBold(true);
- }
-
- if ($categrory_row_index == $category_count && $category_count != 1)
- {
- $worksheet->getStyleByColumnAndRow($column, $block_row)->getFont()->setBold(true);
- }
-
- $row_index ++;
- }
- $categrory_row_index ++;
- $block_row ++;
- }
-
- // exit();
- }
-
- }
-
- }
-
- private function wrap_text($worksheet, $colum, $row)
- {
- $worksheet->getStyleByColumnAndRow($colum, $row)->getAlignment()->setWrapText(true);
-
- }
-
- private function create_page_reporting_data($complex_question, $question)
- {
- $page_reporting_data = array();
-
- $all_participants_ids = $this->participants[self :: ALL_PARTICIPANTS];
- // $reporting_data = $this->create_reporting_data($complex_question, $question, $all_participants_ids);
- $analyzer = SurveyAnalyzer :: factory(SurveyAnalyzer :: TYPE_PERCENTAGE, $question, $all_participants_ids[$complex_question->get_id()]);
- $reporting_data = $analyzer->analyse();
-
- $reporting_data_question = array();
- $reporting_data_question[self :: DATA_GROUP] = Translation :: get('AllGroups');
- $reporting_data_question[self :: DATA_NAME] = $question->get_title();
- $reporting_data_question[self :: DATA_DESCRIPTION] = $question->get_description();
- $reporting_data_question[self :: STARTED_PARTICIPANT_COUNT] = $this->participants[self :: STARTED_PARTICIPANT_COUNT];
- $reporting_data_question[self :: REPORTING_DATA] = $reporting_data;
- $page_reporting_data[] = $reporting_data_question;
-
- $groups = $this->participants[self :: GROUPS];
- foreach ($groups as $group)
- {
- $reporting_data_question = array();
- $reporting_data_question[self :: DATA_GROUP] = $group[self :: GROUP_DESCRIPTION];
- $reporting_data_question[self :: DATA_NAME] = $question->get_title();
- $reporting_data_question[self :: DATA_DESCRIPTION] = $question->get_description();
- $reporting_data_question[self :: STARTED_PARTICIPANT_COUNT] = $group[self :: STARTED_PARTICIPANT_COUNT];
- $all_participants_ids = $group[self :: ALL_PARTICIPANTS];
- // $reporting_data = $this->create_reporting_data($complex_question, $question, $all_participants_ids);
- $analyzer = SurveyAnalyzer :: factory(SurveyAnalyzer :: TYPE_PERCENTAGE, $question, $all_participants_ids[$complex_question->get_id()]);
- $reporting_data = $analyzer->analyse();
- $reporting_data_question[self :: REPORTING_DATA] = $reporting_data;
- $page_reporting_data[] = $reporting_data_question;
- }
-
- return $page_reporting_data;
- }
-
- private function create_participants($id)
- {
-
- $this->participants = array();
- $this->surveys = array();
-
- $surveys = array();
-
- $sv = array();
-
- $survey_publication = SurveyDataManager :: get_instance()->retrieve_survey_publication($id);
- $survey = $survey_publication->get_publication_object();
- $template_type = $survey->get_context_template()->get_type();
-
- $this->surveys[] = $survey;
- $survey_title = $survey->get_title();
- $survey_description = $survey->get_description();
- $sv[self :: SURVEY_NAME] = Utilities :: truncate_string(trim(strip_tags($survey_title)), 20, true, '');
- $sv[self :: SURVEY_DESCRIPTION] = Utilities :: truncate_string(trim(strip_tags($survey_description)), 20, true, '');
- $surveys[$id] = $sv;
-
- $this->participants[self :: SURVEYS] = $surveys;
- $this->participants[self :: SURVEY_COUNT] = count($surveys);
-
- $invitees = SurveyRights :: get_allowed_users(SurveyRights :: RIGHT_PARTICIPATE, $id, SurveyRights :: TYPE_PUBLICATION);
- $invitees = array_unique($invitees);
- $invitee_count = count($invitees);
-
- $started = array();
- $finished = array();
- $not_started = array();
-
- // $condition = new EqualityCondition(SurveyParticipantTracker :: PROPERTY_SURVEY_PUBLICATION_ID, $id);
- //
- // $trackers = Tracker :: get_data(SurveyParticipantTracker :: CLASS_NAME, SurveyManager :: APPLICATION_NAME, $condition);
- //
- $all_participants = array();
-
- $all_user_ids = array();
- // while ($tracker = $trackers->next_result())
- // {
- // $all_participants[] = $tracker->get_id();
- // $all_user_ids[]= $tracker->get_user_id();
- //
- // }
-
-
- $context_ids = array();
- $condition = new InCondition(SurveyQuestionAnswerTracker :: PROPERTY_PUBLICATION_ID, $id);
- $answer_trackers = Tracker :: get_data(SurveyQuestionAnswerTracker :: CLASS_NAME, SurveyManager :: APPLICATION_NAME, $condition);
- $context_user_ids = array();
- $answer_tracker_ids = array();
- while ($answer_tracker = $answer_trackers->next_result())
- {
- $context_id = $answer_tracker->get_context_id();
- $user_id = $answer_tracker->get_user_id();
- $context_user_ids[$context_id][] = $user_id;
- $context_ids[] = $context_id;
- $all_user_ids[] = $user_id;
- $all_participants[$answer_tracker->get_question_cid()][] = $answer_tracker->get_answer();
- $answer_tracker_ids[$context_id][$answer_tracker->get_question_cid()][] = $answer_tracker->get_answer();
- }
-
- $context_ids = array_unique($context_ids);
-
- $all_user_ids = array_unique($all_user_ids);
- $all_user_count = count($all_user_ids);
-
- $not_started = array_diff($invitees, $all_user_ids);
- $not_started_count = count(array_unique($not_started));
-
- $this->participants[self :: ALL_PARTICIPANTS] = $all_participants;
- $this->participants[self :: ALL_PARTICIPANT_COUNT] = $invitee_count;
- $this->participants[self :: NOT_STARTED_PARTICIPANT_COUNT] = $not_started_count;
- $this->participants[self :: STARTED_PARTICIPANT_COUNT] = $all_user_count;
-
- $participatie = $all_user_count / $invitee_count * 100;
- $participatie = number_format($participatie, 2);
- $this->participants[self :: PARTICIPATION_GRADE] = $participatie;
-
- $condition = new InCondition(SurveyContext :: PROPERTY_ID, $context_ids);
- $context = SurveyContextDataManager :: get_instance()->retrieve_survey_context_by_id($context_ids[0]);
- $type = $context->get_type();
- $groups = SurveyContextDataManager :: get_instance()->retrieve_survey_contexts($type, $condition);
-
- $all_users = array();
- $conditions = array();
- $tempate_user_alias = SurveyContextDataManager :: get_instance()->get_alias($template_type);
- $condition = new EqualityCondition(SurveyTemplateUser :: PROPERTY_TYPE, $template_type, SurveyTemplateUser :: get_table_name());
- $template_users = SurveyContextDataManager :: get_instance()->retrieve_survey_template_users($template_type, $condition);
- while ($template_user = $template_users->next_result())
- {
- $property_names = $template_user->get_additional_property_names();
- foreach ($property_names as $name)
- {
- $group_id = $template_user->get_additional_property($name);
- $all_users[$group_id][] = $template_user->get_user_id();
- }
- }
-
- while ($group = $groups->next_result())
- {
-
- $this->participants[self :: GROUPS][$group->get_id()][self :: GROUP_NAME] = $group->get_name();
- $this->participants[self :: GROUPS][$group->get_id()][self :: GROUP_DESCRIPTION] = $group->get_name();
-
- $all_group_users = array_unique($all_users[$group->get_id()]);
- $all_group_user_count = count($all_group_users);
-
- $group_users = $context_user_ids[$group->get_id()];
- $group_users = array_unique($group_users);
- $group_user_count = count($group_users);
-
- $conditions = array();
- $conditions[] = new InCondition(SurveyParticipantTracker :: PROPERTY_USER_ID, $group_users);
- $conditions[] = new InCondition(SurveyParticipantTracker :: PROPERTY_SURVEY_PUBLICATION_ID, $id);
- $condition = new AndCondition($conditions);
- $trackers = Tracker :: get_data(SurveyParticipantTracker :: CLASS_NAME, SurveyManager :: APPLICATION_NAME, $condition);
-
- $all_trackers = array();
- while ($tracker = $trackers->next_result())
- {
- $all_trackers[] = $tracker->get_id();
- }
-
- $all_tracker_count = count($all_trackers);
-
- $this->participants[self :: GROUPS][$group->get_id()][self :: ALL_PARTICIPANTS] = $answer_tracker_ids[$group->get_id()];
-
- $participatie = $group_user_count / $all_group_user_count * 100;
- $participatie = number_format($participatie, 2);
- $this->participants[self :: GROUPS][$group->get_id()][self :: PARTICIPATION_GRADE] = $participatie;
-
- $this->participants[self :: GROUPS][$group->get_id()][self :: ALL_PARTICIPANT_COUNT] = $all_group_user_count;
- $this->participants[self :: GROUPS][$group->get_id()][self :: STARTED_PARTICIPANT_COUNT] = $group_user_count;
- $this->participants[self :: GROUPS][$group->get_id()][self :: NOT_STARTED_PARTICIPANT_COUNT] = $all_group_user_count - $group_user_count;
-
- }
-
- // dump($this->participants);
- // exit;
- }
-
- function transcode_string($string)
- {
- $stripped_answer = trim(strip_tags(html_entity_decode($string, ENT_QUOTES, 'UTF-8')));
- $stripped_answer = str_replace(html_entity_decode(' ', ENT_COMPAT, 'UTF-8'), ' ', $stripped_answer);
- $stripped_answer = preg_replace('/[ \n\r\t]{2,}/', ' ', $stripped_answer);
- return $stripped_answer;
- }
-
- }
-
- ?>