ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestScoringGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
6 include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
7 
18 {
19 
28 function ilTestScoringGUI($a_object)
29 {
30  parent::ilTestServiceGUI($a_object);
31  $this->ctrl->saveParameter($this, "active_id");
32  $this->ctrl->saveParameter($this, "userfilter");
33  $this->ctrl->saveParameter($this, "pass");
34 }
35 
39 function &executeCommand()
40 {
41  $cmd = $this->ctrl->getCmd();
42  $next_class = $this->ctrl->getNextClass($this);
43  if (strlen($_POST['FORM']))
44  {
45  switch ($_POST['FORM'])
46  {
47  case 'formQuestionScoring':
48  $cmd = 'selectQuestion';
49  break;
50  }
51  }
52  if (strlen($cmd) == 0)
53  {
54  $this->ctrl->redirect($this, "manscoring");
55  }
56  $cmd = $this->getCommand($cmd);
57  switch($next_class)
58  {
59  default:
60  $ret =& $this->$cmd();
61  break;
62  }
63  return $ret;
64 }
65 
69 function scoringfilter()
70 {
71  $this->manscoring();
72 }
73 
78 {
79  $this->manscoring();
80 }
81 
85 public function setManScoringDone()
86 {
87  $manscoring_done = ($_POST["manscoring_done"]) ? 1 : 0;
88  $assessmentSetting = new ilSetting("assessment");
89  $assessmentSetting->set("manscoring_done_" . $_GET["active_id"], $manscoring_done);
90  $this->manscoring();
91 }
92 
98 function manscoring()
99 {
100  global $ilAccess;
101  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
102  {
103  // allow only write access
104  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
105  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
106  }
107 
108  $active_id = (strlen($_POST["participants"])) ? $_POST["participants"] : ((strlen($_GET["active_id"])) ? $_GET["active_id"] : 0);
109  $userfiltervalue = (strlen($_POST["userfilter"])) ? $_POST["userfilter"] : ((strlen($_GET["userfilter"])) ? $_GET["userfilter"] : 0);
110 
111  if (strcmp($this->ctrl->getCmd(), "scoringfilterreset") == 0)
112  {
113  $active_id = 0;
114  $userfiltervalue = 0;
115  }
116 
117  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
119  if (count($scoring) == 0)
120  {
121  // allow only if question types are marked for manual scoring
122  ilUtil::sendInfo($this->lng->txt("manscoring_not_allowed"));
123  return;
124  }
125 
126  $pass = $this->object->_getResultPass($active_id);
127  if (array_key_exists("pass", $_GET))
128  {
129  if (strlen($_GET["pass"]))
130  {
131  $maxpass = $this->object->_getMaxPass($active_id);
132  if ($_GET["pass"] <= $maxpass) $pass = $_GET["pass"];
133  }
134  }
135 
136  $participantsfilter = ($userfiltervalue) ? $userfiltervalue : 0;
137  $participants =& $this->object->getTestParticipantsForManualScoring($participantsfilter);
138  if (!array_key_exists($active_id, $participants)) $active_id = 0;
139 
140  $this->ctrl->setParameter($this, "active_id", $active_id);
141  $this->ctrl->setParameter($this, "userfilter", $userfiltervalue);
142 
143  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_manual_scoring.html", "Modules/Test");
144 
145  if ($active_id > 0)
146  {
147  $this->tpl->setCurrentBlock("manscoring_done");
148  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "scoringfilter"));
149  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
150  $this->tpl->setVariable("TEXT_MANSCORING_DONE", $this->lng->txt("set_manscoring_done"));
151  $assessmentSetting = new ilSetting("assessment");
152  $manscoring_done = $assessmentSetting->get("manscoring_done_" . $active_id);
153  if ($manscoring_done)
154  {
155  $this->tpl->setVariable("CHECKED_MANSCORING_DONE", ' checked="checked"');
156  }
157  $this->tpl->parseCurrentBlock();
158  }
159 
160  if (array_key_exists("question", $_POST) || strlen($_GET["anchor"]))
161  {
162  if (strlen($_GET["anchor"]))
163  {
164  $question_id = $_GET["anchor"];
165  }
166  else
167  {
168  $keys = array_keys($_POST["question"]);
169  $question_id = $keys[0];
170  }
171  $this->tpl->setCurrentBlock("lastchanged");
172  $this->tpl->setVariable("LAST_CHANGED", $question_id);
173  $this->tpl->parseCurrentBlock();
174  }
175  $counter = 1;
176  foreach ($participants as $participant_active_id => $data)
177  {
178  $this->tpl->setCurrentBlock("participants");
179  $this->tpl->setVariable("ID_PARTICIPANT", $data["active_id"]);
180  $suffix = "";
181  if ($this->object->getAnonymity())
182  {
183  $suffix = " " . $counter++;
184  }
185  if ($active_id > 0)
186  {
187  if ($active_id == $data["active_id"])
188  {
189  $this->tpl->setVariable("SELECTED_PARTICIPANT", " selected=\"selected\"");
190  }
191  }
192  $this->tpl->setVariable("TEXT_PARTICIPANT", $this->object->userLookupFullName($data["usr_id"], FALSE, TRUE, $suffix));
193  $this->tpl->parseCurrentBlock();
194  }
195  $userfilter = array(
196  "1" => $this->lng->txt("usr_active_only"),
197  "2" => $this->lng->txt("usr_inactive_only"),
198  //"3" => $this->lng->txt("all_users"),
199  "4" => $this->lng->txt("manscoring_done"),
200  "5" => $this->lng->txt("manscoring_none"),
201  //"6" => $this->lng->txt("manscoring_pending")
202  );
203  foreach ($userfilter as $selection => $filtertext)
204  {
205  $this->tpl->setCurrentBlock("userfilter");
206  $this->tpl->setVariable("VALUE_USERFILTER", $selection);
207  $this->tpl->setVariable("TEXT_USERFILTER", $filtertext);
208  if ($userfiltervalue == $selection)
209  {
210  $this->tpl->setVariable("SELECTED_USERFILTER", " selected=\"selected\"");
211  }
212  $this->tpl->parseCurrentBlock();
213  }
214 
215 // ############# select a question for manual scoring ##############
216 
217  $questions = $this->object->getTestQuestions();
218  foreach ($questions as $data)
219  {
220  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
221  $info =& assQuestion::_getQuestionInfo($data['question_id']);
222  $type = $info["question_type_fi"];
223  if (in_array($type, $scoring))
224  {
225  $this->tpl->setCurrentBlock("questions");
226  $this->tpl->setVariable("ID_QUESTION", $data['question_id']);
227  if ($_POST['questions'] > 0)
228  {
229  if ($_POST['questions'] == $data['question_id'])
230  {
231  $this->tpl->setVariable("SELECTED_QUESTION", " selected=\"selected\"");
232  }
233  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "selectQuestion"));
234  }
235  $this->tpl->setVariable("TEXT_QUESTION", $data['title']);
236  $this->tpl->parseCurrentBlock();
237  }
238  }
239  $this->tpl->setCurrentBlock("questselect");
240  $this->tpl->setVariable("FILTER_CLASS_QUESTION", ($_POST['questions'] > 0) ? "filteractive" : "filterinactive");
241  $this->tpl->setVariable("TEXT_SELECT_QUESTION", $this->lng->txt("manscoring_select_question"));
242  $this->tpl->setVariable("PLEASE_SELECT_QUESTION", $this->lng->txt('question'));
243  $this->tpl->setVariable("BUTTON_SELECT_QUESTION", $this->lng->txt("to_filter"));
244  $this->tpl->parseCurrentBlock();
245 // ##########
246 
247  $this->tpl->setVariable("PLEASE_SELECT", $this->lng->txt("participants"));
248  $this->tpl->setVariable("SELECT_USERFILTER", $this->lng->txt("user_status"));
249  $this->tpl->setVariable("SELECT_SCOREDFILTER", $this->lng->txt("manscoring"));
250  $this->tpl->setVariable("BUTTON_SELECT", $this->lng->txt("to_filter"));
251  $this->tpl->setVariable("BUTTON_RESET", $this->lng->txt("reset"));
252  $this->tpl->setVariable("FILTER_CLASS", ($active_id) ? "filteractive" : "filterinactive");
253  $this->tpl->setVariable("FILTER_CLASS_USERFILTER", ($userfiltervalue) ? "filteractive" : "filterinactive");
254  $this->tpl->setVariable("TEXT_SELECT_USER", $this->lng->txt("manscoring_select_user"));
255 
256  if ($active_id > 0)
257  {
258  // print pass overview
259  if ($this->object->getNrOfTries() != 1)
260  {
261  $overview = $this->getPassOverview($active_id, "iltestscoringgui", "manscoring");
262  $this->tpl->setVariable("PASS_OVERVIEW", $overview);
263  }
264  // print pass details with scoring
265  if (strlen($pass))
266  {
267  $result_array =& $this->object->getTestResult($active_id, $pass);
268  $scoring = $this->getPassListOfAnswersWithScoring($result_array, $active_id, $pass, TRUE);
269  $this->tpl->setVariable("SCORING_DATA", $scoring);
270  }
271  }
272  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "scoringfilter"));
273  include_once "./Services/RTE/classes/class.ilRTE.php";
274  $rtestring = ilRTE::_getRTEClassname();
275  include_once "./Services/RTE/classes/class.$rtestring.php";
276  $rte = new $rtestring();
277  $rte->addPlugin("latex");
278  $rte->addButton("latex"); $rte->addButton("pastelatex");
279  include_once "./classes/class.ilObject.php";
280  $obj_id = ilObject::_lookupObjectId($_GET["ref_id"]);
281  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
282  $rte->addRTESupport($obj_id, "fdb", "assessment");
283 }
284 
288 function setPointsManual()
289 {
290  if (array_key_exists("question", $_POST))
291  {
292  $keys = array_keys($_POST["question"]);
293  $question_id = $keys[0];
294  $points = $_POST["question"][$question_id];
295  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
296  $maxpoints = assQuestion::_getMaximumPoints($question_id);
297  $result = assQuestion::_setReachedPoints($_GET["active_id"], $question_id, $points, $maxpoints, $_GET["pass"], 1);
298 
299  // update learning progress
300  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
301  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
302  ilLPStatusWrapper::_updateStatus($this->object->getId(),
303  ilObjTestAccess::_getParticipantId((int) $_GET["active_id"]));
304 
305  if ($result)
306  {
307  ilUtil::sendSuccess($this->lng->txt("tst_change_points_done"));
308  }
309  else
310  {
311  ilUtil::sendFailure($this->lng->txt("tst_change_points_not_done"));
312  }
313  }
314  $this->manscoring();
315 }
316 
318 {
319  if (array_key_exists("feedback", $_POST))
320  {
321  $feedbacks = array_keys($_POST["feedback"]);
322  $question_id = $feedbacks[0];
323  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
324  $feedback = ilUtil::stripSlashes($_POST["feedback"][$question_id], FALSE, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
325  $result = $this->object->saveManualFeedback($_GET["active_id"], $question_id, $_GET["pass"], $feedback);
326  if ($result)
327  {
328  ilUtil::sendSuccess($this->lng->txt("tst_set_feedback_done"));
329  }
330  else
331  {
332  ilUtil::sendFailure($this->lng->txt("tst_set_feedback_not_done"));
333  }
334  }
335  $this->setPointsManual();
336 }
337 
342 function selectQuestion()
343 {
344  $_GET["active_id"] = 0;
345  if (!$_POST["questions"])
346  {
347  $this->manscoring();
348  }
349  else
350  {
351  $this->scoringParticipants($_POST["questions"]);
352  }
353 }
354 
359 function scoringParticipants($q_id = 0)
360 {
361  global $ilAccess, $ilUser;
362 
363  if ((!$ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) && (!$ilAccess->checkAccess("write", "", $this->ref_id)))
364  {
365  // allow only evaluation access
366  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
367  $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
368  }
369 
370  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
371  if ($_POST["cmd"]["scoringParticipants"])
372  {
373  foreach ($_POST as $key => $value)
374  {
375  if (($value > "") && (preg_match("/(\d+)_(\d+)/", $key, $matches)))
376  {
377  $pass = $this->object->_getResultPass($matches[1]);
378  $maxpoints = assQuestion::_getMaximumPoints($matches[2]);
379  assQuestion::_setReachedPoints($matches[1], $matches[2], $value, $maxpoints, $pass, 1);
380  }
381  }
382  $q_id = $_POST["qid"];
383  }
384  $this->manscoring($q_id);
385  $template = new ilTemplate("tpl.il_as_tst_scoring_question.html", TRUE, TRUE, "Modules/Test");
386 
387  $data =& $this->object->getCompleteEvaluationData(FALSE);
388  $foundParticipants =& $data->getParticipants();
389  if (count($foundParticipants) == 0)
390  {
391  $this->tpl->setVariable("EVALUATION_DATA", $this->lng->txt("tst_no_evaluation_data"));
392  }
393  $eval_complete = array();
394  $partcount = 1;
395  foreach ($data->getParticipants() as $active_id => $userdata)
396  {
397  $evalrow = array();
398  $pass = $this->object->_getResultPass($active_id);
399  array_push($evalrow, $partcount++. ". ". $userdata->getName());
400 
401  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
402  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
404 
405  $info =& assQuestion::_getQuestionInfo($q_id);
406  $type = $info["question_type_fi"];
407 
408  if (in_array($type, $scoring))
409  {
410  $question_data = $userdata->getPass($pass)->getAnsweredQuestionByQuestionId($q_id);
411  $reached = $question_data["reached"];
412  $name = $active_id."_".$q_id;
413 
414  $htmloutput = "<input type=\"text\" name=\"".$name."\" size=\"2\" value=\"".$reached."\" />"." ";
415  // Solution
416  $htmloutput .= " [<a href=\"".$this->ctrl->getLinkTargetByClass(get_class($this), "evaluationDetail") . "&userdetail=".$active_id."&answer=".$q_id. "\" target=\"popup\" onclick=\"";
417  $htmloutput .= "window.open('', 'popup', 'width=600, height=300, scrollbars=yes, toolbar=no, status=no, resizable=yes, menubar=no, location=no, directories=no')";
418  $htmloutput .= "\">". "Antwort"."</a>]";
419 
420  array_push($evalrow, $htmloutput);
421  }
422  array_push($eval_complete, $evalrow);
423  }
424  if (count($evalrow) < 2) exit; // es gibt keine Fragen zur manuellen Bewertung
425 
426  $template->setVariable("HEADING", $this->lng->txt("manscoring_question_eval"));
427  $counter = 0;
428  $color_class = array("tblrow1", "tblrow2");
429  foreach ($eval_complete as $row)
430  {
431  foreach ($row as $key => $value)
432  {
433  $template->setCurrentBlock("questions_datacol");
434  $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
435  $template->setVariable("TXT_DATA", $value);
436  $template->parseCurrentBlock();
437  }
438  $template->setCurrentBlock("questions_row");
439  $template->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
440  $template->parseCurrentBlock();
441  $counter++;
442  }
443  $template->setVariable("QID", $q_id);
444  $template->setVariable("BUTTON_SAVE", "Punkte speichern");
445 
446  $manscoring = $template->get();
447  $this->tpl->setVariable("SCORING_DATA", "");
448  $this->tpl->setVariable("QUESTION_MANSCORING", $manscoring);
449  $this->tpl->parseCurrentBlock();
450  if ($_POST["cmd"]["scoringParticipants"])
451  {
452  ilUtil::sendSuccess($this->lng->txt("manscoring_questions_success"), true);
453  $this->ctrl->redirect($this, "manscoring");
454  }
455 }
456 
458 {
459  global $ilUser;
460 
461  $active_id = $_GET["userdetail"];
462  $pass = $this->object->_getResultPass($active_id);
463  $question_id = $_GET["answer"];
464  $question_gui = $this->object->createQuestionGUI("", $question_id);
465  $user_id = $this->object->_getUserIdFromActiveId($active_id);
466  $uname = ilObjUser::_lookupName($user_id);
467 
468  $this->tpl = new ilTemplate("tpl.il_as_tst_correct_solution_output.html", TRUE, TRUE, "Modules/Test");
469  $result_output = $question_gui->getSolutionOutput($active_id, $pass, TRUE, FALSE, FALSE, $this->object->getShowSolutionFeedback());
470  $best_output = $question_gui->getSolutionOutput("", NULL, FALSE, FALSE, FALSE);
471  $this->tpl->setVariable("TEXT_YOUR_SOLUTION", "Antwort von ". $uname["lastname"] . ", " . $uname["firstname"]);
472  $maxpoints = $question_gui->object->getMaximumPoints();
473  if ($maxpoints == 1)
474  {
475  $this->tpl->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("point") . ")");
476  }
477  else
478  {
479  $this->tpl->setVariable("QUESTION_TITLE", $this->object->getQuestionTitle($question_gui->object->getTitle()) . " (" . $maxpoints . " " . $this->lng->txt("points") . ")");
480  }
481  $this->tpl->setVariable("SOLUTION_OUTPUT", $result_output);
482 
483  $your_points = "Der Benutzer hat %s von %s m&ouml;glichen Punkten erreicht.";
484  $this->tpl->setVariable("RECEIVED_POINTS", sprintf($your_points, $question_gui->object->getReachedPoints($active_id, $pass), $maxpoints));
485  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
486  $this->tpl->setVariable("BACKLINK_TEXT", "&lt;&lt; " . $this->lng->txt("back"));
487 }
488 
489 }
490 
491 ?>