• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/Test/classes/class.ilTestEvaluationGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
00025 include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
00026 
00039 class ilTestEvaluationGUI extends ilTestServiceGUI
00040 {
00050   function ilTestEvaluationGUI($a_object)
00051   {
00052                 global $ilAccess;
00053                 
00054                 parent::ilTestServiceGUI($a_object);
00055                 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
00056                 {
00057                         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), TRUE);
00058                         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00059                 }
00060         }
00061 
00062         function &getHeaderNames()
00063         {
00064                 $headernames = array();
00065                 if ($this->object->getAnonymity())
00066                 {
00067                         array_push($headernames, $this->lng->txt("counter"));
00068                 }
00069                 else
00070                 {
00071                         array_push($headernames, $this->lng->txt("name"));
00072                         array_push($headernames, $this->lng->txt("login"));
00073                 }
00074                 array_push($headernames, $this->lng->txt("tst_reached_points"));
00075                 array_push($headernames, $this->lng->txt("tst_mark"));
00076                 if ($this->object->ects_output)
00077                 {
00078                         array_push($headernames, $this->lng->txt("ects_grade"));
00079                 }
00080                 array_push($headernames, $this->lng->txt("tst_answered_questions"));
00081                 array_push($headernames, $this->lng->txt("working_time"));
00082                 array_push($headernames, $this->lng->txt("detailed_evaluation"));
00083                 return $headernames;
00084         }
00085         
00086         function &getHeaderVars()
00087         {
00088                 $headervars = array();
00089                 if ($this->object->getAnonymity())
00090                 {
00091                         array_push($headervars, "counter");
00092                 }
00093                 else
00094                 {
00095                         array_push($headervars, "name");
00096                         array_push($headervars, "login");
00097                 }
00098                 array_push($headervars, "resultspoints");
00099                 array_push($headervars, "resultsmarks");
00100                 if ($this->object->ects_output)
00101                 {
00102                         array_push($headervars, "ects_grade");
00103                 }
00104                 array_push($headervars, "qworkedthrough");
00105                 array_push($headervars, "timeofwork");
00106                 array_push($headervars, "");
00107                 return $headervars;
00108         }
00109 
00117         function outEvaluation()
00118         {
00119                 global $ilAccess;
00120                 
00121                 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
00122                 {
00123                         // allow only evaluation access
00124                         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
00125                         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00126                 }
00127 
00128                 global $ilUser;
00129                 
00130                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation.html", "Modules/Test");
00131 
00132                 $filter = 0;
00133                 $filtertext = "";
00134                 $filterby = "";
00135                 $passedonly = FALSE;
00136                 $setting = new ilSetting("assessment");
00137                 // set filter was pressed
00138                 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("set_filter")) == 0)
00139                 {
00140                         $filter = 1;
00141                         $filtertext = trim($_POST["userfilter"]);
00142                         $filterby = $_POST["filterby"];
00143                         if ($_POST["passedonly"] == 1)
00144                         {
00145                                 $passedonly = TRUE;
00146                         }
00147                         if ((strlen($filtertext) == 0) && ($passedonly == FALSE)) $filter = 0;
00148                         // save the filter for later usage
00149                         $setting->set("tst_stat_filter_passed_" . $this->object->getTestId(), ($passedonly) ? 1 : 0);
00150                         $setting->set("tst_stat_filter_text_" . $this->object->getTestId(), $filtertext);
00151                         $setting->set("tst_stat_filter_by_" . $this->object->getTestId(), $filterby);
00152                 }
00153                 else
00154                 {
00155                         if (array_key_exists("g_userfilter", $_GET))
00156                         {
00157                                 $filtertext = $_GET["g_userfilter"];
00158                                 $filterby = $_GET["g_filterby"];
00159                         }
00160                         else
00161                         {
00162                                 // try to read the filter from the users preferences
00163                                 $pref = $setting->get("tst_stat_filter_text_" . $this->object->getTestId());
00164                                 if ($pref !== FALSE)
00165                                 {
00166                                         $filtertext = $pref;
00167                                 }
00168                                 $pref = $setting->get("tst_stat_filter_by_" . $this->object->getTestId());
00169                                 if ($pref !== FALSE)
00170                                 {
00171                                         $filterby = $pref;
00172                                 }
00173                         }
00174                         if (array_key_exists("g_passedonly", $_GET))
00175                         {
00176                                 if ($_GET["g_passedonly"] == 1)
00177                                 {
00178                                         $passedonly = TRUE;
00179                                 }
00180                         }
00181                         else
00182                         {
00183                                 // try to read the filter from the users preferences
00184                                 $pref = $setting->get("tst_stat_filter_passed_" . $this->object->getTestId());
00185                                 if ($pref !== FALSE)
00186                                 {
00187                                         $passedonly = ($pref) ? TRUE : FALSE;
00188                                 }
00189                         }
00190                 }
00191                 // reset filter was pressed
00192                 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("reset_filter")) == 0)
00193                 {
00194                         $filter = 0;
00195                         $filtertext = "";
00196                         $filterby = "name";
00197                         $passedonly = FALSE;
00198                         $setting->delete("tst_stat_filter_passed_" . $this->object->getTestId());
00199                         $setting->delete("tst_stat_filter_text_" . $this->object->getTestId());
00200                         $setting->delete("tst_stat_filter_by_" . $this->object->getTestId());
00201                 }
00202                 if (strlen($filtertext))
00203                 {
00204                         $this->ctrl->setParameter($this, "g_userfilter", $filtertext);
00205                         $this->ctrl->setParameter($this, "g_filterby", $filterby);
00206                 }
00207                 if ($passedonly)
00208                 {
00209                         $this->ctrl->setParameter($this, "g_passedonly", "1");
00210                 }
00211 
00212                 $offset = ($_GET["offset"]) ? $_GET["offset"] : 0;
00213                 $orderdirection = ($_GET["sort_order"]) ? $_GET["sort_order"] : "asc";
00214                 $defaultOrderColumn = "name";
00215                 if ($this->object->getAnonymity()) $defaultOrderColumn = "counter";
00216                 $ordercolumn = ($_GET["sort_by"]) ? $_GET["sort_by"] : $defaultOrderColumn;
00217                 
00218                 $maxentries = $ilUser->getPref("hits_per_page");
00219                 if ($maxentries < 1)
00220                 {
00221                         $maxentries = 9999;
00222                 }
00223                 
00224                 include_once("./Services/Table/classes/class.ilTableGUI.php");
00225                 $table = new ilTableGUI(0, FALSE);
00226                 $table->setTitle($this->lng->txt("participants_evaluation"));
00227                 $table->setHeaderNames($this->getHeaderNames());
00228 
00229                 $table->enable("auto_sort");
00230                 $table->enable("sort");
00231                 $table->setLimit($maxentries);
00232 
00233                 $header_params = $this->ctrl->getParameterArray($this, "outEvaluation");
00234                 $header_vars = $this->getHeaderVars();
00235                 $table->setHeaderVars($header_vars, $header_params);
00236                 $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
00237 
00238                 $table->setOffset($offset);
00239                 $table->setMaxCount(count($total_users));
00240                 $table->setOrderColumn($ordercolumn);
00241                 $table->setOrderDirection($orderdirection);
00242 
00243                 $evaluation_rows = array();
00244                 $counter = 1;
00245                 $data =& $this->object->getCompleteEvaluationData(FALSE, $filterby, $filtertext);
00246                 $foundParticipants =& $data->getParticipants();
00247                 if (count($foundParticipants) == 0)
00248                 {
00249                         $this->tpl->setVariable("EVALUATION_DATA", $this->lng->txt("tst_no_evaluation_data"));
00250                 }
00251                 foreach ($foundParticipants as $active_id => $userdata)
00252                 {
00253                         $remove = FALSE;
00254                         if ($passedonly)
00255                         {
00256                                 if ($userdata->getPassed() == FALSE)
00257                                 {
00258                                         $remove = TRUE;
00259                                 }
00260                         }
00261                         if (!$remove)
00262                         {
00263                                 // build the evaluation row
00264                                 $evaluationrow = array();
00265                                 $fullname = "";
00266                                 if ($this->object->getAnonymity())
00267                                 {
00268                                         $fullname = $counter;
00269                                         array_push($evaluationrow, $fullname);
00270                                 }
00271                                 else
00272                                 {
00273                                         array_push($evaluationrow, $userdata->getName());
00274                                         if (strlen($userdata->getLogin()))
00275                                         {
00276                                                 array_push($evaluationrow, "[" . $userdata->getLogin() . "]");
00277                                         }
00278                                         else
00279                                         {
00280                                                 array_push($evaluationrow, "");
00281                                         }
00282                                 }
00283                                 array_push($evaluationrow, $userdata->getReached() . " " . strtolower($this->lng->txt("of")) . " " . $userdata->getMaxpoints());
00284                                 array_push($evaluationrow, $userdata->getMark());
00285                                 if ($this->object->ects_output)
00286                                 {
00287                                         array_push($evaluationrow, $userdata->getECTSMark());
00288                                 }
00289                                 array_push($evaluationrow, $userdata->getQuestionsWorkedThrough() . " " . strtolower($this->lng->txt("of")) . " " . $userdata->getNumberOfQuestions() . " (" . sprintf("%2.2f", $userdata->getQuestionsWorkedThroughInPercent()) . " %" . ")");
00290 
00291                                 $time_seconds = $userdata->getTimeOfWork();
00292                                 $time_hours    = floor($time_seconds/3600);
00293                                 $time_seconds -= $time_hours   * 3600;
00294                                 $time_minutes  = floor($time_seconds/60);
00295                                 $time_seconds -= $time_minutes * 60;
00296                                 array_push($evaluationrow, sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
00297                                 $this->ctrl->setParameter($this, "active_id", $active_id);
00298                                 $href = $this->ctrl->getLinkTarget($this, "detailedEvaluation");
00299                                 $detailed_evaluation = $this->lng->txt("detailed_evaluation_show");
00300                                 array_push($evaluationrow, "<a class=\"il_ContainerItemCommand\" href=\"$href\">$detailed_evaluation</a>");
00301                                 array_push($evaluation_rows, $evaluationrow);
00302                                 $counter++;
00303                         }
00304                 }
00305                 if (count($foundParticipants) > 0)
00306                 {
00307                         $table->setData($evaluation_rows);
00308                         $tableoutput = $table->render();
00309                         $this->tpl->setVariable("EVALUATION_DATA", $tableoutput);
00310                 }
00311 
00312                 $template = new ilTemplate("tpl.il_as_tst_evaluation_filter.html", TRUE, TRUE, "Modules/Test");
00313                 $filters = array("name" => $this->lng->txt("name"), "group" => $this->lng->txt("grp"), "course" => $this->lng->txt("crs"));
00314                 foreach ($filters as $value => $name)
00315                 {
00316                         $template->setCurrentBlock("filterby");
00317                         $template->setVariable("FILTER_BY_NAME", $name);
00318                         $template->setVariable("FILTER_BY_VALUE", $value);
00319                         if (strcmp($filterby, $value) == 0)
00320                         {
00321                                 $template->setVariable("FILTER_BY_SELECTED", " selected=\"selected\"");
00322                         }
00323                         $template->parseCurrentBlock();
00324                 }
00325                 $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "outEvaluation"));
00326                 $template->setVariable("TEXT_FILTER_USERS", $this->lng->txt("filter"));
00327                 $template->setVariable("TEXT_FILTER", $this->lng->txt("set_filter"));
00328                 $template->setVariable("TEXT_BY", $this->lng->txt("by"));
00329                 $template->setVariable("TEXT_RESET_FILTER", $this->lng->txt("reset_filter"));
00330                 $template->setVariable("TEXT_PASSEDONLY", $this->lng->txt("passed_only"));
00331                 if ($passedonly)
00332                 {
00333                         $template->setVariable("CHECKED_PASSEDONLY", " checked=\"checked\"");
00334                 }
00335                 if (strlen($filtertext) > 0)
00336                 {
00337                         $template->setVariable("VALUE_FILTER_USERS", " value=\"" . $filtertext . "\"");
00338                 }
00339                 $filteroutput = $template->get();
00340                 
00341                 if (count($foundParticipants) > 0)
00342                 {
00343                         $template = new ilTemplate("tpl.il_as_tst_evaluation_export.html", TRUE, TRUE, "Modules/Test");
00344                         $template->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
00345                         if (!$this->object->getAnonymity())
00346                         {
00347                                 include_once "./Modules/Test/classes/class.ilTestCertificate.php";
00348                                 if (ilTestCertificate::_isComplete($this->object->getId()))
00349                                 {
00350                                         $template->setVariable("TEXT_CERTIFICATE", $this->lng->txt("exp_type_certificate"));
00351                                 }
00352                         }
00353                         $template->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
00354                         $template->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
00355                         $template->setVariable("BTN_EXPORT", $this->lng->txt("export"));
00356                         $template->setVariable("BTN_PRINT", $this->lng->txt("print"));
00357                         $template->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
00358                         $template->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "exportEvaluation"));
00359                         $exportoutput = $template->get();
00360                         $this->tpl->setVariable("EVALUATION_EXPORT", $exportoutput);
00361                 }
00362 
00363                 $this->tpl->setVariable("EVALUATION_FILTER", $filteroutput);
00364                 
00365                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
00366                 if ($this->object->getShowSolutionAnswersOnly())
00367                 {
00368                         $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
00369                 }
00370         }
00371         
00379         function detailedEvaluation()
00380         {
00381                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_evaluation_details.html", "Modules/Test");
00382 
00383                 $active_id = $_GET["active_id"];
00384                 if (strlen($active_id) == 0)
00385                 {
00386                         ilUtil::sendInfo($this->lng->txt("detailed_evaluation_missing_active_id"), TRUE);
00387                         $this->ctrl->redirect($this, "outEvaluation");
00388                 }
00389                 
00390                 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
00391 
00392                 $data =& $this->object->getCompleteEvaluationData();
00393                 $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
00394                 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outEvaluation"));
00395                 $this->tpl->setVariable("HEADING_DETAILED_EVALUATION", sprintf($this->lng->txt("detailed_evaluation_for"), 
00396                         $data->getParticipant($active_id)->getName())
00397                 );
00398                 $this->tpl->setVariable("STATISTICAL_DATA", $this->lng->txt("statistical_data"));
00399                 $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
00400                 $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()) . " %" . ")");
00401                 if (strlen($data->getParticipant($active_id)->getMark()))
00402                 {
00403                         $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
00404                         $this->tpl->setVariable("VALUE_RESULTSMARKS", $data->getParticipant($active_id)->getMark());
00405                         if (strlen($data->getParticipant($active_id)->getECTSMark()))
00406                         {
00407                                 $this->tpl->setVariable("TXT_ECTS", $this->lng->txt("ects_grade"));
00408                                 $this->tpl->setVariable("VALUE_ECTS", $data->getParticipant($active_id)->getECTSMark());
00409                         }
00410                 }
00411                 $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
00412                 $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()) . " %" . ")");
00413 
00414                 $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
00415                 $time_seconds = $data->getParticipant($active_id)->getTimeOfWork();
00416                 $atime_seconds = $data->getParticipant($active_id)->getNumberOfQuestions() ? $time_seconds / $data->getParticipant($active_id)->getNumberOfQuestions() : 0;
00417                 $time_hours    = floor($time_seconds/3600);
00418                 $time_seconds -= $time_hours   * 3600;
00419                 $time_minutes  = floor($time_seconds/60);
00420                 $time_seconds -= $time_minutes * 60;
00421                 $this->tpl->setVariable("VALUE_TIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds));
00422                 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
00423                 $time_hours    = floor($atime_seconds/3600);
00424                 $atime_seconds -= $time_hours   * 3600;
00425                 $time_minutes  = floor($atime_seconds/60);
00426                 $atime_seconds -= $time_minutes * 60;
00427                 $this->tpl->setVariable("VALUE_ATIMEOFWORK", sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $atime_seconds));
00428                 $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
00429                 $this->tpl->setVariable("VALUE_FIRSTVISIT", 
00430                         date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getFirstVisit())
00431                 );
00432                 $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
00433                 $this->tpl->setVariable("VALUE_LASTVISIT",
00434                         date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], $data->getParticipant($active_id)->getLastVisit())
00435                 );
00436                 $this->tpl->setVariable("TXT_NROFPASSES", $this->lng->txt("tst_nr_of_passes"));
00437                 $this->tpl->setVariable("VALUE_NROFPASSES", $data->getParticipant($active_id)->getLastPass() + 1);
00438                 $this->tpl->setVariable("TXT_SCOREDPASS", $this->lng->txt("scored_pass"));
00439                 if ($this->object->getPassScoring() == SCORE_BEST_PASS)
00440                 {
00441                         $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getBestPass() + 1);
00442                 }
00443                 else
00444                 {
00445                         $this->tpl->setVariable("VALUE_SCOREDPASS", $data->getParticipant($active_id)->getLastPass() + 1);
00446                 }
00447                 
00448                 $median = $data->getStatistics()->getStatistics()->median();
00449                 $pct = $data->getParticipant($active_id)->getMaxpoints() ? ($median / $data->getParticipant($active_id)->getMaxpoints()) * 100.0 : 0;
00450                 $mark = $this->object->mark_schema->getMatchingMark($pct);
00451                 if (is_object($mark))
00452                 {
00453                         $this->tpl->setVariable("TXT_MARK_MEDIAN", $this->lng->txt("tst_stat_result_mark_median"));
00454                         $this->tpl->setVariable("VALUE_MARK_MEDIAN", $mark->getShortName());
00455                 }
00456 
00457                 $this->tpl->setVariable("TXT_RANK_PARTICIPANT", $this->lng->txt("tst_stat_result_rank_participant"));
00458                 $this->tpl->setVariable("VALUE_RANK_PARTICIPANT", $data->getStatistics()->getStatistics()->rank($data->getParticipant($active_id)->getReached()));
00459                 $this->tpl->setVariable("TXT_RANK_MEDIAN", $this->lng->txt("tst_stat_result_rank_median"));
00460                 $this->tpl->setVariable("VALUE_RANK_MEDIAN", $data->getStatistics()->getStatistics()->rank_median());
00461                 $this->tpl->setVariable("TXT_TOTAL_PARTICIPANTS", $this->lng->txt("tst_stat_result_total_participants"));
00462                 $this->tpl->setVariable("VALUE_TOTAL_PARTICIPANTS", $data->getStatistics()->getStatistics()->count());
00463                 $this->tpl->setVariable("TXT_RESULT_MEDIAN", $this->lng->txt("tst_stat_result_median"));
00464                 $this->tpl->setVariable("VALUE_RESULT_MEDIAN", $median);
00465 
00466                 for ($pass = 0; $pass <= $data->getParticipant($active_id)->getLastPass(); $pass++)
00467                 {
00468                         $finishdate = $this->object->getPassFinishDate($active_id, $pass);
00469                         if ($finishdate > 0)
00470                         {
00471                                 $this->tpl->setCurrentBlock("question_header");
00472                                 $this->tpl->setVariable("TXT_QUESTION_DATA", sprintf($this->lng->txt("tst_eval_question_points"), $pass+1));
00473                                 $this->tpl->parseCurrentBlock();
00474                                 global $ilAccess;
00475                                 if (($ilAccess->checkAccess("write", "", $_GET["ref_id"])))
00476                                 {
00477                                         $this->tpl->setCurrentBlock("question_footer");
00478                                         $this->tpl->setVariable("TEXT_TO_DETAILED_RESULTS", $this->lng->txt("tst_show_answer_sheet"));
00479                                         $this->ctrl->setParameterByClass("ilTestOutputGUI", "statistics", "1");
00480                                         $this->ctrl->setParameterByClass("ilTestOutputGUI", "active_id", $active_id);
00481                                         $this->ctrl->setParameterByClass("ilTestOutputGUI", "pass", $pass);
00482                                         $this->tpl->setVariable("URL_TO_DETAILED_RESULTS", $this->ctrl->getLinkTargetByClass("ilTestOutputGUI", "outParticipantsPassDetails"));
00483                                         $this->tpl->parseCurrentBlock();
00484                                 }
00485                                 $questions = $data->getParticipant($active_id)->getQuestions($pass);
00486                                 if (!is_array($questions))
00487                                 {
00488                                         $questions = $data->getParticipant($active_id)->getQuestions(0);
00489                                 }
00490                                 $counter = 1;
00491                                 foreach ($questions as $question)
00492                                 {
00493                                         $this->tpl->setCurrentBlock("question_row");
00494                                         $this->tpl->setVariable("QUESTION_COUNTER", $counter);
00495                                         $this->tpl->setVariable("QUESTION_TITLE", $data->getQuestionTitle($question["id"]));
00496                                         $answeredquestion = $data->getParticipant($active_id)->getPass($pass)->getAnsweredQuestionByQuestionId($question["id"]);
00497                                         if (is_array($answeredquestion))
00498                                         {
00499                                                 $percent = $answeredquestion["points"] ? $answeredquestion["reached"] / $answeredquestion["points"] * 100.0 : 0;
00500                                                 $this->tpl->setVariable("QUESTION_POINTS", $answeredquestion["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $answeredquestion["points"] . " (" . sprintf("%.2f", $percent) . " %)");
00501                                         }
00502                                         else
00503                                         {
00504                                                 $this->tpl->setVariable("QUESTION_POINTS",  "0 " . strtolower($this->lng->txt("of")) . " " . $question["points"] . " (" . sprintf("%.2f", 0) . " %) - " . $this->lng->txt("question_not_answered"));
00505                                         }
00506                                         $this->tpl->parseCurrentBlock();
00507                                         $counter++;
00508                                 }
00509                                 $this->tpl->touchBlock("question_stats");
00510                         }
00511                 }
00512         }
00513         
00521         function eval_a()
00522         {
00523                 global $ilAccess;
00524 
00525                 if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
00526                 {
00527                         // allow only evaluation access
00528                         ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
00529                         $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00530                 }
00531 
00532                 $data =& $this->object->getCompleteEvaluationData();
00533                 $color_class = array("tblrow1", "tblrow2");
00534                 $counter = 0;
00535                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", "Modules/Test");
00536                 $foundParticipants =& $data->getParticipants();
00537                 if (count($foundParticipants)) 
00538                 {
00539                         $this->tpl->setCurrentBlock("row");
00540                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_persons"));
00541                         $this->tpl->setVariable("TXT_VALUE", count($foundParticipants));
00542                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00543                         $counter++;
00544                         $this->tpl->parseCurrentBlock();
00545                         $this->tpl->setCurrentBlock("row");
00546                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished"));
00547                         $total_finished = $this->object->evalTotalFinished();
00548                         $this->tpl->setVariable("TXT_VALUE", $total_finished);
00549                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00550                         $counter++;
00551                         $this->tpl->parseCurrentBlock();
00552                         $this->tpl->setCurrentBlock("row");
00553                         $average_time = $this->object->evalTotalStartedAverageTime();
00554                         $diff_seconds = $average_time;
00555                         $diff_hours    = floor($diff_seconds/3600);
00556                         $diff_seconds -= $diff_hours   * 3600;
00557                         $diff_minutes  = floor($diff_seconds/60);
00558                         $diff_seconds -= $diff_minutes * 60;
00559                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished_average_time"));
00560                         $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
00561                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00562                         $counter++;
00563                         $total_passed = 0;
00564                         $total_passed_reached = 0;
00565                         $total_passed_max = 0;
00566                         $total_passed_time = 0;
00567                         foreach ($foundParticipants as $userdata)
00568                         {
00569                                 if ($userdata->getPassed()) 
00570                                 {
00571                                         $total_passed++;
00572                                         $total_passed_reached += $userdata->getReached();
00573                                         $total_passed_max += $userdata->getMaxpoints();
00574                                         $total_passed_time += $userdata->getTimeOfWork();
00575                                 }
00576                         }
00577                         $average_passed_reached = $total_passed ? $total_passed_reached / $total_passed : 0;
00578                         $average_passed_max = $total_passed ? $total_passed_max / $total_passed : 0;
00579                         $average_passed_time = $total_passed ? $total_passed_time / $total_passed : 0;
00580                         $this->tpl->parseCurrentBlock();
00581                         $this->tpl->setCurrentBlock("row");
00582                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed"));
00583                         $this->tpl->setVariable("TXT_VALUE", $total_passed);
00584                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00585                         $counter++;
00586                         $this->tpl->parseCurrentBlock();
00587                         $this->tpl->setCurrentBlock("row");
00588                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_points"));
00589                         $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", $average_passed_reached) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $average_passed_max));
00590                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00591                         $counter++;
00592                         $this->tpl->parseCurrentBlock();
00593                         $this->tpl->setCurrentBlock("row");
00594                         $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_time"));
00595                         $average_time = $average_passed_time;
00596                         $diff_seconds = $average_time;
00597                         $diff_hours    = floor($diff_seconds/3600);
00598                         $diff_seconds -= $diff_hours   * 3600;
00599                         $diff_minutes  = floor($diff_seconds/60);
00600                         $diff_seconds -= $diff_minutes * 60;
00601                         $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
00602                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00603                         $counter++;
00604                         $this->tpl->parseCurrentBlock();
00605                 } 
00606                 else 
00607                 {
00608                         $this->tpl->setCurrentBlock("emptyrow");
00609                         $this->tpl->setVariable("TXT_NO_ANONYMOUS_AGGREGATION", $this->lng->txt("tst_eval_no_anonymous_aggregation"));
00610                         $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00611                         $this->tpl->parseCurrentBlock();
00612                 }
00613                 
00614                 global $ilUser;
00615                 $maxentries = $ilUser->getPref("hits_per_page");
00616                 if ($maxentries < 1)
00617                 {
00618                         $maxentries = 9999;
00619                 }
00620 
00621                 $offset = ($_GET["offset"]) ? $_GET["offset"] : 0;
00622                 $orderdirection = ($_GET["sort_order"]) ? $_GET["sort_order"] : "asc";
00623                 $defaultOrderColumn = "name";
00624                 if ($this->object->getAnonymity()) $defaultOrderColumn = "counter";
00625                 $ordercolumn = ($_GET["sort_by"]) ? $_GET["sort_by"] : $defaultOrderColumn;
00626 
00627                 $counter = 0;
00628                 include_once("./Services/Table/classes/class.ilTableGUI.php");
00629                 $table = new ilTableGUI(0, FALSE);
00630                 $table->setTitle($this->lng->txt("average_reached_points"));
00631                 $table->setHeaderNames(array($this->lng->txt("question_title"), $this->lng->txt("points"), $this->lng->txt("percentage"), $this->lng->txt("number_of_answers")));
00632 
00633                 $table->enable("auto_sort");
00634                 $table->enable("sort");
00635                 $table->setLimit($maxentries);
00636 
00637                 $header_params = $this->ctrl->getParameterArray($this, "eval_a");
00638                 $header_vars = array("question_title", "points", "percentage", "number_of_answers");
00639                 $table->setHeaderVars($header_vars, $header_params);
00640                 $table->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
00641 
00642                 $table->setOffset($offset);
00643                 $table->setMaxCount(count($data->getQuestionTitles()));
00644                 $table->setOrderColumn($ordercolumn);
00645                 $table->setOrderDirection($orderdirection);
00646                 $rows = array();
00647                 foreach ($data->getQuestionTitles() as $question_id => $question_title)
00648                 {
00649                         $answered = 0;
00650                         $reached = 0;
00651                         $max = 0;
00652                         foreach ($foundParticipants as $userdata)
00653                         {
00654                                 for ($i = 0; $i <= $userdata->getLastPass(); $i++)
00655                                 {
00656                                         if (is_object($userdata->getPass($i)))
00657                                         {
00658                                                 $question =& $userdata->getPass($i)->getAnsweredQuestionByQuestionId($question_id);
00659                                                 if (is_array($question))
00660                                                 {
00661                                                         $answered++;
00662                                                         $reached += $question["reached"];
00663                                                         $max += $question["points"];
00664                                                 }
00665                                         }
00666                                 }
00667                         }
00668                         $percent = $max ? $reached/$max * 100.0 : 0;
00669                         $counter++;
00670                         array_push($rows, 
00671                                 array(
00672                                                 $question_title, 
00673                                                 sprintf("%.2f", $answered ? $reached / $answered : 0) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $answered ? $max / $answered : 0),
00674                                                 sprintf("%.2f", $percent) . "%",
00675                                                 $answered
00676                                 )
00677                         );
00678                 }
00679                 $table->setData($rows);
00680                 $tableoutput = $table->render();
00681                 $this->tpl->setVariable("TBL_AVG_REACHED", $tableoutput);
00682 
00683                 $this->tpl->setCurrentBlock("adm_content");
00684                 $this->tpl->setVariable("TXT_ANON_EVAL", $this->lng->txt("tst_anon_eval"));
00685                 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
00686                 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
00687                 $this->tpl->setVariable("TXT_AVG_REACHED", $this->lng->txt("average_reached_points"));
00688                 $this->tpl->setVariable("TXT_QUESTIONTITLE", $this->lng->txt("question_title"));
00689                 $this->tpl->setVariable("TXT_POINTS", $this->lng->txt("points"));
00690                 $this->tpl->setVariable("TXT_ANSWERS", $this->lng->txt("number_of_answers"));
00691                 $this->tpl->setVariable("TXT_PERCENT", $this->lng->txt("percentage"));
00692                 $this->tpl->parseCurrentBlock();
00693         }
00694 
00702         function exportEvaluation()
00703         {
00704                 $filterby = "";
00705                 if (array_key_exists("g_filterby", $_GET))
00706                 {
00707                         $filterby = $_GET["g_filterby"];
00708                 }
00709                 $filtertext = "";
00710                 if (array_key_exists("g_userfilter", $_GET))
00711                 {
00712                         $filtertext = $_GET["g_userfilter"];
00713                 }
00714                 $passedonly = FALSE;
00715                 if (array_key_exists("g_passedonly", $_GET))
00716                 {
00717                         if ($_GET["g_passedonly"] == 1)
00718                         {
00719                                 $passedonly = TRUE;
00720                         }
00721                 }
00722                 switch ($_POST["export_type"])
00723                 {
00724                         case "excel":
00725                                 include_once "./Modules/Test/classes/class.ilTestExport.php";
00726                                 $exportObj = new ilTestExport($this->object, "results");
00727                                 $exportObj->exportToExcel($deliver = TRUE, $filterby, $filtertext, $passedonly);
00728                                 break;
00729                         case "csv":
00730                                 include_once "./Modules/Test/classes/class.ilTestExport.php";
00731                                 $exportObj = new ilTestExport($this->object, "results");
00732                                 $exportObj->exportToCSV($deliver = TRUE, $filterby, $filtertext, $passedonly);
00733                                 break;
00734                         case "certificate":
00735                                 if ($passedonly)
00736                                 {
00737                                         $this->ctrl->setParameterByClass("iltestcertificategui", "g_passedonly", "1");
00738                                 }
00739                                 if (strlen($filtertext))
00740                                 {
00741                                         $this->ctrl->setParameterByClass("iltestcertificategui", "g_userfilter", $filtertext);
00742                                 }
00743                                 $this->ctrl->redirectByClass("iltestcertificategui", "exportCertificate");
00744                                 break;
00745                 }
00746         }
00747         
00754         function getEvaluationQuestionId($question_id, $original_id = "")
00755         {
00756                 if ($original_id > 0)
00757                 {
00758                         return $original_id;
00759                 }
00760                 else
00761                 {
00762                         return $question_id;
00763                 }
00764         }
00765 }
00766 ?>

Generated on Fri Dec 13 2013 17:56:53 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1