00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once "./assessment/classes/inc.AssessmentConstants.php";
00025
00038 class ilTestEvaluationGUI
00039 {
00040 var $object;
00041 var $lng;
00042 var $tpl;
00043 var $ctrl;
00044 var $ilias;
00045 var $tree;
00046
00056 function ilTestEvaluationGUI($a_object)
00057 {
00058 global $lng, $tpl, $ilCtrl, $ilias, $tree;
00059
00060 $this->lng =& $lng;
00061 $this->tpl =& $tpl;
00062 $this->ctrl =& $ilCtrl;
00063 $this->ilias =& $ilias;
00064 $this->object =& $a_object;
00065 $this->tree =& $tree;
00066 }
00067
00071 function &executeCommand()
00072 {
00073 $this->ctrl->saveParameter($this, "etype");
00074 $cmd = $this->ctrl->getCmd();
00075 $next_class = $this->ctrl->getNextClass($this);
00076
00077 $cmd = $this->getCommand($cmd);
00078 switch($next_class)
00079 {
00080 default:
00081 $ret =& $this->$cmd();
00082 break;
00083 }
00084 return $ret;
00085 }
00086
00094 function getCommand($cmd)
00095 {
00096 return $cmd;
00097 }
00098
00106 function outStatSelectedSearchResults()
00107 {
00108 include_once ("./classes/class.ilSearch.php");
00109 global $ilUser;
00110
00111 if (is_array($_POST["search_for"]))
00112 {
00113 if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
00114 {
00115 $search =& new ilSearch($ilUser->id);
00116 $search->setSearchString($_POST["search_term"]);
00117 $search->setCombination($_POST["concatenation"]);
00118 $search->setSearchFor($_POST["search_for"]);
00119 $search->setSearchType("new");
00120 if($search->validate($message))
00121 {
00122 $search->performSearch();
00123 }
00124 if ($message)
00125 {
00126
00127 }
00128 if(!$search->getNumberOfResults() && $search->getSearchFor())
00129 {
00130 sendInfo($this->lng->txt("search_no_match"));
00131 return;
00132 }
00133 $buttons = array("add");
00134 $participants =& $this->object->evalTotalPersonsArray();
00135 $eval_users = $this->object->getEvaluationUsers($ilUser->id);
00136 if ($searchresult = $search->getResultByType("usr"))
00137 {
00138 $users = array();
00139 foreach ($searchresult as $result_array)
00140 {
00141 if (!array_key_exists($result_array["id"], $eval_users))
00142 {
00143 if (array_key_exists($result_array["id"], $participants))
00144 {
00145 $users[$result_array["id"]] = $eval_users[$result_array["id"]];
00146 }
00147 }
00148 }
00149 $this->outEvalSearchResultTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_found_users"), $buttons);
00150 }
00151 $searchresult = array();
00152 if ($searchresult = $search->getResultByType("grp"))
00153 {
00154 $groups = array();
00155 foreach ($searchresult as $result_array)
00156 {
00157 include_once("./classes/class.ilObjGroup.php");
00158 $grp = new ilObjGroup($result_array["id"], true);
00159 $members = $grp->getGroupMemberIds();
00160 $found_member = 0;
00161 foreach ($members as $member_id)
00162 {
00163 if (array_key_exists($member_id, $participants))
00164 {
00165 $found_member = 1;
00166 }
00167 }
00168 if ($found_member)
00169 {
00170 array_push($groups, $result_array["id"]);
00171 }
00172 }
00173 $this->outEvalSearchResultTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_found_groups"), $buttons);
00174 }
00175 if ($searchresult = $search->getResultByType("role"))
00176 {
00177 $roles = array();
00178 foreach ($searchresult as $result_array)
00179 {
00180 array_push($roles, $result_array["id"]);
00181 }
00182 $roles = $this->object->getRoleData($roles);
00183 if (count ($roles))
00184 $this->outEvalSearchResultTable("role", $roles, "role_result", "role_row", $this->lng->txt("search_found_roles"), $buttons);
00185 }
00186 }
00187 }
00188 else
00189 {
00190 sendInfo($this->lng->txt("no_user_or_group_selected"));
00191 }
00192 }
00193
00201 function addFoundUsersToEval()
00202 {
00203 global $ilUser;
00204 if (is_array($_POST["user_select"]))
00205 {
00206 foreach ($_POST["user_select"] as $user_id)
00207 {
00208 $this->object->addSelectedUser($user_id, $ilUser->id);
00209 }
00210 }
00211 $this->evalStatSelected();
00212 }
00213
00221 function removeSelectedUser()
00222 {
00223 global $ilUser;
00224 if (is_array($_POST["selected_users"]))
00225 {
00226 foreach ($_POST["selected_users"] as $user_id)
00227 {
00228 $this->object->removeSelectedUser($user_id, $ilUser->id);
00229 }
00230 }
00231 $this->evalStatSelected();
00232 }
00233
00241 function removeSelectedGroup()
00242 {
00243 global $ilUser;
00244 if (is_array($_POST["selected_groups"]))
00245 {
00246 foreach ($_POST["selected_groups"] as $group_id)
00247 {
00248 $this->object->removeSelectedGroup($group_id, $ilUser->id);
00249 }
00250 }
00251 $this->evalStatSelected();
00252 }
00253
00261 function addFoundGroupsToEval()
00262 {
00263 global $ilUser;
00264 if (is_array($_POST["group_select"]))
00265 {
00266 foreach ($_POST["group_select"] as $group_id)
00267 {
00268 $this->object->addSelectedGroup($group_id, $ilUser->id);
00269 }
00270 }
00271 $this->evalStatSelected();
00272 }
00273
00281 function addFoundRolesToEval()
00282 {
00283 global $ilUser;
00284 if (is_array($_POST["role_select"]))
00285 {
00286 foreach ($_POST["role_select"] as $role_id)
00287 {
00288 $this->object->addSelectedRole($role_id, $ilUser->id);
00289 }
00290 }
00291 $this->evalStatSelected();
00292 }
00293
00301 function searchForEvaluation()
00302 {
00303 $this->evalStatSelected(1);
00304 }
00305
00313 function evalStatSelected($search = 0)
00314 {
00315 global $ilUser;
00316
00317 $this->ctrl->setCmd("evalStatSelected");
00318 $this->setResultsTabs();
00319 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_statistical_evaluation_selection.html", true);
00320 if ($search)
00321 {
00322 $this->outStatSelectedSearchResults();
00323 }
00324 $this->tpl->setCurrentBlock("userselection");
00325 $this->tpl->setVariable("SEARCH_USERSELECTION", $this->lng->txt("eval_search_userselection"));
00326 $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("eval_search_term"));
00327 $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
00328 $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("eval_search_users"));
00329 $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("eval_search_groups"));
00330 $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("eval_search_roles"));
00331 $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("eval_concatenation"));
00332 $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
00333 $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
00334 $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
00335 if (is_array($_POST["search_for"]))
00336 {
00337 if (in_array("usr", $_POST["search_for"]))
00338 {
00339 $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
00340 }
00341 if (in_array("grp", $_POST["search_for"]))
00342 {
00343 $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
00344 }
00345 if (in_array("role", $_POST["search_for"]))
00346 {
00347 $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
00348 }
00349 }
00350 if (strcmp($_POST["concatenation"], "and") == 0)
00351 {
00352 $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
00353 }
00354 else if (strcmp($_POST["concatenation"], "or") == 0)
00355 {
00356 $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
00357 }
00358 $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
00359 $this->tpl->parseCurrentBlock();
00360
00361
00362 $eval_users = $this->object->getEvaluationUsers($ilUser->id);
00363 $buttons = array("remove");
00364 if (count($eval_users))
00365 {
00366 $this->outEvalSearchResultTable("usr", $eval_users, "selected_user_result", "selected_user_row", $this->lng->txt("eval_found_selected_users"), $buttons);
00367 }
00368 $this->tpl->setCurrentBlock("adm_content");
00369 $this->tpl->setVariable("CMD_EVAL", "evalSelectedUsers");
00370 $this->tpl->setVariable("TXT_STAT_USERS_INTRO", $this->lng->txt("tst_stat_users_intro"));
00371 $this->tpl->setVariable("TXT_STAT_ALL_USERS", $this->lng->txt("tst_stat_selected_users"));
00372 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00373 $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
00374 $this->tpl->setVariable("TXT_PWORKEDTHROUGH", $this->lng->txt("tst_stat_result_pworkedthrough"));
00375 $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
00376 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
00377 $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
00378 $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
00379 $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
00380 $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
00381 $this->tpl->setVariable("TXT_DISTANCEMEDIAN", $this->lng->txt("tst_stat_result_distancemedian"));
00382 $this->tpl->setVariable("TXT_SPECIFICATION", $this->lng->txt("tst_stat_result_specification"));
00383 $user_settings = $this->object->evalLoadStatisticalSettings($ilUser->id);
00384 foreach ($user_settings as $key => $value) {
00385 if ($value == 1) {
00386 $user_settings[$key] = " checked=\"checked\"";
00387 } else {
00388 $user_settings[$key] = "";
00389 }
00390 }
00391 $this->tpl->setVariable("CHECKED_QWORKEDTHROUGH", $user_settings["qworkedthrough"]);
00392 $this->tpl->setVariable("CHECKED_PWORKEDTHROUGH", $user_settings["pworkedthrough"]);
00393 $this->tpl->setVariable("CHECKED_TIMEOFWORK", $user_settings["timeofwork"]);
00394 $this->tpl->setVariable("CHECKED_ATIMEOFWORK", $user_settings["atimeofwork"]);
00395 $this->tpl->setVariable("CHECKED_FIRSTVISIT", $user_settings["firstvisit"]);
00396 $this->tpl->setVariable("CHECKED_LASTVISIT", $user_settings["lastvisit"]);
00397 $this->tpl->setVariable("CHECKED_RESULTSPOINTS", $user_settings["resultspoints"]);
00398 $this->tpl->setVariable("CHECKED_RESULTSMARKS", $user_settings["resultsmarks"]);
00399 $this->tpl->setVariable("CHECKED_DISTANCEMEDIAN", $user_settings["distancemedian"]);
00400 $this->tpl->setVariable("TXT_STATISTICAL_EVALUATION", $this->lng->txt("tst_statistical_evaluation"));
00401 $this->tpl->parseCurrentBlock();
00402 }
00403
00411 function outEvalSearchResultTable($a_type, $id_array, $block_result, $block_row, $title_text, $buttons)
00412 {
00413 global $rbacsystem;
00414
00415 $rowclass = array("tblrow1", "tblrow2");
00416 switch($a_type)
00417 {
00418 case "usr":
00419 include_once "./classes/class.ilObjUser.php";
00420 foreach ($id_array as $user_id => $username)
00421 {
00422 $counter = 0;
00423 $user = new ilObjUser($user_id);
00424 $this->tpl->setCurrentBlock($block_row);
00425 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00426 $this->tpl->setVariable("COUNTER", $user->getId());
00427 $this->tpl->setVariable("VALUE_LOGIN", $user->getLogin());
00428 $this->tpl->setVariable("VALUE_FIRSTNAME", $user->getFirstname());
00429 $this->tpl->setVariable("VALUE_LASTNAME", $user->getLastname());
00430 $counter++;
00431 $this->tpl->parseCurrentBlock();
00432 }
00433 if (count($id_array))
00434 {
00435 $this->tpl->setCurrentBlock("selectall_$block_result");
00436 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00437 $counter++;
00438 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00439 $this->tpl->parseCurrentBlock();
00440 }
00441 $this->tpl->setCurrentBlock($block_result);
00442 $this->tpl->setVariable("TEXT_USER_TITLE", $title_text);
00443 $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
00444 $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
00445 $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
00446 $this->tpl->setVariable("SRC_USER_IMAGE", ilUtil::getImagePath("icon_usr_b.gif"));
00447 $this->tpl->setVariable("ALT_USER_IMAGE", $this->lng->txt("objs_".$a_type));
00448 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
00449 {
00450 foreach ($buttons as $cat)
00451 {
00452 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
00453 }
00454 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
00455 }
00456 $this->tpl->parseCurrentBlock();
00457 break;
00458 case "grp":
00459 include_once "./classes/class.ilObjGroup.php";
00460 foreach ($id_array as $group_id)
00461 {
00462 $counter = 0;
00463 $group = new ilObjGroup($group_id);
00464 $this->tpl->setCurrentBlock($block_row);
00465 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00466 $this->tpl->setVariable("COUNTER", $group->getRefId());
00467 $this->tpl->setVariable("VALUE_TITLE", $group->getTitle());
00468 $this->tpl->setVariable("VALUE_DESCRIPTION", $group->getDescription());
00469 $counter++;
00470 $this->tpl->parseCurrentBlock();
00471 }
00472 if (count($id_array))
00473 {
00474 $this->tpl->setCurrentBlock("selectall_$block_result");
00475 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00476 $counter++;
00477 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00478 $this->tpl->parseCurrentBlock();
00479 }
00480 $this->tpl->setCurrentBlock($block_result);
00481 $this->tpl->setVariable("TEXT_GROUP_TITLE", $title_text);
00482 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00483 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00484 $this->tpl->setVariable("SRC_GROUP_IMAGE", ilUtil::getImagePath("icon_grp_b.gif"));
00485 $this->tpl->setVariable("ALT_GROUP_IMAGE", $this->lng->txt("objs_".$a_type));
00486 if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
00487 {
00488 foreach ($buttons as $cat)
00489 {
00490 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
00491 }
00492 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
00493 }
00494 $this->tpl->parseCurrentBlock();
00495 break;
00496 case "role":
00497 $counter = 0;
00498 foreach ($id_array as $key => $data)
00499 {
00500 $this->tpl->setCurrentBlock($block_row);
00501 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00502 $this->tpl->setVariable("COUNTER", $key);
00503 $this->tpl->setVariable("VALUE_TITLE", $data->title);
00504 $this->tpl->setVariable("VALUE_DESCRIPTION", $data->description);
00505 $counter++;
00506 $this->tpl->parseCurrentBlock();
00507 }
00508 if (count($id_array))
00509 {
00510 $this->tpl->setCurrentBlock("selectall_$block_result");
00511 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00512 $counter++;
00513 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00514 $this->tpl->parseCurrentBlock();
00515 }
00516 $this->tpl->setCurrentBlock($block_result);
00517 $this->tpl->setVariable("TEXT_ROLE_TITLE", $title_text);
00518 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00519 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00520 $this->tpl->setVariable("SRC_ROLE_IMAGE", ilUtil::getImagePath("icon_role_b.gif"));
00521 $this->tpl->setVariable("ALT_ROLE_IMAGE", $this->lng->txt("objs_".$a_type));
00522
00523 if ($rbacsystem->checkAccess('write', $this->object->getRefId()))
00524 {
00525 foreach ($buttons as $cat)
00526 {
00527 $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
00528 }
00529 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
00530 }
00531 $this->tpl->parseCurrentBlock();
00532 break;
00533 }
00534 }
00535
00543 function evaluationDetail()
00544 {
00545 include_once "./classes/class.ilObjUser.php";
00546 $answertext = $this->object->getTextAnswer($_GET["userdetail"], $_GET["answer"]);
00547 $questiontext = $this->object->getQuestiontext($_GET["answer"]);
00548 include_once "./classes/class.ilTemplate.php";
00549 $this->tpl = new ilTemplate("./assessment/templates/default/tpl.il_as_tst_eval_user_answer.html", true, true);
00550 $this->tpl->setVariable("TITLE_USER_ANSWER", $this->lng->txt("tst_eval_user_answer"));
00551 $this->tpl->setVariable("TEXT_USER", $this->lng->txt("user"));
00552 if ($this->object->getTestType() == TYPE_SELF_ASSESSMENT)
00553 {
00554 $this->tpl->setVariable("TEXT_USERNAME", trim($this->lng->txt("unknown")));
00555 }
00556 else
00557 {
00558 include_once "./classes/class.ilObjUser.php";
00559 $user = new ilObjUser($_GET["userdetail"]);
00560 $this->tpl->setVariable("TEXT_USERNAME", trim($user->getFirstname() . " " . $user->getLastname()));
00561 }
00562 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00563 $this->tpl->setVariable("TEXT_QUESTIONTEXT", $questiontext);
00564 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00565 $this->tpl->setVariable("TEXT_USER_ANSWER", str_replace("\n", "<br />", ilUtil::prepareFormOutput($answertext)));
00566 }
00567
00568 function eval_stat()
00569 {
00570 $this->ctrl->setCmdClass(get_class($this));
00571 $this->ctrl->setCmd("eval_stat");
00572 $this->setResultsTabs();
00573 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_statistical_evaluation_selection.html", true);
00574 $this->tpl->setCurrentBlock("adm_content");
00575 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00576 $this->tpl->setVariable("CMD_EVAL", "evalAllUsers");
00577 $this->tpl->setVariable("TXT_STAT_USERS_INTRO", $this->lng->txt("tst_stat_users_intro"));
00578 $this->tpl->setVariable("TXT_STAT_ALL_USERS", $this->lng->txt("tst_stat_all_users"));
00579 $this->tpl->setVariable("TXT_QWORKEDTHROUGH", $this->lng->txt("tst_stat_result_qworkedthrough"));
00580 $this->tpl->setVariable("TXT_PWORKEDTHROUGH", $this->lng->txt("tst_stat_result_pworkedthrough"));
00581 $this->tpl->setVariable("TXT_TIMEOFWORK", $this->lng->txt("tst_stat_result_timeofwork"));
00582 $this->tpl->setVariable("TXT_ATIMEOFWORK", $this->lng->txt("tst_stat_result_atimeofwork"));
00583 $this->tpl->setVariable("TXT_FIRSTVISIT", $this->lng->txt("tst_stat_result_firstvisit"));
00584 $this->tpl->setVariable("TXT_LASTVISIT", $this->lng->txt("tst_stat_result_lastvisit"));
00585 $this->tpl->setVariable("TXT_RESULTSPOINTS", $this->lng->txt("tst_stat_result_resultspoints"));
00586 $this->tpl->setVariable("TXT_RESULTSMARKS", $this->lng->txt("tst_stat_result_resultsmarks"));
00587 $this->tpl->setVariable("TXT_DISTANCEMEDIAN", $this->lng->txt("tst_stat_result_distancemedian"));
00588 $this->tpl->setVariable("TXT_SPECIFICATION", $this->lng->txt("tst_stat_result_specification"));
00589 $user_settings = $this->object->evalLoadStatisticalSettings($ilUser->id);
00590 foreach ($user_settings as $key => $value) {
00591 if ($value == 1) {
00592 $user_settings[$key] = " checked=\"checked\"";
00593 } else {
00594 $user_settings[$key] = "";
00595 }
00596 }
00597 $this->tpl->setVariable("CHECKED_QWORKEDTHROUGH", $user_settings["qworkedthrough"]);
00598 $this->tpl->setVariable("CHECKED_PWORKEDTHROUGH", $user_settings["pworkedthrough"]);
00599 $this->tpl->setVariable("CHECKED_TIMEOFWORK", $user_settings["timeofwork"]);
00600 $this->tpl->setVariable("CHECKED_ATIMEOFWORK", $user_settings["atimeofwork"]);
00601 $this->tpl->setVariable("CHECKED_FIRSTVISIT", $user_settings["firstvisit"]);
00602 $this->tpl->setVariable("CHECKED_LASTVISIT", $user_settings["lastvisit"]);
00603 $this->tpl->setVariable("CHECKED_RESULTSPOINTS", $user_settings["resultspoints"]);
00604 $this->tpl->setVariable("CHECKED_RESULTSMARKS", $user_settings["resultsmarks"]);
00605 $this->tpl->setVariable("CHECKED_DISTANCEMEDIAN", $user_settings["distancemedian"]);
00606 $this->tpl->setVariable("TXT_STATISTICAL_EVALUATION", $this->lng->txt("tst_statistical_evaluation"));
00607 $this->tpl->parseCurrentBlock();
00608 }
00609
00610 function saveEvaluationSettings()
00611 {
00612 $eval_statistical_settings = array(
00613 "qworkedthrough" => $_POST["chb_result_qworkedthrough"],
00614 "pworkedthrough" => $_POST["chb_result_pworkedthrough"],
00615 "timeofwork" => $_POST["chb_result_timeofwork"],
00616 "atimeofwork" => $_POST["chb_result_atimeofwork"],
00617 "firstvisit" => $_POST["chb_result_firstvisit"],
00618 "lastvisit" => $_POST["chb_result_lastvisit"],
00619 "resultspoints" => $_POST["chb_result_resultspoints"],
00620 "resultsmarks" => $_POST["chb_result_resultsmarks"],
00621 "distancemedian" => $_POST["chb_result_distancemedian"]
00622 );
00623 $this->object->evalSaveStatisticalSettings($eval_statistical_settings, $ilUser->id);
00624 return $eval_statistical_settings;
00625 }
00626
00627 function evalSelectedUsers($all_users = 0)
00628 {
00629 global $ilUser;
00630
00631 if ($all_users)
00632 {
00633 $this->ctrl->setParameter($this, "etype", "all");
00634 }
00635 else
00636 {
00637 $this->ctrl->setParameter($this, "etype", "selected");
00638 }
00639 $this->tpl->setCurrentBlock("generic_css");
00640 $this->tpl->setVariable("LOCATION_GENERIC_STYLESHEET", "./assessment/templates/default/test_print.css");
00641 $this->tpl->setVariable("MEDIA_GENERIC_STYLESHEET", "print");
00642 $this->tpl->parseCurrentBlock();
00643 $savetextanswers = 0;
00644 $textanswers = 0;
00645 $export = 0;
00646 $filter = 0;
00647 $filtertext = "";
00648 $passedonly = FALSE;
00649 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("set_filter")) == 0)
00650 {
00651 $filter = 1;
00652 $filtertext = $_POST["userfilter"];
00653 if ($_POST["passedonly"] == 1)
00654 {
00655 $passedonly = TRUE;
00656 }
00657 }
00658 else
00659 {
00660 if (array_key_exists("g_userfilter", $_GET))
00661 {
00662 $filtertext = $_GET["userfilter"];
00663 }
00664 if (array_key_exists("g_passedonly", $_GET))
00665 {
00666 if ($_GET["g_passedonly"] == 1)
00667 {
00668 $passedonly = TRUE;
00669 }
00670 }
00671 }
00672 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("reset_filter")) == 0)
00673 {
00674 $filter = 1;
00675 $filtertext = "";
00676 $passedonly = FALSE;
00677 }
00678 if (strlen($filtertext))
00679 {
00680 $this->ctrl->setParameter($this, "g_userfilter", $filtertext);
00681 }
00682 if ($passedonly)
00683 {
00684 $this->ctrl->setParameter($this, "g_passedonly", "1");
00685 }
00686 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("export")) == 0)
00687 {
00688 $export = 1;
00689 }
00690 if (strcmp($_POST["cmd"][$this->ctrl->getCmd()], $this->lng->txt("save_text_answer_points")) == 0)
00691 {
00692
00693 $savetextanswers = 1;
00694 foreach ($_POST as $key => $value)
00695 {
00696 if (preg_match("/(\d+)_(\d+)_(\d+)/", $key, $matches))
00697 {
00698 include_once "./assessment/classes/class.assTextQuestion.php";
00699 ASS_TextQuestion::_setReachedPoints($matches[1], $this->object->getTestId(), $matches[2], $value, $matches[3]);
00700 }
00701 }
00702 sendInfo($this->lng->txt("text_answers_saved"));
00703 }
00704 if ((count($_POST) == 0) || ($export) || ($filter) || ($savetextanswers) || is_numeric($_GET["uid"]))
00705 {
00706 $user_settings = $this->object->evalLoadStatisticalSettings($ilUser->id);
00707 $eval_statistical_settings = array(
00708 "qworkedthrough" => $user_settings["qworkedthrough"],
00709 "pworkedthrough" => $user_settings["pworkedthrough"],
00710 "timeofwork" => $user_settings["timeofwork"],
00711 "atimeofwork" => $user_settings["atimeofwork"],
00712 "firstvisit" => $user_settings["firstvisit"],
00713 "lastvisit" => $user_settings["lastvisit"],
00714 "resultspoints" => $user_settings["resultspoints"],
00715 "resultsmarks" => $user_settings["resultsmarks"],
00716 "distancemedian" => $user_settings["distancemedian"]
00717 );
00718 }
00719 else
00720 {
00721 $eval_statistical_settings = $this->saveEvaluationSettings();
00722 }
00723
00724 $this->setResultsTabs();
00725 $legend = array();
00726 $legendquestions = array();
00727 $titlerow = array();
00728
00729 $sortimage = "";
00730 $sortparameter = "asc";
00731 if (strcmp($_GET["sortname"], "asc") == 0 || strcmp($_GET["sortname"], "") == 0)
00732 {
00733 $sortimage = " <img src=\"".ilUtil::getImagePath("asc_order.png", true)."\" alt=\"" . $this->lng->txt("ascending_order") . "\" />";
00734 $sortparameter = "asc";
00735 $this->ctrl->setParameter($this, "sortname", "asc");
00736 }
00737 else
00738 {
00739 $sortimage = " <img src=\"".ilUtil::getImagePath("desc_order.png", true)."\" alt=\"" . $this->lng->txt("descending_order") . "\" />";
00740 $sortparameter = "desc";
00741 $this->ctrl->setParameter($this, "sortname", "desc");
00742 }
00743 $name_column = $this->lng->txt("name");
00744 if ($this->object->getTestType() == TYPE_SELF_ASSESSMENT)
00745 {
00746 $name_column = $this->lng->txt("counter");
00747 }
00748
00749
00750 $char = "A";
00751 if ($eval_statistical_settings["resultspoints"]) {
00752 array_push($titlerow, $char);
00753 $legend[$char] = $this->lng->txt("tst_stat_result_resultspoints");
00754 $char++;
00755 }
00756 if ($eval_statistical_settings["resultsmarks"]) {
00757 array_push($titlerow, $char);
00758 $legend[$char] = $this->lng->txt("tst_stat_result_resultsmarks");
00759 $char++;
00760
00761 if ($this->object->ects_output)
00762 {
00763 array_push($titlerow, $char);
00764 $legend[$char] = $this->lng->txt("ects_grade");
00765 $char++;
00766 }
00767 }
00768 if ($eval_statistical_settings["qworkedthrough"]) {
00769 array_push($titlerow, $char);
00770 $legend[$char] = $this->lng->txt("tst_stat_result_qworkedthrough");
00771 $char++;
00772 }
00773 if ($eval_statistical_settings["pworkedthrough"]) {
00774 array_push($titlerow, $char);
00775 $legend[$char] = $this->lng->txt("tst_stat_result_pworkedthrough");
00776 $char++;
00777 }
00778 if ($eval_statistical_settings["timeofwork"]) {
00779 array_push($titlerow, $char);
00780 $legend[$char] = $this->lng->txt("tst_stat_result_timeofwork");
00781 $char++;
00782 }
00783 if ($eval_statistical_settings["atimeofwork"]) {
00784 array_push($titlerow, $char);
00785 $legend[$char] = $this->lng->txt("tst_stat_result_atimeofwork");
00786 $char++;
00787 }
00788 if ($eval_statistical_settings["firstvisit"]) {
00789 array_push($titlerow, $char);
00790 $legend[$char] = $this->lng->txt("tst_stat_result_firstvisit");
00791 $char++;
00792 }
00793 if ($eval_statistical_settings["lastvisit"]) {
00794 array_push($titlerow, $char);
00795 $legend[$char] = $this->lng->txt("tst_stat_result_lastvisit");
00796 $char++;
00797 }
00798 if ($eval_statistical_settings["distancemedian"]) {
00799 array_push($titlerow, $char);
00800 $legend[$char] = $this->lng->txt("tst_stat_result_mark_median");
00801 $char++;
00802 array_push($titlerow, $char);
00803 $legend[$char] = $this->lng->txt("tst_stat_result_rank_participant");
00804 $char++;
00805 array_push($titlerow, $char);
00806 $legend[$char] = $this->lng->txt("tst_stat_result_rank_median");
00807 $char++;
00808 array_push($titlerow, $char);
00809 $legend[$char] = $this->lng->txt("tst_stat_result_total_participants");
00810 $char++;
00811 array_push($titlerow, $char);
00812 $legend[$char] = $this->lng->txt("tst_stat_result_median");
00813 $char++;
00814 }
00815
00816 $titlerow_without_questions = $titlerow;
00817 if (!$this->object->isRandomTest())
00818 {
00819 $qtitles =& $this->object->getQuestionTitles();
00820 $i = 1;
00821 foreach ($qtitles as $title)
00822 {
00823 array_push($titlerow, $this->lng->txt("question_short") . " " . $i);
00824 $legendquestions[$i] = $title;
00825 $legend[$this->lng->txt("question_short") . " " . $i] = $i;
00826 $i++;
00827 }
00828 }
00829 else
00830 {
00831 for ($i = 1; $i <= $this->object->getQuestionCount(); $i++)
00832 {
00833 array_push($titlerow, " ");
00834 }
00835 }
00836 $total_users =& $this->object->evalTotalPersonsArray($sortparameter);
00837 $selected_users = array();
00838 if ($all_users == 1)
00839 {
00840 $selected_users = $total_users;
00841 }
00842 else
00843 {
00844 $selected_users =& $this->object->getEvaluationUsers($ilUser->id, $sortparameter);
00845 }
00846
00847 $row = 0;
00848 $question_legend = false;
00849 $question_stat = array();
00850 $evaluation_array = array();
00851 foreach ($total_users as $key => $value)
00852 {
00853
00854
00855 $stat_eval =& $this->object->evalStatistical($key);
00856 foreach ($stat_eval as $sindex => $sarray)
00857 {
00858 if (preg_match("/\d+/", $sindex))
00859 {
00860 $qt = $sarray["title"];
00861 $qt = preg_replace("/<.*?>/", "", $qt);
00862 if (!array_key_exists($sarray["qid"], $question_stat))
00863 {
00864 $question_stat[$sarray["qid"]] = array("max" => 0, "reached" => 0, "title" => $qt);
00865 }
00866 $question_stat[$sarray["qid"]]["single_max"] = $sarray["max"];
00867 $question_stat[$sarray["qid"]]["max"] += $sarray["max"];
00868 $question_stat[$sarray["qid"]]["reached"] += $sarray["reached"];
00869 }
00870 }
00871
00872 $evaluation_array[$key] = $stat_eval;
00873 }
00874
00875 foreach ($selected_users as $key => $name)
00876 {
00877 if (strlen($filtertext))
00878 {
00879 $username = $selected_users[$key]["fullname"];
00880 if (strpos(strtolower($username), strtolower($filtertext)) === FALSE)
00881 {
00882 unset($selected_users[$key]);
00883 }
00884 }
00885 if ($passedonly)
00886 {
00887 if ($evaluation_array[$key]["passed"] == 0)
00888 {
00889 unset($selected_users[$key]);
00890 }
00891 }
00892 }
00893
00894 include_once "./classes/class.ilStatistics.php";
00895
00896 $median_array = array();
00897 foreach ($evaluation_array as $key => $value)
00898 {
00899 array_push($median_array, $value["resultspoints"]);
00900 }
00901 include_once "./classes/class.ilStatistics.php";
00902 $statistics = new ilStatistics();
00903 $statistics->setData($median_array);
00904 $median = $statistics->median();
00905
00906
00907 $evalcounter = 1;
00908 $question_titles = array();
00909 $question_title_counter = 1;
00910 $eval_complete = array();
00911 foreach ($selected_users as $key => $name)
00912 {
00913 $stat_eval = $evaluation_array[$key];
00914
00915 $titlerow_user = array();
00916 if ($this->object->isRandomTest())
00917 {
00918 include_once "./assessment/classes/class.ilObjTest.php";
00919 $counted_pass = ilObjTest::_getResultPass($key, $this->object->getTestId());
00920 $this->object->loadQuestions($key, $counted_pass);
00921 $titlerow_user = $titlerow_without_questions;
00922 $i = 1;
00923 foreach ($stat_eval as $key1 => $value1)
00924 {
00925 if (preg_match("/\d+/", $key1))
00926 {
00927 $qt = $value1["title"];
00928 $qt = preg_replace("/<.*?>/", "", $qt);
00929 if (!array_key_exists($value1["qid"], $legendquestions))
00930 {
00931 array_push($titlerow_user, $this->lng->txt("question_short") . " " . $question_title_counter);
00932 $legend[$this->lng->txt("question_short") . " " . $question_title_counter] = $value1["qid"];
00933 $legendquestions[$value1["qid"]] = $qt;
00934 $question_title_counter++;
00935 }
00936 else
00937 {
00938 $arraykey = array_search($value1["qid"], $legend);
00939 array_push($titlerow_user, $arraykey);
00940 }
00941 }
00942 }
00943 }
00944
00945 $evalrow = array();
00946 $username = $this->lng->txt("user") . " " . $evalcounter++;
00947 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
00948 {
00949 $username = $selected_users[$key]["fullname"];
00950 }
00951 array_push($evalrow, array(
00952 "userid" => $key,
00953 "html" => "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "evalUserDetail")."&uid=$key\">$username</a>",
00954 "xls" => $username,
00955 "csv" => $username
00956 ));
00957 if ($eval_statistical_settings["resultspoints"]) {
00958 array_push($evalrow, array(
00959 "html" => $stat_eval["resultspoints"]." ".strtolower($this->lng->txt("of"))." ". $stat_eval["maxpoints"],
00960 "xls" => $stat_eval["resultspoints"],
00961 "csv" => $stat_eval["resultspoints"]
00962 ));
00963 }
00964 if ($eval_statistical_settings["resultsmarks"]) {
00965 array_push($evalrow, array(
00966 "html" => $stat_eval["resultsmarks"],
00967 "xls" => $stat_eval["resultsmarks"],
00968 "csv" => $stat_eval["resultsmarks"]
00969 ));
00970
00971 if ($this->object->ects_output)
00972 {
00973 $mark_ects = $this->object->getECTSGrade($stat_eval["resultspoints"],$stat_eval["maxpoints"]);
00974 array_push($evalrow, array(
00975 "html" => $mark_ects,
00976 "xls" => $mark_ects,
00977 "csv" => $mark_ects
00978 ));
00979 }
00980 }
00981 if ($eval_statistical_settings["qworkedthrough"]) {
00982 array_push($evalrow, array(
00983 "html" => $stat_eval["qworkedthrough"],
00984 "xls" => $stat_eval["qworkedthrough"],
00985 "csv" => $stat_eval["qworkedthrough"]
00986 ));
00987 }
00988 if ($eval_statistical_settings["pworkedthrough"]) {
00989 array_push($evalrow, array(
00990 "html" => sprintf("%2.2f", $stat_eval["pworkedthrough"] * 100.0) . " %",
00991 "xls" => $stat_eval["pworkedthrough"],
00992 "csv" => $stat_eval["pworkedthrough"],
00993 "format" => "%"
00994 ));
00995 }
00996 if ($eval_statistical_settings["timeofwork"])
00997 {
00998 $time = $stat_eval["timeofwork"];
00999 $time_seconds = $time;
01000 $time_hours = floor($time_seconds/3600);
01001 $time_seconds -= $time_hours * 3600;
01002 $time_minutes = floor($time_seconds/60);
01003 $time_seconds -= $time_minutes * 60;
01004 array_push($evalrow, array(
01005 "html" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
01006 "xls" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
01007 "csv" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)
01008 ));
01009 }
01010 if ($eval_statistical_settings["atimeofwork"])
01011 {
01012 $time = $stat_eval["atimeofwork"];
01013 $time_seconds = $time;
01014 $time_hours = floor($time_seconds/3600);
01015 $time_seconds -= $time_hours * 3600;
01016 $time_minutes = floor($time_seconds/60);
01017 $time_seconds -= $time_minutes * 60;
01018 array_push($evalrow, array(
01019 "html" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
01020 "xls" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds),
01021 "csv" => sprintf("%02d:%02d:%02d", $time_hours, $time_minutes, $time_seconds)
01022 ));
01023 }
01024 if ($eval_statistical_settings["firstvisit"])
01025 {
01026 array_push($evalrow, array(
01027 "html" => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["firstvisit"]["hours"], $stat_eval["firstvisit"]["minutes"], $stat_eval["firstvisit"]["seconds"], $stat_eval["firstvisit"]["mon"], $stat_eval["firstvisit"]["mday"], $stat_eval["firstvisit"]["year"])),
01028 "xls" => ilUtil::excelTime($stat_eval["firstvisit"]["year"],$stat_eval["firstvisit"]["mon"],$stat_eval["firstvisit"]["mday"],$stat_eval["firstvisit"]["hours"],$stat_eval["firstvisit"]["minutes"],$stat_eval["firstvisit"]["seconds"]),
01029 "csv" => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["firstvisit"]["hours"], $stat_eval["firstvisit"]["minutes"], $stat_eval["firstvisit"]["seconds"], $stat_eval["firstvisit"]["mon"], $stat_eval["firstvisit"]["mday"], $stat_eval["firstvisit"]["year"])),
01030 "format" => "t"
01031 ));
01032 }
01033 if ($eval_statistical_settings["lastvisit"]) {
01034 array_push($evalrow, array(
01035 "html" => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["lastvisit"]["hours"], $stat_eval["lastvisit"]["minutes"], $stat_eval["lastvisit"]["seconds"], $stat_eval["lastvisit"]["mon"], $stat_eval["lastvisit"]["mday"], $stat_eval["lastvisit"]["year"])),
01036 "xls" => ilUtil::excelTime($stat_eval["lastvisit"]["year"],$stat_eval["lastvisit"]["mon"],$stat_eval["lastvisit"]["mday"],$stat_eval["lastvisit"]["hours"],$stat_eval["lastvisit"]["minutes"],$stat_eval["lastvisit"]["seconds"]),
01037 "csv" => date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($stat_eval["lastvisit"]["hours"], $stat_eval["lastvisit"]["minutes"], $stat_eval["lastvisit"]["seconds"], $stat_eval["lastvisit"]["mon"], $stat_eval["lastvisit"]["mday"], $stat_eval["lastvisit"]["year"])),
01038 "format" => "t"
01039 ));
01040 }
01041
01042 if ($eval_statistical_settings["distancemedian"]) {
01043 if ($stat_eval["maxpoints"] == 0)
01044 {
01045 $pct = 0;
01046 }
01047 else
01048 {
01049 $pct = ($median / $stat_eval["maxpoints"]) * 100.0;
01050 }
01051 $mark = $this->object->mark_schema->get_matching_mark($pct);
01052 $mark_short_name = "";
01053 if ($mark)
01054 {
01055 $mark_short_name = $mark->get_short_name();
01056 }
01057 array_push($evalrow, array(
01058 "html" => $mark_short_name,
01059 "xls" => $mark_short_name,
01060 "csv" => $mark_short_name
01061 ));
01062 $rank_participant = $statistics->rank($stat_eval["resultspoints"]);
01063 array_push($evalrow, array(
01064 "html" => $rank_participant,
01065 "xls" => $rank_participant,
01066 "csv" => $rank_participant
01067 ));
01068 $rank_median = $statistics->rank_median();
01069 array_push($evalrow, array(
01070 "html" => $rank_median,
01071 "xls" => $rank_median,
01072 "csv" => $rank_median
01073 ));
01074 $total_participants = count($median_array);
01075 array_push($evalrow, array(
01076 "html" => $total_participants,
01077 "xls" => $total_participants,
01078 "csv" => $total_participants
01079 ));
01080 array_push($evalrow, array(
01081 "html" => $median,
01082 "xls" => $median,
01083 "csv" => $median
01084 ));
01085 }
01086
01087 for ($i = 1; $i <= $this->object->getQuestionCount(); $i++)
01088 {
01089 $qshort = "";
01090 $qt = "";
01091 if ($this->object->isRandomTest())
01092 {
01093 $qt = $stat_eval[$i-1]["title"];
01094 $qt = preg_replace("/<.*?>/", "", $qt);
01095 $arrkey = array_search($stat_eval[$i-1]["qid"], $legend);
01096 if ($arrkey)
01097 {
01098 $qshort = "<span title=\"" . ilUtil::prepareFormOutput($qt) . "\">" . $arrkey . "</span>: ";
01099 }
01100 }
01101
01102 $htmloutput = "";
01103 if ($stat_eval[$i-1]["type"] == "qt_text")
01104 {
01105
01106 $name = $key."_".$stat_eval[$i-1]["qid"]."_".$stat_eval[$i-1]["max"];
01107 $htmloutput = $qshort . "<input type=\"text\" name=\"".$name."\" size=\"3\" value=\"".$stat_eval[$i-1]["reached"]."\" />".strtolower($this->lng->txt("of"))." ". $stat_eval[$i-1]["max"];
01108
01109 $htmloutput .= " [<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "evaluationDetail") . "&userdetail=$key&answer=".$stat_eval[$i-1]["qid"]."\" target=\"popup\" onclick=\"";
01110 $htmloutput .= "window.open('', 'popup', 'width=600, height=200, scrollbars=yes, toolbar=no, status=no, resizable=yes, menubar=no, location=no, directories=no')";
01111 $htmloutput .= "\">".$this->lng->txt("tst_eval_show_answer")."</a>]";
01112 $textanswers++;
01113 }
01114 else
01115 {
01116 $htmloutput = $qshort . $stat_eval[$i-1]["reached"] . " " . strtolower($this->lng->txt("of")) . " " . $stat_eval[$i-1]["max"];
01117 }
01118
01119 array_push($evalrow, array(
01120 "html" => $htmloutput,
01121 "xls" => $stat_eval[$i-1]["reached"],
01122 "csv" => $stat_eval[$i-1]["reached"]
01123 ));
01124 }
01125 array_push($eval_complete, array("title" => $titlerow_user, "data" => $evalrow));
01126 }
01127
01128 $noqcount = count($titlerow_without_questions);
01129 if ($export)
01130 {
01131 $testname = preg_replace("/\s/", "_", $this->object->getTitle());
01132 switch ($_POST["export_type"])
01133 {
01134 case TYPE_XLS_PC:
01135
01136 $result = @include_once 'Spreadsheet/Excel/Writer.php';
01137 if (!$result)
01138 {
01139 include_once './classes/Spreadsheet/Excel/Writer.php';
01140 }
01141 $workbook = new Spreadsheet_Excel_Writer();
01142
01143 $workbook->send("$testname.xls");
01144
01145 $format_bold =& $workbook->addFormat();
01146 $format_bold->setBold();
01147 $format_percent =& $workbook->addFormat();
01148 $format_percent->setNumFormat("0.00%");
01149 $format_datetime =& $workbook->addFormat();
01150 $format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
01151 $format_title =& $workbook->addFormat();
01152 $format_title->setBold();
01153 $format_title->setColor('black');
01154 $format_title->setPattern(1);
01155 $format_title->setFgColor('silver');
01156 $worksheet =& $workbook->addWorksheet();
01157 $row = 0;
01158 $col = 0;
01159 include_once "./classes/class.ilExcelUtils.php";
01160 if (!$this->object->isRandomTest())
01161 {
01162 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01163 {
01164 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("lastname"), $_POST["export_type"]), $format_title);
01165 $col++;
01166 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("firstname"), $_POST["export_type"]), $format_title);
01167 $col++;
01168 }
01169 else
01170 {
01171 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("name"), $_POST["export_type"]), $format_title);
01172 $col++;
01173 }
01174 foreach ($titlerow as $title)
01175 {
01176 if (preg_match("/\d+/", $title))
01177 {
01178 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legendquestions[$legend[$title]], $_POST["export_type"]), $format_title);
01179 }
01180 else if (strlen($title) == 1)
01181 {
01182 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legend[$title], $_POST["export_type"]), $format_title);
01183 }
01184 else
01185 {
01186 $worksheet->write($row, $col, ilExcelUtils::_convert_text($title, $_POST["export_type"]), $format_title);
01187 }
01188 $col++;
01189 }
01190 $row++;
01191 }
01192 $pc = 1;
01193 foreach ($eval_complete as $evalrow)
01194 {
01195 $col = 0;
01196 if ($this->object->isRandomTest())
01197 {
01198 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01199 {
01200 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("lastname"), $_POST["export_type"]), $format_title);
01201 $col++;
01202 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("firstname"), $_POST["export_type"]), $format_title);
01203 $col++;
01204 }
01205 else
01206 {
01207 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("name"), $_POST["export_type"]), $format_title);
01208 $col++;
01209 }
01210 foreach ($evalrow["title"] as $key => $value)
01211 {
01212 if (preg_match("/\d+/", $value))
01213 {
01214 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legendquestions[$legend[$value]], $_POST["export_type"]), $format_title);
01215 }
01216 else
01217 {
01218 $worksheet->write($row, $col, ilExcelUtils::_convert_text($legend[$value], $_POST["export_type"]), $format_title);
01219 }
01220 $col++;
01221 }
01222 $row++;
01223 }
01224 $col = 0;
01225 foreach ($evalrow["data"] as $key => $value)
01226 {
01227 if (array_key_exists("userid", $value))
01228 {
01229 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01230 {
01231 $worksheet->write($row, $col, ilExcelUtils::_convert_text($total_users[$value["userid"]]["lastname"], $_POST["export_type"]));
01232 $col++;
01233 $worksheet->write($row, $col, ilExcelUtils::_convert_text($total_users[$value["userid"]]["firstname"], $_POST["export_type"]));
01234 $col++;
01235 }
01236 else
01237 {
01238 $worksheet->write($row, $col, ilExcelUtils::_convert_text($this->lng->txt("user") . " " . $pc, $_POST["export_type"]));
01239 $col++;
01240 }
01241 }
01242 else
01243 {
01244 switch ($value["format"])
01245 {
01246 case "%":
01247 $worksheet->write($row, $col, $value["xls"], $format_percent);
01248 break;
01249 case "t":
01250 $worksheet->write($row, $col, $value["xls"], $format_datetime);
01251 break;
01252 default:
01253 $worksheet->write($row, $col, ilExcelUtils::_convert_text($value["xls"], $_POST["export_type"]));
01254 break;
01255 }
01256 $col++;
01257 }
01258 }
01259 $row++;
01260 $pc++;
01261 }
01262 $workbook->close();
01263 exit;
01264 case TYPE_SPSS:
01265 $csv = "";
01266 $separator = ";";
01267 if (!$this->object->isRandomTest())
01268 {
01269 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01270 {
01271 $headline = array($this->lng->txt("lastname"), $this->lng->txt("firstname"));
01272 }
01273 else
01274 {
01275 $headline = array($this->lng->txt("name"));
01276 }
01277 $newtitlerow = array_merge($headline, $titlerow);
01278 $newtitlerow =& $this->object->processCSVRow($newtitlerow, TRUE, $separator);
01279 $csv .= join($newtitlerow, $separator) . "\n";
01280 }
01281 $pc = 1;
01282 foreach ($eval_complete as $evalrow)
01283 {
01284 $csvrow = array();
01285 foreach ($evalrow["data"] as $dataarray)
01286 {
01287 if (array_key_exists("userid", $dataarray))
01288 {
01289 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01290 {
01291 array_push($csvrow, $total_users[$dataarray["userid"]]["lastname"]);
01292 array_push($csvrow, $total_users[$dataarray["userid"]]["firstname"]);
01293 }
01294 else
01295 {
01296 array_push($csvrow, $this->lng->txt("user") . " " . $pc);
01297 }
01298 }
01299 else
01300 {
01301 array_push($csvrow, $dataarray["csv"]);
01302 }
01303 }
01304 if ($this->object->isRandomTest())
01305 {
01306 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01307 {
01308 $headline = array($this->lng->txt("lastname"), $this->lng->txt("firstname"));
01309 }
01310 else
01311 {
01312 $headline = array($this->lng->txt("name"));
01313 }
01314 $newtitlerow = array_merge($headline, $evalrow["title"]);
01315 $newtitlerow =& $this->object->processCSVRow($newtitlerow, TRUE, $separator);
01316 $csv .= join($newtitlerow, $separator) . "\n";
01317 }
01318 $csvarr = array();
01319 $evalrow["data"] =& $this->object->processCSVRow($csvrow, TRUE, $separator);
01320 $csv .= join($evalrow["data"], $separator) . "\n";
01321 $pc++;
01322 }
01323 ilUtil::deliverData($csv, "$testname.csv");
01324 break;
01325 }
01326 exit;
01327 }
01328 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_statistical_evaluation.html", true);
01329 $color_class = array("tblrow1", "tblrow2");
01330 foreach ($legend as $short => $long)
01331 {
01332 $this->tpl->setCurrentBlock("legendrow");
01333 $this->tpl->setVariable("TXT_SYMBOL", $short);
01334 if (preg_match("/\d+/", $short))
01335 {
01336 $this->tpl->setVariable("TXT_MEANING", $legendquestions[$long]);
01337 }
01338 else
01339 {
01340 $this->tpl->setVariable("TXT_MEANING", $long);
01341 }
01342 $this->tpl->parseCurrentBlock();
01343 }
01344 $this->tpl->setCurrentBlock("legend");
01345 $this->tpl->setVariable("TXT_LEGEND", $this->lng->txt("legend"));
01346 $this->tpl->setVariable("TXT_LEGEND_LINK", $this->lng->txt("eval_legend_link"));
01347 $this->tpl->setVariable("TXT_SYMBOL", $this->lng->txt("symbol"));
01348 $this->tpl->setVariable("TXT_MEANING", $this->lng->txt("meaning"));
01349 $this->tpl->parseCurrentBlock();
01350
01351 $counter = 0;
01352 foreach ($question_stat as $title => $values)
01353 {
01354 $this->tpl->setCurrentBlock("meanrow");
01355 $this->tpl->setVariable("TXT_QUESTION", ilUtil::prepareFormOutput($values["title"]));
01356 $percent = 0;
01357 if ($values["max"] > 0)
01358 {
01359 $percent = $values["reached"] / $values["max"];
01360 }
01361 $this->tpl->setVariable("TXT_MEAN", sprintf("%.2f", $values["single_max"]*$percent) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%.2f", $values["single_max"]) . " (" . sprintf("%.2f", $percent*100) . " %)");
01362 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01363 $counter++;
01364 $this->tpl->parseCurrentBlock();
01365 }
01366 $this->tpl->setCurrentBlock("question_mean_points");
01367 $this->tpl->setVariable("TXT_AVERAGE_POINTS", $this->lng->txt("average_reached_points"));
01368 $this->tpl->setVariable("TXT_QUESTION", $this->lng->txt("question_title"));
01369 $this->tpl->setVariable("TXT_MEAN", $this->lng->txt("average_reached_points"));
01370 $this->tpl->parseCurrentBlock();
01371
01372 $noq = $noqcount;
01373
01374 if (strcmp($sortparameter, "asc") == 0)
01375 {
01376 $this->ctrl->setParameter($this, "sortname", "desc");
01377 }
01378 else
01379 {
01380 $this->ctrl->setParameter($this, "sortname", "asc");
01381 }
01382 if ($all_users)
01383 {
01384 $title = "<a href=\"".$this->ctrl->getLinkTarget($this, "evalAllUsers")."\">" . $this->lng->txt("name") . "</a>";
01385 $title .= $sortimage;
01386 }
01387 else
01388 {
01389 $title = "<a href=\"".$this->ctrl->getLinkTarget($this, "evalSelectedUsers")."\">" . $this->lng->txt("name") . "</a>";
01390 $title .= $sortimage;
01391 }
01392 $this->ctrl->setParameter($this, "sortname", $sortparameter);
01393 if ($noq > 0)
01394 {
01395 $this->tpl->setCurrentBlock("titlecol");
01396 $this->tpl->setVariable("TXT_TITLE", "<div title=\"" . ilUtil::prepareFormOutput($legendquestions[$legend[$title]]) . "\">" . $title . "</div>");
01397 $this->tpl->parseCurrentBlock();
01398 if ($noq == $noqcount)
01399 {
01400 $this->tpl->setCurrentBlock("questions_titlecol");
01401 $this->tpl->setVariable("TXT_TITLE", $title);
01402 $this->tpl->parseCurrentBlock();
01403 }
01404 $noq--;
01405 }
01406 else
01407 {
01408 $this->tpl->setCurrentBlock("questions_titlecol");
01409 $this->tpl->setVariable("TXT_TITLE", "<div title=\"" . $legendquestions[$legend[$title]] . "\">" . $title . "</div>");
01410 $this->tpl->parseCurrentBlock();
01411 }
01412
01413 foreach ($titlerow as $title)
01414 {
01415 if ($noq > 0)
01416 {
01417 $this->tpl->setCurrentBlock("titlecol");
01418 $this->tpl->setVariable("TXT_TITLE", "<div title=\"" . ilUtil::prepareFormOutput($legendquestions[$legend[$title]]) . "\">" . $title . "</div>");
01419 $this->tpl->parseCurrentBlock();
01420 if ($noq == $noqcount)
01421 {
01422 $this->tpl->setCurrentBlock("questions_titlecol");
01423 $this->tpl->setVariable("TXT_TITLE", $title);
01424 $this->tpl->parseCurrentBlock();
01425 }
01426 $noq--;
01427 }
01428 else
01429 {
01430 $this->tpl->setCurrentBlock("questions_titlecol");
01431 $this->tpl->setVariable("TXT_TITLE", "<div title=\"" . $legendquestions[$legend[$title]] . "\">" . $title . "</div>");
01432 $this->tpl->parseCurrentBlock();
01433 }
01434 }
01435 $counter = 0;
01436 foreach ($eval_complete as $row)
01437 {
01438 $noq = $noqcount;
01439 foreach ($row["data"] as $key => $value)
01440 {
01441 if ($noq > 0)
01442 {
01443 $this->tpl->setCurrentBlock("datacol");
01444 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01445 $this->tpl->setVariable("TXT_DATA", $value["html"]);
01446 $this->tpl->parseCurrentBlock();
01447 if ($noq == $noqcount)
01448 {
01449 $this->tpl->setCurrentBlock("questions_datacol");
01450 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01451 $this->tpl->setVariable("TXT_DATA", $value["html"]);
01452 $this->tpl->parseCurrentBlock();
01453 }
01454 $noq--;
01455 }
01456 else
01457 {
01458 $this->tpl->setCurrentBlock("questions_datacol");
01459 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01460 $this->tpl->setVariable("TXT_DATA", $value["html"]);
01461 $this->tpl->parseCurrentBlock();
01462 }
01463 }
01464 $this->tpl->setCurrentBlock("row");
01465 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01466 $this->tpl->parseCurrentBlock();
01467 $this->tpl->setCurrentBlock("questions_row");
01468 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01469 $this->tpl->parseCurrentBlock();
01470 $counter++;
01471 }
01472
01473 if ($textanswers)
01474 {
01475 $this->tpl->setCurrentBlock("questions_output_button");
01476 $this->tpl->setVariable("BUTTON_SAVE", $this->lng->txt("save_text_answer_points"));
01477 $this->tpl->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
01478 $this->tpl->parseCurrentBlock();
01479 }
01480
01481 $this->tpl->setCurrentBlock("questions_output");
01482 $this->tpl->setVariable("TXT_QUESTIONS", $this->lng->txt("ass_questions"));
01483 $this->tpl->setVariable("FORM_ACTION_RESULTS", $this->ctrl->getFormAction($this));
01484 $this->tpl->parseCurrentBlock();
01485
01486 $this->tpl->setCurrentBlock("export_btn");
01487 $this->tpl->setVariable("EXPORT_DATA", $this->lng->txt("exp_eval_data"));
01488 $this->tpl->setVariable("TEXT_EXCEL", $this->lng->txt("exp_type_excel"));
01489 $this->tpl->setVariable("TEXT_CSV", $this->lng->txt("exp_type_spss"));
01490 $this->tpl->setVariable("BTN_EXPORT", $this->lng->txt("export"));
01491 $this->tpl->setVariable("BTN_PRINT", $this->lng->txt("print"));
01492 $this->tpl->setVariable("BTN_COMMAND", $this->ctrl->getCmd());
01493 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01494 $this->tpl->setVariable("TEXT_FILTER_USERS", $this->lng->txt("filter_users"));
01495 $this->tpl->setVariable("TEXT_FILTER", $this->lng->txt("set_filter"));
01496 $this->tpl->setVariable("TEXT_RESET_FILTER", $this->lng->txt("reset_filter"));
01497 $this->tpl->setVariable("TEXT_PASSEDONLY", $this->lng->txt("passed_only"));
01498 if ($passedonly)
01499 {
01500 $this->tpl->setVariable("CHECKED_PASSEDONLY", " checked=\"checked\"");
01501 }
01502 if (strlen($filtertext) > 0)
01503 {
01504 $this->tpl->setVariable("VALUE_FILTER_USERS", " value=\"" . $filtertext . "\"");
01505 }
01506 $this->tpl->parseCurrentBlock();
01507
01508 $this->tpl->setCurrentBlock("adm_content");
01509 $this->tpl->setVariable("TXT_STATISTICAL_DATA", $this->lng->txt("statistical_data"));
01510 $this->tpl->parseCurrentBlock();
01511 $this->tpl->setVariable("PAGETITLE", $this->object->getTitle());
01512 }
01513
01514 function evalAllUsers()
01515 {
01516 $this->evalSelectedUsers(1);
01517 }
01518
01519 function eval_a()
01520 {
01521 $this->setResultsTabs();
01522 $color_class = array("tblrow1", "tblrow2");
01523 $counter = 0;
01524 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_anonymous_aggregation.html", true);
01525 $total_persons = $this->object->evalTotalPersons();
01526 if ($total_persons) {
01527 $this->tpl->setCurrentBlock("row");
01528 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_persons"));
01529 $this->tpl->setVariable("TXT_VALUE", $total_persons);
01530 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01531 $counter++;
01532 $this->tpl->parseCurrentBlock();
01533 $this->tpl->setCurrentBlock("row");
01534 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished"));
01535 $total_finished = $this->object->evalTotalFinished();
01536 $this->tpl->setVariable("TXT_VALUE", $total_finished);
01537 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01538 $counter++;
01539 $this->tpl->parseCurrentBlock();
01540 $this->tpl->setCurrentBlock("row");
01541 $average_time = $this->object->evalTotalStartedAverageTime();
01542 $diff_seconds = $average_time;
01543 $diff_hours = floor($diff_seconds/3600);
01544 $diff_seconds -= $diff_hours * 3600;
01545 $diff_minutes = floor($diff_seconds/60);
01546 $diff_seconds -= $diff_minutes * 60;
01547 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_finished_average_time"));
01548 $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
01549 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01550 $counter++;
01551 $passed_tests = $this->object->evalTotalFinishedPassed();
01552 $this->tpl->parseCurrentBlock();
01553 $this->tpl->setCurrentBlock("row");
01554 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed"));
01555 $this->tpl->setVariable("TXT_VALUE", $passed_tests["total_passed"]);
01556 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01557 $counter++;
01558 $this->tpl->parseCurrentBlock();
01559 $this->tpl->setCurrentBlock("row");
01560 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_points"));
01561 $this->tpl->setVariable("TXT_VALUE", sprintf("%2.2f", $passed_tests["average_points"]) . " " . strtolower($this->lng->txt("of")) . " " . sprintf("%2.2f", $passed_tests["maximum_points"]));
01562 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01563 $counter++;
01564 $this->tpl->parseCurrentBlock();
01565 $this->tpl->setCurrentBlock("row");
01566 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("tst_eval_total_passed_average_time"));
01567 $average_time = $this->object->evalTotalPassedAverageTime();
01568 $diff_seconds = $average_time;
01569 $diff_hours = floor($diff_seconds/3600);
01570 $diff_seconds -= $diff_hours * 3600;
01571 $diff_minutes = floor($diff_seconds/60);
01572 $diff_seconds -= $diff_minutes * 60;
01573 $this->tpl->setVariable("TXT_VALUE", sprintf("%02d:%02d:%02d", $diff_hours, $diff_minutes, $diff_seconds));
01574 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01575 $counter++;
01576 $this->tpl->parseCurrentBlock();
01577 } else {
01578 $this->tpl->setCurrentBlock("emptyrow");
01579 $this->tpl->setVariable("TXT_NO_ANONYMOUS_AGGREGATION", $this->lng->txt("tst_eval_no_anonymous_aggregation"));
01580 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01581 $this->tpl->parseCurrentBlock();
01582 }
01583 $this->tpl->setCurrentBlock("adm_content");
01584 $this->tpl->setVariable("TXT_ANON_EVAL", $this->lng->txt("tst_anon_eval"));
01585 $this->tpl->setVariable("TXT_RESULT", $this->lng->txt("result"));
01586 $this->tpl->setVariable("TXT_VALUE", $this->lng->txt("value"));
01587 $this->tpl->parseCurrentBlock();
01588 }
01589
01597 function evalUserDetail()
01598 {
01599 $user_id = $_GET["uid"];
01600 $this->ctrl->saveParameter($this, "uid");
01601 if (!is_numeric($user_id))
01602 {
01603 $this->ctrl->redirect($this, "eval_stat");
01604 }
01605 if ($this->object->getTestType() != TYPE_VARYING_RANDOMTEST)
01606 {
01607 $this->ctrl->redirect($this, "passDetails");
01608 }
01609 include_once "./assessment/classes/class.ilObjTest.php";
01610 $counted_pass = ilObjTest::_getResultPass($user_id, $this->object->getTestId());
01611 $this->setResultsTabs();
01612 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_user_detail_overview.html", true);
01613 $color_class = array("tblrow1", "tblrow2");
01614 $counter = 0;
01615 $reached_pass = $this->object->_getPass($user_id, $this->object->getTestId());
01616 for ($pass = 0; $pass <= $reached_pass; $pass++)
01617 {
01618 $finishdate = $this->object->getPassFinishDate($user_id, $this->object->getTestId(), $pass);
01619 if ($finishdate > 0)
01620 {
01621 $result_array =& $this->object->getTestResult($user_id, $pass);
01622 if (!$result_array["test"]["total_max_points"])
01623 {
01624 $percentage = 0;
01625 }
01626 else
01627 {
01628 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
01629 }
01630 $total_max = $result_array["test"]["total_max_points"];
01631 $total_reached = $result_array["test"]["total_reached_points"];
01632 $this->tpl->setCurrentBlock("result_row");
01633 if ($pass == $counted_pass)
01634 {
01635 $this->tpl->setVariable("COLOR_CLASS", "tblrowmarked");
01636 }
01637 else
01638 {
01639 $this->tpl->setVariable("COLOR_CLASS", $color_class[$pass % 2]);
01640 }
01641 $this->tpl->setVariable("VALUE_PASS", $pass + 1);
01642 $this->tpl->setVariable("VALUE_DATE", ilFormat::formatDate(ilFormat::ftimestamp2dateDB($finishdate), "date"));
01643 $this->tpl->setVariable("VALUE_ANSWERED", $this->object->getAnsweredQuestionCount($user_id, $this->object->getTestId(), $pass) . " " . strtolower($this->lng->txt("of")) . " " . (count($result_array)-1));
01644 $this->tpl->setVariable("VALUE_REACHED", $total_reached . " " . strtolower($this->lng->txt("of")) . " " . $total_max);
01645 $this->tpl->setVariable("VALUE_PERCENTAGE", sprintf("%.2f", $percentage) . "%");
01646 if ($this->object->canViewResults())
01647 {
01648 $this->tpl->setVariable("HREF_PASS_DETAILS", "<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "passDetails")."&pass=$pass\">" . $this->lng->txt("show_details") . "</a>");
01649 }
01650 $this->tpl->parseCurrentBlock();
01651 }
01652 }
01653 include_once "./classes/class.ilObjUser.php";
01654 $uname = ilObjUser::_lookupName($user_id);
01655 $struname = trim($uname["title"] . " " . $uname["firstname"] . " " . $uname["lastname"]);
01656 $this->tpl->setCurrentBlock("test_user_name");
01657 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name"), $struname));
01658 $this->tpl->parseCurrentBlock();
01659 $this->tpl->setCurrentBlock("adm_content");
01660 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01661 $this->tpl->setVariable("PASS_COUNTER", $this->lng->txt("pass"));
01662 $this->tpl->setVariable("DATE", $this->lng->txt("date"));
01663 $this->tpl->setVariable("ANSWERED_QUESTIONS", $this->lng->txt("tst_answered_questions"));
01664 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
01665 $this->tpl->setVariable("PERCENTAGE_CORRECT", $this->lng->txt("tst_percent_solved"));
01666 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01667 $this->tpl->setVariable("BACK_TO_EVALUATION", $this->lng->txt("tst_results_back_evaluation"));
01668 $back_command = ($_GET["etype"] == "all") ? "evalAllUsers" : "evalSelectedUsers";
01669 $this->tpl->setVariable("BACK_COMMAND", $back_command);
01670 $this->tpl->parseCurrentBlock();
01671 }
01672
01680 function passDetails()
01681 {
01682 function sort_percent($a, $b)
01683 {
01684 if (strcmp($_GET["order"], "ASC"))
01685 {
01686 $smaller = 1;
01687 $greater = -1;
01688 }
01689 else
01690 {
01691 $smaller = -1;
01692 $greater = 1;
01693 }
01694 if ($a["percent"] == $b["percent"])
01695 {
01696 if ($a["nr"] == $b["nr"]) return 0;
01697 return ($a["nr"] < $b["nr"]) ? -1 : 1;
01698 }
01699 return ($a["percent"] < $b["percent"]) ? $smaller : $greater;
01700 }
01701
01702 function sort_nr($a, $b)
01703 {
01704 if (strcmp($_GET["order"], "ASC"))
01705 {
01706 $smaller = 1;
01707 $greater = -1;
01708 }
01709 else
01710 {
01711 $smaller = -1;
01712 $greater = 1;
01713 }
01714 if ($a["nr"] == $b["nr"]) return 0;
01715 return ($a["nr"] < $b["nr"]) ? $smaller : $greater;
01716 }
01717
01718 $pass = $_GET["pass"];
01719 $user_id = $_GET["uid"];
01720 $this->ctrl->saveParameter($this, "uid");
01721 $this->ctrl->saveParameter($this, "pass");
01722 if (!is_numeric($pass)) $pass = NULL;
01723
01724 $this->setResultsTabs();
01725 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_eval_user_detail_detail.html", true);
01726 $color_class = array("tblrow1", "tblrow2");
01727 $counter = 0;
01728 $result_array =& $this->object->getTestResult($user_id, $pass);
01729
01730 if (!$result_array["test"]["total_max_points"])
01731 {
01732 $percentage = 0;
01733 }
01734 else
01735 {
01736 $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
01737 }
01738 $total_max = $result_array["test"]["total_max_points"];
01739 $total_reached = $result_array["test"]["total_reached_points"];
01740 $img_title_percent = "";
01741 $img_title_nr = "";
01742 switch ($_GET["sortres"])
01743 {
01744 case "percent":
01745 usort($result_array, "sort_percent");
01746 $img_title_percent = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
01747 if (strcmp($_GET["order"], "ASC") == 0)
01748 {
01749 $sortpercent = "DESC";
01750 }
01751 else
01752 {
01753 $sortpercent = "ASC";
01754 }
01755 break;
01756 case "nr":
01757 usort($result_array, "sort_nr");
01758 $img_title_nr = " <img src=\"" . ilUtil::getImagePath(strtolower($_GET["order"]) . "_order.png", true) . "\" alt=\"".$this->lng->txt(strtolower($_GET["order"])."ending_order")."\" />";
01759 if (strcmp($_GET["order"], "ASC") == 0)
01760 {
01761 $sortnr = "DESC";
01762 }
01763 else
01764 {
01765 $sortnr = "ASC";
01766 }
01767 break;
01768 }
01769 if (!$sortpercent)
01770 {
01771 $sortpercent = "ASC";
01772 }
01773 if (!$sortnr)
01774 {
01775 $sortnr = "ASC";
01776 }
01777
01778 foreach ($result_array as $key => $value)
01779 {
01780 if (preg_match("/\d+/", $key))
01781 {
01782 $this->tpl->setCurrentBlock("question_row");
01783 $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
01784 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", $value["nr"]);
01785
01786 $this->tpl->setVariable("VALUE_QUESTION_TITLE", $value["title"]);
01787
01788
01789 $this->tpl->setVariable("VALUE_MAX_POINTS", $value["max"]);
01790 $this->tpl->setVariable("VALUE_REACHED_POINTS", $value["reached"]);
01791 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", $value["percent"]);
01792 $this->tpl->parseCurrentBlock();
01793 $counter++;
01794 }
01795 }
01796
01797 $this->tpl->setCurrentBlock("question_footer");
01798 $this->tpl->setVariable("VALUE_QUESTION_COUNTER", "<strong>" . $this->lng->txt("total") . "</strong>");
01799 $this->tpl->setVariable("VALUE_QUESTION_TITLE", "");
01800 $this->tpl->setVariable("VALUE_MAX_POINTS", "<strong>" . sprintf("%d", $total_max) . "</strong>");
01801 $this->tpl->setVariable("VALUE_REACHED_POINTS", "<strong>" . sprintf("%d", $total_reached) . "</strong>");
01802 $this->tpl->setVariable("VALUE_PERCENT_SOLVED", "<strong>" . sprintf("%2.2f", $percentage) . " %" . "</strong>");
01803 $this->tpl->parseCurrentBlock();
01804
01805 $this->tpl->setCurrentBlock("test_user_name");
01806 include_once "./classes/class.ilObjUser.php";
01807 $uname = ilObjUser::_lookupName($user_id);
01808 $struname = trim($uname["title"] . " " . $uname["firstname"] . " " . $uname["lastname"]);
01809 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
01810 {
01811 include_once "./classes/class.ilObjUser.php";
01812 $uname = ilObjUser::_lookupName($user_id);
01813 $struname = trim($uname["title"] . " " . $uname["firstname"] . " " . $uname["lastname"]);
01814 $this->tpl->setCurrentBlock("test_user_name");
01815 $this->tpl->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name"), $struname));
01816 $this->tpl->parseCurrentBlock();
01817 }
01818 $this->tpl->parseCurrentBlock();
01819
01820 if ($this->object->isRandomTest())
01821 {
01822 $this->object->loadQuestions($user_id, $pass);
01823 }
01824 $counter = 1;
01825
01826 if (strlen(ilObjUser::_lookupLogin($user_id)) == 0)
01827 {
01828 $ilUser = new ilObjUser();
01829 $ilUser->id = $user_id;
01830 }
01831 else
01832 {
01833 $ilUser = new ilObjUser($user_id);
01834 }
01835 foreach ($this->object->questions as $question_id)
01836 {
01837 $this->tpl->setCurrentBlock("question");
01838 $question_gui = $this->object->createQuestionGUI("", $question_id);
01839
01840 $this->tpl->setVariable("COUNTER_QUESTION", $counter.". ");
01841 $this->tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
01842 $idx = $this->object->test_id;
01843 switch ($question_gui->getQuestionType())
01844 {
01845 case "qt_imagemap" :
01846 $question_gui->outWorkingForm($idx, false, $show_solutions=false, $formaction, $show_question_page=false, $show_solution_only = false, $ilUser, $pass, $mixpass = FALSE);
01847 break;
01848 case "qt_javaapplet" :
01849 $question_gui->outWorkingForm($idx, $is_postponed = false, $showsolution = 0, $show_question_page=false, $show_solution_only = false, $ilUser, $pass, $mixpass = FALSE);
01850 break;
01851 default :
01852 $question_gui->outWorkingForm($idx, $is_postponed = false, $showsolution = 0, $show_question_page=false, $show_solution_only = false, $ilUser, $pass, $mixpass = FALSE);
01853 }
01854 $this->tpl->parseCurrentBlock();
01855 $counter ++;
01856 }
01857
01858 $this->tpl->setCurrentBlock("adm_content");
01859 $this->tpl->setVariable("TEST_RESULTS_BY_PASS", $this->lng->txt("tst_eval_results_by_pass"));
01860 $this->tpl->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
01861 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01862 $this->tpl->setVariable("QUESTION_COUNTER", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "passDetails") . "&sortres=nr&order=$sortnr\">" . $this->lng->txt("tst_question_no") . "</a>$img_title_nr");
01863 $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
01864 $this->tpl->setVariable("MAX_POINTS", $this->lng->txt("tst_maximum_points"));
01865 $this->tpl->setVariable("REACHED_POINTS", $this->lng->txt("tst_reached_points"));
01866 $this->tpl->setVariable("PERCENT_SOLVED", "<a href=\"" . $this->ctrl->getLinkTargetByClass(get_class($this), "passDetails") . "&sortres=percent&order=$sortpercent\">" . $this->lng->txt("tst_percent_solved") . "</a>$img_title_percent");
01867 $back_command = "evalUserDetail";
01868 $back_text = $this->lng->txt("tst_results_back_overview");
01869 if (is_null($pass))
01870 {
01871 $back_command = ($_GET["etype"] == "all") ? "evalAllUsers" : "evalSelectedUsers";
01872 $back_text = $this->lng->txt("tst_results_back_evaluation");
01873 }
01874 $this->tpl->setVariable("BACK_TO_OVERVIEW", $back_text);
01875 $this->tpl->setVariable("BACK_COMMAND", $back_command);
01876 $this->tpl->parseCurrentBlock();
01877 }
01878
01879 function outShowAnswers($isForm, &$ilUser)
01880 {
01881 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_print_answers_sheet_details.html", true);
01882 $this->outShowAnswersDetails($isForm, $ilUser);
01883 }
01884
01885 function outShowAnswersDetails($isForm, &$ilUser)
01886 {
01887 $tpl = &$this->tpl;
01888 $invited_users = array_pop($this->object->getInvitedUsers($ilUser->getId()));
01889 $active = $this->object->getActiveTestUser($ilUser->getId());
01890 $t = $active->submittimestamp;
01891
01892
01893 if ($active->submitted)
01894 {
01895
01896 $tpl->setCurrentBlock("freefield_bottom");
01897 $tpl->setVariable("TITLE", $this->object->getTitle());
01898 $tpl->setVariable("TXT_DATE", $this->lng->txt("date"));
01899 $tpl->setVariable("VALUE_DATE", strftime("%Y-%m-%d %H:%M:%S", ilUtil::date_mysql2time($t)));
01900 $tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_answer_sheet"));
01901
01902 $freefieldtypes = array ("freefield_bottom" => array( array ("title" => $this->lng->txt("tst_signature"), "length" => 300)));
01903
01904
01905
01906
01907
01908
01909 foreach ($freefieldtypes as $type => $freefields) {
01910 $counter = 0;
01911
01912 while ($counter < count ($freefields)) {
01913 $freefield = $freefields[$counter];
01914
01915
01916
01917 $tpl->setVariable("TXT_FREE_FIELD", $freefield["title"]);
01918 $tpl->setVariable("VALUE_FREE_FIELD", "<img height=\"30px\" alt=\"".$this->lng->txt("spacer")."\" border=\"0\" src=\"".ilUtil :: getImagePath("spacer.gif", false)."\" width=\"".$freefield["length"]."px\" />");
01919
01920 $counter ++;
01921
01922
01923 }
01924 }
01925 $tpl->parseCurrentBlock();
01926 }
01927
01928 $counter = 1;
01929
01930
01931 foreach ($this->object->questions as $question)
01932 {
01933 $tpl->setCurrentBlock("question");
01934 $question_gui = $this->object->createQuestionGUI("", $question);
01935
01936 $tpl->setVariable("COUNTER_QUESTION", $counter.". ");
01937 $tpl->setVariable("QUESTION_TITLE", $question_gui->object->getTitle());
01938
01939 $idx = $this->object->test_id;
01940
01941 switch ($question_gui->getQuestionType()) {
01942 case "qt_imagemap" :
01943 $question_gui->outWorkingForm($idx, false, $show_solutions=false, $formaction, $show_question_page=false, $show_solution_only = false, $ilUser);
01944 break;
01945 case "qt_javaapplet" :
01946 $question_gui->outWorkingForm("", $is_postponed = false, $showsolution = 0, $show_question_page=false, $show_solution_only = false, $ilUser);
01947 break;
01948 default :
01949 $question_gui->outWorkingForm($idx, $is_postponed = false, $showsolution = 0, $show_question_page=false, $show_solution_only = false, $ilUser);
01950 }
01951 $tpl->parseCurrentBlock();
01952 $counter ++;
01953 }
01954
01955 if ($isForm && !$active->submitted)
01956 {
01957 $tpl->setCurrentBlock("confirm");
01958 $tpl->setVariable("TXT_SUBMIT_ANSWERS", $this->lng->txt("tst_submit_answers_txt"));
01959 $tpl->setVariable("BTN_CANCEL", $this->lng->txt("back"));
01960 $tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_answers"));
01961 $tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
01962 $tpl->parseCurrentBlock();
01963 }
01964
01965
01966 $tpl->setCurrentBlock("adm_content");
01967 $tpl->setVariable("TXT_TEST_TITLE", $this->lng->txt("title"));
01968 $tpl->setVariable("VALUE_TEST_TITLE", $this->object->getTitle());
01969 $tpl->setVariable("TXT_USR_NAME", $this->lng->txt("name"));
01970 $tpl->setVariable("VALUE_USR_NAME", $ilUser->getLastname().", ".$ilUser->getFirstname());
01971 $tpl->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation"));
01972 $tpl->setVariable("VALUE_USR_MATRIC", $ilUser->getMatriculation());
01973 $tpl->setVariable("TXT_CLIENT_IP", $this->lng->txt("client_ip"));
01974 $tpl->setVariable("VALUE_CLIENT_IP", $invited_users->clientip);
01975 $tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
01976
01977 $tpl->parseCurrentBlock();
01978
01979 }
01980
01984 function setResultsTabs()
01985 {
01986 global $ilTabs;
01987
01988 include_once ("./classes/class.ilTabsGUI.php");
01989 $tabs_gui = new ilTabsGUI();
01990
01991
01992 $tabs_gui->addTarget("tst_results_aggregated",
01993 $this->ctrl->getLinkTarget($this, "eval_a"),
01994 array("eval_a"),
01995 "", "");
01996
01997 $force_active = (is_numeric($_GET["uid"]) && $_GET["etype"] == "all") ? true : false;
01998 $tabs_gui->addTarget("eval_all_users",
01999 $this->ctrl->getLinkTargetByClass(get_class($this), "eval_stat"),
02000 array("eval_stat", "evalAllUsers", "evalUserDetail"),
02001 "", "", $force_active
02002 );
02003
02004 if ($this->object->getTestType() != TYPE_SELF_ASSESSMENT)
02005 {
02006 $force_active = (is_numeric($_GET["uid"]) && $_GET["etype"] == "selected") ? true : false;
02007 $tabs_gui->addTarget("eval_selected_users",
02008 $this->ctrl->getLinkTargetByClass(get_class($this), "evalStatSelected"),
02009 array("evalStatSelected", "evalSelectedUsers", "searchForEvaluation",
02010 "addFoundUsersToEval", "removeSelectedUser"),
02011 "", "", $force_active
02012 );
02013 }
02014 $ilTabs = $tabs_gui;
02015 #$this->tpl->setVariable("TABS", $tabs_gui->getHTML());
02016 }
02017 }
02018 ?>