24 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
59 $this->
object =& $a_object;
67 $cmd = $this->ctrl->getCmd();
68 $next_class = $this->ctrl->getNextClass($this);
97 if ($rbacsystem->checkAccess(
"write",
$_GET[
"ref_id"]))
109 $surveycode = $this->
object->getUserAccessCode($ilUser->getId());
110 if ($this->object->isAnonymizedParticipant($surveycode))
115 $this->tpl->setVariable(
"TABS",
"");
116 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation_checkaccess.html",
"Modules/Survey");
117 $this->tpl->setCurrentBlock(
"adm_content");
118 $this->tpl->setVariable(
"AUTHENTICATION_NEEDED", $this->lng->txt(
"svy_check_evaluation_authentication_needed"));
119 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this,
"checkAnonymizedEvaluationAccess"));
120 $this->tpl->setVariable(
"EVALUATION_CHECKACCESS_INTRODUCTION", $this->lng->txt(
"svy_check_evaluation_access_introduction"));
121 $this->tpl->setVariable(
"VALUE_CHECK", $this->lng->txt(
"ok"));
122 $this->tpl->setVariable(
"VALUE_CANCEL", $this->lng->txt(
"cancel"));
123 $this->tpl->setVariable(
"TEXT_SURVEY_CODE", $this->lng->txt(
"survey_code"));
124 $this->tpl->parseCurrentBlock();
136 $surveycode =
$_POST[
"surveycode"];
137 if ($this->object->isAnonymizedParticipant($surveycode))
158 include_once
"./Services/Utilities/classes/class.ilUtil.php";
160 $path = $tree->getPathFull($this->object->getRefID());
179 $format_percent =
"";
180 $format_datetime =
"";
184 switch (
$_POST[
"export_format"])
187 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
190 switch (
$_POST[
'export_label'])
193 $adapter->setCellValue(0, $column, $this->lng->txt(
"label"),
CELL_FORMAT_BOLD);
196 $adapter->setCellValue(0, $column, $this->lng->txt(
"title"),
CELL_FORMAT_BOLD);
199 $adapter->setCellValue(0, $column, $this->lng->txt(
"title"),
CELL_FORMAT_BOLD);
201 $adapter->setCellValue(0, $column, $this->lng->txt(
"label"),
CELL_FORMAT_BOLD);
205 $adapter->setCellValue(0, $column, $this->lng->txt(
"question"),
CELL_FORMAT_BOLD);
207 $adapter->setCellValue(0, $column, $this->lng->txt(
"question_type"),
CELL_FORMAT_BOLD);
209 $adapter->setCellValue(0, $column, $this->lng->txt(
"users_answered"),
CELL_FORMAT_BOLD);
211 $adapter->setCellValue(0, $column, $this->lng->txt(
"users_skipped"),
CELL_FORMAT_BOLD);
213 $adapter->setCellValue(0, $column, $this->lng->txt(
"mode"),
CELL_FORMAT_BOLD);
215 $adapter->setCellValue(0, $column, $this->lng->txt(
"mode_text"),
CELL_FORMAT_BOLD);
217 $adapter->setCellValue(0, $column, $this->lng->txt(
"mode_nr_of_selections"),
CELL_FORMAT_BOLD);
219 $adapter->setCellValue(0, $column, $this->lng->txt(
"median"),
CELL_FORMAT_BOLD);
221 $adapter->setCellValue(0, $column, $this->lng->txt(
"arithmetic_mean"),
CELL_FORMAT_BOLD);
226 switch (
$_POST[
'export_label'])
229 array_push($csvrow, $this->lng->txt(
"label"));
232 array_push($csvrow, $this->lng->txt(
"title"));
235 array_push($csvrow, $this->lng->txt(
"title"));
236 array_push($csvrow, $this->lng->txt(
"label"));
239 array_push($csvrow, $this->lng->txt(
"question"));
240 array_push($csvrow, $this->lng->txt(
"question_type"));
241 array_push($csvrow, $this->lng->txt(
"users_answered"));
242 array_push($csvrow, $this->lng->txt(
"users_skipped"));
243 array_push($csvrow, $this->lng->txt(
"mode"));
248 array_push($csvrow, $this->lng->txt(
"mode_nr_of_selections"));
249 array_push($csvrow, $this->lng->txt(
"median"));
250 array_push($csvrow, $this->lng->txt(
"arithmetic_mean"));
251 array_push($csvfile, $csvrow);
254 $questions =& $this->
object->getSurveyQuestions();
256 foreach ($questions as
$data)
258 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
261 $eval = $this->
object->getCumulatedResults($question);
262 switch (
$_POST[
"export_format"])
265 $counter = $question->setExportCumulatedXLS($adapter, $eval, $counter,
$_POST[
'export_label']);
268 $csvrows =& $question->setExportCumulatedCVS($eval,
$_POST[
'export_label']);
269 foreach ($csvrows as $csvrow)
271 array_push($csvfile, $csvrow);
277 switch (
$_POST[
"export_format"])
280 $question->setExportDetailsXLS($adapter, $eval,
$_POST[
'export_label']);
281 $adapter->setActiveWorksheet(0);
287 switch (
$_POST[
"export_format"])
291 $adapter->deliver($surveyname .
"." . $adapter->getFileExtension());
297 foreach ($csvfile as $csvrow)
299 $csvrow =& $this->
object->processCSVRow($csvrow, TRUE,
$separator);
302 include_once
"./Services/Utilities/classes/class.ilUtil.php";
311 if (strlen(
$_POST[
"export_format"]))
318 $this->ctrl->redirect($this,
'evaluation');
324 if (strlen(
$_POST[
"export_format"]))
331 $this->ctrl->redirect($this,
'evaluation');
338 $this->ctrl->redirect($this,
'evaluation');
347 if (!$rbacsystem->checkAccess(
"read",
$_GET[
"ref_id"]))
352 switch ($this->object->getEvaluationAccess())
355 if (!$rbacsystem->checkAccess(
"write",
$_GET[
"ref_id"]))
362 include_once
"./Modules/Survey/classes/class.ilObjSurveyAccess.php";
370 if (($this->object->getAnonymize() == 1) && (
$_SESSION[
"anon_evaluation_access"] !=
$_GET[
"ref_id"]))
378 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation.html",
"Modules/Survey");
379 $questions =& $this->
object->getSurveyQuestions();
382 foreach ($questions as $qdata)
384 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
386 $question = $question_gui->object;
387 $c = $question->getCumulatedResultData($this->object->getSurveyId(), $counter);
392 array_push(
$data, $a);
397 array_push(
$data, $c);
402 $detail = $question_gui->getCumulatedResultsDetails($this->object->getSurveyId(), $counter-1);
403 $this->tpl->setCurrentBlock(
"detail");
404 $this->tpl->setVariable(
"DETAIL", $detail);
405 $this->tpl->parseCurrentBlock();
409 $exporttypes = array(
410 "excel" => $this->lng->txt(
'exp_type_excel'),
411 "csv" => $this->lng->txt(
'exp_type_csv')
413 foreach ($exporttypes as $key => $value)
415 $this->tpl->setCurrentBlock(
'exportoption');
416 $this->tpl->setVariable(
'OPTION_VALUE', $key);
418 $this->tpl->parseCurrentBlock();
421 array(
"title" => $this->lng->txt(
'export_label_only'),
'value' =>
'label_only'),
422 array(
"title" => $this->lng->txt(
'export_title_only'),
'value' =>
'title_only'),
423 array(
"title" => $this->lng->txt(
'export_title_label'),
'value' =>
'title_label')
425 foreach ($labeldata as $label)
427 $this->tpl->setCurrentBlock(
"label_option");
428 $this->tpl->setVariable(
"LABEL_VALUE", $label[
'value']);
430 $this->tpl->parseCurrentBlock();
434 $this->tpl->setVariable(
'SUBMIT_CMD',
'exportDetailData');
438 $this->tpl->setVariable(
'SUBMIT_CMD',
'exportData');
440 $this->tpl->setVariable(
'SUBMIT_VALUE', $this->lng->txt(
"export"));
442 include_once
"./Modules/Survey/classes/tables/class.ilSurveyResultsCumulatedTableGUI.php";
444 $table_gui->setData(
$data);
445 $this->tpl->setVariable(
'CUMULATED', $table_gui->getHTML());
446 $this->tpl->addCss(
"./Modules/Survey/templates/default/survey_print.css",
"print");
447 $this->tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this,
'evaluation'));
463 $questions = array();
464 $questions =& $this->
object->getSurveyQuestions(
true);
465 array_push($csvrow, $this->lng->txt(
"username"));
466 if ($this->object->canExportSurveyCode())
468 array_push($csvrow, $this->lng->txt(
"codes"));
472 array_push($csvrow, $this->lng->txt(
"gender"));
475 foreach ($questions as $question_id => $question_data)
477 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
479 $question->addUserSpecificResultsExportTitles($csvrow, $export_label);
480 $questions[$question_data[
"question_id"]] = $question;
482 array_push($csvfile, $csvrow);
483 $participants =& $this->
object->getSurveyFinishedIds();
484 foreach ($participants as $user_id)
486 $resultset =& $this->
object->getEvaluationByUser($questions, $user_id);
488 array_push($csvrow, $resultset[
"name"]);
489 if ($this->object->canExportSurveyCode())
491 array_push($csvrow, $user_id);
495 array_push($csvrow, $resultset[
"gender"]);
497 foreach ($questions as $question_id => $question)
499 $question->addUserSpecificResultsData($csvrow, $resultset);
501 $wt = $this->
object->getWorkingtimeForParticipant($user_id);
502 array_push($csvrow, $wt);
503 array_push($csvfile, $csvrow);
505 switch ($export_format)
508 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
510 $pages = floor((count($csvfile[0])) / 250) + 1;
511 for ($i = 0; $i < $pages; $i++)
513 $adapter->addWorksheet($this->lng->txt(
'page') .
' ' . ($i+2));
516 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
517 $contentstartrow = 0;
518 foreach ($csvfile as $csvrow)
524 $adapter->setActiveWorksheet($worksheet);
525 foreach ($csvrow as $text)
530 foreach ($text as $string)
534 $contentstartrow = max($contentstartrow, $textcount);
546 $adapter->setActiveWorksheet($worksheet);
551 $row = $contentstartrow;
556 $adapter->setActiveWorksheet($worksheet);
557 foreach ($csvrow as $text)
559 if (is_numeric($text))
561 $adapter->setCellValue(
$row, $col++, $text);
565 $adapter->setCellValue(
$row, $col++, $text);
571 $adapter->setActiveWorksheet($worksheet);
572 $adapter->setCellValue(
$row, 0, $csvrow[0]);
578 $adapter->deliver($surveyname .
"." . $adapter->getFileExtension());
584 foreach ($csvfile as $csvrow)
586 $csvrow =& str_replace(
"\n",
" ", $this->object->processCSVRow($csvrow, TRUE,
$separator));
589 include_once
"./Services/Utilities/classes/class.ilUtil.php";
609 $participants =& $this->
object->getSurveyParticipantsState();
613 #get the keys for header row and then break after first row
614 while ($el = each($participants))
617 while ($field = each($el[
'value']))
619 array_push($csvrow, $field[
'key']);
620 #reset($el['value']);
622 array_push($csvfile, $csvrow);
625 #then get all data rows
626 reset($participants);
627 while ($el = each($participants)) {
629 while ($field = each($el[
'value']))
631 array_push($csvrow, $field[
'value']);
633 array_push($csvfile, $csvrow);
636 switch ($export_format)
644 foreach ($csvfile as $csvrow)
646 $csvrow =& str_replace(
"\n",
" ", $this->object->processCSVRow($csvrow, TRUE,
$separator));
649 include_once
"./Services/Utilities/classes/class.ilUtil.php";
670 if (!$ilAccess->checkAccess(
"write",
"", $this->object->getRefId()))
673 $this->ctrl->redirectByClass(
"ilObjSurveyGUI",
"infoScreen");
679 if (array_key_exists(
"export_format",
$_POST))
684 $this->tpl->addCss(
"./Modules/Survey/templates/default/survey_print.css",
"print");
685 $userResults =& $this->
object->getUserSpecificResults();
687 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation_user.html",
"Modules/Survey");
688 $questions =& $this->
object->getSurveyQuestions(
true);
689 $participants =& $this->
object->getSurveyParticipants();
690 $tabledata = array();
691 foreach ($participants as
$data)
693 $questioncounter = 1;
697 foreach ($questions as $question_id => $question_data)
699 $found = $userResults[$question_id][$data[
"active_id"]];
701 if (is_array($found))
703 $text = implode(
"<br />", $found);
709 if (strlen($text) == 0) $text = $this->lng->txt(
"skipped");
710 $wt = $this->
object->getWorkingtimeForParticipant($data[
'active_id']);
713 array_push($tabledata, array(
714 'username' => $data[
"sortname"],
715 'gender' => $data[
"gender"],
716 'question' => $questioncounter++ .
". " . $question_data[
"title"],
724 array_push($tabledata, array(
727 'question' => $questioncounter++ .
". " . $question_data[
"title"],
729 'workingtime' => null
734 $this->tpl->setCurrentBlock(
"generic_css");
735 $this->tpl->setVariable(
"LOCATION_GENERIC_STYLESHEET",
"./Modules/Survey/templates/default/evaluation_print.css");
736 $this->tpl->setVariable(
"MEDIA_GENERIC_STYLESHEET",
"print");
737 $this->tpl->parseCurrentBlock();
739 array(
"title" => $this->lng->txt(
'export_label_only'),
'value' =>
'label_only'),
740 array(
"title" => $this->lng->txt(
'export_title_only'),
'value' =>
'title_only'),
741 array(
"title" => $this->lng->txt(
'export_title_label'),
'value' =>
'title_label')
743 foreach ($labeldata as $label)
745 $this->tpl->setCurrentBlock(
"label_option");
746 $this->tpl->setVariable(
"LABEL_VALUE", $label[
'value']);
748 $this->tpl->parseCurrentBlock();
750 $this->tpl->setCurrentBlock(
"adm_content");
751 $this->tpl->setVariable(
"EXPORT_DATA", $this->lng->txt(
"export_data_as"));
752 $this->tpl->setVariable(
"TEXT_EXCEL", $this->lng->txt(
"exp_type_excel"));
753 $this->tpl->setVariable(
"TEXT_CSV", $this->lng->txt(
"exp_type_csv"));
754 $this->tpl->setVariable(
"BTN_EXPORT", $this->lng->txt(
"export"));
755 $this->tpl->setVariable(
"BTN_PRINT", $this->lng->txt(
"print"));
756 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this,
"evaluationuser"));
757 $this->tpl->setVariable(
"PRINT_ACTION", $this->ctrl->getFormAction($this,
"evaluationuser"));
758 $this->tpl->setVariable(
"CMD_EXPORT",
"evaluationuser");
759 include_once
"./Modules/Survey/classes/tables/class.ilSurveyResultsUserTableGUI.php";
761 $table_gui->
setData($tabledata);
762 $this->tpl->setVariable(
'TABLE', $table_gui->getHTML());
763 $this->tpl->parseCurrentBlock();
777 if (!$ilAccess->checkAccess(
"write",
"", $this->object->getRefId()))
780 $this->ctrl->redirectByClass(
"ilObjSurveyGUI",
"infoScreen");
786 if (array_key_exists(
"export_format",
$_POST))
792 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation_participants_state.html",
"Modules/Survey");
794 $classes = array(
"tblrow1top",
"tblrow2top");
796 $this->tpl->setCurrentBlock(
"headercell");
797 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"fullname"));
798 $this->tpl->parseCurrentBlock();
800 $this->tpl->setCurrentBlock(
"headercell");
801 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"login"));
802 $this->tpl->parseCurrentBlock();
804 $this->tpl->setCurrentBlock(
"headercell");
805 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"gender"));
806 $this->tpl->parseCurrentBlock();
808 $this->tpl->setCurrentBlock(
"headercell");
809 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"email"));
810 $this->tpl->parseCurrentBlock();
812 $this->tpl->setCurrentBlock(
"headercell");
813 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"status"));
814 $this->tpl->parseCurrentBlock();
818 $participants =& $this->
object->getSurveyParticipantsState();
820 foreach ($participants as
$data)
822 $this->tpl->setCurrentBlock(
"bodycell");
823 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
824 $this->tpl->setVariable(
"TEXT_BODY_CELL", $data[
"sortname"]);
825 $this->tpl->parseCurrentBlock();
827 $this->tpl->setCurrentBlock(
"bodycell");
828 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
829 $this->tpl->setVariable(
"TEXT_BODY_CELL", $data[
"login"]);
830 $this->tpl->parseCurrentBlock();
832 $this->tpl->setCurrentBlock(
"bodycell");
833 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
834 $this->tpl->setVariable(
"TEXT_BODY_CELL", $data[
"gender"]);
835 $this->tpl->parseCurrentBlock();
837 $this->tpl->setCurrentBlock(
"bodycell");
838 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
839 $this->tpl->setVariable(
"TEXT_BODY_CELL", $data[
"email"]);
840 $this->tpl->parseCurrentBlock();
842 $this->tpl->setCurrentBlock(
"bodycell");
843 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
844 $status = ($data[
"status"]) ? $this->lng->txt(
"svy_finished") : $this->lng->txt(
"svy_not_finished");
845 $this->tpl->setVariable(
"TEXT_BODY_CELL", $status);
846 $this->tpl->parseCurrentBlock();
847 $this->tpl->setCurrentBlock(
"row");
848 $this->tpl->parse(
"row");
851 $this->tpl->setCurrentBlock(
"adm_content");
852 $this->tpl->setVariable(
"EXPORT_DATA", $this->lng->txt(
"export_data_as"));
853 $this->tpl->setVariable(
"TEXT_EXCEL", $this->lng->txt(
"exp_type_excel"));
854 $this->tpl->setVariable(
"TEXT_CSV", $this->lng->txt(
"exp_type_csv"));
855 $this->tpl->setVariable(
"BTN_EXPORT", $this->lng->txt(
"export"));
856 $this->tpl->setVariable(
"BTN_PRINT", $this->lng->txt(
"print"));
857 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
858 $this->tpl->setVariable(
"PRINT_ACTION", $this->ctrl->getFormAction($this));
859 $this->tpl->setVariable(
"CMD_EXPORT",
"evaluationparticipantsstate");
860 $this->tpl->parseCurrentBlock();
873 $survey_id =
$_GET[
"survey"];
874 $question_id =
$_GET[
"question"];
876 $question =& $this->
object->_instanciateQuestion($question_id);
877 $question->outChart($survey_id,
$type);