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