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

Modules/Test/classes/class.ilTestServiceGUI.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 
00039 class ilTestServiceGUI
00040 {
00041         var $object;
00042         var $lng;
00043         var $tpl;
00044         var $ctrl;
00045         var $ilias;
00046         var $tree;
00047         var $ref_id;
00048         
00057   function ilTestServiceGUI($a_object)
00058   {
00059                 global $lng, $tpl, $ilCtrl, $ilias, $tree;
00060 
00061     $this->lng =& $lng;
00062     $this->tpl =& $tpl;
00063                 $this->ctrl =& $ilCtrl;
00064                 $this->ilias =& $ilias;
00065                 $this->object =& $a_object;
00066                 $this->tree =& $tree;
00067                 $this->ref_id = $a_object->ref_id;
00068         }
00069         
00073         function &executeCommand()
00074         {
00075                 $cmd = $this->ctrl->getCmd();
00076                 $next_class = $this->ctrl->getNextClass($this);
00077 
00078                 $cmd = $this->getCommand($cmd);
00079                 switch($next_class)
00080                 {
00081                         default:
00082                                 $ret =& $this->$cmd();
00083                                 break;
00084                 }
00085                 return $ret;
00086         }
00087 
00095         function getCommand($cmd)
00096         {
00097                 return $cmd;
00098         }
00099         
00108         function getPassOverview($active_id, $targetclass = "", $targetcommand = "", $short = FALSE, $hide_details = FALSE)
00109         {
00110                 global $ilUser;
00111 
00112                 if ($short)
00113                 {
00114                         $template = new ilTemplate("tpl.il_as_tst_pass_overview_short.html", TRUE, TRUE, "Modules/Test");
00115                 }
00116                 else
00117                 {
00118                         $template = new ilTemplate("tpl.il_as_tst_pass_overview.html", TRUE, TRUE, "Modules/Test");
00119                 }
00120                 $color_class = array("tblrow1", "tblrow2");
00121                 $counter = 0;
00122 
00123                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
00124                 $counted_pass = $this->object->_getResultPass($active_id);
00125                 $reached_pass = $this->object->_getPass($active_id);
00126 
00127                 $result_percentage = 0;
00128                 $result_total_reached = 0;
00129                 $result_total_max = 0;
00130                 for ($pass = 0; $pass <= $reached_pass; $pass++)
00131                 {
00132                         $finishdate = $this->object->getPassFinishDate($active_id, $pass);
00133                         if ($finishdate > 0)
00134                         {
00135                                 if (!$short)
00136                                 {
00137                                         $result_array =& $this->object->getTestResult($active_id, $pass);
00138                                         if (!$result_array["test"]["total_max_points"])
00139                                         {
00140                                                 $percentage = 0;
00141                                         }
00142                                         else
00143                                         {
00144                                                 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
00145                                         }
00146                                         $total_max = $result_array["test"]["total_max_points"];
00147                                         $total_reached = $result_array["test"]["total_reached_points"];
00148                                 }
00149                                 if (!$hide_details)
00150                                 {
00151                                         if (strlen($targetclass) && strlen($targetcommand))
00152                                         {
00153                                                 $this->ctrl->setParameterByClass($targetclass, "active_id", $active_id);
00154                                                 $this->ctrl->setParameterByClass($targetclass, "pass", $pass);
00155                                                 $template->setCurrentBlock("pass_details");
00156                                                 $template->setVariable("HREF_PASS_DETAILS", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommand));
00157                                                 $template->setVariable("TEXT_PASS_DETAILS", $this->lng->txt("tst_pass_details"));
00158                                                 $template->parseCurrentBlock();
00159                                         }
00160                                 }
00161 
00162                                 $template->setCurrentBlock("result_row");
00163 
00164                                 if (($pass == $counted_pass) && (!$short))
00165                                 {
00166                                         $template->setVariable("COLOR_CLASS", "tblrowmarked");
00167                                         $template->setVariable("VALUE_SCORED", "&otimes;");
00168                                         $result_percentage = $percentage;
00169                                         $result_total_reached = $total_reached;
00170                                         $result_total_max = $total_max;
00171                                 }
00172                                 else
00173                                 {
00174                                         $template->setVariable("COLOR_CLASS", $color_class[$pass % 2]);
00175                                 }
00176                                 $template->setVariable("VALUE_PASS", $pass + 1);
00177                                 $template->setVariable("VALUE_DATE", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($finishdate), "date"));
00178                                 if (!$short)
00179                                 {
00180                                         $template->setVariable("VALUE_ANSWERED", $this->object->getAnsweredQuestionCount($active_id, $pass) . " " . strtolower($this->lng->txt("of")) . " " . (count($result_array)-1));
00181                                         $template->setVariable("VALUE_REACHED", $total_reached . " " . strtolower($this->lng->txt("of")) . " " . $total_max);
00182                                         $template->setVariable("VALUE_PERCENTAGE", sprintf("%.2f", $percentage) . "%");
00183                                 }
00184                                 $template->parseCurrentBlock();
00185                         }
00186                 }
00187 
00188                 $template->setVariable("PASS_COUNTER", $this->lng->txt("pass"));
00189                 $template->setVariable("DATE", $this->lng->txt("date"));
00190                 if (!$short)
00191                 {
00192                         $template->setVariable("PASS_SCORED", $this->lng->txt("scored_pass"));
00193                         $template->setVariable("ANSWERED_QUESTIONS", $this->lng->txt("tst_answered_questions"));
00194                         $template->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
00195                         $template->setVariable("PERCENTAGE_CORRECT", $this->lng->txt("tst_percent_solved"));
00196                 }
00197                 $template->parseCurrentBlock();
00198                 
00199                 return $template->get();
00200         }
00201 
00211         function getFinalStatement(&$test_data_array)
00212         {
00213                 if (!$test_data_array["total_max_points"])
00214                 {
00215                         $percentage = 0;
00216                 }
00217                 else
00218                 {
00219                         $percentage = ($test_data_array["total_reached_points"]/$test_data_array["total_max_points"])*100;
00220                 }
00221                 $total_max = $test_data_array["total_max_points"];
00222                 $total_reached = $test_data_array["total_reached_points"];
00223                 $result_percentage = $percentage;
00224                 $result_total_reached = $total_reached;
00225                 $result_total_max = $total_max;
00226 
00227                 $mark = "";
00228                 $markects = "";
00229                 $mark_obj = $this->object->mark_schema->getMatchingMark($result_percentage);
00230                 if ($mark_obj)
00231                 {
00232                         if ($mark_obj->getPassed()) 
00233                         {
00234                                 $mark = $this->lng->txt("mark_tst_passed");
00235                         } 
00236                         else 
00237                         {
00238                                 $mark = $this->lng->txt("mark_tst_failed");
00239                         }
00240                         $mark = str_replace("[mark]", $mark_obj->getOfficialName(), $mark);
00241                         $mark = str_replace("[markshort]", $mark_obj->getShortName(), $mark);
00242                         $mark = str_replace("[percentage]", sprintf("%.2f", $result_percentage), $mark);
00243                         $mark = str_replace("[reached]", $result_total_reached, $mark);
00244                         $mark = str_replace("[max]", $result_total_max, $mark);
00245                 }
00246                 if ($this->object->ects_output)
00247                 {
00248                         $ects_mark = $this->object->getECTSGrade($result_total_reached, $result_total_max);
00249                         $markects = $this->lng->txt("mark_tst_ects");
00250                         $markects = str_replace("[markects]", $this->lng->txt("ects_grade_". strtolower($ects_mark)), $markects);
00251                 }
00252                 return array("mark" => $mark, "markects" => $markects);
00253         }
00254 
00267         function getPassListOfAnswers(&$result_array, $active_id, $pass, $show_solutions = FALSE, $only_answered_questions = FALSE, $show_question_only = FALSE, $show_reached_points = FALSE)
00268         {
00269                 $maintemplate = new ilTemplate("tpl.il_as_tst_list_of_answers.html", TRUE, TRUE, "Modules/Test");
00270 
00271                 $counter = 1;
00272                 // output of questions with solutions
00273                 foreach ($result_array as $question_data)
00274                 {
00275                         if (($question_data["workedthrough"] == 1) || ($only_answered_questions == FALSE))
00276                         {
00277                                 $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
00278                                 $question = $question_data["qid"];
00279                                 if (is_numeric($question))
00280                                 {
00281                                         $maintemplate->setCurrentBlock("printview_question");
00282                                         $question_gui = $this->object->createQuestionGUI("", $question);
00283 
00284                                         if ($show_reached_points)
00285                                         {
00286                                                 $template->setCurrentBlock("result_points");
00287                                                 $template->setVariable("RESULT_POINTS", $this->lng->txt("tst_reached_points") . ": " . $question_gui->object->getReachedPoints($active_id, $pass) . " " . $this->lng->txt("of") . " " . $question_gui->object->getMaximumPoints());
00288                                                 $template->parseCurrentBlock();
00289                                         }
00290                                         $template->setVariable("COUNTER_QUESTION", $counter.". ");
00291                                         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()));
00292 
00293                                         $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
00294                                         $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_solutions, FALSE, $show_question_only, $this->object->getShowSolutionFeedback());
00295 
00296                                         $template->setVariable("SOLUTION_OUTPUT", $result_output);
00297                                         $maintemplate->setCurrentBlock("printview_question");
00298                                         $maintemplate->setVariable("QUESTION_PRINTVIEW", $template->get());
00299                                         $maintemplate->parseCurrentBlock();
00300                                         $counter ++;
00301                                 }
00302                         }
00303                 }
00304                 $maintemplate->setVariable("RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_eval_results_by_pass"), $pass+1));
00305                 return $maintemplate->get();
00306         }
00307         
00320         function getPassListOfAnswersWithScoring(&$result_array, $active_id, $pass, $show_solutions = FALSE)
00321         {
00322                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
00323                 
00324                 $maintemplate = new ilTemplate("tpl.il_as_tst_list_of_answers.html", TRUE, TRUE, "Modules/Test");
00325 
00326                 include_once "./classes/class.ilObjAssessmentFolder.php";
00327                 $scoring = ilObjAssessmentFolder::_getManualScoring();
00328                 
00329                 $counter = 1;
00330                 // output of questions with solutions
00331                 foreach ($result_array as $question_data)
00332                 {
00333                         $question = $question_data["qid"];
00334                         if (is_numeric($question))
00335                         {
00336                                 $question_gui = $this->object->createQuestionGUI("", $question);
00337                                 if (in_array($question_gui->object->getQuestionTypeID(), $scoring))
00338                                 {
00339                                         $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", TRUE, TRUE, "Modules/TestQuestionPool");
00340                                         $scoretemplate = new ilTemplate("tpl.il_as_tst_manual_scoring_points.html", TRUE, TRUE, "Modules/Test");
00341                                         $this->tpl->setCurrentBlock("printview_question");
00342                                         $template->setVariable("COUNTER_QUESTION", $counter.". ");
00343                                         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()));
00344                                         $points = $question_gui->object->getMaximumPoints();
00345                                         if ($points == 1)
00346                                         {
00347                                                 $template->setVariable("QUESTION_POINTS", $points . " " . $this->lng->txt("point"));
00348                                         }
00349                                         else
00350                                         {
00351                                                 $template->setVariable("QUESTION_POINTS", $points . " " . $this->lng->txt("points"));
00352                                         }
00353                                         
00354                                         $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
00355                                         $result_output = $question_gui->getSolutionOutput($active_id, $pass, $show_solutions, FALSE, $show_question_only, $this->object->getShowSolutionFeedback());
00356                                         if ($this->object->getShowSolutionFeedback())
00357                                         {
00358                                                 $scoretemplate->setCurrentBlock("feedback");
00359                                                 $scoretemplate->setVariable("FEEDBACK_NAME_INPUT", $question);
00360                                                 $feedback = $this->object->getManualFeedback($active_id, $question, $pass);
00361                                                 $scoretemplate->setVariable("VALUE_FEEDBACK", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($feedback, TRUE)));
00362                                                 $scoretemplate->setVariable("VALUE_SAVE", $this->lng->txt("save"));
00363                                                 $scoretemplate->setVariable("TEXT_MANUAL_FEEDBACK", $this->lng->txt("set_manual_feedback"));
00364                                                 $scoretemplate->parseCurrentBlock();
00365                                         }
00366                                         $scoretemplate->setVariable("NAME_INPUT", $question);
00367                                         $this->ctrl->setParameter($this, "active_id", $active_id);
00368                                         $this->ctrl->setParameter($this, "pass", $pass);
00369                                         $scoretemplate->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00370                                         $scoretemplate->setVariable("LABEL_INPUT", $this->lng->txt("tst_change_points_for_question"));
00371                                         $scoretemplate->setVariable("BUTTON_POINTS", $this->lng->txt("change"));
00372                                         $scoretemplate->setVariable("VALUE_INPUT", " value=\"" . assQuestion::_getReachedPoints($active_id, $question_data["qid"], $pass) . "\"");
00373                                         
00374                                         $template->setVariable("SOLUTION_OUTPUT", $result_output);
00375                                         $maintemplate->setCurrentBlock("printview_question");
00376                                         $maintemplate->setVariable("QUESTION_PRINTVIEW", $template->get());
00377                                         $maintemplate->setVariable("QUESTION_SCORING", $scoretemplate->get());
00378                                         $maintemplate->parseCurrentBlock();
00379                                 }
00380                                 $counter ++;
00381                         }
00382                 }
00383                 if ($counter == 1)
00384                 {
00385                         // no scorable questions found
00386                         $maintemplate->setVariable("NO_QUESTIONS_FOUND", $this->lng->txt("manscoring_questions_not_found"));
00387                 }
00388                 $maintemplate->setVariable("RESULTS_OVERVIEW", sprintf($this->lng->txt("manscoring_results_pass"), $pass+1));
00389 
00390                 return $maintemplate->get();
00391         }
00392 
00393 
00409         function getPassDetailsOverview($result_array, $active_id, $pass, $targetclass = "", $targetcommandsort = "", $targetcommanddetails = "", $standard_header = TRUE)
00410         {
00411                 global $ilUser;
00412 
00413                 $testresults = $result_array["test"];
00414                 unset($result_array["test"]);
00415                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
00416 
00417                 $sort = ($_GET["sort"]) ? ($_GET["sort"]) : "nr";
00418                 $sortorder = ($_GET["sortorder"]) ? ($_GET["sortorder"]) : "asc";
00419 
00420                 if (!$standard_header)
00421                 {
00422                         // change sortorder of result array
00423                         usort($result_array, "sortResults");
00424                 }
00425                 $color_class = array("tblrow1", "tblrow2");
00426                 $counter = 0;
00427                 $template = new ilTemplate("tpl.il_as_tst_pass_details_overview.html", TRUE, TRUE, "Modules/Test");
00428                 $this->ctrl->setParameterByClass($targetclass, "pass", "$pass");
00429 
00430                 if (!$testresults["total_max_points"])
00431                 {
00432                         $percentage = 0;
00433                 }
00434                 else
00435                 {
00436                         $percentage = ($testresults["total_reached_points"]/$testresults["total_max_points"])*100;
00437                 }
00438                 $total_max = $testresults["total_max_points"];
00439                 $total_reached = $testresults["total_reached_points"];
00440 
00441                 $img_title_percent = "";
00442                 $img_title_nr = "";
00443                 $hasSuggestedSolutions = FALSE;
00444                 
00445                 foreach ($result_array as $key => $value)
00446                 {
00447                         if (strlen($value["solution"]))
00448                         {
00449                                 $hasSuggestedSolutions = TRUE;
00450                         }
00451                 }
00452                 foreach ($result_array as $key => $value) 
00453                 {
00454                         if (preg_match("/\d+/", $key)) 
00455                         {
00456                                 if (strlen($targetclass) && strlen($targetcommanddetails))
00457                                 {
00458                                         $template->setCurrentBlock("linked_title");
00459                                         $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00460                                         $template->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
00461                                         $this->ctrl->setParameterByClass($targetclass, "evaluation", $value["qid"]);
00462                                         $this->ctrl->setParameterByClass($targetclass, "active_id", $active_id);
00463                                         $template->setVariable("URL_QUESTION_TITLE", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommanddetails));
00464                                         $template->parseCurrentBlock();
00465                                 }
00466                                 else
00467                                 {
00468                                         $template->setCurrentBlock("plain_title");
00469                                         $template->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
00470                                         $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00471                                         $template->parseCurrentBlock();
00472                                 }
00473                                 if ($hasSuggestedSolutions)
00474                                 {
00475                                         $template->setCurrentBlock("question_suggested_solution");
00476                                         $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00477                                         if ((preg_match("/http/", $value["solution"])) || (preg_match("/goto/", $value["solution"])))
00478                                         {
00479                                                 $template->setVariable("SOLUTION_HINT", "<a href=\"".$value["solution"]."\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a>");
00480                                         }
00481                                         else
00482                                         {
00483                                                 if ($value["solution"])
00484                                                 {
00485                                                         $template->setVariable("SOLUTION_HINT", $this->lng->txt($value["solution"]));
00486                                                 }
00487                                                 else
00488                                                 {
00489                                                         $template->setVariable("SOLUTION_HINT", "");
00490                                                 }
00491                                         }
00492                                         $template->parseCurrentBlock();
00493                                 }
00494                                 $template->setCurrentBlock("question");
00495                                 $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
00496                                 $template->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
00497                                 $template->setVariable("VALUE_MAX_POINTS", $value["max"]);
00498                                 $template->setVariable("VALUE_REACHED_POINTS", $value["reached"]);
00499                                 $template->setVariable("VALUE_PERCENT_SOLVED", $value["percent"]);
00500                                 $template->parseCurrentBlock();
00501                                 $counter++;
00502                         }
00503                 }
00504 
00505                 if ($hasSuggestedSolutions)
00506                 {
00507                         $template->touchBlock("footer_suggested_solution");
00508                 }
00509                 $template->setCurrentBlock("footer");
00510                 $template->setVariable("VALUE_QUESTION_COUNTER", "<strong>" . $this->lng->txt("total") . "</strong>");
00511                 $template->setVariable("VALUE_QUESTION_TITLE", "");
00512                 $template->setVariable("VALUE_MAX_POINTS", "<strong>$total_max</strong>");
00513                 $template->setVariable("VALUE_REACHED_POINTS", "<strong>$total_reached</strong>");
00514                 $template->setVariable("VALUE_PERCENT_SOLVED", "<strong>" . sprintf("%2.2f", $percentage) . " %" . "</strong>");
00515                 $template->parseCurrentBlock();
00516 
00517                 if ($standard_header)
00518                 {
00519                         if ($hasSuggestedSolutions)
00520                         {
00521                                 $template->setCurrentBlock("standard_header_suggested_solution");
00522                                 $template->setVariable("SOLUTION_HINT_HEADER", $this->lng->txt("solution_hint"));
00523                                 $template->parseCurrentBlock();
00524                         }
00525                         $template->setCurrentBlock("standard_header");
00526                         $template->setVariable("QUESTION_COUNTER", $this->lng->txt("tst_question_no"));
00527                         $template->setVariable("PERCENT_SOLVED", $this->lng->txt("tst_percent_solved"));
00528                         $template->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
00529                         $template->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
00530                         $template->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
00531                         $template->parseCurrentBlock();
00532                 }
00533                 else
00534                 {
00535                         if ($hasSuggestedSolutions)
00536                         {
00537                                 $template->setCurrentBlock("linked_header_suggested_solution");
00538                                 if (strcmp($sort, "solution") == 0)
00539                                 {
00540                                         $this->ctrl->setParameterByClass($targetclass, "sortorder", !strcmp($sortorder, "asc") ? "desc" : "asc");
00541                                 }
00542                                 else
00543                                 {
00544                                         $this->ctrl->setParameterByClass($targetclass, "sortorder", "asc");
00545                                 }
00546                                 $this->ctrl->setParameterByClass($targetclass, "sort", "solution");
00547                                 $template->setVariable("URL_SOLUTION_HINT_HEADER", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommandsort));
00548                                 $template->setVariable("SOLUTION_HINT_HEADER", $this->lng->txt("solution_hint"));
00549                                 if (strcmp($sort, "solution") == 0)
00550                                 {
00551                                         $image = new ilTemplate("tpl.image.html", TRUE, TRUE);
00552                                         $image->setVariable("IMAGE_SOURCE", ilUtil::getImagePath($sortorder . "_order.gif"));
00553                                         $image->setVariable("IMAGE_ALT", $this->lng->txt("change_sort_direction"));
00554                                         $image->setVariable("IMAGE_TITLE", $this->lng->txt("change_sort_direction"));
00555                                         $template->setVariable("IMAGE_SOLUTION_HINT_HEADER", $image->get());
00556                                 }
00557                                 $template->parseCurrentBlock();
00558                         }
00559                         $template->setCurrentBlock("linked_header");
00560                         $this->ctrl->setParameterByClass($targetclass, "sort", "nr");
00561                         if (strcmp($sort, "nr") == 0)
00562                         {
00563                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", !strcmp($sortorder, "asc") ? "desc" : "asc");
00564                         }
00565                         else
00566                         {
00567                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", "asc");
00568                         }
00569                         $template->setVariable("URL_QUESTION_COUNTER", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommandsort));
00570                         $template->setVariable("QUESTION_COUNTER", $this->lng->txt("tst_question_no"));
00571                         if (strcmp($sort, "nr") == 0)
00572                         {
00573                                 $image = new ilTemplate("tpl.image.html", TRUE, TRUE);
00574                                 $image->setVariable("IMAGE_SOURCE", ilUtil::getImagePath($sortorder . "_order.gif"));
00575                                 $image->setVariable("IMAGE_ALT", $this->lng->txt("change_sort_direction"));
00576                                 $image->setVariable("IMAGE_TITLE", $this->lng->txt("change_sort_direction"));
00577                                 $template->setVariable("IMAGE_QUESTION_COUNTER", $image->get());
00578                         }
00579                         $this->ctrl->setParameterByClass($targetclass, "sort", "percent");
00580                         if (strcmp($sort, "percent") == 0)
00581                         {
00582                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", !strcmp($sortorder, "asc") ? "desc" : "asc");
00583                         }
00584                         else
00585                         {
00586                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", "asc");
00587                         }
00588                         $template->setVariable("URL_PERCENT_SOLVED", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommandsort));
00589                         $template->setVariable("PERCENT_SOLVED", $this->lng->txt("tst_percent_solved"));
00590                         if (strcmp($sort, "percent") == 0)
00591                         {
00592                                 $image = new ilTemplate("tpl.image.html", TRUE, TRUE);
00593                                 $image->setVariable("IMAGE_SOURCE", ilUtil::getImagePath($sortorder . "_order.gif"));
00594                                 $image->setVariable("IMAGE_ALT", $this->lng->txt("change_sort_direction"));
00595                                 $image->setVariable("IMAGE_TITLE", $this->lng->txt("change_sort_direction"));
00596                                 $template->setVariable("IMAGE_PERCENT_SOLVED", $image->get());
00597                         }
00598                         $this->ctrl->setParameterByClass($targetclass, "sort", "title");
00599                         if (strcmp($sort, "title") == 0)
00600                         {
00601                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", !strcmp($sortorder, "asc") ? "desc" : "asc");
00602                         }
00603                         else
00604                         {
00605                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", "asc");
00606                         }
00607                         $template->setVariable("URL_QUESTION_TITLE", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommandsort));
00608                         $template->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
00609                         if (strcmp($sort, "title") == 0)
00610                         {
00611                                 $image = new ilTemplate("tpl.image.html", TRUE, TRUE);
00612                                 $image->setVariable("IMAGE_SOURCE", ilUtil::getImagePath($sortorder . "_order.gif"));
00613                                 $image->setVariable("IMAGE_ALT", $this->lng->txt("change_sort_direction"));
00614                                 $image->setVariable("IMAGE_TITLE", $this->lng->txt("change_sort_direction"));
00615                                 $template->setVariable("IMAGE_QUESTION_TITLE", $image->get());
00616                         }
00617                         $this->ctrl->setParameterByClass($targetclass, "sort", "max");
00618                         if (strcmp($sort, "max") == 0)
00619                         {
00620                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", strcmp($sortorder, "asc") ? "desc" : "asc");
00621                         }
00622                         else
00623                         {
00624                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", "asc");
00625                         }
00626                         $template->setVariable("URL_MAX_POINTS", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommandsort));
00627                         $template->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
00628                         if (strcmp($sort, "max") == 0)
00629                         {
00630                                 $image = new ilTemplate("tpl.image.html", TRUE, TRUE);
00631                                 $image->setVariable("IMAGE_SOURCE", ilUtil::getImagePath($sortorder . "_order.gif"));
00632                                 $image->setVariable("IMAGE_ALT", $this->lng->txt("change_sort_direction"));
00633                                 $image->setVariable("IMAGE_TITLE", $this->lng->txt("change_sort_direction"));
00634                                 $template->setVariable("IMAGE_MAX_POINTS", $image->get());
00635                         }
00636                         $this->ctrl->setParameterByClass($targetclass, "sort", "reached");
00637                         if (strcmp($sort, "reached") == 0)
00638                         {
00639                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", !strcmp($sortorder, "asc") ? "desc" : "asc");
00640                         }
00641                         else
00642                         {
00643                                 $this->ctrl->setParameterByClass($targetclass, "sortorder", "asc");
00644                         }
00645                         $template->setVariable("URL_REACHED_POINTS", $this->ctrl->getLinkTargetByClass($targetclass, $targetcommandsort));
00646                         $template->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
00647                         if (strcmp($sort, "reached") == 0)
00648                         {
00649                                 $image = new ilTemplate("tpl.image.html", TRUE, TRUE);
00650                                 $image->setVariable("IMAGE_SOURCE", ilUtil::getImagePath($sortorder . "_order.gif"));
00651                                 $image->setVariable("IMAGE_ALT", $this->lng->txt("change_sort_direction"));
00652                                 $image->setVariable("IMAGE_TITLE", $this->lng->txt("change_sort_direction"));
00653                                 $template->setVariable("IMAGE_REACHED_POINTS", $image->get());
00654                         }
00655                         $template->parseCurrentBlock();
00656                 }
00657 
00658                 return $template->get();
00659         }
00660 
00669         function getResultsSignature()
00670         {
00671                 if ($this->object->getShowSolutionSignature() && !$this->object->getAnonymity())
00672                 {
00673                         // output of time/date and signature
00674                         $template = new ilTemplate("tpl.il_as_tst_results_userdata_signature.html", TRUE, TRUE, "Modules/Test");
00675                         $template->setVariable("TXT_DATE", $this->lng->txt("date"));
00676                         $template->setVariable("VALUE_DATE", strftime("%Y-%m-%d %H:%M:%S", time()));
00677                         $template->setVariable("TXT_SIGNATURE", $this->lng->txt("tst_signature"));
00678                         $template->setVariable("IMG_SPACER", ilUtil::getImagePath("spacer.gif"));
00679                         return $template->get();
00680                 }
00681                 else
00682                 {
00683                         return "";
00684                 }
00685         }
00686         
00697         function getResultsUserdata($active_id, $overwrite_anonymity = FALSE)
00698         {
00699                 $template = new ilTemplate("tpl.il_as_tst_results_userdata.html", TRUE, TRUE, "Modules/Test");
00700                 include_once './Services/User/classes/class.ilObjUser.php';
00701                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
00702                 if (strlen(ilObjUser::_lookupLogin($user_id)) > 0)
00703                 {
00704                         $user = new ilObjUser($user_id);
00705                 }
00706                 else
00707                 {
00708                         $user = new ilObjUser();
00709                         $user->setLastname($this->lng->txt("deleted_user"));
00710                 }
00711                 $t = $this->object->getTestSession($active_id)->getSubmittedTimestamp();
00712                 if (!$t)
00713                 {
00714                         $t = $this->object->_getLastAccess($this->object->getTestSession()->getActiveId());
00715                 }
00716                 $print_date = mktime(date("H"), date("i"), date("s"), date("m")  , date("d"), date("Y"));
00717 
00718                 $title_matric = "";
00719                 if (strlen($user->getMatriculation()) && (($this->object->getAnonymity() == FALSE) || ($overwrite_anonymity)))
00720                 {
00721                         $template->setCurrentBlock("user_matric");
00722                         $template->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
00723                         $template->parseCurrentBlock();
00724                         $template->setCurrentBlock("user_matric_value");
00725                         $template->setVariable("VALUE_USR_MATRIC", $user->getMatriculation());
00726                         $template->parseCurrentBlock();
00727                         $template->touchBlock("user_matric_separator");
00728                         $title_matric = " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation();
00729                 }
00730 
00731                 $invited_user = array_pop($this->object->getInvitedUsers($user_id));
00732                 if (strlen($invited_user->clientip))
00733                 {
00734                         $template->setCurrentBlock("user_clientip");
00735                         $template->setVariable("TXT_CLIENT_IP", $this->lng->txt("client_ip"));
00736                         $template->parseCurrentBlock();
00737                         $template->setCurrentBlock("user_clientip_value");
00738                         $template->setVariable("VALUE_CLIENT_IP", $invited_user->clientip);
00739                         $template->parseCurrentBlock();
00740                         $template->touchBlock("user_clientip_separator");
00741                         $title_client = " - " . $this->lng->txt("clientip") . ": " . $invited_user->clientip;
00742                 }
00743 
00744                 $template->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
00745                 $template->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
00746                 $template->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
00747                 $uname = $this->object->userLookupFullName($user_id, $overwrite_anonymity);
00748                 $template->setVariable("VALUE_USR_NAME", $uname);
00749                 $template->setVariable("TXT_TEST_DATE", $this->lng->txt("tst_tst_date"));
00750                 $template->setVariable("VALUE_TEST_DATE", strftime("%Y-%m-%d %H:%M:%S",ilUtil::date_mysql2time($t)));
00751                 $template->setVariable("TXT_PRINT_DATE", $this->lng->txt("tst_print_date"));
00752                 $template->setVariable("VALUE_PRINT_DATE", strftime("%Y-%m-%d %H:%M:%S",$print_date));
00753                 
00754                 // change the pagetitle
00755                 $pagetitle = ": " . $this->object->getTitle() . $title_matric . $title_client;
00756                 $this->tpl->setHeaderPageTitle($pagetitle);
00757                 
00758                 return $template->get();
00759         }
00760 
00772         function getCorrectSolutionOutput($question_id, $active_id, $pass)
00773         {
00774                 global $ilUser;
00775 
00776                 $test_id = $this->object->getTestId();
00777                 $question_gui = $this->object->createQuestionGUI("", $question_id);
00778 
00779                 $template = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", TRUE, TRUE, "Modules/Test");
00780                 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? TRUE : FALSE;
00781                 $result_output = $question_gui->getSolutionOutput($active_id, $pass, TRUE, FALSE, $show_question_only, $this->object->getShowSolutionFeedback());
00782                 $best_output = $question_gui->getSolutionOutput("", NULL, FALSE, FALSE, $show_question_only);
00783                 $template->setVariable("TEXT_YOUR_SOLUTION", $this->lng->txt("tst_your_answer_was"));
00784                 $template->setVariable("TEXT_BEST_SOLUTION", $this->lng->txt("tst_best_solution_is"));
00785                 $maxpoints = $question_gui->object->getMaximumPoints();
00786                 if ($maxpoints == 1)
00787                 {
00788                         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
00789                 }
00790                 else
00791                 {
00792                         $template->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
00793                 }
00794                 $template->setVariable("SOLUTION_OUTPUT", $result_output);
00795                 $template->setVariable("BEST_OUTPUT", $best_output);
00796                 $template->setVariable("RECEIVED_POINTS", sprintf($this->lng->txt("you_received_a_of_b_points"), $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
00797                 $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00798                 $template->setVariable("BACKLINK_TEXT", "&lt;&lt; " . $this->lng->txt("back"));
00799                 return $template->get();
00800         }
00801 
00809         function getResultsOfUserOutput($active_id, $pass, $show_pass_details = TRUE, $show_answers = TRUE, $show_question_only = FALSE, $show_reached_points = FALSE)
00810         {
00811                 global $ilias, $tpl;
00812 
00813                 include_once("./classes/class.ilTemplate.php");
00814                 $template = new ilTemplate("tpl.il_as_tst_results_participant.html", TRUE, TRUE, "Modules/Test");
00815 
00816                 $user_id = $this->object->_getUserIdFromActiveId($active_id);
00817                 $uname = $this->object->userLookupFullName($user_id, TRUE);
00818 
00819                 if (((array_key_exists("pass", $_GET)) && (strlen($_GET["pass"]) > 0)) || (!is_null($pass)))
00820                 {
00821                         if (is_null($pass))     $pass = $_GET["pass"];
00822                 }
00823 
00824                 $result_pass = $this->object->_getResultPass($active_id);
00825                 $result_array =& $this->object->getTestResult($active_id, $result_pass);
00826                 $statement = $this->getFinalStatement($result_array["test"]);
00827                 $user_data = $this->getResultsUserdata($active_id, TRUE);
00828 
00829                 if (!is_null($pass))
00830                 {
00831                         $result_array =& $this->object->getTestResult($active_id, $pass);
00832                         $command_solution_details = "";
00833                         if ($show_pass_details)
00834                         {
00835                                 $detailsoverview = $this->getPassDetailsOverview($result_array, $active_id, $pass, "iltestservicegui", "getResultsOfUserOutput", $command_solution_details);
00836                         }
00837 
00838                         $user_id = $this->object->_getUserIdFromActiveId($active_id);
00839                         $showAllAnswers = TRUE;
00840                         if ($this->object->isExecutable($user_id))
00841                         {
00842                                 $showAllAnswers = FALSE;
00843                         }
00844                         if ($show_answers)
00845                         {
00846                                 $list_of_answers = $this->getPassListOfAnswers($result_array, $active_id, $pass, FALSE, $showAllAnswers, $show_question_only, $show_reached_points);
00847                         }
00848 
00849                         $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
00850                         //$template->setVariable("PASS_RESULTS_OVERVIEW", sprintf($this->lng->txt("tst_results_overview_pass"), $pass + 1));
00851                         $template->setVariable("PASS_DETAILS", $detailsoverview);
00852 
00853                         $signature = $this->getResultsSignature();
00854                         $template->setVariable("SIGNATURE", $signature);
00855                 }
00856                 $template->setVariable("TEXT_HEADING", sprintf($this->lng->txt("tst_result_user_name"), $uname));
00857                 $template->setVariable("USER_DATA", $user_data);
00858                 $template->setVariable("USER_MARK", $statement["mark"]);
00859                 if (strlen($statement["markects"]))
00860                 {
00861                         $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
00862                 }
00863                 $template->parseCurrentBlock();
00864 
00865                 return $template->get();
00866         }
00867 }
00868 
00869 // internal sort function to sort the result array
00870 function sortResults($a, $b)
00871 {
00872         $sort = ($_GET["sort"]) ? ($_GET["sort"]) : "nr";
00873         $sortorder = ($_GET["sortorder"]) ? ($_GET["sortorder"]) : "asc";
00874         if (strcmp($sortorder, "asc")) 
00875         {
00876                 $smaller = 1;
00877                 $greater = -1;
00878         } 
00879         else 
00880         {
00881                 $smaller = -1;
00882                 $greater = 1;
00883         }
00884         if ($a[$sort] == $b[$sort]) return 0;
00885         return ($a[$sort] < $b[$sort]) ? $smaller : $greater;
00886 }
00887 
00888 ?>

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