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))
160 include_once
"./Services/Utilities/classes/class.ilUtil.php";
162 $path = $tree->getPathFull($this->object->getRefID());
163 $ilCtrl->setParameterByClass(
"ilrepositorygui",
"ref_id",
165 $ilCtrl->redirectByClass(
"ilrepositorygui",
"frameset");
183 $format_percent =
"";
184 $format_datetime =
"";
187 switch (
$_POST[
"export_format"])
190 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
193 $workbook = $adapter->getWorkbook();
194 $workbook->setVersion(8);
196 $format_bold =& $workbook->addFormat();
197 $format_bold->setBold();
198 $format_percent =& $workbook->addFormat();
199 $format_percent->setNumFormat(
"0.00%");
200 $format_datetime =& $workbook->addFormat();
201 $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
202 $format_title =& $workbook->addFormat();
203 $format_title->setBold();
204 $format_title->setColor(
'black');
205 $format_title->setPattern(1);
206 $format_title->setFgColor(
'silver');
207 $format_title->setAlign(
'center');
209 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
210 $mainworksheet =& $workbook->addWorksheet();
212 switch (
$_POST[
'export_label'])
248 switch (
$_POST[
'export_label'])
251 array_push($csvrow, $this->lng->txt(
"label"));
254 array_push($csvrow, $this->lng->txt(
"title"));
257 array_push($csvrow, $this->lng->txt(
"title"));
258 array_push($csvrow, $this->lng->txt(
"label"));
261 array_push($csvrow, $this->lng->txt(
"question"));
262 array_push($csvrow, $this->lng->txt(
"question_type"));
263 array_push($csvrow, $this->lng->txt(
"users_answered"));
264 array_push($csvrow, $this->lng->txt(
"users_skipped"));
265 array_push($csvrow, $this->lng->txt(
"mode"));
270 array_push($csvrow, $this->lng->txt(
"mode_nr_of_selections"));
271 array_push($csvrow, $this->lng->txt(
"median"));
272 array_push($csvrow, $this->lng->txt(
"arithmetic_mean"));
273 array_push($csvfile, $csvrow);
276 $questions =& $this->
object->getSurveyQuestions();
278 foreach ($questions as
$data)
280 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
283 $eval = $this->
object->getCumulatedResults($question);
284 switch (
$_POST[
"export_format"])
287 $counter = $question->setExportCumulatedXLS($mainworksheet, $format_title, $format_bold, $eval, $counter,
$_POST[
'export_label']);
290 $csvrows =& $question->setExportCumulatedCVS($eval,
$_POST[
'export_label']);
291 foreach ($csvrows as $csvrow)
293 array_push($csvfile, $csvrow);
299 switch (
$_POST[
"export_format"])
302 $question->setExportDetailsXLS($workbook, $format_title, $format_bold, $eval,
$_POST[
'export_label']);
311 $type = $this->lng->txt(
"svy_eval_cumulated");
315 $type = $this->lng->txt(
"svy_eval_detail");
317 $surveyname = $this->
object->getTitle().
" ".$type.
" ".date(
"Y-m-d");
318 $surveyname = preg_replace(
"/\s/",
"_", trim($surveyname));
321 switch (
$_POST[
"export_format"])
332 foreach ($csvfile as $csvrow)
334 $csvrow =& $this->
object->processCSVRow($csvrow, TRUE,
$separator);
337 include_once
"./Services/Utilities/classes/class.ilUtil.php";
346 if (strlen(
$_POST[
"export_format"]))
353 $this->ctrl->redirect($this,
'evaluation');
359 if (strlen(
$_POST[
"export_format"]))
366 $this->ctrl->redirect($this,
'evaluation');
373 $this->ctrl->redirect($this,
'evaluation');
383 if (!$rbacsystem->checkAccess(
"read",
$_GET[
"ref_id"]))
389 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
391 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
393 $format->setOptions(array(
394 "excel" => $this->lng->txt(
'exp_type_excel'),
395 "csv" => $this->lng->txt(
'exp_type_csv')
397 $ilToolbar->addInputItem($format);
399 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
401 $label->setOptions(array(
402 'label_only' => $this->lng->txt(
'export_label_only'),
403 'title_only' => $this->lng->txt(
'export_title_only'),
404 'title_label'=> $this->lng->txt(
'export_title_label')
406 $ilToolbar->addInputItem($label);
410 $ilToolbar->addFormButton($this->lng->txt(
"export"),
'exportDetailData');
414 $ilToolbar->addFormButton($this->lng->txt(
"export"),
'exportData');
417 switch ($this->object->getEvaluationAccess())
420 if (!$rbacsystem->checkAccess(
"write",
$_GET[
"ref_id"]))
427 include_once
"./Modules/Survey/classes/class.ilObjSurveyAccess.php";
435 if (($this->object->getAnonymize() == 1) && (
$_SESSION[
"anon_evaluation_access"] !=
$_GET[
"ref_id"]))
443 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation.html",
"Modules/Survey");
444 $questions =& $this->
object->getSurveyQuestions();
447 $last_questionblock_id = null;
448 foreach ($questions as $qdata)
450 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
452 $question = $question_gui->object;
453 $c = $question->getCumulatedResultData($this->object->getSurveyId(), $counter);
458 array_push(
$data, $a);
463 array_push(
$data, $c);
469 if($qdata[
"questionblock_id"] && $qdata[
"questionblock_id"] != $last_questionblock_id)
471 $qblock = $this->
object->getQuestionblock($qdata[
"questionblock_id"]);
472 if($qblock[
"show_blocktitle"])
474 $this->tpl->setCurrentBlock(
"detail_qblock");
475 $this->tpl->setVariable(
"BLOCKTITLE", $qdata[
"questionblock_title"]);
476 $this->tpl->parseCurrentBlock();
479 $last_questionblock_id = $qdata[
"questionblock_id"];
482 $detail = $question_gui->getCumulatedResultsDetails($this->object->getSurveyId(), $counter-1);
483 $this->tpl->setCurrentBlock(
"detail");
484 $this->tpl->setVariable(
"DETAIL", $detail);
485 $this->tpl->parseCurrentBlock();
489 include_once
"./Modules/Survey/classes/tables/class.ilSurveyResultsCumulatedTableGUI.php";
491 $table_gui->setData(
$data);
492 $this->tpl->setVariable(
'CUMULATED', $table_gui->getHTML());
493 $this->tpl->addCss(
"./Modules/Survey/templates/default/survey_print.css",
"print");
494 $this->tpl->setVariable(
'FORMACTION', $this->ctrl->getFormAction($this,
'evaluation'));
511 $questions = array();
512 $questions =& $this->
object->getSurveyQuestions(
true);
513 array_push($csvrow, $this->lng->txt(
"lastname"));
514 array_push($csvrow, $this->lng->txt(
"firstname"));
515 array_push($csvrow, $this->lng->txt(
"login"));
516 array_push($csvrow2,
"");
517 array_push($csvrow2,
"");
518 array_push($csvrow2,
"");
519 if ($this->object->canExportSurveyCode())
521 array_push($csvrow, $this->lng->txt(
"codes"));
522 array_push($csvrow2,
"");
532 foreach ($questions as $question_id => $question_data)
534 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
536 switch ($export_label)
539 $question->addUserSpecificResultsExportTitles($csvrow,
true);
543 $question->addUserSpecificResultsExportTitles($csvrow,
false);
547 $question->addUserSpecificResultsExportTitles($csvrow,
false);
548 $question->addUserSpecificResultsExportTitles($csvrow2,
true,
false);
552 $questions[$question_data[
"question_id"]] = $question;
554 array_push($csvfile, $csvrow);
555 if(
sizeof($csvrow2) && implode(
"", $csvrow2))
557 array_push($csvfile, $csvrow2);
559 $participants =& $this->
object->getSurveyFinishedIds();
560 foreach ($participants as $user_id)
562 $resultset =& $this->
object->getEvaluationByUser($questions, $user_id);
566 array_push($csvrow, (trim($resultset[
"lastname"]))
567 ? $resultset[
"lastname"]
568 : $resultset[
"name"]);
569 array_push($csvrow, $resultset[
"firstname"]);
571 array_push($csvrow, $resultset[
"login"]);
572 if ($this->object->canExportSurveyCode())
574 array_push($csvrow, $user_id);
582 foreach ($questions as $question_id => $question)
584 $question->addUserSpecificResultsData($csvrow, $resultset);
586 $wt = $this->
object->getWorkingtimeForParticipant($user_id);
587 array_push($csvrow, $wt);
588 array_push($csvfile, $csvrow);
592 $surveyname = $this->
object->getTitle().
" ".$this->lng->txt(
"svy_eval_user").
" ".date(
"Y-m-d");
593 $surveyname = preg_replace(
"/\s/",
"_", trim($surveyname));
596 switch ($export_format)
599 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
602 $workbook = $adapter->getWorkbook();
603 $workbook->setVersion(8);
605 $format_bold =& $workbook->addFormat();
606 $format_bold->setBold();
607 $format_percent =& $workbook->addFormat();
608 $format_percent->setNumFormat(
"0.00%");
609 $format_datetime =& $workbook->addFormat();
610 $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
611 $format_title =& $workbook->addFormat();
612 $format_title->setBold();
613 $format_title->setColor(
'black');
614 $format_title->setPattern(1);
615 $format_title->setFgColor(
'silver');
616 $format_title_plain =& $workbook->addFormat();
617 $format_title_plain->setColor(
'black');
618 $format_title_plain->setPattern(1);
619 $format_title_plain->setFgColor(
'silver');
621 $pages = floor((count($csvfile[0])) / 250) + 1;
622 $worksheets = array();
623 for ($i = 0; $i < $pages; $i++)
625 $worksheets[$i] =& $workbook->addWorksheet();
628 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
629 $contentstartrow = 0;
630 foreach ($csvfile as $csvrow)
636 $mainworksheet =& $worksheets[$worksheet];
637 foreach ($csvrow as $text)
642 foreach ($text as $string)
646 $contentstartrow = max($contentstartrow, $textcount);
658 $mainworksheet =& $worksheets[$worksheet];
663 $row = $contentstartrow;
668 $mainworksheet =& $worksheets[$worksheet];
669 foreach ($csvrow as $text)
671 if (is_numeric($text))
673 $mainworksheet->writeNumber(
$row, $col++, $text);
683 $mainworksheet =& $worksheets[$worksheet];
697 foreach ($csvfile as $csvrow)
699 $csvrow =& str_replace(
"\n",
" ", $this->object->processCSVRow($csvrow, TRUE,
$separator));
702 include_once
"./Services/Utilities/classes/class.ilUtil.php";
718 global $ilAccess,
$ilLog, $ilToolbar;
720 if (!$ilAccess->checkAccess(
"write",
"", $this->object->getRefId()))
723 $this->ctrl->redirectByClass(
"ilObjSurveyGUI",
"infoScreen");
729 if (array_key_exists(
"export_format",
$_POST))
734 $userResults =& $this->
object->getUserSpecificResults();
735 $questions =& $this->
object->getSurveyQuestions(
true);
736 $participants =& $this->
object->getSurveyParticipants();
737 $tabledata = array();
738 foreach ($participants as
$data)
740 $questioncounter = 1;
744 foreach ($questions as $question_id => $question_data)
746 $found = $userResults[$question_id][$data[
"active_id"]];
748 if (is_array($found))
750 $text = implode(
"<br />", $found);
756 if (strlen($text) == 0) $text = $this->lng->txt(
"skipped");
757 $wt = $this->
object->getWorkingtimeForParticipant($data[
'active_id']);
760 array_push($tabledata, array(
761 'username' => $data[
"sortname"],
763 'question' => $questioncounter++ .
". " . $question_data[
"title"],
771 array_push($tabledata, array(
774 'question' => $questioncounter++ .
". " . $question_data[
"title"],
776 'workingtime' => null
782 $this->tpl->addCss(
"./Modules/Survey/templates/default/survey_print.css",
"print");
783 $this->tpl->setCurrentBlock(
"generic_css");
784 $this->tpl->setVariable(
"LOCATION_GENERIC_STYLESHEET",
"./Modules/Survey/templates/default/evaluation_print.css");
785 $this->tpl->setVariable(
"MEDIA_GENERIC_STYLESHEET",
"print");
786 $this->tpl->parseCurrentBlock();
788 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
"evaluationuser"));
790 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
792 $format->setOptions(array(
793 "excel" => $this->lng->txt(
'exp_type_excel'),
794 "csv" => $this->lng->txt(
'exp_type_csv')
796 $ilToolbar->addInputItem($format);
798 include_once
"Services/Form/classes/class.ilPropertyFormGUI.php";
800 $label->setOptions(array(
801 'label_only' => $this->lng->txt(
'export_label_only'),
802 'title_only' => $this->lng->txt(
'export_title_only'),
803 'title_label'=> $this->lng->txt(
'export_title_label')
805 $ilToolbar->addInputItem($label);
807 $ilToolbar->addFormButton($this->lng->txt(
"export"),
'evaluationuser');
809 $ilToolbar->addSeparator();
811 $ilToolbar->addButton($this->lng->txt(
"print"),
"#",
"",
"",
"onclick=\"javascript:window.print()\"");
813 include_once
"./Modules/Survey/classes/tables/class.ilSurveyResultsUserTableGUI.php";
815 $table_gui->
setData($tabledata);
816 $this->tpl->setContent($table_gui->getHTML());