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());
161 ilUtil::redirect(
"repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2][
"child"]);
179 $format_percent =
"";
180 $format_datetime =
"";
184 switch ($_POST[
"export_format"])
187 include_once
"./classes/class.ilExcelWriterAdapter.php";
190 $workbook = $adapter->getWorkbook();
191 $workbook->setVersion(8);
193 $format_bold =& $workbook->addFormat();
194 $format_bold->setBold();
195 $format_percent =& $workbook->addFormat();
196 $format_percent->setNumFormat(
"0.00%");
197 $format_datetime =& $workbook->addFormat();
198 $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
199 $format_title =& $workbook->addFormat();
200 $format_title->setBold();
201 $format_title->setColor(
'black');
202 $format_title->setPattern(1);
203 $format_title->setFgColor(
'silver');
204 $format_title->setAlign(
'center');
206 include_once (
"./classes/class.ilExcelUtils.php");
207 $mainworksheet =& $workbook->addWorksheet();
209 $mainworksheet->writeString(0, 1,
ilExcelUtils::_convert_text($this->lng->txt(
"question"), $_POST[
"export_format"]), $format_bold);
210 $mainworksheet->writeString(0, 2,
ilExcelUtils::_convert_text($this->lng->txt(
"question_type"), $_POST[
"export_format"]), $format_bold);
211 $mainworksheet->writeString(0, 3,
ilExcelUtils::_convert_text($this->lng->txt(
"users_answered"), $_POST[
"export_format"]), $format_bold);
212 $mainworksheet->writeString(0, 4,
ilExcelUtils::_convert_text($this->lng->txt(
"users_skipped"), $_POST[
"export_format"]), $format_bold);
214 $mainworksheet->writeString(0, 6,
ilExcelUtils::_convert_text($this->lng->txt(
"mode_text"), $_POST[
"export_format"]), $format_bold);
215 $mainworksheet->writeString(0, 7,
ilExcelUtils::_convert_text($this->lng->txt(
"mode_nr_of_selections"), $_POST[
"export_format"]), $format_bold);
217 $mainworksheet->writeString(0, 9,
ilExcelUtils::_convert_text($this->lng->txt(
"arithmetic_mean"), $_POST[
"export_format"]), $format_bold);
222 array_push($csvrow, $this->lng->txt(
"title"));
223 array_push($csvrow, $this->lng->txt(
"question"));
224 array_push($csvrow, $this->lng->txt(
"question_type"));
225 array_push($csvrow, $this->lng->txt(
"users_answered"));
226 array_push($csvrow, $this->lng->txt(
"users_skipped"));
227 array_push($csvrow, $this->lng->txt(
"mode"));
232 array_push($csvrow, $this->lng->txt(
"mode_nr_of_selections"));
233 array_push($csvrow, $this->lng->txt(
"median"));
234 array_push($csvrow, $this->lng->txt(
"arithmetic_mean"));
235 array_push($csvfile, $csvrow);
238 $questions =& $this->
object->getSurveyQuestions();
240 foreach ($questions as
$data)
242 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
245 $eval = $this->
object->getCumulatedResults($question);
246 switch ($_POST[
"export_format"])
249 $counter = $question->setExportCumulatedXLS($mainworksheet, $format_title, $format_bold, $eval, $counter);
252 $csvrows =& $question->setExportCumulatedCVS($eval);
253 foreach ($csvrows as $csvrow)
255 array_push($csvfile, $csvrow);
261 switch ($_POST[
"export_format"])
264 $question->setExportDetailsXLS($workbook, $format_title, $format_bold, $eval);
270 switch ($_POST[
"export_format"])
281 foreach ($csvfile as $csvrow)
283 $csvrow =& $this->
object->processCSVRow($csvrow, TRUE,
$separator);
286 include_once
"./Services/Utilities/classes/class.ilUtil.php";
299 if (!$rbacsystem->checkAccess(
"read",
$_GET[
"ref_id"]))
304 switch ($this->object->getEvaluationAccess())
307 if (!$rbacsystem->checkAccess(
"write",
$_GET[
"ref_id"]))
314 include_once
"./Modules/Survey/classes/class.ilObjSurveyAccess.php";
322 if (($this->object->getAnonymize() == 1) && (
$_SESSION[
"anon_evaluation_access"] !=
$_GET[
"ref_id"]))
330 if (strlen($_POST[
"export_format"]))
337 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation.html",
"Modules/Survey");
338 $this->tpl->addCss(
"./Modules/Survey/templates/default/survey_print.css",
"print");
340 $classes = array(
"tblrow1",
"tblrow2");
341 $questions =& $this->
object->getSurveyQuestions();
342 foreach ($questions as
$data)
344 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
346 $question = $question_gui->object;
347 $row = $question_gui->getCumulatedResultRow($counter, $classes[$counter % 2], $this->object->getSurveyId());
348 $this->tpl->setCurrentBlock(
"row");
349 $this->tpl->setVariable(
"ROW", $row);
350 $this->tpl->parseCurrentBlock();
353 $detail = $question_gui->getCumulatedResultsDetails($this->object->getSurveyId(), $counter+1);
354 $this->tpl->setCurrentBlock(
"detail");
355 $this->tpl->setVariable(
"DETAIL", $detail);
356 $this->tpl->parseCurrentBlock();
361 $this->tpl->setCurrentBlock(
"generic_css");
362 $this->tpl->setVariable(
"LOCATION_GENERIC_STYLESHEET",
"./Modules/Survey/templates/default/evaluation_print.css");
363 $this->tpl->setVariable(
"MEDIA_GENERIC_STYLESHEET",
"print");
364 $this->tpl->parseCurrentBlock();
365 $this->tpl->setCurrentBlock(
"adm_content");
366 $this->tpl->setVariable(
"QUESTION_TITLE", $this->lng->txt(
"title"));
367 $this->tpl->setVariable(
"QUESTION_TEXT", $this->lng->txt(
"question"));
368 $this->tpl->setVariable(
"QUESTION_TYPE", $this->lng->txt(
"question_type"));
369 $this->tpl->setVariable(
"USERS_ANSWERED", $this->lng->txt(
"users_answered"));
370 $this->tpl->setVariable(
"USERS_SKIPPED", $this->lng->txt(
"users_skipped"));
371 $this->tpl->setVariable(
"MODE", $this->lng->txt(
"mode"));
372 $this->tpl->setVariable(
"MODE_NR_OF_SELECTIONS", $this->lng->txt(
"mode_nr_of_selections"));
373 $this->tpl->setVariable(
"MEDIAN", $this->lng->txt(
"median"));
374 $this->tpl->setVariable(
"ARITHMETIC_MEAN", $this->lng->txt(
"arithmetic_mean"));
376 if ($ilAccess->checkAccess(
"write",
"", $this->object->getRefId()))
378 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this,
"evaluation"));
379 $this->tpl->setVariable(
"EXPORT_DATA", $this->lng->txt(
"export_data_as"));
380 $this->tpl->setVariable(
"TEXT_EXCEL", $this->lng->txt(
"exp_type_excel"));
381 $this->tpl->setVariable(
"TEXT_CSV", $this->lng->txt(
"exp_type_csv"));
382 $this->tpl->setVariable(
"BTN_EXPORT", $this->lng->txt(
"export"));
385 $this->tpl->setVariable(
"CMD_EXPORT",
"evaluationdetails");
389 $this->tpl->setVariable(
"CMD_EXPORT",
"evaluation");
392 $this->tpl->setVariable(
"BTN_PRINT", $this->lng->txt(
"print"));
393 $this->tpl->setVariable(
"VALUE_DETAIL", $details);
394 $this->tpl->setVariable(
"PRINT_ACTION", $this->ctrl->getFormAction($this,
"evaluation"));
395 $this->tpl->parseCurrentBlock();
411 $questions = array();
412 $questions =& $this->
object->getSurveyQuestions(
true);
413 array_push($csvrow, $this->lng->txt(
"username"));
414 if ($this->object->canExportSurveyCode())
416 array_push($csvrow, $this->lng->txt(
"codes"));
420 array_push($csvrow, $this->lng->txt(
"gender"));
423 foreach ($questions as $question_id => $question_data)
425 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
427 $question->addUserSpecificResultsExportTitles($csvrow);
428 $questions[$question_data[
"question_id"]] = $question;
430 array_push($csvfile, $csvrow);
431 $participants =& $this->
object->getSurveyFinishedIds();
433 foreach ($participants as $user_id)
435 $resultset =& $this->
object->getEvaluationByUser($questions, $user_id);
437 array_push($csvrow, $resultset[
"name"]);
438 if ($this->object->canExportSurveyCode())
440 array_push($csvrow, $user_id);
444 array_push($csvrow, $resultset[
"gender"]);
446 foreach ($questions as $question_id => $question)
448 $question->addUserSpecificResultsData($csvrow, $resultset);
450 array_push($csvfile, $csvrow);
452 switch ($export_format)
455 include_once
"./classes/class.ilExcelWriterAdapter.php";
458 $workbook = $adapter->getWorkbook();
459 $workbook->setVersion(8);
461 $format_bold =& $workbook->addFormat();
462 $format_bold->setBold();
463 $format_percent =& $workbook->addFormat();
464 $format_percent->setNumFormat(
"0.00%");
465 $format_datetime =& $workbook->addFormat();
466 $format_datetime->setNumFormat(
"DD/MM/YYYY hh:mm:ss");
467 $format_title =& $workbook->addFormat();
468 $format_title->setBold();
469 $format_title->setColor(
'black');
470 $format_title->setPattern(1);
471 $format_title->setFgColor(
'silver');
472 $format_title_plain =& $workbook->addFormat();
473 $format_title_plain->setColor(
'black');
474 $format_title_plain->setPattern(1);
475 $format_title_plain->setFgColor(
'silver');
477 $pages = floor((count($csvfile[0])) / 250) + 1;
478 $worksheets = array();
479 for ($i = 0; $i < $pages; $i++)
481 $worksheets[$i] =& $workbook->addWorksheet();
484 include_once
"./classes/class.ilExcelUtils.php";
485 foreach ($csvfile as $csvrow)
491 $mainworksheet =& $worksheets[$worksheet];
492 foreach ($csvrow as $text)
499 $mainworksheet =& $worksheets[$worksheet];
507 $mainworksheet =& $worksheets[$worksheet];
508 foreach ($csvrow as $text)
510 if (is_numeric($text))
512 $mainworksheet->writeNumber($row, $col++, $text);
522 $mainworksheet =& $worksheets[$worksheet];
536 foreach ($csvfile as $csvrow)
538 $csvrow =& str_replace(
"\n",
" ", $this->object->processCSVRow($csvrow, TRUE,
$separator));
541 include_once
"./Services/Utilities/classes/class.ilUtil.php";
559 if (!$ilAccess->checkAccess(
"write",
"", $this->object->getRefId()))
562 $this->ctrl->redirectByClass(
"ilObjSurveyGUI",
"infoScreen");
564 if (!is_array($_POST))
568 if (array_key_exists(
"export_format", $_POST))
573 $this->tpl->addCss(
"./Modules/Survey/templates/default/survey_print.css",
"print");
574 $userResults =& $this->
object->getUserSpecificResults();
576 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_evaluation_user.html",
"Modules/Survey");
578 $classes = array(
"tblrow1top",
"tblrow2top");
579 $questions =& $this->
object->getSurveyQuestions(
true);
580 $this->tpl->setCurrentBlock(
"headercell");
581 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"username"));
582 $this->tpl->parseCurrentBlock();
585 $this->tpl->setCurrentBlock(
"headercell");
586 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"gender"));
587 $this->tpl->parseCurrentBlock();
589 $this->tpl->setCurrentBlock(
"headercell");
590 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"question"));
591 $this->tpl->parseCurrentBlock();
593 $this->tpl->setCurrentBlock(
"headercell");
594 $this->tpl->setVariable(
"TEXT_HEADER_CELL", $this->lng->txt(
"results"));
595 $this->tpl->parseCurrentBlock();
598 $participants =& $this->
object->getSurveyParticipants();
599 foreach ($participants as
$data)
601 $this->tpl->setCurrentBlock(
"bodycell");
602 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
603 $this->tpl->setVariable(
"TEXT_BODY_CELL", $data[
"sortname"]);
604 $this->tpl->parseCurrentBlock();
607 $this->tpl->setCurrentBlock(
"bodycell");
608 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
609 $this->tpl->setVariable(
"TEXT_BODY_CELL", $data[
"gender"]);
610 $this->tpl->parseCurrentBlock();
613 $questioncounter = 1;
614 foreach ($questions as $question_id => $question_data)
624 $this->tpl->setCurrentBlock(
"bodycell");
625 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
626 $this->tpl->parseCurrentBlock();
628 $this->tpl->setCurrentBlock(
"bodycell");
629 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
630 $this->tpl->parseCurrentBlock();
632 $this->tpl->setCurrentBlock(
"bodycell");
633 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
634 $this->tpl->setVariable(
"TEXT_BODY_CELL", $questioncounter++ .
". " . $question_data[
"title"]);
635 $this->tpl->parseCurrentBlock();
637 $found = $userResults[$question_id][$data[
"active_id"]];
639 if (is_array($found))
641 $text = implode(
"<br />", $found);
647 if (strlen($text) == 0) $text = $this->lng->txt(
"skipped");
648 $this->tpl->setCurrentBlock(
"bodycell");
649 $this->tpl->setVariable(
"COLOR_CLASS", $classes[$counter % 2]);
650 $this->tpl->setVariable(
"TEXT_BODY_CELL", $text);
651 $this->tpl->parseCurrentBlock();
652 $this->tpl->setCurrentBlock(
"row");
653 $this->tpl->parse(
"row");
657 $this->tpl->setCurrentBlock(
"generic_css");
658 $this->tpl->setVariable(
"LOCATION_GENERIC_STYLESHEET",
"./Modules/Survey/templates/default/evaluation_print.css");
659 $this->tpl->setVariable(
"MEDIA_GENERIC_STYLESHEET",
"print");
660 $this->tpl->parseCurrentBlock();
661 $this->tpl->setCurrentBlock(
"adm_content");
662 $this->tpl->setVariable(
"EXPORT_DATA", $this->lng->txt(
"export_data_as"));
663 $this->tpl->setVariable(
"TEXT_EXCEL", $this->lng->txt(
"exp_type_excel"));
664 $this->tpl->setVariable(
"TEXT_CSV", $this->lng->txt(
"exp_type_csv"));
665 $this->tpl->setVariable(
"BTN_EXPORT", $this->lng->txt(
"export"));
666 $this->tpl->setVariable(
"BTN_PRINT", $this->lng->txt(
"print"));
667 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this,
"evaluationuser"));
668 $this->tpl->setVariable(
"PRINT_ACTION", $this->ctrl->getFormAction($this,
"evaluationuser"));
669 $this->tpl->setVariable(
"CMD_EXPORT",
"evaluationuser");
670 $this->tpl->parseCurrentBlock();
682 $survey_id =
$_GET[
"survey"];
683 $question_id =
$_GET[
"question"];
684 $type = (strlen(
$_GET[
"type"])) ?
$_GET[
"type"] :
"";
685 $question =& $this->
object->_instanciateQuestion($question_id);
686 $question->outChart($survey_id, $type);