ILIAS  eassessment Revision 61809
 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 
133  public function filterEvaluation()
134  {
135  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
136  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
137  $table_gui->writeFilterToSession();
138  $this->ctrl->redirect($this, "outEvaluation");
139  }
140 
141  public function resetfilterEvaluation()
142  {
143  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
144  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation');
145  $table_gui->resetFilter();
146  $this->ctrl->redirect($this, "outEvaluation");
147  }
148 
154  function outEvaluation()
155  {
156  global $ilAccess;
157 
158  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
159  {
160  // allow only evaluation access
161  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
162  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
163  }
164 
165  include_once "./Modules/Test/classes/tables/class.ilEvaluationAllTableGUI.php";
166  $table_gui = new ilEvaluationAllTableGUI($this, 'outEvaluation', $this->object->getAnonymity());
167  $data = array();
168  $arrFilter = array();
169  foreach ($table_gui->getFilterItems() as $item)
170  {
171  if ($item->getValue() !== false)
172  {
173  switch ($item->getPostVar())
174  {
175  case 'group':
176  case 'name':
177  case 'course':
178  $arrFilter[$item->getPostVar()] = $item->getValue();
179  break;
180  case 'passed_only':
181  $passedonly = $item->getChecked();
182  break;
183  }
184  }
185  }
186  include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
187  $eval = new ilTestEvaluationData($this->object);
188  $eval->setFilterArray($arrFilter);
189  $foundParticipants =& $eval->getParticipants();
190  $counter = 1;
191  if (count($foundParticipants) > 0)
192  {
193  if ($this->object->ects_output)
194  {
195  $passed_array =& $this->object->getTotalPointsPassedArray();
196  }
197  foreach ($foundParticipants as $active_id => $userdata)
198  {
199  $remove = FALSE;
200  if ($passedonly)
201  {
202  $mark_obj = $this->object->getMarkSchema()->getMatchingMark($userdata->getReachedPointsInPercent());
203  if ($mark_obj->getPassed() == FALSE)
204  {
205  $remove = TRUE;
206  }
207  }
208  if (!$remove)
209  {
210  // build the evaluation row
211  $userfields = ilObjUser::_lookupFields($userdata->getUserID());
212  foreach ($userfields as $key => $value)
213  {
214  $evaluationrow[$key] = strlen($value) ? $value : ' ';
215  }
216  $evaluationrow = array();
217  $fullname = "";
218  if ($this->object->getAnonymity())
219  {
220  $fullname = $counter;
221  $evaluationrow['name'] = $fullname;
222  $evaluationrow['login'] = '';
223  }
224  else
225  {
226  $evaluationrow['name'] = $userdata->getName();
227  if (strlen($userdata->getLogin()))
228  {
229  $evaluationrow['login'] = "[" . $userdata->getLogin() . "]";
230  }
231  else
232  {
233  $evaluationrow['login'] = '';
234  }
235  }
236 
237  $evaluationrow['reached'] = $userdata->getReached();
238  $evaluationrow['max'] = $userdata->getMaxpoints();
239  $percentage = $userdata->getReachedPointsInPercent();
240  $mark = $this->object->getMarkSchema()->getMatchingMark($percentage);
241  if (is_object($mark))
242  {
243  $evaluationrow['mark'] = $mark->getShortName();
244  }
245  if ($this->object->ects_output)
246  {
247  $ects_mark = $this->object->getECTSGrade($passed_array, $userdata->getReached(), $userdata->getMaxPoints());
248  $evaluationrow['ects_grade'] = $ects_mark;
249  }
250  $evaluationrow['answered'] = $userdata->getQuestionsWorkedThrough() . " " . strtolower($this->lng->txt("of")) . " " . $userdata->getNumberOfQuestions() . " (" . sprintf("%2.2f", $userdata->getQuestionsWorkedThroughInPercent()) . " %" . ")";
251  $time_seconds = $userdata->getTimeOfWork();
252  $time_hours = floor($time_seconds/3600);
253  $time_seconds -= $time_hours * 3600;
254  $time_minutes = floor($time_seconds/60);
255  $time_seconds -= $time_minutes * 60;
256  $evaluationrow['working_time'] = sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds);
257  $this->ctrl->setParameter($this, "active_id", $active_id);
258  $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
259  $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
260  $evaluationrow['details'] = "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>";
261  $userfields = ilObjUser::_lookupFields($userdata->getUserID());
262  $evaluationrow['gender'] = $userfields['gender'];
263  $evaluationrow['email'] = $userfields['email'];
264  $evaluationrow['institution'] = $userfields['institution'];
265  $evaluationrow['street'] = $userfields['street'];
266  $evaluationrow['city'] = $userfields['city'];
267  $evaluationrow['zipcode'] = $userfields['zipcode'];
268  $evaluationrow['country'] = $userfields['country'];
269  $evaluationrow['departement'] = $userfields['departement'];
270  $evaluationrow['matriculation'] = $userfields['matriculation'];
271  $counter++;
272  array_push($data, $evaluationrow);
273  }
274  }
275  }
276 
277  $table_gui->setData($data);
278  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation.html", "Modules/Test");
279  $this->tpl->setVariable('EVALUATION_DATA', $table_gui->getHTML());
280  if (count($foundParticipants) > 0)
281  {
282  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
283  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
284  if (!$this->object->getAnonymity())
285  {
286  include_once "./Services/Certificate/classes/class.ilCertificate.php";
287  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
289  {
290  $template->setVariable("TEXT_CERTIFICATE", $this->lng->txt("exp_type_certificate"));
291  }
292  }
293  if (!$this->object->isRandomTest() && $this->object->hasSingleChoiceQuestions())
294  {
295  $template->setCurrentBlock('singlechoice');
296  $template->setVariable("TEXT_SINGLECHOICE", $this->lng->txt("exp_type_singlechoice"));
297  $template->parseCurrentBlock();
298  }
299 
300  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
301  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
302  $template->setVariable("TEXT_IMS_CSV", $this->lng->txt("exp_type_imsm"));
303  $template->setVariable("CMD_EXPORT", "exportEvaluation");
304  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
305  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
306  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
307  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportEvaluation"));
308  $exportoutput = $template->get();
309  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
310  }
311 
312  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
313  if ($this->object->getShowSolutionAnswersOnly())
314  {
315  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
316  }
317  }
318 
327  {
328  global $ilAccess;
329 
330  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
331  {
332  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), TRUE);
333  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
334  }
335 
336  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation_details.html", "Modules/Test");
337 
338  $active_id = $_GET["active_id"];
339  if (strlen($active_id) == 0)
340  {
341  ilUtil::sendInfo($this->lng->txt("detailed_evaluation_missing_active_id"), TRUE);
342  $this->ctrl->redirect($this, "outEvaluation");
343  }
344 
345  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
346 
347  $data =& $this->object->getCompleteEvaluationData();
348  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
349  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outEvaluation"));
350  $this->tpl->setVariable("HEADING_DETAILED_EVALUATION", sprintf($this->lng->txt("detailed_evaluation_for"),
351  $data->getParticipant($active_id)->getName())
352  );
353  $this->tpl->setVariable("STATISTICAL_DATA", $this->lng->txt("statistical_data"));
354  $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
355  $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()) . " %" . ")");
356  if (strlen($data->getParticipant($active_id)->getMark()))
357  {
358  $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
359  $this->tpl->setVariable("VALUE_RESULTSMARKS", $data->getParticipant($active_id)->getMark());
360  if (strlen($data->getParticipant($active_id)->getECTSMark()))
361  {
362  $this->tpl->setVariable("TXT_ECTS", $this->lng->txt("ects_grade"));
363  $this->tpl->setVariable("VALUE_ECTS", $data->getParticipant($active_id)->getECTSMark());
364  }
365  }
366  $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
367  $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()) . " %" . ")");
368 
369  $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
370  $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
371  $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
372  $time_hours = floor($time_seconds/3600);
373  $time_seconds -= $time_hours * 3600;
374  $time_minutes = floor($time_seconds/60);
375  $time_seconds -= $time_minutes * 60;
376  $this->tpl->setVariable("VALUE_TIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
377  $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
378  $time_hours = floor($atime_seconds/3600);
379  $atime_seconds -= $time_hours * 3600;
380  $time_minutes = floor($atime_seconds/60);
381  $atime_seconds -= $time_minutes * 60;
382  $this->tpl->setVariable("VALUE_ATIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
383  $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
384  #$this->tpl->setVariable("VALUE_FIRSTVISIT",
385  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getFirstVisit())
386  #);
387  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
388  new ilDateTime($data->getParticipant($active_id)->getFirstVisit(),IL_CAL_UNIX)));
389  $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
390  #$this->tpl->setVariable("VALUE_LASTVISIT",
391  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getLastVisit())
392  #);
393  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
394  new ilDateTime($data->getParticipant($active_id)->getLastVisit(),IL_CAL_UNIX)));
395 
396  $this->tpl->setVariable("TXT_NROFPASSES", $this->lng->txt("tst_nr_of_passes"));
397  $this->tpl->setVariable("VALUE_NROFPASSES", $data->getParticipant($active_id)->getLastPass() + 1);
398  $this->tpl->setVariable("TXT_SCOREDPASS", $this->lng->txt("scored_pass"));
399  if ($this->object->getPassScoring() == SCORE_BEST_PASS)
400  {
401  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getBestPass() + 1);
402  }
403  else
404  {
405  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getLastPass() + 1);
406  }
407 
408  $median = $data->getStatistics()->getStatistics()->median();
409  $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
410  $mark = $this->object->mark_schema->getMatchingMark($pct);
411  if (is_object($mark))
412  {
413  $this->tpl->setVariable("TXT_MARK_MEDIAN", $this->lng->txt("tst_stat_result_mark_median"));
414  $this->tpl->setVariable("VALUE_MARK_MEDIAN", $mark->getShortName());
415  }
416 
417  $this->tpl->setVariable("TXT_RANK_PARTICIPANT", $this->lng->txt("tst_stat_result_rank_participant"));
418  $this->tpl->setVariable("VALUE_RANK_PARTICIPANT", $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
419  $this->tpl->setVariable("TXT_RANK_MEDIAN", $this->lng->txt("tst_stat_result_rank_median"));
420  $this->tpl->setVariable("VALUE_RANK_MEDIAN", $data->getStatistics()->getStatistics()->rank_median());
421  $this->tpl->setVariable("TXT_TOTAL_PARTICIPANTS", $this->lng->txt("tst_stat_result_total_participants"));
422  $this->tpl->setVariable("VALUE_TOTAL_PARTICIPANTS", $data->getStatistics()->getStatistics()->count());
423  $this->tpl->setVariable("TXT_RESULT_MEDIAN", $this->lng->txt("tst_stat_result_median"));
424  $this->tpl->setVariable("VALUE_RESULT_MEDIAN", $median);
425 
426  for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
427  {
428  $finishdate = $this->object->getPassFinishDate($active_id, $pass);
429  if ($finishdate > 0)
430  {
431  $this->tpl->setCurrentBlock("question_header");
432  $this->tpl->setVariable("TXT_QUESTION_DATA", sprintf($this->lng->txt("tst_eval_question_points"), $pass+1));
433  $this->tpl->parseCurrentBlock();
434  global $ilAccess;
435  if (($ilAccess->checkAccess("write", "", $_GET["ref_id"])))
436  {
437  $this->tpl->setCurrentBlock("question_footer");
438  $this->tpl->setVariable("TEXT_TO_DETAILED_RESULTS", $this->lng->txt("tst_show_answer_sheet"));
439  $this->ctrl->setParameter($this, "statistics", "1");
440  $this->ctrl->setParameter($this, "active_id", $active_id);
441  $this->ctrl->setParameter($this, "pass", $pass);
442  $this->tpl->setVariable("URL_TO_DETAILED_RESULTS", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
443  $this->tpl->parseCurrentBlock();
444  }
445  $questions = $data->getParticipant($active_id)->getQuestions($pass);
446  if (!is_array($questions))
447  {
448  $questions = $data->getParticipant($active_id)->getQuestions(0);
449  }
450  $counter = 1;
451  foreach ($questions as $question)
452  {
453  $this->tpl->setCurrentBlock("question_row");
454  $this->tpl->setVariable("QUESTION_COUNTER", $counter);
455  $this->tpl->setVariable("QUESTION_TITLE", $data->getQuestionTitle($question["id"]));
456  $this->tpl->setVariable("QUESTION_ID", $question["id"]);
457  $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
458 
459  if (is_array($answeredquestion))
460  {
461  $percent = $answeredquestion["points"] ? $answeredquestion["reached"] / $answeredquestion["points"] * 100.0 : 0;
462  $this->tpl->setVariable("QUESTION_POINTS", $answeredquestion["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $answeredquestion["points"] . " (" . sprintf("%.2f", $percent) . " %)");
463  }
464  else
465  {
466  $this->tpl->setVariable("QUESTION_POINTS", "0 " . strtolower($this->lng->txt("of")) . " " . $question["points"] . " (" . sprintf("%.2f", 0) . " %) - " . $this->lng->txt("question_not_answered"));
467  }
468  $this->tpl->parseCurrentBlock();
469  $counter++;
470  }
471  $this->tpl->touchBlock("question_stats");
472  }
473  }
474  }
475 
482  {
483  $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
484  }
485 
492  {
493  $question_object =& ilObjTest::_instanciateQuestion($_GET["qid"]);
494  $download = "";
495  if (method_exists($question_object, "getFileUploadZIPFile"))
496  {
497  $question_object->getFileUploadZIPFile($this->object->getTestId());
498  }
499  else
500  {
501  $this->ctrl->redirect($this, "singleResults");
502  }
503  }
504 
512  function eval_a()
513  {
514  global $ilAccess;
515 
516  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
517  {
518  // allow only evaluation access
519  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
520  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
521  }
522 
523  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
524  $eval =& $this->object->getCompleteEvaluationData();
525  $data = array();
526  $foundParticipants =& $eval->getParticipants();
527  if (count($foundParticipants))
528  {
529  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
530  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
531  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
532  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
533  $template->setVariable("CMD_EXPORT", "exportAggregatedResults");
534  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
535  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
536  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
537  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportAggregatedResults"));
538  $exportoutput = $template->get();
539  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
540 
541  array_push($data, array(
542  'result' => $this->lng->txt("tst_eval_total_persons"),
543  'value' => count($foundParticipants)
544  ));
545  $total_finished = $this->object->evalTotalFinished();
546  array_push($data, array(
547  'result' => $this->lng->txt("tst_eval_total_finished"),
548  'value' => $total_finished
549  ));
550  $average_time = $this->object->evalTotalStartedAverageTime();
551  $diff_seconds = $average_time;
552  $diff_hours = floor($diff_seconds/3600);
553  $diff_seconds -= $diff_hours * 3600;
554  $diff_minutes = floor($diff_seconds/60);
555  $diff_seconds -= $diff_minutes * 60;
556  array_push($data, array(
557  'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
558  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
559  ));
560  $total_passed = 0;
561  $total_passed_reached = 0;
562  $total_passed_max = 0;
563  $total_passed_time = 0;
564  foreach ($foundParticipants as $userdata)
565  {
566  if ($userdata->getPassed())
567  {
568  $total_passed++;
569  $total_passed_reached += $userdata->getReached();
570  $total_passed_max += $userdata->getMaxpoints();
571  $total_passed_time += $userdata->getTimeOfWork();
572  }
573  }
574  $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
575  $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
576  $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
577  array_push($data, array(
578  'result' => $this->lng->txt("tst_eval_total_passed"),
579  'value' => $total_passed
580  ));
581  array_push($data, array(
582  'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
583  'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
584  ));
585  $average_time = $average_passed_time;
586  $diff_seconds = $average_time;
587  $diff_hours = floor($diff_seconds/3600);
588  $diff_seconds -= $diff_hours * 3600;
589  $diff_minutes = floor($diff_seconds/60);
590  $diff_seconds -= $diff_minutes * 60;
591  array_push($data, array(
592  'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
593  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
594  ));
595  }
596 
597  include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
598  $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
599  $table_gui->setData($data);
600  $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
601 
602  $rows = array();
603  foreach ($eval->getQuestionTitles() as $question_id => $question_title)
604  {
605  $answered = 0;
606  $reached = 0;
607  $max = 0;
608  foreach ($foundParticipants as $userdata)
609  {
610  for ($i = 0; $i <= $userdata->getLastPass(); $i++)
611  {
612  if (is_object($userdata->getPass($i)))
613  {
614  $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
615  if (is_array($question))
616  {
617  $answered++;
618  $reached += $question["reached"];
619  $max += $question["points"];
620  }
621  }
622  }
623  }
624  $percent = $max ? $reached/$max * 100.0 : 0;
625  $counter++;
626  $this->ctrl->setParameter($this, "qid", $question_id);
627  array_push($rows,
628  array(
629  'title' => $question_title,
630  'id' => $question_id,
631  'points' => sprintf("%.2f", $answered ? $reached / $answered : 0) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $answered ? $max / $answered : 0),
632  'percentage' => (float)$percent,
633  'answers' => $answered
634  )
635  );
636  }
637  include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
638  $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
639  $table_gui->setData($rows);
640  $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
641  }
642 
643  function partialEvaluation()
644  {
645  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
646  $form = new ilPropertyFormGUI();
647  $form->setFormAction($this->ctrl->getFormAction($this, 'partialEvaluation'));
648  $form->setTitle($this->lng->txt('partial_export'));
649  $form->setDescription($this->lng->txt('partial_export_desc'));
650  $form->setMultipart(FALSE);
651  $form->setTableWidth("100%");
652  $form->setId("partialEvaluation");
653 
654  $start = new ilNumberInputGUI($this->lng->txt('dataset_start'), 'dataset_start');
655  $start->setValue(1);
656  $start->setSize(3);
657  $start->setInfo($this->lng->txt('dataset_start_desc'));
658  $start->setRequired(true);
659  $form->addItem($start);
660 
661  $end = new ilNumberInputGUI($this->lng->txt('dataset_end'), 'dataset_end');
662  $end->setValue(1);
663  $end->setSize(3);
664  $end->setInfo($this->lng->txt('dataset_end_desc'));
665  $end->setRequired(true);
666  $form->addItem($end);
667 
668  $form->addCommandButton("saveRandomQuestions", $this->lng->txt("start"));
669 
670  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
671 /*
672  include_once "./Modules/Test/classes/class.ilTestExport.php";
673  $exportObj = new ilTestExport($this->object, "results");
674  $exportObj->singleChoiceExport();
675 */
676  }
677 
683  function exportEvaluation()
684  {
685  $filterby = "";
686  if (array_key_exists("g_filterby", $_GET))
687  {
688  $filterby = $_GET["g_filterby"];
689  }
690  $filtertext = "";
691  if (array_key_exists("g_userfilter", $_GET))
692  {
693  $filtertext = $_GET["g_userfilter"];
694  }
695  $passedonly = FALSE;
696  if (array_key_exists("g_passedonly", $_GET))
697  {
698  if ($_GET["g_passedonly"] == 1)
699  {
700  $passedonly = TRUE;
701  }
702  }
703  switch ($_POST["export_type"])
704  {
705  case "excel":
706  include_once "./Modules/Test/classes/class.ilTestExport.php";
707  $exportObj = new ilTestExport($this->object, "results");
708  $exportObj->exportToExcel($deliver = TRUE, $filterby, $filtertext, $passedonly);
709  break;
710  case "singlechoice":
711 // $this->ctrl->redirect($this, "partialEvaluation");
712  include_once "./Modules/Test/classes/class.ilTestExport.php";
713  $exportObj = new ilTestExport($this->object, "results");
714  $exportObj->singleChoiceExport();
715  break;
716  case "csv":
717  include_once "./Modules/Test/classes/class.ilTestExport.php";
718  $exportObj = new ilTestExport($this->object, "results");
719  $exportObj->exportToCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
720  break;
721  case "ims_csv":
722  include_once "./Modules/Test/classes/class.ilTestExport.php";
723  $exportObj = new ilTestExport($this->object, "results");
724  $exportObj->exportToImsCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
725  break;
726  case "certificate":
727  if ($passedonly)
728  {
729  $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
730  }
731  if (strlen($filtertext))
732  {
733  $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
734  }
735  $this->ctrl->redirect($this, "exportCertificate");
736  break;
737  }
738  }
739 
746  {
747  switch ($_POST["export_type"])
748  {
749  case "excel":
750  include_once "./Modules/Test/classes/class.ilTestExport.php";
751  $exportObj = new ilTestExport($this->object, "aggregated");
752  $exportObj->exportToExcel($deliver = TRUE);
753  break;
754  case "csv":
755  include_once "./Modules/Test/classes/class.ilTestExport.php";
756  $exportObj = new ilTestExport($this->object, "aggregated");
757  $exportObj->exportToCSV($deliver = TRUE);
758  break;
759  }
760  }
761 
768  public function exportCertificate()
769  {
770  global $ilUser;
771 
772  include_once "./Services/Utilities/classes/class.ilUtil.php";
773  include_once "./Services/Certificate/classes/class.ilCertificate.php";
774  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
775  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
776  $archive_dir = $certificate->createArchiveDirectory();
777  $total_users = array();
778  $total_users =& $this->object->evalTotalPersonsArray();
779  if (count($total_users))
780  {
781  foreach ($total_users as $active_id => $name)
782  {
783  $user_id = $this->object->_getUserIdFromActiveId($active_id);
784  $pdf = $certificate->outCertificate(
785  array(
786  "active_id" => $active_id,
787  "userfilter" => $userfilter,
788  "passedonly" => $passedonly
789  ),
790  FALSE
791  );
792  if (strlen($pdf))
793  {
794  $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
795  }
796  }
797  $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, TRUE);
798  }
799 
800  }
801 
808  function getEvaluationQuestionId($question_id, $original_id = "")
809  {
810  if ($original_id > 0)
811  {
812  return $original_id;
813  }
814  else
815  {
816  return $question_id;
817  }
818  }
819 
820  function saveEvalSettings()
821  {
822  $results = $_POST;
823 
824  $additionalFields = array();
825  foreach ($results as $key => $value)
826  {
827  if (preg_match("/cb_(\w+)/", $key, $matches) && ($value == 1))
828  {
829  array_push($additionalFields, $matches[1]);
830  }
831  }
832  $this->object->setEvaluationAdditionalFields($additionalFields);
833  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
834  $this->ctrl->redirect($this, "evalSettings");
835  }
836 
837  function evalSettings()
838  {
839  global $ilAccess;
840 
841  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
842  {
843  // allow only evaluation access
844  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
845  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
846  }
847 
848  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
849  $form = new ilPropertyFormGUI();
850  $form->setFormAction($this->ctrl->getFormAction($this, "saveEvalSettings"));
851  $form->setTitle($this->lng->txt("assessment_eval_settings"));
852 
853  include_once("./Services/Form/classes/class.ilFormSectionHeaderGUI.php");
854  $header = new ilFormSectionHeaderGUI();
855  $header->setTitle($this->lng->txt("assessment_eval_additional_fields_settings"));
856  $form->addItem($header);
857 
858  // Additional User fields
859  $fields = array("gender", "email", "institution", "street", "city", "zipcode", "country", "department", "matriculation");
860  $additionalFields = $this->object->getEvaluationAdditionalFields();
861 
862  foreach ($fields as $dbfield)
863  {
864  $checkbox = new ilCheckboxInputGUI($this->lng->txt($dbfield), "cb_" . $dbfield);
865  if ($this->object->getAnonymity())
866  {
867  $checkbox->setDisabled(TRUE);
868  }
869  else
870  {
871  if (in_array($dbfield, $additionalFields)) $checkbox->setChecked(TRUE);
872  }
873  $form->addItem($checkbox);
874  }
875  $form->addCommandButton("saveEvalSettings", $this->lng->txt("save"));
876 
877  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
878  }
879 
888  {
889  global $ilias;
890 
891  $this->ctrl->saveParameter($this, "pass");
892  $this->ctrl->saveParameter($this, "active_id");
893  $active_id = $_GET["active_id"];
894  $pass = $_GET["pass"];
895  $result_array =& $this->object->getTestResult($active_id, $pass);
896  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outParticipantsPassDetails");
897  $user_data = $this->getResultsUserdata($active_id, FALSE);
898  $user_id = $this->object->_getUserIdFromActiveId($active_id);
899 // TODO
900 //include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
901 //print_r(ilTestEvaluationData::_getTimeStatsForParticipant($active_id));
902  $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
903 
904  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
906  {
907  $this->ctrl->setParameter($this, "pdf", "1");
908  $template->setCurrentBlock("pdf_export");
909  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
910  $this->ctrl->setParameter($this, "pdf", "");
911  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
912  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
913  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
914  $template->parseCurrentBlock();
915  }
916 
917  if (array_key_exists("statistics", $_GET) && ($_GET["statistics"] == 1))
918  {
919  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
920  $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
921  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilTestEvaluationGUI", "detailedEvaluation"));
922  }
923  else
924  {
925  if ($this->object->getNrOfTries() == 1)
926  {
927  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
928  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
929  }
930  else
931  {
932  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outParticipantsResultsOverview"));
933  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
934  }
935  }
936  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
937  $template->setVariable("PRINT_URL", "javascript:window.print();");
938 
939  if ($this->object->getNrOfTries() == 1)
940  {
941  $statement = $this->getFinalStatement($active_id);
942  $template->setVariable("USER_MARK", $statement["mark"]);
943  if (strlen($statement["markects"]))
944  {
945  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
946  }
947  }
948 
949  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, TRUE);
950  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
951  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
952  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
953  $template->setVariable("PASS_DETAILS", $overview);
954  $template->setVariable("USER_DETAILS", $user_data);
955  $uname = $this->object->userLookupFullName($user_id);
956  $template->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
957 
958  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
959  if ($this->object->getShowSolutionAnswersOnly())
960  {
961  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
962  }
963 
964  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
965  {
966  $this->object->deliverPDFFromHTML($template->get());
967  }
968  else
969  {
970  $this->tpl->setVariable("ADM_CONTENT", $template->get());
971  }
972  }
973 
982  {
983  global $ilias;
984 
985  $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", TRUE, TRUE, "Modules/Test");
986 
987  $active_id = $_GET["active_id"];
988  if ($this->object->getNrOfTries() == 1)
989  {
990  $this->ctrl->setParameter($this, "active_id", $active_id);
991  $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
992  $this->ctrl->redirect($this, "outParticipantsPassDetails");
993  }
994 
995  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
997  {
998  $this->ctrl->setParameter($this, "pdf", "1");
999  $template->setCurrentBlock("pdf_export");
1000  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsResultsOverview"));
1001  $this->ctrl->setParameter($this, "pdf", "");
1002  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
1003  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
1004  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
1005  $template->parseCurrentBlock();
1006  }
1007 
1008  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outParticipantsPassDetails");
1009  $template->setVariable("PASS_OVERVIEW", $overview);
1010  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1011  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
1012  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
1013  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1014  $template->setVariable("PRINT_URL", "javascript:window.print();");
1015 
1016  $statement = $this->getFinalStatement($active_id);
1017  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1018  $user_data = $this->getResultsUserdata($active_id);
1019  $template->setVariable("USER_DATA", $user_data);
1020  $template->setVariable("TEXT_OVERVIEW", $this->lng->txt("tst_results_overview"));
1021  $template->setVariable("USER_MARK", $statement["mark"]);
1022  if (strlen($statement["markects"]))
1023  {
1024  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
1025  }
1026  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1027  $template->parseCurrentBlock();
1028 
1029  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1030  if ($this->object->getShowSolutionAnswersOnly())
1031  {
1032  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1033  }
1034 
1035  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1036  {
1037  $this->object->deliverPDFFromHTML($template->get(), $this->object->getTitle());
1038  }
1039  else
1040  {
1041  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1042  }
1043  }
1044 
1053  {
1054  $this->ctrl->saveParameter($this, "pass");
1055  $this->ctrl->saveParameter($this, "active_id");
1056  $active_id = $_GET["active_id"];
1057  $pass = $_GET["pass"];
1058  $result_array =& $this->object->getTestResult($active_id, $pass);
1059 
1060  $command_solution_details = "";
1061  if ($this->object->getShowSolutionDetails())
1062  {
1063  $command_solution_details = "outCorrectSolution";
1064  }
1065  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserPassDetails", $command_solution_details);
1066 
1067  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1068 
1069  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_pass_details_overview_participants.html", "Modules/Test");
1070 
1071  if ($this->object->getNrOfTries() == 1)
1072  {
1073  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1074  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1075  }
1076  else
1077  {
1078  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outUserResultsOverview"));
1079  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
1080  }
1081 
1082  $this->tpl->parseCurrentBlock();
1083 
1084  if ($this->object->getNrOfTries() == 1)
1085  {
1086  $statement = $this->getFinalStatement($active_id);
1087  $this->tpl->setVariable("USER_MARK", $statement["mark"]);
1088  if (strlen($statement["markects"]))
1089  {
1090  $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
1091  }
1092  }
1093 
1094  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
1095 
1096  $this->tpl->setCurrentBlock("adm_content");
1097  $this->tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1098  $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
1099  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1100  $this->tpl->setVariable("PASS_DETAILS", $overview);
1101  $uname = $this->object->userLookupFullName($user_id, TRUE);
1102  $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
1103  $this->tpl->parseCurrentBlock();
1104 
1105  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1106  if ($this->object->getShowSolutionAnswersOnly())
1107  {
1108  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1109  }
1110  }
1111 
1120  {
1121  global $ilUser, $ilias, $ilLog;
1122 
1123  if (!$this->object->canShowTestResults($ilUser->getId())) $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1124  include_once("./classes/class.ilTemplate.php");
1125  $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
1126  $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
1127 
1128  $pass = null;
1129  $user_id = $ilUser->getId();
1130  $uname = $this->object->userLookupFullName($user_id, TRUE);
1131  $active_id = $this->object->getTestSession()->getActiveId();
1132  $hide_details = !$this->object->getShowPassDetails();
1133  if ($hide_details)
1134  {
1135  $executable = $this->object->isExecutable($ilUser->getId());
1136  if (!$executable["executable"]) $hide_details = FALSE;
1137  }
1138  $begin = microtime(true);
1139  if (($this->object->getNrOfTries() == 1) && (!$hide_details))
1140  {
1141  $pass = 0;
1142  }
1143  else
1144  {
1145  $template->setCurrentBlock("pass_overview");
1146  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserResultsOverview", FALSE, $hide_details);
1147  $template->setVariable("PASS_OVERVIEW", $overview);
1148  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview"));
1149  $template->parseCurrentBlock();
1150  }
1151 
1152  if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
1153  {
1154  if (is_null($pass)) $pass = $_GET["pass"];
1155  }
1156 
1157  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
1159  {
1160  $this->ctrl->setParameter($this, "pass", $pass);
1161  $this->ctrl->setParameter($this, "pdf", "1");
1162  $templatehead->setCurrentBlock("pdf_export");
1163  $templatehead->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1164  $this->ctrl->setParameter($this, "pass", "");
1165  $this->ctrl->setParameter($this, "pdf", "");
1166  $templatehead->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
1167  $templatehead->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
1168  $templatehead->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
1169  $templatehead->parseCurrentBlock();
1170  if ($this->object->canShowCertificate($user_id, $active_id))
1171  {
1172  $templatehead->setVariable("CERTIFICATE_URL", $this->ctrl->getLinkTarget($this, "outCertificate"));
1173  $templatehead->setVariable("CERTIFICATE_TEXT", $this->lng->txt("certificate"));
1174  }
1175  }
1176  $templatehead->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1177  $templatehead->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1178  $templatehead->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1179  $templatehead->setVariable("PRINT_URL", "javascript:window.print();");
1180 
1181  $statement = $this->getFinalStatement($active_id);
1182  $user_data = $this->getResultsUserdata($active_id, TRUE);
1183 
1184  // output of the details of a selected pass
1185  $this->ctrl->saveParameter($this, "pass");
1186  $this->ctrl->saveParameter($this, "active_id");
1187  if (!is_null($pass))
1188  {
1189  $result_array =& $this->object->getTestResult($active_id, $pass);
1190  $command_solution_details = "";
1191  if ($this->object->getShowSolutionDetails())
1192  {
1193  $command_solution_details = "outCorrectSolution";
1194  }
1195  $detailsoverview = (!$hide_details) ? $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserResultsOverview", $command_solution_details) : '';
1196 
1197  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1198 
1199  if (!$hide_details && $this->object->getShowSolutionPrintview())
1200  {
1201  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, $show_solutions = FALSE, $only_answered_questions = FALSE, $show_question_only = FALSE, $show_reached_points = FALSE, $compare_solutions = $this->object->getShowSolutionListComparison());
1202  }
1203  else if ($this->object->getShowSolutionDetails())
1204  {
1205  // if this is not commented out, all questions with checkmarks/crosses will be shown
1206  // $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, true);
1207  }
1208 
1209  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1210  $template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
1211  $template->setVariable("PASS_DETAILS", $detailsoverview);
1212 
1213  $signature = $this->getResultsSignature();
1214  $template->setVariable("SIGNATURE", $signature);
1215  }
1216  $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1217  $template->setVariable("USER_DATA", $user_data);
1218  $template->setVariable("USER_MARK", $statement["mark"]);
1219  if (strlen($statement["markects"]))
1220  {
1221  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
1222  }
1223  $template->parseCurrentBlock();
1224 
1225  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1226  if ($this->object->getShowSolutionAnswersOnly())
1227  {
1228  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1229  }
1230  $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1231 
1232  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1233  {
1234  $this->object->deliverPDFFromHTML($template->get(), sprintf($this->lng->txt("tst_result_user_name"), $uname));
1235  }
1236  else
1237  {
1238  $this->tpl->setVariable("PRINT_CONTENT", $templatehead->get());
1239  }
1240  }
1241 
1250  {
1251  global $ilUser;
1252 
1253  if (!$this->object->getShowSolutionPrintview())
1254  {
1255  ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1256  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1257  }
1258 
1259  $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test");
1260 
1261  $pass = null;
1262  if (array_key_exists("pass", $_GET))
1263  {
1264  if (strlen($_GET["pass"])) $pass = $_GET["pass"];
1265  }
1266  $user_id = $ilUser->getId();
1267  $active_id = $this->object->getTestSession()->getActiveId();
1268  $overview = "";
1269  if ($this->object->getNrOfTries() == 1)
1270  {
1271  $pass = 0;
1272  }
1273  else
1274  {
1275  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserListOfAnswerPasses", TRUE);
1276  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1277  $template->setVariable("PASS_OVERVIEW", $overview);
1278  }
1279 
1280  $signature = "";
1281  if (strlen($pass))
1282  {
1283  $signature = $this->getResultsSignature();
1284  $result_array =& $this->object->getTestResult($active_id, $pass);
1285  $user_id =& $this->object->_getUserIdFromActiveId($active_id);
1286  $showAllAnswers = TRUE;
1287  if ($this->object->isExecutable($user_id))
1288  {
1289  $showAllAnswers = FALSE;
1290  }
1291  $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers, $show_question_only = FALSE, $show_reached_points = FALSE, $compare_solutions = $this->object->getShowSolutionListComparison());
1292  $template->setVariable("PASS_DETAILS", $answers);
1293  }
1294  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1295  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1296  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1297  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1298  $template->setVariable("PRINT_URL", "javascript:window.print();");
1299 
1300  $user_data = $this->getResultsUserdata($active_id, TRUE);
1301  $template->setVariable("USER_DATA", $user_data);
1302  $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1303  if (strlen($signature))
1304  {
1305  $template->setVariable("SIGNATURE", $signature);
1306  }
1307  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1308 
1309  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1310  if ($this->object->getShowSolutionAnswersOnly())
1311  {
1312  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1313  }
1314  }
1315 
1323  function passDetails()
1324  {
1325  if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1326  {
1327  $this->ctrl->saveParameter($this, "pass");
1328  $this->ctrl->saveParameter($this, "active_id");
1329  $this->outTestResults(false, $_GET["pass"]);
1330  }
1331  else
1332  {
1333  $this->outTestResults(false);
1334  }
1335  }
1336 
1343  {
1344  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "Modules/Test");
1345 
1346  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1347  $this->tpl->setCurrentBlock("ContentStyle");
1348  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
1349  $this->tpl->parseCurrentBlock();
1350 
1351  $this->tpl->setCurrentBlock("SyntaxStyle");
1352  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
1353  $this->tpl->parseCurrentBlock();
1354 
1355  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1356  if ($this->object->getShowSolutionAnswersOnly())
1357  {
1358  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1359  }
1360 
1361  $this->tpl->setCurrentBlock("adm_content");
1362  $solution = $this->getCorrectSolutionOutput($_GET["evaluation"], $_GET["active_id"], $_GET["pass"]);
1363  $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
1364  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
1365  $this->ctrl->saveParameter($this, "pass");
1366  $this->ctrl->saveParameter($this, "active_id");
1367  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1368  $this->tpl->parseCurrentBlock();
1369  }
1370 
1376  function singleResults()
1377  {
1378  global $ilAccess;
1379 
1380  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
1381  {
1382  // allow only evaluation access
1383  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1384  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1385  }
1386 
1387  $data =& $this->object->getCompleteEvaluationData();
1388  $color_class = array("tblrow1", "tblrow2");
1389  $counter = 0;
1390  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1391  $foundParticipants =& $data->getParticipants();
1392  if (count($foundParticipants) == 0)
1393  {
1394  ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1395  return;
1396  }
1397  else
1398  {
1399  include_once "./Modules/Test/classes/class.ilTestEvaluationData.php";
1400  $times = ilTestEvaluationData::_getTimeStatsForTest($this->object->getTestId());
1401  $rows = array();
1402  foreach ($data->getQuestionTitles() as $question_id => $question_title)
1403  {
1404  $answered = 0;
1405  $reached = 0;
1406  $max = 0;
1407  foreach ($foundParticipants as $userdata)
1408  {
1409  $pass = $userdata->getScoredPass();
1410  if (is_object($userdata->getPass($pass)))
1411  {
1412  $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1413  if (is_array($question))
1414  {
1415  $answered++;
1416  }
1417  }
1418  }
1419  $counter++;
1420  $this->ctrl->setParameter($this, "qid", $question_id);
1421  $question_object =& ilObjTest::_instanciateQuestion($question_id);
1422  $download = "";
1423  if (method_exists($question_object, "hasFileUploads"))
1424  {
1425  if ($question_object->hasFileUploads($this->object->getTestId()))
1426  {
1427  $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants"). "\">" . $this->lng->txt("download") . "</a>";
1428  }
1429  }
1430  $timeByQuestion = 0;
1431  $numberOfTries = 0;
1432  if (is_array($times[$question_id]))
1433  {
1434  foreach ($times[$question_id] as $pass => $passdata)
1435  {
1436  foreach ($passdata as $active_id => $timesInSeconds)
1437  {
1438  foreach ($timesInSeconds as $timeInSeconds)
1439  {
1440  $numberOfTries++;
1441  $timeByQuestion += $timeInSeconds;
1442  }
1443  }
1444  }
1445  }
1446  $meanTimeByQuestion = ($numberOfTries > 0) ? ($timeByQuestion*1.0)/($numberOfTries*1.0) : 0;
1447  array_push($rows,
1448  array(
1449  "id" => $question_id,
1450  "title" => $question_title,
1451  "noa" => $answered,
1452  "output" => "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants"). "\">" . $this->lng->txt("pdf_export") . "</a>",
1453  "download" => $download,
1454  "time" => $timeByQuestion,
1455  "meantime" => $meanTimeByQuestion
1456  )
1457  );
1458  }
1459  if (count($rows))
1460  {
1461  include_once("./Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php");
1462  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
1463  $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults", ilHTMLToPDFTransformer::transformerAvailable());
1464  $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1465  $table_gui->setData($rows);
1466 
1467  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1468  }
1469  else
1470  {
1471  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1472  }
1473  }
1474  }
1475 
1479  public function outCertificate()
1480  {
1481  global $ilUser;
1482 
1483  $active_id = $this->object->getTestSession()->getActiveId();
1484  $counted_pass = ilObjTest::_getResultPass($active_id);
1485  include_once "./Services/Certificate/classes/class.ilCertificate.php";
1486  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
1487  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
1488  $certificate->outCertificate(array("active_id" => $active_id, "pass" => $counted_pass));
1489  }
1490 
1491 }
1492 ?>