ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestEvaluationGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
25 include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
26 
40 {
50  function ilTestEvaluationGUI($a_object)
51  {
52  global $ilAccess;
53 
54  parent::ilTestServiceGUI($a_object);
55  }
56 
60  function &executeCommand()
61  {
62  global $ilUser;
63  $cmd = $this->ctrl->getCmd();
64  $next_class = $this->ctrl->getNextClass($this);
65  $this->ctrl->saveParameter($this, "sequence");
66  $this->ctrl->saveParameter($this, "active_id");
67  $cmd = $this->getCommand($cmd);
68  switch($next_class)
69  {
70  default:
71  $ret =& $this->$cmd();
72  break;
73  }
74  return $ret;
75  }
76 
77  function &getHeaderNames()
78  {
79  $headernames = array();
80  if ($this->object->getAnonymity())
81  {
82  array_push($headernames, $this->lng->txt("counter"));
83  }
84  else
85  {
86  array_push($headernames, $this->lng->txt("name"));
87  array_push($headernames, $this->lng->txt("login"));
88  }
89  $additionalFields = $this->object->getEvaluationAdditionalFields();
90  if (count($additionalFields))
91  {
92  foreach ($additionalFields as $fieldname)
93  {
94  array_push($headernames, $this->lng->txt($fieldname));
95  }
96  }
97  array_push($headernames, $this->lng->txt("tst_reached_points"));
98  array_push($headernames, $this->lng->txt("tst_mark"));
99  if ($this->object->ects_output)
100  {
101  array_push($headernames, $this->lng->txt("ects_grade"));
102  }
103  array_push($headernames, $this->lng->txt("tst_answered_questions"));
104  array_push($headernames, $this->lng->txt("working_time"));
105  array_push($headernames, $this->lng->txt("detailed_evaluation"));
106  return $headernames;
107  }
108 
109  function &getHeaderVars()
110  {
111  $headervars = array();
112  if ($this->object->getAnonymity())
113  {
114  array_push($headervars, "counter");
115  }
116  else
117  {
118  array_push($headervars, "name");
119  array_push($headervars, "login");
120  }
121  array_push($headervars, "resultspoints");
122  array_push($headervars, "resultsmarks");
123  if ($this->object->ects_output)
124  {
125  array_push($headervars, "ects_grade");
126  }
127  array_push($headervars, "qworkedthrough");
128  array_push($headervars, "timeofwork");
129  array_push($headervars, "");
130  return $headervars;
131  }
132 
140  function outEvaluation()
141  {
142  global $ilAccess;
143 
144  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
145  {
146  // allow only evaluation access
147  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
148  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
149  }
150 
151  global $ilUser;
152 
153  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation.html", "Modules/Test");
154 
155  $filter = 0;
156  $filtertext = "";
157  $filterby = "";
158  $passedonly = FALSE;
159  $setting = new ilSetting("assessment");
160  // set filter was pressed
161  if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("set_filter")) == 0)
162  {
163  $filter = 1;
164  $filtertext = trim($_POST["userfilter"]);
165  $filterby = $_POST["filterby"];
166  if ($_POST["passedonly"] == 1)
167  {
168  $passedonly = TRUE;
169  }
170  if ((strlen($filtertext) == 0) && ($passedonly == FALSE)) $filter = 0;
171  // save the filter for later usage
172  $setting->set("tst_stat_filter_passed_" . $this->object->getTestId(), ($passedonly) ? 1 : 0);
173  $setting->set("tst_stat_filter_text_" . $this->object->getTestId(), $filtertext);
174  $setting->set("tst_stat_filter_by_" . $this->object->getTestId(), $filterby);
175  }
176  else
177  {
178  if (array_key_exists("g_userfilter", $_GET))
179  {
180  $filtertext = $_GET["g_userfilter"];
181  $filterby = $_GET["g_filterby"];
182  }
183  else
184  {
185  // try to read the filter from the users preferences
186  $pref = $setting->get("tst_stat_filter_text_" . $this->object->getTestId());
187  if ($pref !== FALSE)
188  {
189  $filtertext = $pref;
190  }
191  $pref = $setting->get("tst_stat_filter_by_" . $this->object->getTestId());
192  if ($pref !== FALSE)
193  {
194  $filterby = $pref;
195  }
196  }
197  if (array_key_exists("g_passedonly", $_GET))
198  {
199  if ($_GET["g_passedonly"] == 1)
200  {
201  $passedonly = TRUE;
202  }
203  }
204  else
205  {
206  // try to read the filter from the users preferences
207  $pref = $setting->get("tst_stat_filter_passed_" . $this->object->getTestId());
208  if ($pref !== FALSE)
209  {
210  $passedonly = ($pref) ? TRUE : FALSE;
211  }
212  }
213  }
214  // reset filter was pressed
215  if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("reset_filter")) == 0)
216  {
217  $filter = 0;
218  $filtertext = "";
219  $filterby = "name";
220  $passedonly = FALSE;
221  $setting->delete("tst_stat_filter_passed_" . $this->object->getTestId());
222  $setting->delete("tst_stat_filter_text_" . $this->object->getTestId());
223  $setting->delete("tst_stat_filter_by_" . $this->object->getTestId());
224  }
225  if (strlen($filtertext))
226  {
227  $this->ctrl->setParameter($this, "g_userfilter", $filtertext);
228  $this->ctrl->setParameter($this, "g_filterby", $filterby);
229  }
230  if ($passedonly)
231  {
232  $this->ctrl->setParameter($this, "g_passedonly", "1");
233  }
234 
235  $offset = ($_GET["offset"]) ? $_GET["offset"] : 0;
236  $orderdirection = ($_GET["sort_order"]) ? $_GET["sort_order"] : "asc";
237  $defaultOrderColumn = "name";
238  if ($this->object->getAnonymity()) $defaultOrderColumn = "counter";
239  $ordercolumn = ($_GET["sort_by"]) ? $_GET["sort_by"] : $defaultOrderColumn;
240 
241  $maxentries = $ilUser->getPref("hits_per_page");
242  if ($maxentries < 1)
243  {
244  $maxentries = 9999;
245  }
246 
247  include_once("./Services/Table/classes/class.ilTableGUI.php");
248  $table = new ilTableGUI(0, FALSE);
249  $table->setTitle($this->lng->txt("participants_evaluation"));
250  $table->setHeaderNames($this->getHeaderNames());
251 
252  $table->enable("auto_sort");
253  $table->enable("sort");
254  $table->setLimit($maxentries);
255 
256  $header_params = $this->ctrl->getParameterArray($this, "outEvaluation");
257  $header_vars = $this->getHeaderVars();
258  $table->setHeaderVars($header_vars, $header_params);
259  $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
260 
261  $table->setOffset($offset);
262  $table->setMaxCount(count($total_users));
263  $table->setOrderColumn($ordercolumn);
264  $table->setOrderDirection($orderdirection);
265 
266  $evaluation_rows = array();
267  $counter = 1;
268  include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
269  $data = new ilTestEvaluationData($this->object);
270 // $data =& $this->object->getCompleteEvaluationData(FALSE, $filterby, $filtertext);
271  $data->setFilter($filterby, $filtertext);
272  $foundParticipants =& $data->getParticipants();
273  if (count($foundParticipants) == 0)
274  {
275  $this->tpl->setVariable("EVALUATION_DATA", $this->lng->txt("tst_no_evaluation_data"));
276  }
277  $additionalFields = $this->object->getEvaluationAdditionalFields();
278 
279  if ($this->object->ects_output)
280  {
281  $passed_array =& $this->object->getTotalPointsPassedArray();
282  }
283  foreach ($data->getParticipants() as $active_id => $userdata)
284  {
285  $remove = FALSE;
286  if ($passedonly)
287  {
288  if ($userdata->getPassed() == FALSE)
289  {
290  $remove = TRUE;
291  }
292  }
293  if (!$remove)
294  {
295  // build the evaluation row
296  $evaluationrow = array();
297  $fullname = "";
298  if ($this->object->getAnonymity())
299  {
300  $fullname = $counter;
301  array_push($evaluationrow, $fullname);
302  }
303  else
304  {
305  array_push($evaluationrow, $userdata->getName());
306  if (strlen($userdata->getLogin()))
307  {
308  array_push($evaluationrow, "[" . $userdata->getLogin() . "]");
309  }
310  else
311  {
312  array_push($evaluationrow, "");
313  }
314  }
315  if (count($additionalFields))
316  {
317  $userfields = ilObjUser::_lookupFields($userdata->getUserID());
318  foreach ($additionalFields as $fieldname)
319  {
320  if (strcmp($fieldname, "gender") == 0)
321  {
322  array_push($evaluationrow, $this->lng->txt("gender_" . $userfields[$fieldname]));
323  }
324  else
325  {
326  array_push($evaluationrow, $userfields[$fieldname]);
327  }
328  }
329  }
330  array_push($evaluationrow, $userdata->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $userdata->getMaxpoints());
331  $percentage = $userdata->getReachedPointsInPercent();
332  $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
333  if (is_object($mark))
334  {
335  array_push($evaluationrow, $mark->getShortName());
336  }
337  if ($this->object->ects_output)
338  {
339  $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
340  array_push($evaluationrow, $ects_mark);
341  }
342  array_push($evaluationrow, $userdata->getQuestionsWorkedThrough() . " " . strtolower($this->lng->txt("of")) . " " . $userdata->getNumberOfQuestions() . " (" . sprintf("%2.2f", $userdata->getQuestionsWorkedThroughInPercent()) . " %" . ")");
343 
344  $time_seconds = $userdata->getTimeOfWork();
345  $time_hours = floor($time_seconds/3600);
346  $time_seconds -= $time_hours * 3600;
347  $time_minutes = floor($time_seconds/60);
348  $time_seconds -= $time_minutes * 60;
349  array_push($evaluationrow, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
350  $this->ctrl->setParameter($this, "active_id", $active_id);
351  $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
352  $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
353  array_push($evaluationrow, "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>");
354  array_push($evaluation_rows, $evaluationrow);
355  $counter++;
356  }
357  }
358  if (count($foundParticipants) > 0)
359  {
360  $table->setData($evaluation_rows);
361  $tableoutput = $table->render();
362  $this->tpl->setVariable("EVALUATION_DATA", $tableoutput);
363  }
364 
365  $template = new ilTemplate("tpl.il_as_tst_evaluation_filter.html", TRUE, TRUE, "Modules/Test");
366  $filters = array("name" => $this->lng->txt("name"), "group" => $this->lng->txt("grp"), "course" => $this->lng->txt("crs"));
367  foreach ($filters as $value => $name)
368  {
369  $template->setCurrentBlock("filterby");
370  $template->setVariable("FILTER_BY_NAME", $name);
371  $template->setVariable("FILTER_BY_VALUE", $value);
372  if (strcmp($filterby, $value) == 0)
373  {
374  $template->setVariable("FILTER_BY_SELECTED", " selected=\"selected\"");
375  }
376  $template->parseCurrentBlock();
377  }
378  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "outEvaluation"));
379  $template->setVariable("TEXT_FILTER_USERS", $this->lng->txt("filter"));
380  $template->setVariable("TEXT_FILTER", $this->lng->txt("set_filter"));
381  $template->setVariable("TEXT_BY", $this->lng->txt("by"));
382  $template->setVariable("TEXT_RESET_FILTER", $this->lng->txt("reset_filter"));
383  $template->setVariable("TEXT_PASSEDONLY", $this->lng->txt("passed_only"));
384  if ($passedonly)
385  {
386  $template->setVariable("CHECKED_PASSEDONLY", " checked=\"checked\"");
387  }
388  if (strlen($filtertext) > 0)
389  {
390  $template->setVariable("VALUE_FILTER_USERS", " value=\"" . $filtertext . "\"");
391  }
392  $filteroutput = $template->get();
393 
394  if (count($foundParticipants) > 0)
395  {
396  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
397  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
398  if (!$this->object->getAnonymity())
399  {
400  include_once "./Modules/Test/classes/class.ilTestCertificate.php";
401  if (ilTestCertificate::_isComplete($this->object->getId()))
402  {
403  $template->setVariable("TEXT_CERTIFICATE", $this->lng->txt("exp_type_certificate"));
404  }
405  }
406  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
407  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
408  $template->setVariable("CMD_EXPORT", "exportEvaluation");
409  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
410  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
411  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
412  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportEvaluation"));
413  $exportoutput = $template->get();
414  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
415  }
416 
417  $this->tpl->setVariable("EVALUATION_FILTER", $filteroutput);
418 
419  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
420  if ($this->object->getShowSolutionAnswersOnly())
421  {
422  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
423  }
424  }
425 
434  {
435  global $ilAccess;
436 
437  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
438  {
439  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), TRUE);
440  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
441  }
442 
443  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation_details.html", "Modules/Test");
444 
445  $active_id = $_GET["active_id"];
446  if (strlen($active_id) == 0)
447  {
448  ilUtil::sendInfo($this->lng->txt("detailed_evaluation_missing_active_id"), TRUE);
449  $this->ctrl->redirect($this, "outEvaluation");
450  }
451 
452  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
453 
454  $data =& $this->object->getCompleteEvaluationData();
455  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
456  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outEvaluation"));
457  $this->tpl->setVariable("HEADING_DETAILED_EVALUATION", sprintf($this->lng->txt("detailed_evaluation_for"),
458  $data->getParticipant($active_id)->getName())
459  );
460  $this->tpl->setVariable("STATISTICAL_DATA", $this->lng->txt("statistical_data"));
461  $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
462  $this->tpl->setVariable("VALUE_RESULTSPOINTS", $data->getParticipant($active_id)->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getMaxpoints() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getReachedPointsInPercent()) . " %" . ")");
463  if (strlen($data->getParticipant($active_id)->getMark()))
464  {
465  $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
466  $this->tpl->setVariable("VALUE_RESULTSMARKS", $data->getParticipant($active_id)->getMark());
467  if (strlen($data->getParticipant($active_id)->getECTSMark()))
468  {
469  $this->tpl->setVariable("TXT_ECTS", $this->lng->txt("ects_grade"));
470  $this->tpl->setVariable("VALUE_ECTS", $data->getParticipant($active_id)->getECTSMark());
471  }
472  }
473  $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
474  $this->tpl->setVariable("VALUE_QWORKEDTHROUGH", $data->getParticipant($active_id)->getQuestionsWorkedThrough() . " " . strtolower($this->lng->txt("of")) . " " . $data->getParticipant($active_id)->getNumberOfQuestions() . " (" . sprintf("%2.2f", $data->getParticipant($active_id)->getQuestionsWorkedThroughInPercent()) . " %" . ")");
475 
476  $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
477  $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
478  $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
479  $time_hours = floor($time_seconds/3600);
480  $time_seconds -= $time_hours * 3600;
481  $time_minutes = floor($time_seconds/60);
482  $time_seconds -= $time_minutes * 60;
483  $this->tpl->setVariable("VALUE_TIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
484  $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
485  $time_hours = floor($atime_seconds/3600);
486  $atime_seconds -= $time_hours * 3600;
487  $time_minutes = floor($atime_seconds/60);
488  $atime_seconds -= $time_minutes * 60;
489  $this->tpl->setVariable("VALUE_ATIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
490  $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
491  #$this->tpl->setVariable("VALUE_FIRSTVISIT",
492  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getFirstVisit())
493  #);
494  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
495  new ilDateTime($data->getParticipant($active_id)->getFirstVisit(),IL_CAL_UNIX)));
496  $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
497  #$this->tpl->setVariable("VALUE_LASTVISIT",
498  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getLastVisit())
499  #);
500  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
501  new ilDateTime($data->getParticipant($active_id)->getLastVisit(),IL_CAL_UNIX)));
502 
503  $this->tpl->setVariable("TXT_NROFPASSES", $this->lng->txt("tst_nr_of_passes"));
504  $this->tpl->setVariable("VALUE_NROFPASSES", $data->getParticipant($active_id)->getLastPass() + 1);
505  $this->tpl->setVariable("TXT_SCOREDPASS", $this->lng->txt("scored_pass"));
506  if ($this->object->getPassScoring() == SCORE_BEST_PASS)
507  {
508  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getBestPass() + 1);
509  }
510  else
511  {
512  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getLastPass() + 1);
513  }
514 
515  $median = $data->getStatistics()->getStatistics()->median();
516  $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
517  $mark = $this->object->mark_schema->getMatchingMark($pct);
518  if (is_object($mark))
519  {
520  $this->tpl->setVariable("TXT_MARK_MEDIAN", $this->lng->txt("tst_stat_result_mark_median"));
521  $this->tpl->setVariable("VALUE_MARK_MEDIAN", $mark->getShortName());
522  }
523 
524  $this->tpl->setVariable("TXT_RANK_PARTICIPANT", $this->lng->txt("tst_stat_result_rank_participant"));
525  $this->tpl->setVariable("VALUE_RANK_PARTICIPANT", $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
526  $this->tpl->setVariable("TXT_RANK_MEDIAN", $this->lng->txt("tst_stat_result_rank_median"));
527  $this->tpl->setVariable("VALUE_RANK_MEDIAN", $data->getStatistics()->getStatistics()->rank_median());
528  $this->tpl->setVariable("TXT_TOTAL_PARTICIPANTS", $this->lng->txt("tst_stat_result_total_participants"));
529  $this->tpl->setVariable("VALUE_TOTAL_PARTICIPANTS", $data->getStatistics()->getStatistics()->count());
530  $this->tpl->setVariable("TXT_RESULT_MEDIAN", $this->lng->txt("tst_stat_result_median"));
531  $this->tpl->setVariable("VALUE_RESULT_MEDIAN", $median);
532 
533  for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
534  {
535  $finishdate = $this->object->getPassFinishDate($active_id, $pass);
536  if ($finishdate > 0)
537  {
538  $this->tpl->setCurrentBlock("question_header");
539  $this->tpl->setVariable("TXT_QUESTION_DATA", sprintf($this->lng->txt("tst_eval_question_points"), $pass+1));
540  $this->tpl->parseCurrentBlock();
541  global $ilAccess;
542  if (($ilAccess->checkAccess("write", "", $_GET["ref_id"])))
543  {
544  $this->tpl->setCurrentBlock("question_footer");
545  $this->tpl->setVariable("TEXT_TO_DETAILED_RESULTS", $this->lng->txt("tst_show_answer_sheet"));
546  $this->ctrl->setParameter($this, "statistics", "1");
547  $this->ctrl->setParameter($this, "active_id", $active_id);
548  $this->ctrl->setParameter($this, "pass", $pass);
549  $this->tpl->setVariable("URL_TO_DETAILED_RESULTS", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
550  $this->tpl->parseCurrentBlock();
551  }
552  $questions = $data->getParticipant($active_id)->getQuestions($pass);
553  if (!is_array($questions))
554  {
555  $questions = $data->getParticipant($active_id)->getQuestions(0);
556  }
557  $counter = 1;
558  foreach ($questions as $question)
559  {
560  $this->tpl->setCurrentBlock("question_row");
561  $this->tpl->setVariable("QUESTION_COUNTER", $counter);
562  $this->tpl->setVariable("QUESTION_TITLE", $data->getQuestionTitle($question["id"]));
563  $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
564  if (is_array($answeredquestion))
565  {
566  $percent = $answeredquestion["points"] ? $answeredquestion["reached"] / $answeredquestion["points"] * 100.0 : 0;
567  $this->tpl->setVariable("QUESTION_POINTS", $answeredquestion["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $answeredquestion["points"] . " (" . sprintf("%.2f", $percent) . " %)");
568  }
569  else
570  {
571  $this->tpl->setVariable("QUESTION_POINTS", "0 " . strtolower($this->lng->txt("of")) . " " . $question["points"] . " (" . sprintf("%.2f", 0) . " %) - " . $this->lng->txt("question_not_answered"));
572  }
573  $this->tpl->parseCurrentBlock();
574  $counter++;
575  }
576  $this->tpl->touchBlock("question_stats");
577  }
578  }
579  }
580 
587  {
588  $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
589  }
590 
598  function eval_a()
599  {
600  global $ilAccess;
601 
602  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
603  {
604  // allow only evaluation access
605  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
606  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
607  }
608 
609  $data =& $this->object->getCompleteEvaluationData();
610  $color_class = array("tblrow1", "tblrow2");
611  $counter = 0;
612  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
613  $foundParticipants =& $data->getParticipants();
614  if (count($foundParticipants))
615  {
616  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
617  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
618  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
619  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
620  $template->setVariable("CMD_EXPORT", "exportAggregatedResults");
621  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
622  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
623  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
624  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportAggregatedResults"));
625  $exportoutput = $template->get();
626  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
627 
628  $this->tpl->setCurrentBlock("row");
629  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_persons"));
630  $this->tpl->setVariable("TXT_VALUE", count($foundParticipants));
631  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
632  $counter++;
633  $this->tpl->parseCurrentBlock();
634  $this->tpl->setCurrentBlock("row");
635  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished"));
636  $total_finished = $this->object->evalTotalFinished();
637  $this->tpl->setVariable("TXT_VALUE", $total_finished);
638  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
639  $counter++;
640  $this->tpl->parseCurrentBlock();
641  $this->tpl->setCurrentBlock("row");
642  $average_time = $this->object->evalTotalStartedAverageTime();
643  $diff_seconds = $average_time;
644  $diff_hours = floor($diff_seconds/3600);
645  $diff_seconds -= $diff_hours * 3600;
646  $diff_minutes = floor($diff_seconds/60);
647  $diff_seconds -= $diff_minutes * 60;
648  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished_average_time"));
649  $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
650  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
651  $counter++;
652  $total_passed = 0;
653  $total_passed_reached = 0;
654  $total_passed_max = 0;
655  $total_passed_time = 0;
656  foreach ($foundParticipants as $userdata)
657  {
658  if ($userdata->getPassed())
659  {
660  $total_passed++;
661  $total_passed_reached += $userdata->getReached();
662  $total_passed_max += $userdata->getMaxpoints();
663  $total_passed_time += $userdata->getTimeOfWork();
664  }
665  }
666  $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
667  $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
668  $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
669  $this->tpl->parseCurrentBlock();
670  $this->tpl->setCurrentBlock("row");
671  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed"));
672  $this->tpl->setVariable("TXT_VALUE", $total_passed);
673  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
674  $counter++;
675  $this->tpl->parseCurrentBlock();
676  $this->tpl->setCurrentBlock("row");
677  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_points"));
678  $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max));
679  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
680  $counter++;
681  $this->tpl->parseCurrentBlock();
682  $this->tpl->setCurrentBlock("row");
683  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_time"));
684  $average_time = $average_passed_time;
685  $diff_seconds = $average_time;
686  $diff_hours = floor($diff_seconds/3600);
687  $diff_seconds -= $diff_hours * 3600;
688  $diff_minutes = floor($diff_seconds/60);
689  $diff_seconds -= $diff_minutes * 60;
690  $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
691  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
692  $counter++;
693  $this->tpl->parseCurrentBlock();
694  }
695  else
696  {
697  $this->tpl->setCurrentBlock("emptyrow");
698  $this->tpl->setVariable("TXT_NO_ANONYMOUS_AGGREGATION", $this->lng->txt("tst_eval_no_anonymous_aggregation"));
699  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
700  $this->tpl->parseCurrentBlock();
701  }
702 
703  global $ilUser;
704  $maxentries = $ilUser->getPref("hits_per_page");
705  if ($maxentries < 1)
706  {
707  $maxentries = 9999;
708  }
709 
710  $offset = ($_GET["offset"]) ? $_GET["offset"] : 0;
711  $orderdirection = ($_GET["sort_order"]) ? $_GET["sort_order"] : "asc";
712  $defaultOrderColumn = "name";
713  if ($this->object->getAnonymity()) $defaultOrderColumn = "counter";
714  $ordercolumn = ($_GET["sort_by"]) ? $_GET["sort_by"] : $defaultOrderColumn;
715 
716  $counter = 0;
717  include_once("./Services/Table/classes/class.ilTableGUI.php");
718  $table = new ilTableGUI(0, FALSE);
719  $table->setTitle($this->lng->txt("average_reached_points"));
720  $table->setHeaderNames(array($this->lng->txt("question_title"), $this->lng->txt("points"), $this->lng->txt("percentage"), $this->lng->txt("number_of_answers")));
721 
722  $table->enable("auto_sort");
723  $table->enable("sort");
724  $table->setLimit($maxentries);
725 
726  $header_params = $this->ctrl->getParameterArray($this, "eval_a");
727  $header_vars = array("question_title", "points", "percentage", "number_of_answers");
728  $table->setHeaderVars($header_vars, $header_params);
729  $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
730 
731  $table->setOffset($offset);
732  $table->setMaxCount(count($data->getQuestionTitles()));
733  $table->setOrderColumn($ordercolumn);
734  $table->setOrderDirection($orderdirection);
735  $rows = array();
736  foreach ($data->getQuestionTitles() as $question_id => $question_title)
737  {
738  $answered = 0;
739  $reached = 0;
740  $max = 0;
741  foreach ($foundParticipants as $userdata)
742  {
743  for ($i = 0; $i <= $userdata->getLastPass(); $i++)
744  {
745  if (is_object($userdata->getPass($i)))
746  {
747  $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
748  if (is_array($question))
749  {
750  $answered++;
751  $reached += $question["reached"];
752  $max += $question["points"];
753  }
754  }
755  }
756  }
757  $percent = $max ? $reached/$max * 100.0 : 0;
758  $counter++;
759  $this->ctrl->setParameter($this, "qid", $question_id);
760  array_push($rows,
761  array(
762  $question_title,
763  sprintf("%.2f", $answered ? $reached / $answered : 0) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $answered ? $max / $answered : 0),
764  sprintf("%.2f", $percent) . "%",
765  $answered
766  )
767  );
768  }
769  $table->setData($rows);
770  $tableoutput = $table->render();
771  $this->tpl->setVariable("TBL_AVG_REACHED", $tableoutput);
772 
773  $this->tpl->setCurrentBlock("adm_content");
774  $this->tpl->setVariable("TXT_ANON_EVAL", $this->lng->txt("tst_anon_eval"));
775  $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
776  $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
777  $this->tpl->setVariable("TXT_AVG_REACHED", $this->lng->txt("average_reached_points"));
778  $this->tpl->setVariable("TXT_QUESTIONTITLE", $this->lng->txt("question_title"));
779  $this->tpl->setVariable("TXT_POINTS", $this->lng->txt("points"));
780  $this->tpl->setVariable("TXT_ANSWERS", $this->lng->txt("number_of_answers"));
781  $this->tpl->setVariable("TXT_PERCENT", $this->lng->txt("percentage"));
782  $this->tpl->parseCurrentBlock();
783  }
784 
792  function exportEvaluation()
793  {
794  $filterby = "";
795  if (array_key_exists("g_filterby", $_GET))
796  {
797  $filterby = $_GET["g_filterby"];
798  }
799  $filtertext = "";
800  if (array_key_exists("g_userfilter", $_GET))
801  {
802  $filtertext = $_GET["g_userfilter"];
803  }
804  $passedonly = FALSE;
805  if (array_key_exists("g_passedonly", $_GET))
806  {
807  if ($_GET["g_passedonly"] == 1)
808  {
809  $passedonly = TRUE;
810  }
811  }
812  switch ($_POST["export_type"])
813  {
814  case "excel":
815  include_once "./Modules/Test/classes/class.ilTestExport.php";
816  $exportObj = new ilTestExport($this->object, "results");
817  $exportObj->exportToExcel($deliver = TRUE, $filterby, $filtertext, $passedonly);
818  break;
819  case "csv":
820  include_once "./Modules/Test/classes/class.ilTestExport.php";
821  $exportObj = new ilTestExport($this->object, "results");
822  $exportObj->exportToCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
823  break;
824  case "certificate":
825  if ($passedonly)
826  {
827  $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
828  }
829  if (strlen($filtertext))
830  {
831  $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
832  }
833  $this->ctrl->redirectByClass("iltestcertificategui", "exportCertificate");
834  break;
835  }
836  }
837 
844  {
845  switch ($_POST["export_type"])
846  {
847  case "excel":
848  include_once "./Modules/Test/classes/class.ilTestExport.php";
849  $exportObj = new ilTestExport($this->object, "aggregated");
850  $exportObj->exportToExcel($deliver = TRUE);
851  break;
852  case "csv":
853  include_once "./Modules/Test/classes/class.ilTestExport.php";
854  $exportObj = new ilTestExport($this->object, "aggregated");
855  $exportObj->exportToCSV($deliver = TRUE);
856  break;
857  }
858  }
859 
866  function getEvaluationQuestionId($question_id, $original_id = "")
867  {
868  if ($original_id > 0)
869  {
870  return $original_id;
871  }
872  else
873  {
874  return $question_id;
875  }
876  }
877 
878  function saveEvalSettings()
879  {
880  $results = $_POST;
881  $additionalFields = array();
882  foreach ($results as $key => $value)
883  {
884  if (preg_match("/cb_(\w+)/", $key, $matches) && ($value == 1))
885  {
886  array_push($additionalFields, $matches[1]);
887  }
888  }
889  $this->object->setEvaluationAdditionalFields($additionalFields);
890  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), TRUE);
891  $this->ctrl->redirect($this, "evalSettings");
892  }
893 
894  function evalSettings()
895  {
896  global $ilAccess;
897 
898  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
899  {
900  // allow only evaluation access
901  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
902  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
903  }
904 
905  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
906  $form = new ilPropertyFormGUI();
907  $form->setFormAction($this->ctrl->getFormAction($this, "saveEvalSettings"));
908  $form->setTitle($this->lng->txt("assessment_eval_settings"));
909 
910  // Additional User fields
911  $fields = array("gender", "email", "institution", "street", "city", "zipcode", "country", "department", "matriculation");
912  $additionalFields = $this->object->getEvaluationAdditionalFields();
913 
914  foreach ($fields as $dbfield)
915  {
916  $checkbox = new ilCheckboxInputGUI($this->lng->txt($dbfield), "cb_" . $dbfield);
917 // $checkbox->setInfo($lng->txt("assessment_use_javascript_desc"));
918  if ($this->object->getAnonymity())
919  {
920  $checkbox->setDisabled(TRUE);
921  }
922  else
923  {
924  if (in_array($dbfield, $additionalFields)) $checkbox->setChecked(TRUE);
925  }
926  $form->addItem($checkbox);
927  }
928  $form->addCommandButton("saveEvalSettings", $this->lng->txt("save"));
929 
930  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
931  }
932 
941  {
942  global $ilias;
943 
944  $this->ctrl->saveParameter($this, "pass");
945  $this->ctrl->saveParameter($this, "active_id");
946  $active_id = $_GET["active_id"];
947  $pass = $_GET["pass"];
948  $result_array =& $this->object->getTestResult($active_id, $pass);
949 
950  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outParticipantsPassDetails");
951  $user_data = $this->getResultsUserdata($active_id, FALSE);
952 
953  $user_id = $this->object->_getUserIdFromActiveId($active_id);
954 
955  $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
956 
957  if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
958  {
959  $this->ctrl->setParameter($this, "pdf", "1");
960  $template->setCurrentBlock("pdf_export");
961  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
962  $this->ctrl->setParameter($this, "pdf", "");
963  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
964  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
965  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
966  $template->parseCurrentBlock();
967  }
968 
969  if (array_key_exists("statistics", $_GET) && ($_GET["statistics"] == 1))
970  {
971  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
972  $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
973  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilTestEvaluationGUI", "detailedEvaluation"));
974  }
975  else
976  {
977  if ($this->object->getNrOfTries() == 1)
978  {
979  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
980  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
981  }
982  else
983  {
984  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outParticipantsResultsOverview"));
985  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
986  }
987  }
988  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
989  $template->setVariable("PRINT_URL", "javascript:window.print();");
990 
991  if ($this->object->getNrOfTries() == 1)
992  {
993  $statement = $this->getFinalStatement($result_array["test"]);
994  $template->setVariable("USER_MARK", $statement["mark"]);
995  if (strlen($statement["markects"]))
996  {
997  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
998  }
999  }
1000 
1001  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, TRUE);
1002 
1003  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1004  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1005  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1006  $template->setVariable("PASS_DETAILS", $overview);
1007  $template->setVariable("USER_DETAILS", $user_data);
1008  $uname = $this->object->userLookupFullName($user_id);
1009  $template->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1010 
1011  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1012  if ($this->object->getShowSolutionAnswersOnly())
1013  {
1014  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1015  }
1016 
1017  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1018  {
1019  $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
1020  $printbody->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
1021  $printbody->setVariable("ADM_CONTENT", $template->get());
1022  $printoutput = $printbody->get();
1023  $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
1024  $fo = $this->object->processPrintoutput2FO($printoutput);
1025  $this->object->deliverPDFfromFO($fo);
1026  }
1027  else
1028  {
1029  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1030  }
1031  }
1032 
1041  {
1042  global $ilias;
1043 
1044  $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", TRUE, TRUE, "Modules/Test");
1045 
1046  $active_id = $_GET["active_id"];
1047  if ($this->object->getNrOfTries() == 1)
1048  {
1049  $this->ctrl->setParameter($this, "active_id", $active_id);
1050  $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
1051  $this->ctrl->redirect($this, "outParticipantsPassDetails");
1052  }
1053 
1054  if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
1055  {
1056  $this->ctrl->setParameter($this, "pdf", "1");
1057  $template->setCurrentBlock("pdf_export");
1058  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsResultsOverview"));
1059  $this->ctrl->setParameter($this, "pdf", "");
1060  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
1061  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
1062  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
1063  $template->parseCurrentBlock();
1064  }
1065 
1066  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outParticipantsPassDetails");
1067  $template->setVariable("PASS_OVERVIEW", $overview);
1068  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1069  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
1070  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
1071  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1072  $template->setVariable("PRINT_URL", "javascript:window.print();");
1073 
1074  $result_pass = $this->object->_getResultPass($active_id);
1075  $result_array =& $this->object->getTestResult($active_id, $result_pass);
1076  $statement = $this->getFinalStatement($result_array["test"]);
1077  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1078  $user_data = $this->getResultsUserdata($active_id);
1079  $template->setVariable("USER_DATA", $user_data);
1080  $template->setVariable("TEXT_OVERVIEW", $this->lng->txt("tst_results_overview"));
1081  $template->setVariable("USER_MARK", $statement["mark"]);
1082  if (strlen($statement["markects"]))
1083  {
1084  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
1085  }
1086  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1087  $template->parseCurrentBlock();
1088 
1089  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1090  if ($this->object->getShowSolutionAnswersOnly())
1091  {
1092  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1093  }
1094 
1095  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1096  {
1097  $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
1098  $printbody->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
1099  $printbody->setVariable("ADM_CONTENT", $template->get());
1100  $printoutput = $printbody->get();
1101  $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
1102  $fo = $this->object->processPrintoutput2FO($printoutput);
1103  $this->object->deliverPDFfromFO($fo);
1104  }
1105  else
1106  {
1107  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1108  }
1109  }
1110 
1119  {
1120  $this->ctrl->saveParameter($this, "pass");
1121  $this->ctrl->saveParameter($this, "active_id");
1122  $active_id = $_GET["active_id"];
1123  $pass = $_GET["pass"];
1124  $result_array =& $this->object->getTestResult($active_id, $pass);
1125 
1126  $command_solution_details = "";
1127  if ($this->object->getShowSolutionDetails())
1128  {
1129  $command_solution_details = "outCorrectSolution";
1130  }
1131  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserPassDetails", $command_solution_details);
1132 
1133  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1134 
1135  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_pass_details_overview_participants.html", "Modules/Test");
1136 
1137  if ($this->object->getNrOfTries() == 1)
1138  {
1139  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1140  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1141  }
1142  else
1143  {
1144  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outUserResultsOverview"));
1145  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
1146  }
1147 
1148  $this->tpl->parseCurrentBlock();
1149 
1150  if ($this->object->getNrOfTries() == 1)
1151  {
1152  $statement = $this->getFinalStatement($result_array["test"]);
1153  $this->tpl->setVariable("USER_MARK", $statement["mark"]);
1154  if (strlen($statement["markects"]))
1155  {
1156  $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
1157  }
1158  }
1159 
1160  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
1161 
1162  $this->tpl->setCurrentBlock("adm_content");
1163  $this->tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1164  $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1165  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1166  $this->tpl->setVariable("PASS_DETAILS", $overview);
1167  $uname = $this->object->userLookupFullName($user_id, TRUE);
1168  $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1169  $this->tpl->parseCurrentBlock();
1170 
1171  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1172  if ($this->object->getShowSolutionAnswersOnly())
1173  {
1174  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1175  }
1176  }
1177 
1186  {
1187  global $ilUser, $ilias;
1188 
1189  if (!$this->object->canShowTestResults($ilUser->getId())) $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1190  include_once("./classes/class.ilTemplate.php");
1191  $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
1192  $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
1193 
1194  $pass = null;
1195  $user_id = $ilUser->getId();
1196  $uname = $this->object->userLookupFullName($user_id, TRUE);
1197  $active_id = $this->object->getTestSession()->getActiveId();
1198  $hide_details = !$this->object->getShowPassDetails();
1199  if ($hide_details)
1200  {
1201  $executable = $this->object->isExecutable($ilUser->getId());
1202  if (!$executable["executable"]) $hide_details = FALSE;
1203  }
1204  if (($this->object->getNrOfTries() == 1) && (!$hide_details))
1205  {
1206  $pass = 0;
1207  }
1208  else
1209  {
1210  $template->setCurrentBlock("pass_overview");
1211  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserResultsOverview", FALSE, $hide_details);
1212  $template->setVariable("PASS_OVERVIEW", $overview);
1213  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview"));
1214  $template->parseCurrentBlock();
1215  }
1216 
1217  if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
1218  {
1219  if (is_null($pass)) $pass = $_GET["pass"];
1220  }
1221 
1222  if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
1223  {
1224  $this->ctrl->setParameter($this, "pass", $pass);
1225  $this->ctrl->setParameter($this, "pdf", "1");
1226  $templatehead->setCurrentBlock("pdf_export");
1227  $templatehead->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1228  $this->ctrl->setParameter($this, "pass", "");
1229  $this->ctrl->setParameter($this, "pdf", "");
1230  $templatehead->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
1231  $templatehead->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
1232  $templatehead->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
1233  $templatehead->parseCurrentBlock();
1234  if ($this->object->canShowCertificate($user_id, $active_id))
1235  {
1236  $templatehead->setVariable("CERTIFICATE_URL", $this->ctrl->getLinkTargetByClass("iltestcertificategui", "outCertificate"));
1237  $templatehead->setVariable("CERTIFICATE_TEXT", $this->lng->txt("certificate"));
1238  }
1239  }
1240  $templatehead->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1241  $templatehead->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1242  $templatehead->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1243  $templatehead->setVariable("PRINT_URL", "javascript:window.print();");
1244 
1245  $result_pass = $this->object->_getResultPass($active_id);
1246  $result_array =& $this->object->getTestResult($active_id, $result_pass);
1247  $statement = $this->getFinalStatement($result_array["test"]);
1248  $user_data = $this->getResultsUserdata($active_id, TRUE);
1249 
1250  // output of the details of a selected pass
1251  $this->ctrl->saveParameter($this, "pass");
1252  $this->ctrl->saveParameter($this, "active_id");
1253  if (!is_null($pass))
1254  {
1255  $result_array =& $this->object->getTestResult($active_id, $pass);
1256  $command_solution_details = "";
1257  if ($this->object->getShowSolutionDetails())
1258  {
1259  $command_solution_details = "outCorrectSolution";
1260  }
1261  $detailsoverview = (!$hide_details) ? $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserResultsOverview", $command_solution_details) : '';
1262 
1263  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1264 
1265  if (!$hide_details && $this->object->canShowSolutionPrintview())
1266  {
1267  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
1268  }
1269 
1270  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1271  $template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
1272  $template->setVariable("PASS_DETAILS", $detailsoverview);
1273 
1274  $signature = $this->getResultsSignature();
1275  $template->setVariable("SIGNATURE", $signature);
1276  }
1277  $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1278  $template->setVariable("USER_DATA", $user_data);
1279  $template->setVariable("USER_MARK", $statement["mark"]);
1280  if (strlen($statement["markects"]))
1281  {
1282  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
1283  }
1284  $template->parseCurrentBlock();
1285 
1286  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1287  if ($this->object->getShowSolutionAnswersOnly())
1288  {
1289  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1290  }
1291  $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1292 
1293  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1294  {
1295  $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
1296  $printbody->setVariable("TITLE", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1297  $printbody->setVariable("ADM_CONTENT", $template->get());
1298  $printoutput = $printbody->get();
1299  $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
1300  $fo = $this->object->processPrintoutput2FO($printoutput);
1301  $this->object->deliverPDFfromFO($fo);
1302  }
1303  else
1304  {
1305  $this->tpl->setVariable("PRINT_CONTENT", $templatehead->get());
1306  }
1307  }
1308 
1317  {
1318  global $ilUser;
1319 
1320  $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test");
1321 
1322  $pass = null;
1323  if (array_key_exists("pass", $_GET))
1324  {
1325  if (strlen($_GET["pass"])) $pass = $_GET["pass"];
1326  }
1327  $user_id = $ilUser->getId();
1328  $active_id = $this->object->getTestSession()->getActiveId();
1329  $overview = "";
1330  if ($this->object->getNrOfTries() == 1)
1331  {
1332  $pass = 0;
1333  }
1334  else
1335  {
1336  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserListOfAnswerPasses", TRUE);
1337  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1338  $template->setVariable("PASS_OVERVIEW", $overview);
1339  }
1340 
1341  $signature = "";
1342  if (strlen($pass))
1343  {
1344  $signature = $this->getResultsSignature();
1345  $result_array =& $this->object->getTestResult($active_id, $pass);
1346  $user_id =& $this->object->_getUserIdFromActiveId($active_id);
1347  $showAllAnswers = TRUE;
1348  if ($this->object->isExecutable($user_id))
1349  {
1350  $showAllAnswers = FALSE;
1351  }
1352  $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers);
1353  $template->setVariable("PASS_DETAILS", $answers);
1354  }
1355  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1356  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1357  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1358  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1359  $template->setVariable("PRINT_URL", "javascript:window.print();");
1360 
1361  $user_data = $this->getResultsUserdata($active_id, TRUE);
1362  $template->setVariable("USER_DATA", $user_data);
1363  $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1364  if (strlen($signature))
1365  {
1366  $template->setVariable("SIGNATURE", $signature);
1367  }
1368  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1369 
1370  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1371  if ($this->object->getShowSolutionAnswersOnly())
1372  {
1373  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1374  }
1375  }
1376 
1384  function passDetails()
1385  {
1386  if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1387  {
1388  $this->ctrl->saveParameter($this, "pass");
1389  $this->ctrl->saveParameter($this, "active_id");
1390  $this->outTestResults(false, $_GET["pass"]);
1391  }
1392  else
1393  {
1394  $this->outTestResults(false);
1395  }
1396  }
1397 
1404  {
1405  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "Modules/Test");
1406 
1407  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1408  $this->tpl->setCurrentBlock("ContentStyle");
1409  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
1410  $this->tpl->parseCurrentBlock();
1411 
1412  $this->tpl->setCurrentBlock("SyntaxStyle");
1413  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
1414  $this->tpl->parseCurrentBlock();
1415 
1416  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1417  if ($this->object->getShowSolutionAnswersOnly())
1418  {
1419  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1420  }
1421 
1422  $this->tpl->setCurrentBlock("adm_content");
1423  $solution = $this->getCorrectSolutionOutput($_GET["evaluation"], $_GET["active_id"], $_GET["pass"]);
1424  $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
1425  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
1426  $this->ctrl->saveParameter($this, "pass");
1427  $this->ctrl->saveParameter($this, "active_id");
1428  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1429  $this->tpl->parseCurrentBlock();
1430  }
1431 
1437  function singleResults()
1438  {
1439  global $ilAccess;
1440 
1441  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
1442  {
1443  // allow only evaluation access
1444  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1445  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1446  }
1447 
1448  $data =& $this->object->getCompleteEvaluationData();
1449  $color_class = array("tblrow1", "tblrow2");
1450  $counter = 0;
1451  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1452  $foundParticipants =& $data->getParticipants();
1453  if (count($foundParticipants) == 0)
1454  {
1455  $this->tpl->setCurrentBlock("no_participants");
1456  $this->tpl->setVariable("NO_PARTICIPANTS", $this->lng->txt("tst_no_evaluation_data"));
1457  $this->tpl->parseCurrentBlock();
1458  $this->tpl->setVariable("TXT_SINGLE_ANSWERS", $this->lng->txt("tst_answered_questions"));
1459  return;
1460  }
1461  $this->tpl->setVariable("TXT_SINGLE_ANSWERS", $this->lng->txt("tst_answered_questions"));
1462 
1463  global $ilUser;
1464  $maxentries = $ilUser->getPref("hits_per_page");
1465  if ($maxentries < 1)
1466  {
1467  $maxentries = 9999;
1468  }
1469 
1470  $offset = ($_GET["offset"]) ? $_GET["offset"] : 0;
1471  $orderdirection = ($_GET["sort_order"]) ? $_GET["sort_order"] : "asc";
1472  $defaultOrderColumn = "name";
1473  if ($this->object->getAnonymity()) $defaultOrderColumn = "counter";
1474  $ordercolumn = ($_GET["sort_by"]) ? $_GET["sort_by"] : $defaultOrderColumn;
1475 
1476  $counter = 0;
1477  include_once("./Services/Table/classes/class.ilTableGUI.php");
1478  $table = new ilTableGUI(0, FALSE);
1479  $table->setTitle($this->lng->txt("tst_answered_questions_test"));
1480  $table->setHeaderNames(array($this->lng->txt("question_title"), $this->lng->txt("number_of_answers"), $this->lng->txt("output")));
1481 
1482  $table->enable("auto_sort");
1483  $table->enable("sort");
1484  $table->setLimit($maxentries);
1485 
1486  $header_params = $this->ctrl->getParameterArray($this, "singleResults");
1487  $header_vars = array("question_title", "number_of_answers", "export");
1488  $table->setHeaderVars($header_vars, $header_params);
1489  $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1490 
1491  $table->setOffset($offset);
1492  $table->setMaxCount(count($data->getQuestionTitles()));
1493  $table->setOrderColumn($ordercolumn);
1494  $table->setOrderDirection($orderdirection);
1495  $rows = array();
1496  foreach ($data->getQuestionTitles() as $question_id => $question_title)
1497  {
1498  $answered = 0;
1499  $reached = 0;
1500  $max = 0;
1501  foreach ($foundParticipants as $userdata)
1502  {
1503  $pass = $userdata->getScoredPass();
1504  if (is_object($userdata->getPass($pass)))
1505  {
1506  $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1507  if (is_array($question))
1508  {
1509  $answered++;
1510  }
1511  }
1512  }
1513  $counter++;
1514  $this->ctrl->setParameter($this, "qid", $question_id);
1515  array_push($rows,
1516  array(
1517  $question_title,
1518  $answered,
1519  "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants"). "\">" . $this->lng->txt("pdf_export") . "</a>"
1520  )
1521  );
1522  }
1523  $table->setData($rows);
1524  $tableoutput = $table->render();
1525  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $tableoutput);
1526  }
1527 }
1528 ?>