ILIAS  Release_4_1_x_branch Revision 61804
 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  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
294  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
295  $template->setVariable("CMD_EXPORT", "exportEvaluation");
296  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
297  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
298  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
299  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportEvaluation"));
300  $exportoutput = $template->get();
301  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
302  }
303 
304  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
305  if ($this->object->getShowSolutionAnswersOnly())
306  {
307  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
308  }
309  }
310 
319  {
320  global $ilAccess;
321 
322  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
323  {
324  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), TRUE);
325  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
326  }
327 
328  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation_details.html", "Modules/Test");
329 
330  $active_id = $_GET["active_id"];
331  if (strlen($active_id) == 0)
332  {
333  ilUtil::sendInfo($this->lng->txt("detailed_evaluation_missing_active_id"), TRUE);
334  $this->ctrl->redirect($this, "outEvaluation");
335  }
336 
337  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
338 
339  $data =& $this->object->getCompleteEvaluationData();
340  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
341  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outEvaluation"));
342  $this->tpl->setVariable("HEADING_DETAILED_EVALUATION", sprintf($this->lng->txt("detailed_evaluation_for"),
343  $data->getParticipant($active_id)->getName())
344  );
345  $this->tpl->setVariable("STATISTICAL_DATA", $this->lng->txt("statistical_data"));
346  $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
347  $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()) . " %" . ")");
348  if (strlen($data->getParticipant($active_id)->getMark()))
349  {
350  $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
351  $this->tpl->setVariable("VALUE_RESULTSMARKS", $data->getParticipant($active_id)->getMark());
352  if (strlen($data->getParticipant($active_id)->getECTSMark()))
353  {
354  $this->tpl->setVariable("TXT_ECTS", $this->lng->txt("ects_grade"));
355  $this->tpl->setVariable("VALUE_ECTS", $data->getParticipant($active_id)->getECTSMark());
356  }
357  }
358  $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
359  $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()) . " %" . ")");
360 
361  $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
362  $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
363  $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
364  $time_hours = floor($time_seconds/3600);
365  $time_seconds -= $time_hours * 3600;
366  $time_minutes = floor($time_seconds/60);
367  $time_seconds -= $time_minutes * 60;
368  $this->tpl->setVariable("VALUE_TIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
369  $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
370  $time_hours = floor($atime_seconds/3600);
371  $atime_seconds -= $time_hours * 3600;
372  $time_minutes = floor($atime_seconds/60);
373  $atime_seconds -= $time_minutes * 60;
374  $this->tpl->setVariable("VALUE_ATIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
375  $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
376  #$this->tpl->setVariable("VALUE_FIRSTVISIT",
377  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getFirstVisit())
378  #);
379  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
380  new ilDateTime($data->getParticipant($active_id)->getFirstVisit(),IL_CAL_UNIX)));
381  $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
382  #$this->tpl->setVariable("VALUE_LASTVISIT",
383  # date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getLastVisit())
384  #);
385  $this->tpl->setVariable('VAL_FIRST_VISIT',ilDatePresentation::formatDate(
386  new ilDateTime($data->getParticipant($active_id)->getLastVisit(),IL_CAL_UNIX)));
387 
388  $this->tpl->setVariable("TXT_NROFPASSES", $this->lng->txt("tst_nr_of_passes"));
389  $this->tpl->setVariable("VALUE_NROFPASSES", $data->getParticipant($active_id)->getLastPass() + 1);
390  $this->tpl->setVariable("TXT_SCOREDPASS", $this->lng->txt("scored_pass"));
391  if ($this->object->getPassScoring() == SCORE_BEST_PASS)
392  {
393  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getBestPass() + 1);
394  }
395  else
396  {
397  $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getLastPass() + 1);
398  }
399 
400  $median = $data->getStatistics()->getStatistics()->median();
401  $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
402  $mark = $this->object->mark_schema->getMatchingMark($pct);
403  if (is_object($mark))
404  {
405  $this->tpl->setVariable("TXT_MARK_MEDIAN", $this->lng->txt("tst_stat_result_mark_median"));
406  $this->tpl->setVariable("VALUE_MARK_MEDIAN", $mark->getShortName());
407  }
408 
409  $this->tpl->setVariable("TXT_RANK_PARTICIPANT", $this->lng->txt("tst_stat_result_rank_participant"));
410  $this->tpl->setVariable("VALUE_RANK_PARTICIPANT", $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
411  $this->tpl->setVariable("TXT_RANK_MEDIAN", $this->lng->txt("tst_stat_result_rank_median"));
412  $this->tpl->setVariable("VALUE_RANK_MEDIAN", $data->getStatistics()->getStatistics()->rank_median());
413  $this->tpl->setVariable("TXT_TOTAL_PARTICIPANTS", $this->lng->txt("tst_stat_result_total_participants"));
414  $this->tpl->setVariable("VALUE_TOTAL_PARTICIPANTS", $data->getStatistics()->getStatistics()->count());
415  $this->tpl->setVariable("TXT_RESULT_MEDIAN", $this->lng->txt("tst_stat_result_median"));
416  $this->tpl->setVariable("VALUE_RESULT_MEDIAN", $median);
417 
418  for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
419  {
420  $finishdate = $this->object->getPassFinishDate($active_id, $pass);
421  if ($finishdate > 0)
422  {
423  $this->tpl->setCurrentBlock("question_header");
424  $this->tpl->setVariable("TXT_QUESTION_DATA", sprintf($this->lng->txt("tst_eval_question_points"), $pass+1));
425  $this->tpl->parseCurrentBlock();
426  global $ilAccess;
427  if (($ilAccess->checkAccess("write", "", $_GET["ref_id"])))
428  {
429  $this->tpl->setCurrentBlock("question_footer");
430  $this->tpl->setVariable("TEXT_TO_DETAILED_RESULTS", $this->lng->txt("tst_show_answer_sheet"));
431  $this->ctrl->setParameter($this, "statistics", "1");
432  $this->ctrl->setParameter($this, "active_id", $active_id);
433  $this->ctrl->setParameter($this, "pass", $pass);
434  $this->tpl->setVariable("URL_TO_DETAILED_RESULTS", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
435  $this->tpl->parseCurrentBlock();
436  }
437  $questions = $data->getParticipant($active_id)->getQuestions($pass);
438  if (!is_array($questions))
439  {
440  $questions = $data->getParticipant($active_id)->getQuestions(0);
441  }
442  $counter = 1;
443  foreach ($questions as $question)
444  {
445  $this->tpl->setCurrentBlock("question_row");
446  $this->tpl->setVariable("QUESTION_COUNTER", $counter);
447  $this->tpl->setVariable("QUESTION_TITLE", $data->getQuestionTitle($question["id"]));
448  $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
449  if (is_array($answeredquestion))
450  {
451  $percent = $answeredquestion["points"] ? $answeredquestion["reached"] / $answeredquestion["points"] * 100.0 : 0;
452  $this->tpl->setVariable("QUESTION_POINTS", $answeredquestion["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $answeredquestion["points"] . " (" . sprintf("%.2f", $percent) . " %)");
453  }
454  else
455  {
456  $this->tpl->setVariable("QUESTION_POINTS", "0 " . strtolower($this->lng->txt("of")) . " " . $question["points"] . " (" . sprintf("%.2f", 0) . " %) - " . $this->lng->txt("question_not_answered"));
457  }
458  $this->tpl->parseCurrentBlock();
459  $counter++;
460  }
461  $this->tpl->touchBlock("question_stats");
462  }
463  }
464  }
465 
472  {
473  $this->getQuestionResultForTestUsers($_GET["qid"], $this->object->getTestId());
474  }
475 
482  {
483  $question_object =& ilObjTest::_instanciateQuestion($_GET["qid"]);
484  $download = "";
485  if (method_exists($question_object, "getFileUploadZIPFile"))
486  {
487  $question_object->getFileUploadZIPFile($this->object->getTestId());
488  }
489  else
490  {
491  $this->ctrl->redirect($this, "singleResults");
492  }
493  }
494 
502  function eval_a()
503  {
504  global $ilAccess;
505 
506  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
507  {
508  // allow only evaluation access
509  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
510  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
511  }
512 
513  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
514  $eval =& $this->object->getCompleteEvaluationData();
515  $data = array();
516  $foundParticipants =& $eval->getParticipants();
517  if (count($foundParticipants))
518  {
519  $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
520  $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
521  $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
522  $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
523  $template->setVariable("CMD_EXPORT", "exportAggregatedResults");
524  $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
525  $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
526  $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
527  $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportAggregatedResults"));
528  $exportoutput = $template->get();
529  $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
530 
531  array_push($data, array(
532  'result' => $this->lng->txt("tst_eval_total_persons"),
533  'value' => count($foundParticipants)
534  ));
535  $total_finished = $this->object->evalTotalFinished();
536  array_push($data, array(
537  'result' => $this->lng->txt("tst_eval_total_finished"),
538  'value' => $total_finished
539  ));
540  $average_time = $this->object->evalTotalStartedAverageTime();
541  $diff_seconds = $average_time;
542  $diff_hours = floor($diff_seconds/3600);
543  $diff_seconds -= $diff_hours * 3600;
544  $diff_minutes = floor($diff_seconds/60);
545  $diff_seconds -= $diff_minutes * 60;
546  array_push($data, array(
547  'result' => $this->lng->txt("tst_eval_total_finished_average_time"),
548  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
549  ));
550  $total_passed = 0;
551  $total_passed_reached = 0;
552  $total_passed_max = 0;
553  $total_passed_time = 0;
554  foreach ($foundParticipants as $userdata)
555  {
556  if ($userdata->getPassed())
557  {
558  $total_passed++;
559  $total_passed_reached += $userdata->getReached();
560  $total_passed_max += $userdata->getMaxpoints();
561  $total_passed_time += $userdata->getTimeOfWork();
562  }
563  }
564  $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
565  $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
566  $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
567  array_push($data, array(
568  'result' => $this->lng->txt("tst_eval_total_passed"),
569  'value' => $total_passed
570  ));
571  array_push($data, array(
572  'result' => $this->lng->txt("tst_eval_total_passed_average_points"),
573  'value' => sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max)
574  ));
575  $average_time = $average_passed_time;
576  $diff_seconds = $average_time;
577  $diff_hours = floor($diff_seconds/3600);
578  $diff_seconds -= $diff_hours * 3600;
579  $diff_minutes = floor($diff_seconds/60);
580  $diff_seconds -= $diff_minutes * 60;
581  array_push($data, array(
582  'result' => $this->lng->txt("tst_eval_total_passed_average_time"),
583  'value' => sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds)
584  ));
585  }
586 
587  include_once "./Modules/Test/classes/tables/class.ilTestAggregatedResultsTableGUI.php";
588  $table_gui = new ilTestAggregatedResultsTableGUI($this, 'eval_a');
589  $table_gui->setData($data);
590  $this->tpl->setVariable('AGGREGATED_RESULTS', $table_gui->getHTML());
591 
592  $rows = array();
593  foreach ($eval->getQuestionTitles() as $question_id => $question_title)
594  {
595  $answered = 0;
596  $reached = 0;
597  $max = 0;
598  foreach ($foundParticipants as $userdata)
599  {
600  for ($i = 0; $i <= $userdata->getLastPass(); $i++)
601  {
602  if (is_object($userdata->getPass($i)))
603  {
604  $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
605  if (is_array($question))
606  {
607  $answered++;
608  $reached += $question["reached"];
609  $max += $question["points"];
610  }
611  }
612  }
613  }
614  $percent = $max ? $reached/$max * 100.0 : 0;
615  $counter++;
616  $this->ctrl->setParameter($this, "qid", $question_id);
617  array_push($rows,
618  array(
619  'title' => $question_title,
620  'points' => sprintf("%.2f", $answered ? $reached / $answered : 0) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $answered ? $max / $answered : 0),
621  'percentage' => (float)$percent,
622  'answers' => $answered
623  )
624  );
625  }
626  include_once "./Modules/Test/classes/tables/class.ilTestAverageReachedPointsTableGUI.php";
627  $table_gui = new ilTestAverageReachedPointsTableGUI($this, 'eval_a');
628  $table_gui->setData($rows);
629  $this->tpl->setVariable('TBL_AVG_REACHED', $table_gui->getHTML());
630  }
631 
637  function exportEvaluation()
638  {
639  $filterby = "";
640  if (array_key_exists("g_filterby", $_GET))
641  {
642  $filterby = $_GET["g_filterby"];
643  }
644  $filtertext = "";
645  if (array_key_exists("g_userfilter", $_GET))
646  {
647  $filtertext = $_GET["g_userfilter"];
648  }
649  $passedonly = FALSE;
650  if (array_key_exists("g_passedonly", $_GET))
651  {
652  if ($_GET["g_passedonly"] == 1)
653  {
654  $passedonly = TRUE;
655  }
656  }
657  switch ($_POST["export_type"])
658  {
659  case "excel":
660  include_once "./Modules/Test/classes/class.ilTestExport.php";
661  $exportObj = new ilTestExport($this->object, "results");
662  $exportObj->exportToExcel($deliver = TRUE, $filterby, $filtertext, $passedonly);
663  break;
664  case "csv":
665  include_once "./Modules/Test/classes/class.ilTestExport.php";
666  $exportObj = new ilTestExport($this->object, "results");
667  $exportObj->exportToCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
668  break;
669  case "certificate":
670  if ($passedonly)
671  {
672  $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
673  }
674  if (strlen($filtertext))
675  {
676  $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
677  }
678  $this->ctrl->redirect($this, "exportCertificate");
679  break;
680  }
681  }
682 
689  {
690  switch ($_POST["export_type"])
691  {
692  case "excel":
693  include_once "./Modules/Test/classes/class.ilTestExport.php";
694  $exportObj = new ilTestExport($this->object, "aggregated");
695  $exportObj->exportToExcel($deliver = TRUE);
696  break;
697  case "csv":
698  include_once "./Modules/Test/classes/class.ilTestExport.php";
699  $exportObj = new ilTestExport($this->object, "aggregated");
700  $exportObj->exportToCSV($deliver = TRUE);
701  break;
702  }
703  }
704 
711  public function exportCertificate()
712  {
713  global $ilUser;
714 
715  include_once "./Services/Utilities/classes/class.ilUtil.php";
716  include_once "./Services/Certificate/classes/class.ilCertificate.php";
717  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
718  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
719  $archive_dir = $certificate->createArchiveDirectory();
720  $total_users = array();
721  $total_users =& $this->object->evalTotalPersonsArray();
722  if (count($total_users))
723  {
724  foreach ($total_users as $active_id => $name)
725  {
726  $user_id = $this->object->_getUserIdFromActiveId($active_id);
727  $pdf = $certificate->outCertificate(
728  array(
729  "active_id" => $active_id,
730  "userfilter" => $userfilter,
731  "passedonly" => $passedonly
732  ),
733  FALSE
734  );
735  if (strlen($pdf))
736  {
737  $certificate->addPDFtoArchiveDirectory($pdf, $archive_dir, $user_id . "_" . str_replace(" ", "_", ilUtil::getASCIIFilename($name)) . ".pdf");
738  }
739  }
740  $zipArchive = $certificate->zipCertificatesInArchiveDirectory($archive_dir, TRUE);
741  }
742 
743  }
744 
751  function getEvaluationQuestionId($question_id, $original_id = "")
752  {
753  if ($original_id > 0)
754  {
755  return $original_id;
756  }
757  else
758  {
759  return $question_id;
760  }
761  }
762 
771  {
772  global $ilias;
773 
774  $this->ctrl->saveParameter($this, "pass");
775  $this->ctrl->saveParameter($this, "active_id");
776  $active_id = $_GET["active_id"];
777  $pass = $_GET["pass"];
778  $result_array =& $this->object->getTestResult($active_id, $pass);
779 
780  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outParticipantsPassDetails");
781  $user_data = $this->getResultsUserdata($active_id, FALSE);
782  $user_id = $this->object->_getUserIdFromActiveId($active_id);
783 
784  $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
785 
786  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
787  if(ilRPCServerSettings::getInstance()->isEnabled())
788  {
789  $this->ctrl->setParameter($this, "pdf", "1");
790  $template->setCurrentBlock("pdf_export");
791  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
792  $this->ctrl->setParameter($this, "pdf", "");
793  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
794  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
795  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
796  $template->parseCurrentBlock();
797  }
798 
799  if (array_key_exists("statistics", $_GET) && ($_GET["statistics"] == 1))
800  {
801  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
802  $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
803  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilTestEvaluationGUI", "detailedEvaluation"));
804  }
805  else
806  {
807  if ($this->object->getNrOfTries() == 1)
808  {
809  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
810  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
811  }
812  else
813  {
814  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outParticipantsResultsOverview"));
815  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
816  }
817  }
818  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
819  $template->setVariable("PRINT_URL", "javascript:window.print();");
820 
821  if ($this->object->getNrOfTries() == 1)
822  {
823  $statement = $this->getFinalStatement($active_id);
824  $template->setVariable("USER_MARK", $statement["mark"]);
825  if (strlen($statement["markects"]))
826  {
827  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
828  }
829  }
830 
831  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, TRUE);
832  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
833  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
834  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
835  $template->setVariable("PASS_DETAILS", $overview);
836  $template->setVariable("USER_DETAILS", $user_data);
837  $uname = $this->object->userLookupFullName($user_id);
838  $template->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
839 
840  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
841  if ($this->object->getShowSolutionAnswersOnly())
842  {
843  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
844  }
845 
846  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
847  {
848  $this->object->deliverPDFfromHTML($template->get());
849  }
850  else
851  {
852  $this->tpl->setVariable("ADM_CONTENT", $template->get());
853  }
854  }
855 
864  {
865  global $ilias;
866 
867  $template = new ilTemplate("tpl.il_as_tst_pass_overview_participants.html", TRUE, TRUE, "Modules/Test");
868 
869  $active_id = $_GET["active_id"];
870  if ($this->object->getNrOfTries() == 1)
871  {
872  $this->ctrl->setParameter($this, "active_id", $active_id);
873  $this->ctrl->setParameter($this, "pass", ilObjTest::_getResultPass($active_id));
874  $this->ctrl->redirect($this, "outParticipantsPassDetails");
875  }
876 
877  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
878  if(ilRPCServerSettings::getInstance()->isEnabled())
879  {
880  $this->ctrl->setParameter($this, "pdf", "1");
881  $template->setCurrentBlock("pdf_export");
882  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsResultsOverview"));
883  $this->ctrl->setParameter($this, "pdf", "");
884  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
885  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
886  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
887  $template->parseCurrentBlock();
888  }
889 
890  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outParticipantsPassDetails");
891  $template->setVariable("PASS_OVERVIEW", $overview);
892  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
893  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
894  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
895  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
896  $template->setVariable("PRINT_URL", "javascript:window.print();");
897 
898  $statement = $this->getFinalStatement($active_id);
899  $user_id = $this->object->_getUserIdFromActiveId($active_id);
900  $user_data = $this->getResultsUserdata($active_id);
901  $template->setVariable("USER_DATA", $user_data);
902  $template->setVariable("TEXT_OVERVIEW", $this->lng->txt("tst_results_overview"));
903  $template->setVariable("USER_MARK", $statement["mark"]);
904  if (strlen($statement["markects"]))
905  {
906  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
907  }
908  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
909  $template->parseCurrentBlock();
910 
911  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
912  if ($this->object->getShowSolutionAnswersOnly())
913  {
914  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
915  }
916 
917  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
918  {
919  $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
920  }
921  else
922  {
923  $this->tpl->setVariable("ADM_CONTENT", $template->get());
924  }
925  }
926 
935  {
936  $this->ctrl->saveParameter($this, "pass");
937  $this->ctrl->saveParameter($this, "active_id");
938  $active_id = $_GET["active_id"];
939  $pass = $_GET["pass"];
940  $result_array =& $this->object->getTestResult($active_id, $pass);
941 
942  $command_solution_details = "";
943  if ($this->object->getShowSolutionDetails())
944  {
945  $command_solution_details = "outCorrectSolution";
946  }
947  $overview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserPassDetails", $command_solution_details);
948 
949  $user_id = $this->object->_getUserIdFromActiveId($active_id);
950 
951  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_pass_details_overview_participants.html", "Modules/Test");
952 
953  if ($this->object->getNrOfTries() == 1)
954  {
955  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
956  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
957  }
958  else
959  {
960  $this->tpl->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outUserResultsOverview"));
961  $this->tpl->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
962  }
963 
964  $this->tpl->parseCurrentBlock();
965 
966  if ($this->object->getNrOfTries() == 1)
967  {
968  $statement = $this->getFinalStatement($active_id);
969  $this->tpl->setVariable("USER_MARK", $statement["mark"]);
970  if (strlen($statement["markects"]))
971  {
972  $this->tpl->setVariable("USER_MARK_ECTS", $statement["markects"]);
973  }
974  }
975 
976  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
977 
978  $this->tpl->setCurrentBlock("adm_content");
979  $this->tpl->setVariable("LIST_OF_ANSWERS", $list_of_answers);
980  $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
981  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
982  $this->tpl->setVariable("PASS_DETAILS", $overview);
983  $uname = $this->object->userLookupFullName($user_id, TRUE);
984  $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $uname));
985  $this->tpl->parseCurrentBlock();
986 
987  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
988  if ($this->object->getShowSolutionAnswersOnly())
989  {
990  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
991  }
992  }
993 
1002  {
1003  global $ilUser, $ilias, $ilLog;
1004 
1005  if (!$this->object->canShowTestResults($ilUser->getId())) $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1006  include_once("./classes/class.ilTemplate.php");
1007  $templatehead = new ilTemplate("tpl.il_as_tst_results_participants.html", TRUE, TRUE, "Modules/Test");
1008  $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
1009 
1010  $pass = null;
1011  $user_id = $ilUser->getId();
1012  $uname = $this->object->userLookupFullName($user_id, TRUE);
1013  $active_id = $this->object->getTestSession()->getActiveId();
1014  $hide_details = !$this->object->getShowPassDetails();
1015  if ($hide_details)
1016  {
1017  $executable = $this->object->isExecutable($ilUser->getId());
1018  if (!$executable["executable"]) $hide_details = FALSE;
1019  }
1020  $begin = microtime(true);
1021  if (($this->object->getNrOfTries() == 1) && (!$hide_details))
1022  {
1023  $pass = 0;
1024  }
1025  else
1026  {
1027  $template->setCurrentBlock("pass_overview");
1028  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserResultsOverview", FALSE, $hide_details);
1029  $template->setVariable("PASS_OVERVIEW", $overview);
1030  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results_overview"));
1031  $template->parseCurrentBlock();
1032  }
1033 
1034  if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
1035  {
1036  if (is_null($pass)) $pass = $_GET["pass"];
1037  }
1038 
1039  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
1040  if(ilRPCServerSettings::getInstance()->isEnabled())
1041  {
1042  $this->ctrl->setParameter($this, "pass", $pass);
1043  $this->ctrl->setParameter($this, "pdf", "1");
1044  $templatehead->setCurrentBlock("pdf_export");
1045  $templatehead->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1046  $this->ctrl->setParameter($this, "pass", "");
1047  $this->ctrl->setParameter($this, "pdf", "");
1048  $templatehead->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
1049  $templatehead->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
1050  $templatehead->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
1051  $templatehead->parseCurrentBlock();
1052  if ($this->object->canShowCertificate($user_id, $active_id))
1053  {
1054  $templatehead->setVariable("CERTIFICATE_URL", $this->ctrl->getLinkTarget($this, "outCertificate"));
1055  $templatehead->setVariable("CERTIFICATE_TEXT", $this->lng->txt("certificate"));
1056  }
1057  }
1058  $templatehead->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1059  $templatehead->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1060  $templatehead->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1061  $templatehead->setVariable("PRINT_URL", "javascript:window.print();");
1062 
1063  $statement = $this->getFinalStatement($active_id);
1064  $user_data = $this->getResultsUserdata($active_id, TRUE);
1065 
1066  // output of the details of a selected pass
1067  $this->ctrl->saveParameter($this, "pass");
1068  $this->ctrl->saveParameter($this, "active_id");
1069  if (!is_null($pass))
1070  {
1071  $result_array =& $this->object->getTestResult($active_id, $pass);
1072  $command_solution_details = "";
1073  if ($this->object->getShowSolutionDetails())
1074  {
1075  $command_solution_details = "outCorrectSolution";
1076  }
1077  $detailsoverview = (!$hide_details) ? $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestevaluationgui", "outUserResultsOverview", $command_solution_details) : '';
1078 
1079  $user_id = $this->object->_getUserIdFromActiveId($active_id);
1080 
1081  if (!$hide_details && $this->object->canShowSolutionPrintview())
1082  {
1083  $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass);
1084  }
1085  else if ($this->object->getShowSolutionDetails())
1086  {
1087  // if this is not commented out, all questions with checkmarks/crosses will be shown
1088  // $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, true);
1089  }
1090 
1091  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
1092  $template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
1093  $template->setVariable("PASS_DETAILS", $detailsoverview);
1094 
1095  $signature = $this->getResultsSignature();
1096  $template->setVariable("SIGNATURE", $signature);
1097  }
1098  $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
1099  $template->setVariable("USER_DATA", $user_data);
1100  $template->setVariable("USER_MARK", $statement["mark"]);
1101  if (strlen($statement["markects"]))
1102  {
1103  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
1104  }
1105  $template->parseCurrentBlock();
1106 
1107  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1108  if ($this->object->getShowSolutionAnswersOnly())
1109  {
1110  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1111  }
1112  $templatehead->setVariable("RESULTS_PARTICIPANT", $template->get());
1113 
1114  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
1115  {
1116  $this->object->deliverPDFfromHTML($template->get(), sprintf($this->lng->txt("tst_result_user_name"), $uname));
1117  }
1118  else
1119  {
1120  $this->tpl->setVariable("PRINT_CONTENT", $templatehead->get());
1121  }
1122  }
1123 
1132  {
1133  global $ilUser;
1134 
1135  if (!$this->object->getShowSolutionPrintview())
1136  {
1137  ilUtil::sendInfo($this->lng->txt("no_permission"), true);
1138  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1139  }
1140 
1141  $template = new ilTemplate("tpl.il_as_tst_info_list_of_answers.html", TRUE, TRUE, "Modules/Test");
1142 
1143  $pass = null;
1144  if (array_key_exists("pass", $_GET))
1145  {
1146  if (strlen($_GET["pass"])) $pass = $_GET["pass"];
1147  }
1148  $user_id = $ilUser->getId();
1149  $active_id = $this->object->getTestSession()->getActiveId();
1150  $overview = "";
1151  if ($this->object->getNrOfTries() == 1)
1152  {
1153  $pass = 0;
1154  }
1155  else
1156  {
1157  $overview = $this->getPassOverview($active_id, "iltestevaluationgui", "outUserListOfAnswerPasses", TRUE);
1158  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_passes"));
1159  $template->setVariable("PASS_OVERVIEW", $overview);
1160  }
1161 
1162  $signature = "";
1163  if (strlen($pass))
1164  {
1165  $signature = $this->getResultsSignature();
1166  $result_array =& $this->object->getTestResult($active_id, $pass);
1167  $user_id =& $this->object->_getUserIdFromActiveId($active_id);
1168  $showAllAnswers = TRUE;
1169  if ($this->object->isExecutable($user_id))
1170  {
1171  $showAllAnswers = FALSE;
1172  }
1173  $answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers);
1174  $template->setVariable("PASS_DETAILS", $answers);
1175  }
1176  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1177  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_introduction"));
1178  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "infoScreen"));
1179  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
1180  $template->setVariable("PRINT_URL", "javascript:window.print();");
1181 
1182  $user_data = $this->getResultsUserdata($active_id, TRUE);
1183  $template->setVariable("USER_DATA", $user_data);
1184  $template->setVariable("TEXT_LIST_OF_ANSWERS", $this->lng->txt("tst_list_of_answers"));
1185  if (strlen($signature))
1186  {
1187  $template->setVariable("SIGNATURE", $signature);
1188  }
1189  $this->tpl->setVariable("ADM_CONTENT", $template->get());
1190 
1191  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1192  if ($this->object->getShowSolutionAnswersOnly())
1193  {
1194  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1195  }
1196  }
1197 
1205  function passDetails()
1206  {
1207  if (array_key_exists("pass", $_GET) && (strlen($_GET["pass"]) > 0))
1208  {
1209  $this->ctrl->saveParameter($this, "pass");
1210  $this->ctrl->saveParameter($this, "active_id");
1211  $this->outTestResults(false, $_GET["pass"]);
1212  }
1213  else
1214  {
1215  $this->outTestResults(false);
1216  }
1217  }
1218 
1225  {
1226  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "Modules/Test");
1227 
1228  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1229  $this->tpl->setCurrentBlock("ContentStyle");
1230  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
1231  $this->tpl->parseCurrentBlock();
1232 
1233  $this->tpl->setCurrentBlock("SyntaxStyle");
1234  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
1235  $this->tpl->parseCurrentBlock();
1236 
1237  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
1238  if ($this->object->getShowSolutionAnswersOnly())
1239  {
1240  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
1241  }
1242 
1243  $this->tpl->setCurrentBlock("adm_content");
1244  $solution = $this->getCorrectSolutionOutput($_GET["evaluation"], $_GET["active_id"], $_GET["pass"]);
1245  $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
1246  $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
1247  $this->ctrl->saveParameter($this, "pass");
1248  $this->ctrl->saveParameter($this, "active_id");
1249  $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1250  $this->tpl->parseCurrentBlock();
1251  }
1252 
1258  function singleResults()
1259  {
1260  global $ilAccess;
1261 
1262  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
1263  {
1264  // allow only evaluation access
1265  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1266  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
1267  }
1268 
1269  $data =& $this->object->getCompleteEvaluationData();
1270  $color_class = array("tblrow1", "tblrow2");
1271  $counter = 0;
1272  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_single_answers.html", "Modules/Test");
1273  $foundParticipants =& $data->getParticipants();
1274  if (count($foundParticipants) == 0)
1275  {
1276  ilUtil::sendInfo($this->lng->txt("tst_no_evaluation_data"));
1277  return;
1278  }
1279  else
1280  {
1281  $rows = array();
1282  foreach ($data->getQuestionTitles() as $question_id => $question_title)
1283  {
1284  $answered = 0;
1285  $reached = 0;
1286  $max = 0;
1287  foreach ($foundParticipants as $userdata)
1288  {
1289  $pass = $userdata->getScoredPass();
1290  if (is_object($userdata->getPass($pass)))
1291  {
1292  $question =& $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($question_id);
1293  if (is_array($question))
1294  {
1295  $answered++;
1296  }
1297  }
1298  }
1299  $counter++;
1300  $this->ctrl->setParameter($this, "qid", $question_id);
1301  $question_object =& ilObjTest::_instanciateQuestion($question_id);
1302  $download = "";
1303  if (method_exists($question_object, "hasFileUploads"))
1304  {
1305  if ($question_object->hasFileUploads($this->object->getTestId()))
1306  {
1307  $download = "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportFileUploadsForAllParticipants"). "\">" . $this->lng->txt("download") . "</a>";
1308  }
1309  }
1310  array_push($rows,
1311  array(
1312  $question_title,
1313  $answered,
1314  "<a href=\"" . $this->ctrl->getLinkTarget($this, "exportQuestionForAllParticipants"). "\">" . $this->lng->txt("pdf_export") . "</a>",
1315  $download
1316  )
1317  );
1318  }
1319  if (count($rows))
1320  {
1321  include_once("./Modules/Test/classes/tables/class.ilResultsByQuestionTableGUI.php");
1322  $table_gui = new ilResultsByQuestionTableGUI($this, "singleResults", $this->object->hasPDFProcessing());
1323 
1324  $table_gui->setTitle($this->lng->txt("tst_answered_questions_test"));
1325  $table_gui->setData($rows);
1326 
1327  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $table_gui->getHTML());
1328  }
1329  else
1330  {
1331  $this->tpl->setVariable("TBL_SINGLE_ANSWERS", $this->lng->txt("adm_no_special_users"));
1332  }
1333  }
1334  }
1335 
1339  public function outCertificate()
1340  {
1341  global $ilUser;
1342 
1343  $active_id = $this->object->getTestSession()->getActiveId();
1344  $counted_pass = ilObjTest::_getResultPass($active_id);
1345  include_once "./Services/Certificate/classes/class.ilCertificate.php";
1346  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
1347  $certificate = new ilCertificate(new ilTestCertificateAdapter($this->object));
1348  $certificate->outCertificate(array("active_id" => $active_id, "pass" => $counted_pass));
1349  }
1350 
1351 }
1352 ?>