ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSurveyEvaluationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
20 protected $tabs;
21
25 protected $access;
26
30 protected $user;
31
35 protected $rbacsystem;
36
40 protected $tree;
41
45 protected $toolbar;
46
47 const TYPE_XLS = "excel";
48 const TYPE_SPSS = "csv";
49
50 const EXCEL_SUBTITLE = "DDDDDD";
51
52 public $object;
53 public $lng;
54 public $tpl;
55 public $ctrl;
56 public $appr_id = null;
57
66 public function __construct($a_object)
67 {
68 global $DIC;
69
70 $this->tabs = $DIC->tabs();
71 $this->access = $DIC->access();
72 $this->user = $DIC->user();
73 $this->rbacsystem = $DIC->rbac()->system();
74 $this->tree = $DIC->repositoryTree();
75 $this->toolbar = $DIC->toolbar();
76 $this->ui = $DIC->ui();
77 $lng = $DIC->language();
78 $tpl = $DIC["tpl"];
79 $ilCtrl = $DIC->ctrl();
80
81 $this->lng = $lng;
82 $this->tpl = $tpl;
83 $this->ctrl = $ilCtrl;
84 $this->object = $a_object;
85 $this->log = ilLoggerFactory::getLogger("svy");
86 $this->array_panels = array();
87
88 if ($this->object->get360Mode()) {
89 $this->determineAppraiseeId();
90 }
91 }
92
96 public function executeCommand()
97 {
98 include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
99 $skmg_set = new ilSkillManagementSettings();
100 if ($this->object->get360SkillService() && $skmg_set->isActivated()) {
101 $cmd = $this->ctrl->getCmd("competenceEval");
102 } else {
103 $cmd = $this->ctrl->getCmd("evaluation");
104 }
105
106 $next_class = $this->ctrl->getNextClass($this);
107
108 $cmd = $this->getCommand($cmd);
109 switch ($next_class) {
110 default:
111 $this->setEvalSubTabs();
112 $ret =&$this->$cmd();
113 break;
114 }
115 return $ret;
116 }
117
118 public function getCommand($cmd)
119 {
120 return $cmd;
121 }
122
128 public function setEvalSubtabs()
129 {
130 $ilTabs = $this->tabs;
131 $ilAccess = $this->access;
132
133 include_once("./Services/Skill/classes/class.ilSkillManagementSettings.php");
134 $skmg_set = new ilSkillManagementSettings();
135 if ($this->object->get360SkillService() && $skmg_set->isActivated()) {
136 $ilTabs->addSubTabTarget(
137 "svy_eval_competences",
138 $this->ctrl->getLinkTarget($this, "competenceEval"),
139 array("competenceEval")
140 );
141 }
142
143 $ilTabs->addSubTabTarget(
144 "svy_eval_cumulated",
145 $this->ctrl->getLinkTarget($this, "evaluation"),
146 array("evaluation", "checkEvaluationAccess")
147 );
148
149 $ilTabs->addSubTabTarget(
150 "svy_eval_detail",
151 $this->ctrl->getLinkTarget($this, "evaluationdetails"),
152 array("evaluationdetails")
153 );
154
155 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
156 $ilTabs->addSubTabTarget(
157 "svy_eval_user",
158 $this->ctrl->getLinkTarget($this, "evaluationuser"),
159 array("evaluationuser")
160 );
161 }
162 }
163
164
170 public function setAppraiseeId($a_val)
171 {
172 $this->appr_id = $a_val;
173 }
174
180 public function getAppraiseeId()
181 {
182 return $this->appr_id;
183 }
184
188 public function determineAppraiseeId()
189 {
192
193 $appr_id = "";
194
195 // always start with current user
196 if ($_REQUEST["appr_id"] == "") {
197 $req_appr_id = $ilUser->getId();
198 } else {
199 $req_appr_id = (int) $_REQUEST["appr_id"];
200 }
201
202 // write access? allow selection
203 if ($req_appr_id > 0) {
204 $all_appr = ($this->object->get360Results() == ilObjSurvey::RESULTS_360_ALL);
205
206 $valid = array();
207 foreach ($this->object->getAppraiseesData() as $item) {
208 if ($item["closed"] &&
209 ($item["user_id"] == $ilUser->getId() ||
210 $rbacsystem->checkAccess("write", $this->object->getRefId()) ||
211 $all_appr)) {
212 $valid[] = $item["user_id"];
213 }
214 }
215 if (in_array($req_appr_id, $valid)) {
216 $appr_id = $req_appr_id;
217 } else {
218 // current selection / user is not valid, use 1st valid instead
219 $appr_id = array_shift($valid);
220 }
221 }
222
223 $this->ctrl->setParameter($this, "appr_id", $appr_id);
224 $this->setAppraiseeId($appr_id);
225 }
226
227
236 {
238
239 if ($this->object->getAnonymize() == 1 &&
240 $_SESSION["anon_evaluation_access"] == $_GET["ref_id"]) {
241 return true;
242 }
243
244 include_once "Modules/Survey/classes/class.ilObjSurveyAccess.php";
246 if ($this->object->getAnonymize() == 1) {
247 $_SESSION["anon_evaluation_access"] = $_GET["ref_id"];
248 }
249 return true;
250 }
251
252 if ($this->object->getAnonymize() == 1) {
253 // autocode
254 $surveycode = $this->object->getUserAccessCode($ilUser->getId());
255 if ($this->object->isAnonymizedParticipant($surveycode)) {
256 $_SESSION["anon_evaluation_access"] = $_GET["ref_id"];
257 return true;
258 }
259
260 /* try to find code for current (registered) user from existing run
261 if($this->object->findCodeForUser($ilUser->getId()))
262 {
263 $_SESSION["anon_evaluation_access"] = $_GET["ref_id"];
264 return true;
265 }
266 */
267
268 // code needed
269 $this->tpl->setVariable("TABS", "");
270 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation_checkaccess.html", "Modules/Survey");
271 $this->tpl->setCurrentBlock("adm_content");
272 $this->tpl->setVariable("AUTHENTICATION_NEEDED", $this->lng->txt("svy_check_evaluation_authentication_needed"));
273 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "checkEvaluationAccess"));
274 $this->tpl->setVariable("EVALUATION_CHECKACCESS_INTRODUCTION", $this->lng->txt("svy_check_evaluation_access_introduction"));
275 $this->tpl->setVariable("VALUE_CHECK", $this->lng->txt("ok"));
276 $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
277 $this->tpl->setVariable("TEXT_SURVEY_CODE", $this->lng->txt("survey_code"));
278 $this->tpl->parseCurrentBlock();
279 }
280
281 $_SESSION["anon_evaluation_access"] = null;
282 return false;
283 }
284
292 public function checkEvaluationAccess()
293 {
294 $surveycode = $_POST["surveycode"];
295 if ($this->object->isAnonymizedParticipant($surveycode)) {
296 $_SESSION["anon_evaluation_access"] = $_GET["ref_id"];
297 $this->evaluation();
298 } else {
299 ilUtil::sendFailure($this->lng->txt("svy_check_evaluation_wrong_key", true));
300 $this->cancelEvaluationAccess();
301 }
302 }
303
311 public function cancelEvaluationAccess()
312 {
315 $path = $tree->getPathFull($this->object->getRefID());
316 $ilCtrl->setParameterByClass(
317 "ilrepositorygui",
318 "ref_id",
319 $path[count($path) - 2]["child"]
320 );
321 $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
322 }
323
331 public function evaluationdetails()
332 {
333 $this->evaluation(1);
334 }
335
336 public function exportCumulatedResults($details = 0)
337 {
338 $finished_ids = null;
339 if ($this->object->get360Mode()) {
340 $appr_id = $_REQUEST["appr_id"];
341 if (!$appr_id) {
342 $this->ctrl->redirect($this, $details ? "evaluationdetails" : "evaluation");
343 }
344 $finished_ids = $this->object->getFinishedIdsForAppraiseeId($appr_id);
345 if (!sizeof($finished_ids)) {
346 $finished_ids = array(-1);
347 }
348 }
349
350 // titles
351 $title_row = array();
352 $do_title = $do_label = true;
353 switch ($_POST['export_label']) {
354 case 'label_only':
355 $title_row[] = $this->lng->txt("label");
356 $do_title = false;
357 break;
358
359 case 'title_only':
360 $title_row[] = $this->lng->txt("title");
361 $do_label = false;
362 break;
363
364 default:
365 $title_row[] = $this->lng->txt("title");
366 $title_row[] = $this->lng->txt("label");
367 break;
368 }
369 $title_row[] = $this->lng->txt("question");
370 $title_row[] = $this->lng->txt("question_type");
371 $title_row[] = $this->lng->txt("users_answered");
372 $title_row[] = $this->lng->txt("users_skipped");
373 $title_row[] = $this->lng->txt("mode");
374 $title_row[] = $this->lng->txt("mode_text");
375 $title_row[] = $this->lng->txt("mode_nr_of_selections");
376 $title_row[] = $this->lng->txt("median");
377 $title_row[] = $this->lng->txt("arithmetic_mean");
378
379 // creating container
380 switch ($_POST["export_format"]) {
381 case self::TYPE_XLS:
382 include_once "Services/Excel/classes/class.ilExcel.php";
383 $excel = new ilExcel();
384 $excel->addSheet($this->lng->txt("svy_eval_cumulated"));
385 $excel->setCellArray(array($title_row), "A1");
386 $excel->setBold("A1:" . $excel->getColumnCoord(sizeof($title_row)-1) . "1");
387 break;
388
389 case self::TYPE_SPSS:
390 $csvfile = array($title_row);
391 break;
392 }
393
394
395 // parse answer data in evaluation results
396 $ov_row = 2;
397 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
398 foreach ($this->object->getSurveyQuestions() as $qdata) {
399 $q_eval = SurveyQuestion::_instanciateQuestionEvaluation($qdata["question_id"], $finished_ids);
400 $q_res = $q_eval->getResults();
401 $ov_rows = $q_eval->exportResults($q_res, $do_title, $do_label);
402
403 switch ($_POST["export_format"]) {
404 case self::TYPE_XLS:
405 $excel->setActiveSheet(0);
406 foreach ($ov_rows as $row) {
407 foreach ($row as $col => $value) {
408 $excel->setCell($ov_row, $col, $value);
409 }
410 $ov_row++;
411 }
412 break;
413
414 case self::TYPE_SPSS:
415 foreach ($ov_rows as $row) {
416 $csvfile[] = $row;
417 }
418 break;
419 }
420
421 if ($details) {
422 switch ($_POST["export_format"]) {
423 case self::TYPE_XLS:
424 $this->exportResultsDetailsExcel($excel, $q_eval, $q_res, $do_title, $do_label);
425 break;
426 }
427 }
428 }
429
430 // #11179
431 $type = !$details
432 ? $this->lng->txt("svy_eval_cumulated")
433 : $this->lng->txt("svy_eval_detail");
434
435 $surveyname = $this->object->getTitle() . " " . $type . " " . date("Y-m-d");
436 $surveyname = preg_replace("/\s/", "_", trim($surveyname));
437 $surveyname = ilUtil::getASCIIFilename($surveyname);
438
439 // send to client
440 switch ($_POST["export_format"]) {
441 case self::TYPE_XLS:
442 $excel->sendToClient($surveyname);
443 break;
444
445 case self::TYPE_SPSS:
446 $csv = "";
447 $separator = ";";
448 foreach ($csvfile as $csvrow) {
449 $csvrow = $this->processCSVRow($csvrow, true, $separator);
450 $csv .= join($csvrow, $separator) . "\n";
451 }
452 ilUtil::deliverData($csv, $surveyname . ".csv");
453 exit();
454 break;
455 }
456 }
457
467 protected function exportResultsDetailsExcel(ilExcel $a_excel, SurveyQuestionEvaluation $a_eval, $a_results, $a_do_title, $a_do_label)
468 {
469 $question_res = $a_results;
470 $matrix = false;
471 if (is_array($question_res)) {
472 $question_res = $question_res[0][1];
473 $matrix = true;
474 }
475 $question = $question_res->getQuestion();
476
477 $a_excel->addSheet($question->getTitle());
478
479
480 // question "overview"
481
482 $kv = array();
483
484 if ($a_do_title) {
485 $kv[$this->lng->txt("title")] = $question->getTitle();
486 }
487 if ($a_do_label) {
488 $kv[$this->lng->txt("label")] = $question->label;
489 }
490
491 // question
492 $kv[$this->lng->txt("question")] = $question->getQuestiontext();
493
494 // question type
495 $kv[$this->lng->txt("question_type")] = SurveyQuestion::_getQuestionTypeName($question->getQuestionType());
496
497 // :TODO: present subtypes (hrz/vrt, mc/sc mtx, metric scale)?
498
499 // answered and skipped users
500 $kv[$this->lng->txt("users_answered")] = (int) $question_res->getUsersAnswered();
501 $kv[$this->lng->txt("users_skipped")] = (int) $question_res->getUsersSkipped(); // #0021671
502
503 $excel_row = 1;
504
505 foreach ($kv as $key => $value) {
506 $a_excel->setCell($excel_row, 0, $key);
507 $a_excel->setCell($excel_row++, 1, $value);
508 }
509
510 if (!$matrix) {
511 $this->parseResultsToExcel(
512 $a_excel,
513 $question_res,
514 $excel_row,
515 $a_eval->getExportGrid($a_results),
516 $a_eval->getTextAnswers($a_results)
517 );
518 } else {
519 // question
520 $this->parseResultsToExcel(
521 $a_excel,
522 $question_res,
523 $excel_row,
524 null,
525 null,
526 false
527 );
528
529 $texts = $a_eval->getTextAnswers($a_results);
530
531 // "rows"
532 foreach ($a_results as $row_results) {
533 $row_title = $row_results[0];
534
535 $a_excel->setCell($excel_row, 0, $this->lng->txt("row"));
536 $a_excel->setCell($excel_row++, 1, $row_title);
537
538 $this->parseResultsToExcel(
539 $a_excel,
540 $row_results[1],
541 $excel_row,
542 $a_eval->getExportGrid($row_results[1]),
543 is_array($texts[$row_title])
544 ? array(""=>$texts[$row_title])
545 : null
546 );
547 }
548 }
549
550 // matrix question: overview #21438
551 if ($matrix) {
552 $a_excel->setCell($excel_row++, 0, $this->lng->txt("overview"));
553
554 // title row with variables
555 $counter = 0;
556 $cats = $question->getColumns();
557 foreach ($cats->getCategories() as $cat) {
559 $a_excel->setCell($excel_row, 1 + $counter, $cat->title);
560 $counter++;
561 }
562 $excel_row++;
563
564 foreach ($a_results as $row_results) {
565 $row_title = $row_results[0];
566 $counter = 0;
567 $a_excel->setCell($excel_row, 0, $row_title);
568
569 $vars = $row_results[1]->getVariables();
570 if ($vars) {
571 foreach ($vars as $var) {
572 $a_excel->setCell($excel_row, ++$counter, $var->abs);
573 }
574 }
575 $excel_row++;
576 }
577 }
578
579 // 1st column is bold
580 $a_excel->setBold("A1:A" . $excel_row);
581 }
582
583 protected function parseResultsToExcel(ilExcel $a_excel, ilSurveyEvaluationResults $a_results, &$a_excel_row, array $a_grid = null, array $a_text_answers = null, $a_include_mode = true)
584 {
585 $kv = array();
586
587 if ($a_include_mode) {
588 if ($a_results->getModeValue() !== null) {
589 // :TODO:
590 $kv[$this->lng->txt("mode")] = is_array($a_results->getModeValue())
591 ? implode(", ", $a_results->getModeValue())
592 : $a_results->getModeValue();
593
594 $kv[$this->lng->txt("mode_text")] = $a_results->getModeValueAsText();
595 $kv[$this->lng->txt("mode_nr_of_selections")] = (int) $a_results->getModeNrOfSelections();
596 }
597
598 if ($a_results->getMedian() !== null) {
599 $kv[$this->lng->txt("median")] = $a_results->getMedianAsText();
600 }
601
602 if ($a_results->getMean() !== null) {
603 $kv[$this->lng->txt("arithmetic_mean")] = $a_results->getMean();
604 }
605 }
606
607 foreach ($kv as $key => $value) {
608 $a_excel->setCell($a_excel_row, 0, $key);
609 $a_excel->setCell($a_excel_row++, 1, $value);
610 }
611
612 // grid
613 if ($a_grid) {
614 // header
615 $a_excel->setColors("B" . $a_excel_row . ":E" . $a_excel_row, ilSurveyEvaluationGUI::EXCEL_SUBTITLE);
616 $a_excel->setCell($a_excel_row, 0, $this->lng->txt("categories"));
617 foreach ($a_grid["cols"] as $col_idx => $col) {
618 $a_excel->setCell($a_excel_row, $col_idx+1, $col);
619 }
620 $a_excel_row++;
621
622 // rows
623 foreach ($a_grid["rows"] as $cols) {
624 foreach ($cols as $col_idx => $col) {
625 $a_excel->setCell($a_excel_row, $col_idx+1, $col);
626 }
627 $a_excel_row++;
628 }
629 }
630
631 // text answers
632 if ($a_text_answers) {
633 // "given_answers" ?
634 $a_excel->setCell($a_excel_row, 0, $this->lng->txt("freetext_answers"));
635
636 // mc/sc
637 if (!is_array($a_text_answers[""])) {
638 $a_excel->setColors("B" . $a_excel_row . ":C" . $a_excel_row, ilSurveyEvaluationGUI::EXCEL_SUBTITLE);
639 $a_excel->setCell($a_excel_row, 1, $this->lng->txt("title"));
640 $a_excel->setCell($a_excel_row++, 2, $this->lng->txt("answer"));
641 }
642 // mtx (row), txt
643 else {
644 $a_excel->setColors("B" . $a_excel_row . ":B" . $a_excel_row, ilSurveyEvaluationGUI::EXCEL_SUBTITLE);
645 $a_excel->setCell($a_excel_row++, 1, $this->lng->txt("answer"));
646 }
647
648 foreach ($a_text_answers as $var => $items) {
649 foreach ($items as $item) {
650 if (!is_array($a_text_answers[""])) {
651 $a_excel->setCell($a_excel_row, 1, $var);
652 $a_excel->setCell($a_excel_row++, 2, $item);
653 } else {
654 $a_excel->setCell($a_excel_row++, 1, $item);
655 }
656 }
657 }
658 }
659 }
660
661 public function exportData()
662 {
663 if (strlen($_POST["export_format"])) {
664 $this->exportCumulatedResults(0);
665 return;
666 } else {
667 $this->ctrl->redirect($this, 'evaluation');
668 }
669 }
670
671 public function exportDetailData()
672 {
673 if (strlen($_POST["export_format"])) {
674 $this->exportCumulatedResults(1);
675 return;
676 } else {
677 $this->ctrl->redirect($this, 'evaluation');
678 }
679 }
680
681 public function printEvaluation()
682 {
683 ilUtil::sendInfo($this->lng->txt('use_browser_print_function'), true);
684 $this->ctrl->redirect($this, 'evaluation');
685 }
686
687 protected function buildExportModal($a_id, $a_cmd)
688 {
690
691 $form_id = "svymdfrm";
692
693 // hide modal on form submit
694 $tpl->addOnLoadCode('$("#form_' . $form_id . '").submit(function() { $("#' . $a_id . '").modal("hide"); });');
695
696 include_once "Services/UIComponent/Modal/classes/class.ilModalGUI.php";
697 $modal = ilModalGUI::getInstance();
698 $modal->setId($a_id);
699 $modal->setHeading(($this->lng->txt("svy_export_format")));
700
701 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
702 $form = new ilPropertyFormGUI();
703 $form->setId($form_id);
704 $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
705
706 $format = new ilSelectInputGUI($this->lng->txt("filetype"), "export_format");
707 $format->setOptions(array(
708 self::TYPE_XLS => $this->lng->txt('exp_type_excel'),
709 self::TYPE_SPSS => $this->lng->txt('exp_type_csv')
710 ));
711 $form->addItem($format, true);
712
713 $label = new ilSelectInputGUI($this->lng->txt("title"), "export_label");
714 $label->setOptions(array(
715 'label_only' => $this->lng->txt('export_label_only'),
716 'title_only' => $this->lng->txt('export_title_only'),
717 'title_label'=> $this->lng->txt('export_title_label')
718 ));
719 $form->addItem($label);
720
721 $form->addCommandButton($a_cmd, $this->lng->txt("export"));
722 $form->setPreventDoubleSubmission(false);
723
724 $modal->setBody($form->getHTML());
725
726 return $modal->getHTML();
727 }
728
729 public function evaluation($details = 0)
730 {
732 $ilToolbar = $this->toolbar;
734 $ui = $this->ui;
735
736 $ui_factory = $ui->factory();
737 $ui_renderer = $ui->renderer();
738
739 // auth
740 if (!$rbacsystem->checkAccess("write", $_GET["ref_id"])) {
741 if (!$rbacsystem->checkAccess("read", $_GET["ref_id"])) {
742 ilUtil::sendFailure($this->lng->txt("permission_denied"));
743 return;
744 }
745
746 switch ($this->object->getEvaluationAccess()) {
748 ilUtil::sendFailure($this->lng->txt("permission_denied"));
749 return;
750
753 if (!$this->checkAnonymizedEvaluationAccess()) {
754 ilUtil::sendFailure($this->lng->txt("permission_denied"));
755 return;
756 }
757 break;
758 }
759 }
760
761 $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
762 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
763
764 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_evaluation.html", "Modules/Survey");
765
766 if ($this->object->get360Mode()) {
767 $appr_id = $this->getAppraiseeId();
769 }
770
771 $results = array();
772 if (!$this->object->get360Mode() || $appr_id) {
773 if ($details) {
774 $captions = new ilSelectInputGUI($this->lng->txt("svy_eval_captions"), "cp");
775 $captions->setOptions(array(
776 "ap" => $this->lng->txt("svy_eval_captions_abs_perc"),
777 "a" => $this->lng->txt("svy_eval_captions_abs"),
778 "p" => $this->lng->txt("svy_eval_captions_perc")
779 ));
780 $captions->setValue($_POST["cp"]);
781 $ilToolbar->addInputItem($captions, true);
782
783 $view = new ilSelectInputGUI($this->lng->txt("svy_eval_view"), "vw");
784 $view->setOptions(array(
785 "tc" => $this->lng->txt("svy_eval_view_tables_charts"),
786 "t" => $this->lng->txt("svy_eval_view_tables"),
787 "c" => $this->lng->txt("svy_eval_view_charts")
788 ));
789 $view->setValue($_POST["vw"]);
790 $ilToolbar->addInputItem($view, true);
791
792 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
793 $button = ilSubmitButton::getInstance();
794 $button->setCaption("ok");
795 $button->setCommand("evaluationdetails");
796 $button->setOmitPreventDoubleSubmission(true);
797 $ilToolbar->addButtonInstance($button);
798
799 $ilToolbar->addSeparator();
800
801 //templates: results, table of contents
802 $dtmpl = new ilTemplate("tpl.il_svy_svy_results_details.html", true, true, "Modules/Survey");
803 $toc_tpl = new ilTemplate("tpl.svy_results_table_contents.html", true, true, "Modules/Survey");
804 $this->lng->loadLanguageModule("content");
805 $toc_tpl->setVariable("TITLE_TOC", $this->lng->txt('cont_toc'));
806 }
807
808 $modal_id = "svy_ev_exp";
809 $modal = $this->buildExportModal($modal_id, $details
810 ? 'exportDetailData'
811 : 'exportData');
812
813 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
814 $button = ilLinkButton::getInstance();
815 $button->setCaption("export");
816 $button->setOnClick('$(\'#' . $modal_id . '\').modal(\'show\')');
817 $ilToolbar->addButtonInstance($button);
818
819 $ilToolbar->addSeparator();
820
821 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
822 $button = ilLinkButton::getInstance();
823 $button->setCaption("print");
824 $button->setOnClick("if(il.Accordion) { il.Accordion.preparePrint(); } window.print(); return false;");
825 $button->setOmitPreventDoubleSubmission(true);
826 $ilToolbar->addButtonInstance($button);
827
828 $finished_ids = null;
829 if ($appr_id) {
830 $finished_ids = $this->object->getFinishedIdsForAppraiseeId($appr_id);
831 if (!sizeof($finished_ids)) {
832 $finished_ids = array(-1);
833 }
834 }
835
836 $details_figure = $_POST["cp"]
837 ? $_POST["cp"]
838 : "ap";
839 $details_view = $_POST["vw"]
840 ? $_POST["vw"]
841 : "tc";
842
843 // parse answer data in evaluation results
844 include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
845 $list = new ilNestedList();
846
847 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
848 foreach ($this->object->getSurveyQuestions() as $qdata) {
849 $q_eval = SurveyQuestion::_instanciateQuestionEvaluation($qdata["question_id"], $finished_ids);
850 $q_res = $q_eval->getResults();
851 $results[] = $q_res;
852
853 if ($details) {
854 //$this->renderDetails($details_view, $details_figure, $dtmpl, $qdata, $q_eval, $q_res);
855 $this->renderDetails($details_view, $details_figure, $qdata, $q_eval, $q_res);
856
857 // TABLE OF CONTENTS
858 if ($qdata["questionblock_id"] &&
859 $qdata["questionblock_id"] != $this->last_questionblock_id) {
860 $qblock = ilObjSurvey::_getQuestionblock($qdata["questionblock_id"]);
861 if ($qblock["show_blocktitle"]) {
862 $list->addListNode($qdata["questionblock_title"], "q" . $qdata["questionblock_id"]);
863 }
864 $this->last_questionblock_id = $qdata["questionblock_id"];
865 }
866 $anchor_id = "svyrdq" . $qdata["question_id"];
867 $list->addListNode("<a href='#" . $anchor_id . "'>" . $qdata["title"] . "</a>", $qdata["question_id"], $qdata["questionblock_id"] ?
868 "q" . $qdata["questionblock_id"] : 0);
869 }
870 }
871
872 if ($details) {
873 $list->setListClass("il_Explorer");
874 $toc_tpl->setVariable("LIST", $list->getHTML());
875
876 //TABLE OF CONTENTS
877 $panel_toc = $ui_factory->panel()->standard("", $ui_factory->legacy($toc_tpl->get()));
878 $render_toc = $ui_renderer->render($panel_toc);
879 $dtmpl->setVariable("PANEL_TOC", $render_toc);
880
881 //REPORT
882 $report_title = "";
883 $panel_report = $ui_factory->panel()->report($report_title, $this->array_panels);
884 $render_report = $ui_renderer->render($panel_report);
885 $dtmpl->setVariable("PANEL_REPORT", $render_report);
886
887 //print the main template
888 $this->tpl->setVariable('DETAIL', $dtmpl->get());
889 }
890 }
891
892 $this->tpl->setVariable('MODAL', $modal);
893 if (!$details) {
894 include_once "./Modules/Survey/classes/tables/class.ilSurveyResultsCumulatedTableGUI.php";
895 $table_gui = new ilSurveyResultsCumulatedTableGUI($this, $details ? 'evaluationdetails' : 'evaluation', $results);
896 $this->tpl->setVariable('CUMULATED', $table_gui->getHTML());
897 }
898 unset($dtmpl);
899 unset($table_gui);
900 unset($modal);
901
902
903 // print header
904
905 $path = "";
906 $path_full = $tree->getPathFull($this->object->getRefId());
907 foreach ($path_full as $data) {
908 $path .= " &raquo; ";
909 $path .= $data['title'];
910 }
911
913 include_once "Services/Link/classes/class.ilLink.php";
914
915 $props = array(
916 $this->lng->txt("link") => ilLink::_getStaticLink($this->object->getRefId()),
917 $this->lng->txt("path") => $path,
918 $this->lng->txt("svy_results") => !$details
919 ? $this->lng->txt("svy_eval_cumulated")
920 : $this->lng->txt("svy_eval_detail"),
921 $this->lng->txt("date") => ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX)),
922 );
923
924 $this->tpl->setCurrentBlock("print_header_bl");
925 foreach ($props as $key => $value) {
926 $this->tpl->setVariable("HEADER_PROP_KEY", $key);
927 $this->tpl->setVariable("HEADER_PROP_VALUE", $value);
928 $this->tpl->parseCurrentBlock();
929 }
930
931 // $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print");
932 }
933
944 //protected function renderDetails($a_details_parts, $a_details_figure, ilTemplate $a_tpl, array $a_qdata, SurveyQuestionEvaluation $a_eval, $a_results)
945 protected function renderDetails($a_details_parts, $a_details_figure, array $a_qdata, SurveyQuestionEvaluation $a_eval, $a_results)
946 {
947 $ui_factory = $this->ui->factory();
948 $a_tpl = new ilTemplate("tpl.svy_results_details_panel.html", true, true, "Modules/Survey");
949
950 $question_res = $a_results;
951 $matrix = false;
952 if (is_array($question_res)) {
953 $question_res = $question_res[0][1];
954 $matrix = true;
955 }
956 $question = $question_res->getQuestion();
957
958 // question "overview"
959
960 // :TODO: present subtypes (hrz/vrt, mc/sc mtx)?
961
962 $a_tpl->setVariable("QTYPE", SurveyQuestion::_getQuestionTypeName($question->getQuestionType()));
963
964 $kv = array();
965 $kv["users_answered"] = $question_res->getUsersAnswered();
966 $kv["users_skipped"] = $question_res->getUsersSkipped();
967
968 if (!$matrix) {
969 if ($question_res->getModeValue() !== null) {
970 $kv["mode"] = wordwrap($question_res->getModeValueAsText(), 50, "<br />");
971 $kv["mode_nr_of_selections"] = $question_res->getModeNrOfSelections();
972 }
973 if ($question_res->getMedian() !== null) {
974 $kv["median"] = $question_res->getMedianAsText();
975 }
976 if ($question_res->getMean() !== null) {
977 $kv["arithmetic_mean"] = $question_res->getMean();
978 }
979 }
980
981 $svy_type_title = SurveyQuestion::_getQuestionTypeName($question->getQuestionType());
982 $qst_title = $question->getTitle();
983 $svy_text = nl2br($question->getQuestiontext());
984 $card_table_tpl = new ilTemplate("tpl.svy_results_details_card.html", true, true, "Modules/Survey");
985 foreach ($kv as $key => $value) {
986 $card_table_tpl->setCurrentBlock("question_statistics_card");
987 $card_table_tpl->setVariable("QUESTION_STATISTIC_KEY", $this->lng->txt($key));
988 $card_table_tpl->setVariable("QUESTION_STATISTIC_VALUE", $value);
989 $card_table_tpl->parseCurrentBlock();
990 }
991 //anchor in title. Used in TOC
992 $anchor_id = "svyrdq" . $question->getId();
993 $title = "<span id='$anchor_id'>$qst_title</span>";
994 $panel_qst_card = $ui_factory->panel()->sub($title, $ui_factory->legacy($svy_text))
995 ->withCard($ui_factory->card($svy_type_title)->withSections(array($ui_factory->legacy($card_table_tpl->get()))));
996 array_push($this->array_panels, $panel_qst_card);
997
998 // grid
999 if ($a_details_parts == "t" ||
1000 $a_details_parts == "tc") {
1001 $grid = $a_eval->getGrid(
1002 $a_results,
1003 ($a_details_figure == "ap" || $a_details_figure == "a"),
1004 ($a_details_figure == "ap" || $a_details_figure == "p")
1005 );
1006 if ($grid) {
1007 foreach ($grid["cols"] as $col) {
1008 $a_tpl->setCurrentBlock("grid_col_header_bl");
1009 $a_tpl->setVariable("COL_HEADER", $col);
1010 $a_tpl->parseCurrentBlock();
1011 }
1012 foreach ($grid["rows"] as $cols) {
1013 foreach ($cols as $idx => $col) {
1014 if ($idx > 0) {
1015 $a_tpl->touchBlock("grid_col_nowrap_bl");
1016 }
1017
1018 $a_tpl->setCurrentBlock("grid_col_bl");
1019 $a_tpl->setVariable("COL_CAPTION", trim($col));
1020 $a_tpl->parseCurrentBlock();
1021 }
1022
1023 $a_tpl->touchBlock("grid_row_bl");
1024 }
1025 }
1026 }
1027
1028 // text answers
1029 $texts = $a_eval->getTextAnswers($a_results);
1030 if ($texts) {
1031 if (array_key_exists("", $texts)) {
1032 $a_tpl->setVariable("TEXT_HEADING", $this->lng->txt("given_answers"));
1033 foreach ($texts[""] as $item) {
1034 $a_tpl->setCurrentBlock("text_direct_item_bl");
1035 $a_tpl->setVariable("TEXT_DIRECT", nl2br($item));
1036 $a_tpl->parseCurrentBlock();
1037 }
1038 } else {
1039 include_once "Services/Accordion/classes/class.ilAccordionGUI.php";
1040 $acc = new ilAccordionGUI();
1041 $acc->setId("svyevaltxt" . $question->getId());
1042
1043 $a_tpl->setVariable("TEXT_HEADING", $this->lng->txt("freetext_answers"));
1044
1045 foreach ($texts as $var => $items) {
1046 $list = array("<ul class=\"small\">");
1047 foreach ($items as $item) {
1048 $list[] = "<li>" . nl2br($item) . "</li>";
1049 }
1050 $list[] = "</ul>";
1051 $acc->addItem($var, implode("\n", $list));
1052 }
1053
1054 $a_tpl->setVariable("TEXT_ACC", $acc->getHTML());
1055 }
1056 }
1057
1058 // chart
1059 if ($a_details_parts == "c" ||
1060 $a_details_parts == "tc") {
1061 $chart = $a_eval->getChart($a_results);
1062 if ($chart) {
1063 if (is_array($chart)) {
1064 // legend
1065 if (is_array($chart[1])) {
1066 foreach ($chart[1] as $legend_item) {
1067 $r = hexdec(substr($legend_item[1], 1, 2));
1068 $g = hexdec(substr($legend_item[1], 3, 2));
1069 $b = hexdec(substr($legend_item[1], 5, 2));
1070
1071 $a_tpl->setCurrentBlock("legend_bl");
1072 $a_tpl->setVariable("LEGEND_CAPTION", $legend_item[0]);
1073 $a_tpl->setVariable("LEGEND_COLOR", $legend_item[1]);
1074 $a_tpl->setVariable("LEGEND_COLOR_SVG", $r . "," . $g . "," . $b);
1075 $a_tpl->parseCurrentBlock();
1076 }
1077 }
1078
1079 $chart = $chart[0];
1080 }
1081 $a_tpl->setVariable("CHART", $chart);
1082 }
1083 }
1084 $panel = $ui_factory->panel()->sub("", $ui_factory->legacy($a_tpl->get()));
1085 array_push($this->array_panels, $panel);
1086 }
1087
1095 {
1096 $ilToolbar = $this->toolbar;
1098
1099 if ($this->object->get360Mode()) {
1100 $appr_id = $this->getAppraiseeId();
1101
1102 $options = array();
1103 if (!$appr_id) {
1104 $options[""] = $this->lng->txt("please_select");
1105 }
1106 $no_appr = true;
1107 foreach ($this->object->getAppraiseesData() as $item) {
1108 if ($item["closed"]) {
1109 $options[$item["user_id"]] = $item["login"];
1110 $no_appr = false;
1111 }
1112 }
1113
1114 if (!$no_appr) {
1115 if ($rbacsystem->checkAccess("write", $this->object->getRefId()) ||
1116 $this->object->get360Results() == ilObjSurvey::RESULTS_360_ALL) {
1117 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1118 $appr = new ilSelectInputGUI($this->lng->txt("survey_360_appraisee"), "appr_id");
1119 $appr->setOptions($options);
1120 $appr->setValue($this->getAppraiseeId());
1121 $ilToolbar->addInputItem($appr, true);
1122
1123 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
1124 $button = ilSubmitButton::getInstance();
1125 $button->setCaption("survey_360_select_appraisee");
1126 $button->setCommand($this->ctrl->getCmd());
1127 $ilToolbar->addButtonInstance($button);
1128
1129 if ($appr_id) {
1130 $ilToolbar->addSeparator();
1131 }
1132 }
1133 } else {
1134 ilUtil::sendFailure($this->lng->txt("survey_360_no_closed_appraisees"));
1135 }
1136 }
1137 }
1138
1149 public function processCSVRow($row, $quoteAll = false, $separator = ";")
1150 {
1151 $resultarray = array();
1152 foreach ($row as $rowindex => $entry) {
1153 if (is_array($entry)) {
1154 $entry = implode("/", $entry);
1155 }
1156 $surround = false;
1157 if ($quoteAll) {
1158 $surround = true;
1159 }
1160 if (strpos($entry, "\"") !== false) {
1161 $entry = str_replace("\"", "\"\"", $entry);
1162 $surround = true;
1163 }
1164 if (strpos($entry, $separator) !== false) {
1165 $surround = true;
1166 }
1167 // replace all CR LF with LF (for Excel for Windows compatibility
1168 $entry = str_replace(chr(13) . chr(10), chr(10), $entry);
1169 if ($surround) {
1170 $resultarray[$rowindex] = utf8_decode("\"" . $entry . "\"");
1171 } else {
1172 $resultarray[$rowindex] = utf8_decode($entry);
1173 }
1174 }
1175 return $resultarray;
1176 }
1177
1178
1179 public function exportEvaluationUser()
1180 {
1181 // build title row(s)
1182
1183 $title_row = $title_row2 = array();
1184 $title_row[] = $this->lng->txt("lastname"); // #12756
1185 $title_row[] = $this->lng->txt("firstname");
1186 $title_row[] = $this->lng->txt("login");
1187 $title_row[] = $this->lng->txt('workingtime'); // #13622
1188 $title_row[] = $this->lng->txt('survey_results_finished');
1189 $title_row2[] = "";
1190 $title_row2[] = "";
1191 $title_row2[] = "";
1192 $title_row2[] = "";
1193 $title_row2[] = "";
1194 if ($this->object->canExportSurveyCode()) {
1195 $title_row[] = $this->lng->txt("codes");
1196 $title_row2[] = "";
1197 }
1198
1199 $questions = array();
1200
1201 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1202 foreach ($this->object->getSurveyQuestions() as $qdata) {
1203 $q_eval = SurveyQuestion::_instanciateQuestionEvaluation($qdata["question_id"], $finished_ids);
1204 $q_res = $q_eval->getResults();
1205
1206 $questions[$qdata["question_id"]] = array($q_eval, $q_res);
1207
1208 $question = is_array($q_res)
1209 ? $q_res[0][1]->getQuestion()
1210 : $q_res->getQuestion();
1211
1212 $do_title = $do_label = true;
1213 switch ($_POST['export_label']) {
1214 case "label_only":
1215 $title_row[] = $question->label;
1216 $title_row2[] = "";
1217 $do_title = false;
1218 break;
1219
1220 case "title_only":
1221 $title_row[] = $question->getTitle();
1222 $title_row2[] = "";
1223 $do_label = false;
1224 break;
1225
1226 default:
1227 $title_row[] = $question->getTitle();
1228 $title_row2[] = $question->label;
1229 break;
1230 }
1231
1232 $q_eval->getUserSpecificVariableTitles($title_row, $title_row2, $do_title, $do_label);
1233 }
1234
1235 $rows = array();
1236
1237 // add title row(s)
1238 $rows[] = $title_row;
1239 if (implode("", $title_row2)) {
1240 $rows[] = $title_row2;
1241 }
1242
1243 // #13620
1245
1246 $finished_ids = null;
1247 if ($this->object->get360Mode()) {
1248 $appr_id = $_REQUEST["appr_id"];
1249 if (!$appr_id) {
1250 $this->ctrl->redirect($this, "evaluationuser");
1251 }
1252 $finished_ids = $this->object->getFinishedIdsForAppraiseeId($appr_id);
1253 if (!sizeof($finished_ids)) {
1254 $finished_ids = array(-1);
1255 }
1256 }
1257
1258 $participants = $this->object->getSurveyParticipants($finished_ids);
1259
1260 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1261 foreach ($participants as $user) {
1262 $user_id = $user["active_id"];
1263
1264 $row = array();
1265 $row[] = trim($user["lastname"])
1266 ? $user["lastname"]
1267 : $user["name"]; // anonymous
1268 $row[] = $user["firstname"];
1269 $row[] = $user["login"]; // #10579
1270
1271 if ($this->object->canExportSurveyCode()) {
1272 $row[] = $user_id;
1273 }
1274
1275 $row[] = $this->object->getWorkingtimeForParticipant($user_id);
1276
1277 if ((bool) $user["finished"]) {
1278 $dt = new ilDateTime($user["finished_tstamp"], IL_CAL_UNIX);
1279 $row[] = ($_POST["export_format"] == self::TYPE_XLS)
1280 ? $dt
1282 } else {
1283 $row[] = "-"; // :TODO:
1284 }
1285
1286 foreach ($questions as $item) {
1287 $q_eval = $item[0];
1288 $q_res = $item[1];
1289
1290 $q_eval->addUserSpecificResults($row, $user_id, $q_res);
1291 }
1292
1293 $rows[] = $row;
1294 }
1295
1296 // #11179
1297 $surveyname = $this->object->getTitle() . " " . $this->lng->txt("svy_eval_user") . " " . date("Y-m-d");
1298 $surveyname = preg_replace("/\s/", "_", trim($surveyname));
1299 $surveyname = ilUtil::getASCIIFilename($surveyname);
1300
1301 switch ($_POST["export_format"]) {
1302 case self::TYPE_XLS:
1303 include_once "Services/Excel/classes/class.ilExcel.php";
1304 $excel = new ilExcel();
1305 $excel->addSheet($this->lng->txt("svy_eval_user"));
1306
1307 foreach ($rows as $row_idx => $row) {
1308 foreach ($row as $col_idx => $col) {
1309 $excel->setCell($row_idx+1, $col_idx, $col);
1310 }
1311 if (!$row_idx) {
1312 $excel->setBold("A1:" . $excel->getColumnCoord(sizeof($row)-1) . "1");
1313 }
1314 }
1315 $excel->sendToClient($surveyname);
1316
1317 // no break
1318 case self::TYPE_SPSS:
1319 $csv = "";
1320 $separator = ";";
1321 foreach ($rows as $csvrow) {
1322 $csvrow = str_replace("\n", " ", $this->processCSVRow($csvrow, true, $separator));
1323 $csv .= join($csvrow, $separator) . "\n";
1324 }
1325 ilUtil::deliverData($csv, "$surveyname.csv");
1326 exit();
1327 }
1328 }
1329
1337 public function evaluationuser()
1338 {
1339 $ilAccess = $this->access;
1340 $ilToolbar = $this->toolbar;
1341
1342 if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
1343 ilUtil::sendFailure($this->lng->txt("no_permission"), true);
1344 $this->ctrl->redirectByClass("ilObjSurveyGUI", "infoScreen");
1345 }
1346
1347 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1348 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "evaluationuser"));
1349
1350 if ($this->object->get360Mode()) {
1351 $appr_id = $this->getAppraiseeId();
1353 }
1354
1355 $tabledata = null;
1356 if (!$this->object->get360Mode() || $appr_id) {
1357 $modal_id = "svy_ev_exp";
1358 $modal = $this->buildExportModal($modal_id, "exportevaluationuser");
1359
1360 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1361 $button = ilLinkButton::getInstance();
1362 $button->setCaption("export");
1363 $button->setOnClick('$(\'#' . $modal_id . '\').modal(\'show\')');
1364 $ilToolbar->addButtonInstance($button);
1365
1366 $ilToolbar->addSeparator();
1367
1368 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1369 $button = ilLinkButton::getInstance();
1370 $button->setCaption("print");
1371 $button->setOnClick("window.print(); return false;");
1372 $button->setOmitPreventDoubleSubmission(true);
1373 $ilToolbar->addButtonInstance($button);
1374
1375 $finished_ids = null;
1376 if ($appr_id) {
1377 $finished_ids = $this->object->getFinishedIdsForAppraiseeId($appr_id);
1378 if (!sizeof($finished_ids)) {
1379 $finished_ids = array(-1);
1380 }
1381 }
1382
1383 $data = $this->parseUserSpecificResults($finished_ids);
1384 }
1385
1386 /*
1387 $this->tpl->addCss("./Modules/Survey/templates/default/survey_print.css", "print");
1388 $this->tpl->setCurrentBlock("generic_css");
1389 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./Modules/Survey/templates/default/evaluation_print.css");
1390 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
1391 $this->tpl->parseCurrentBlock();
1392 */
1393
1394 include_once "./Modules/Survey/classes/tables/class.ilSurveyResultsUserTableGUI.php";
1395 $table_gui = new ilSurveyResultsUserTableGUI($this, 'evaluationuser', $this->object->hasAnonymizedResults());
1396 $table_gui->setData($data);
1397 $this->tpl->setContent($table_gui->getHTML() . $modal);
1398 }
1399
1400 protected function parseUserSpecificResults(array $a_finished_ids = null)
1401 {
1402 $data = array();
1403
1404 $participants = $this->object->getSurveyParticipants($a_finished_ids);
1405
1406 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1407 foreach ($this->object->getSurveyQuestions() as $qdata) {
1408 $q_eval = SurveyQuestion::_instanciateQuestionEvaluation($qdata["question_id"], $a_finished_ids);
1409 $q_res = $q_eval->getResults();
1410
1411 $question = is_array($q_res)
1412 ? $q_res[0][1]->getQuestion()
1413 : $q_res->getQuestion();
1414
1415 foreach ($participants as $user) {
1416 $user_id = $user["active_id"];
1417
1418 $parsed_results = $q_eval->parseUserSpecificResults($q_res, $user_id);
1419
1420 if (!array_key_exists($user_id, $data)) {
1421 $wt = $this->object->getWorkingtimeForParticipant($user_id);
1422
1423 $finished = $user["finished"]
1424 ? $user["finished_tstamp"]
1425 : false;
1426
1427 $data[$user_id] = array(
1428 "username" => $user["sortname"],
1429 "question" => $question->getTitle(),
1430 "results" => $parsed_results,
1431 "workingtime" => $wt,
1432 "finished" => $finished,
1433 "subitems" => array()
1434 );
1435 } else {
1436 $data[$user_id]["subitems"][] = array(
1437 "username" => " ",
1438 "question" => $question->getTitle(),
1439 "results" => $parsed_results,
1440 "workingtime" => null,
1441 "finished" => null
1442 );
1443 }
1444 }
1445 }
1446
1447 return $data;
1448 }
1449
1456 public function competenceEval()
1457 {
1459 $lng = $this->lng;
1461 $ilToolbar = $this->toolbar;
1462 $tpl = $this->tpl;
1463 $ilTabs = $this->tabs;
1464
1465 $survey = $this->object;
1466
1467 $ilTabs->activateSubtab("svy_eval_competences");
1468 $ilTabs->activateTab("svy_results");
1469
1470 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "competenceEval"));
1471
1472 if ($this->object->get360Mode()) {
1473 $appr_id = $this->getAppraiseeId();
1475 }
1476
1477 if ($appr_id == 0) {
1478 return;
1479 }
1480
1481 // evaluation modes
1482 $eval_modes = array();
1483
1484 // get all competences of survey
1485 include_once("./Modules/Survey/classes/class.ilSurveySkill.php");
1486 $sskill = new ilSurveySkill($survey);
1487 $opts = $sskill->getAllAssignedSkillsAsOptions();
1488 $skills = array();
1489 foreach ($opts as $id => $o) {
1490 $idarr = explode(":", $id);
1491 $skills[$id] = array("id" => $id, "title" => $o, "profiles" => array(),
1492 "base_skill" => $idarr[0], "tref_id" => $idarr[1]);
1493 }
1494 //var_dump($opts);
1495
1496 // get matching user competence profiles
1497 // -> add gap analysis to profile
1498 include_once("./Services/Skill/classes/class.ilSkillProfile.php");
1500 foreach ($profiles as $p) {
1501 $prof = new ilSkillProfile($p["id"]);
1502 $prof_levels = $prof->getSkillLevels();
1503 foreach ($prof_levels as $pl) {
1504 if (isset($skills[$pl["base_skill_id"] . ":" . $pl["tref_id"]])) {
1505 $skills[$pl["base_skill_id"] . ":" . $pl["tref_id"]]["profiles"][] =
1506 $p["id"];
1507
1508 $eval_modes["gap_" . $p["id"]] =
1509 $lng->txt("svy_gap_analysis") . ": " . $prof->getTitle();
1510 }
1511 }
1512 }
1513 //var_dump($skills);
1514 //var_dump($eval_modes);
1515
1516 // if one competence does not match any profiles
1517 // -> add "competences of survey" alternative
1518 reset($skills);
1519 foreach ($skills as $sk) {
1520 if (count($sk["profiles"]) == 0) {
1521 $eval_modes["skills_of_survey"] = $lng->txt("svy_all_survey_competences");
1522 }
1523 }
1524
1525 // final determination of current evaluation mode
1526 $comp_eval_mode = $_GET["comp_eval_mode"];
1527 if ($_POST["comp_eval_mode"] != "") {
1528 $comp_eval_mode = $_POST["comp_eval_mode"];
1529 }
1530
1531 if (!isset($eval_modes[$comp_eval_mode])) {
1532 reset($eval_modes);
1533 $comp_eval_mode = key($eval_modes);
1534 $ilCtrl->setParameter($this, "comp_eval_mode", $comp_eval_mode);
1535 }
1536
1537 $ilCtrl->saveParameter($this, "comp_eval_mode");
1538
1539 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1540 $mode_sel = new ilSelectInputGUI($lng->txt("svy_analysis"), "comp_eval_mode");
1541 $mode_sel->setOptions($eval_modes);
1542 $mode_sel->setValue($comp_eval_mode);
1543 $ilToolbar->addInputItem($mode_sel, true);
1544
1545 $ilToolbar->addFormButton($lng->txt("select"), "competenceEval");
1546
1547 if (substr($comp_eval_mode, 0, 4) == "gap_") {
1548 // gap analysis
1549 $profile_id = (int) substr($comp_eval_mode, 4);
1550
1551 include_once("./Services/Skill/classes/class.ilPersonalSkillsGUI.php");
1552 $pskills_gui = new ilPersonalSkillsGUI();
1553 $pskills_gui->setProfileId($profile_id);
1554 $pskills_gui->setGapAnalysisActualStatusModePerObject($survey->getId(), $lng->txt("skmg_eval_type_1"));
1555 if ($survey->getFinishedIdForAppraiseeIdAndRaterId($appr_id, $appr_id) > 0) {
1556 $sskill = new ilSurveySkill($survey);
1557 $self_levels = array();
1558 foreach ($sskill->determineSkillLevelsForAppraisee($appr_id, true) as $sl) {
1559 $self_levels[$sl["base_skill_id"]][$sl["tref_id"]] = $sl["new_level_id"];
1560 }
1561 $pskills_gui->setGapAnalysisSelfEvalLevels($self_levels);
1562 }
1563 $html = $pskills_gui->getGapAnalysisHTML($appr_id);
1564
1565 $tpl->setContent($html);
1566 } else { // must be all survey competences
1567 include_once("./Services/Skill/classes/class.ilPersonalSkillsGUI.php");
1568 $pskills_gui = new ilPersonalSkillsGUI();
1569 $pskills_gui->setGapAnalysisActualStatusModePerObject($survey->getId(), $lng->txt("skmg_eval_type_1"));
1570 if ($survey->getFinishedIdForAppraiseeIdAndRaterId($appr_id, $appr_id) > 0) {
1571 $sskill = new ilSurveySkill($survey);
1572 $self_levels = array();
1573 foreach ($sskill->determineSkillLevelsForAppraisee($appr_id, true) as $sl) {
1574 $self_levels[$sl["base_skill_id"]][$sl["tref_id"]] = $sl["new_level_id"];
1575 }
1576 $pskills_gui->setGapAnalysisSelfEvalLevels($self_levels);
1577 }
1578 $sk = array();
1579 foreach ($skills as $skill) {
1580 $sk[] = array(
1581 "base_skill_id" => (int) $skill["base_skill"],
1582 "tref_id" => (int) $skill["tref_id"]
1583 );
1584 }
1585 $html = $pskills_gui->getGapAnalysisHTML($appr_id, $sk);
1586
1587 $tpl->setContent($html);
1588 }
1589 }
1590}
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
user()
Definition: user.php:4
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
getExportGrid($a_results)
Get grid data.
getGrid($a_results, $a_abs=true, $a_perc=true)
Get grid data.
getTextAnswers($a_results)
Get text answers.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _instanciateQuestionEvaluation($question_id, array $a_finished_ids=null)
Creates an instance of a question evaluation with a given question id.
const IL_CAL_UNIX
Accordion user interface class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
@classDescription Date and time handling
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
getCoordByColumnAndRow($pColumn=0, $pRow=1)
Get cell coordinate (e.g.
setColors($a_coords, $a_background, $a_font=null)
Set cell(s) colors.
setBold($a_coords)
Set cell(s) to bold.
addSheet($a_name, $a_activate=true)
Add sheet.
static getInstance()
Factory.
static getLogger($a_component_id)
Get component logger.
static getInstance()
Get instance.
static _hasEvaluationAccess($a_obj_id, $user_id)
const EVALUATION_ACCESS_PARTICIPANTS
const EVALUATION_ACCESS_ALL
static _getQuestionblock($questionblock_id)
Returns the database row for a given question block.
const EVALUATION_ACCESS_OFF
static _lookupObjId($a_id)
Personal skills GUI class.
This class represents a property form user interface.
This class represents a selection list property in a property form.
static getProfilesOfUser($a_user_id)
Get profiles of a user.
static getInstance()
Factory.
Survey evaluation graphical output.
exportResultsDetailsExcel(ilExcel $a_excel, SurveyQuestionEvaluation $a_eval, $a_results, $a_do_title, $a_do_label)
Export details (excel only)
setEvalSubtabs()
Set the tabs for the evaluation output.
__construct($a_object)
ilSurveyEvaluationGUI constructor
cancelEvaluationAccess()
Cancels the input of the survey access code for evaluation access.
addApprSelectionToToolbar()
Add appraisee selection to toolbar.
checkAnonymizedEvaluationAccess()
Show the detailed evaluation.
renderDetails($a_details_parts, $a_details_figure, array $a_qdata, SurveyQuestionEvaluation $a_eval, $a_results)
Render details.
setAppraiseeId($a_val)
Set appraisee id.
processCSVRow($row, $quoteAll=false, $separator=";")
Processes an array as a CSV row and converts the array values to correct CSV values.
evaluationdetails()
Show the detailed evaluation.
determineAppraiseeId()
Determine appraisee id.
parseResultsToExcel(ilExcel $a_excel, ilSurveyEvaluationResults $a_results, &$a_excel_row, array $a_grid=null, array $a_text_answers=null, $a_include_mode=true)
checkEvaluationAccess()
Checks the evaluation access after entering the survey access code.
competenceEval()
Competence Evaluation.
parseUserSpecificResults(array $a_finished_ids=null)
evaluationuser()
Print the survey evaluation for a selected user.
Skill/Competence handling in surveys.
special template class to simplify handling of ITX/PEAR
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
$key
Definition: croninfo.php:18
$valid
$html
Definition: example_001.php:87
$r
Definition: example_031.php:79
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
const TYPE_SPSS
$format
Definition: metadata.php:141
$ret
Definition: parser.php:6
$type
if(isset($_POST['submit'])) $form
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $DIC
Definition: saml.php:7
$results
Definition: svg-scanner.php:47
$ilUser
Definition: imgupload.php:18
$cols
Definition: xhr_table.php:11
$rows
Definition: xhr_table.php:10