55 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
57 $this->
object =& $a_object;
66 $result = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions WHERE question_fi = %s",
67 array(
'integer'), array($qid)
69 if ($ilDB->numRows($result) > 0)
71 $result = $ilDB->queryF(
"DELETE FROM tst_temp_solutions WHERE question_fi = %s",
72 array(
'integer'), array($qid)
75 $ilDB->queryF(
"INSERT INTO tst_temp_solutions (SELECT * FROM tst_solutions WHERE question_fi = %s)",
76 array(
'integer'), array($qid)
84 foreach ($postvars as $key => $value)
86 if (strpos($value,
","))
88 $value = str_replace(
",",
".",$value);
90 if (preg_match(
"/(\d+)_(\d+)/", $key, $matches) && is_numeric($value))
102 if ($maxpoints == $sum || $sum == 0)
116 $qid = $postvars[
"id"];
118 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_ordering_old WHERE question_fi = %s",
119 array(
'integer'), array($qid)
121 if ($ilDB->numRows($result) > 0)
123 $result = $ilDB->queryF(
"DELETE FROM qpl_a_ordering_old WHERE question_fi = %s",
124 array(
'integer'), array($qid)
131 foreach ($postvars as $key => $value)
133 if (strpos($value,
","))
135 $value = str_replace(
",",
".",$value);
137 if (preg_match(
"/(\d+)_(\d+)/", $key, $matches) && is_numeric($value))
139 $order = $matches[2];
142 $next_id = $ilDB->nextId(
'qpl_a_ordering_old');
143 $affectedRows = $ilDB->manipulateF(
"INSERT INTO qpl_a_ordering_old (answer_id, question_fi, ".
144 "points, aorder, tstamp) VALUES (%s, %s, %s, %s, %s)",
145 array(
'integer',
'integer',
'float',
'integer',
'integer'),
164 $orderingItemPoints = array();
165 $result = $ilDB->queryF(
"SELECT * FROM qpl_a_ordering_old WHERE question_fi = %s ORDER BY aorder ASC",
169 if ($result->numRows() > 0)
171 while (
$data = $ilDB->fetchAssoc($result))
173 array_push($orderingItemPoints,
$data[
"points"]);
176 return $orderingItemPoints;
181 global
$ilDB, $ilUser;
183 $qid = $postvars[
"id"];
185 $question = $this->
object->createQuestionGUI(
"", $qid);
189 $orderingItemPoints = array();
190 foreach ($postvars as $key => $value)
192 if (!is_array($value) && strpos($value,
","))
194 $value = str_replace(
",",
".",$value);
196 if (preg_match(
"/(\d+)_(\d+)/", $key, $matches))
198 $order = $matches[2];
202 if ($question->object->gaps[$matches[1]]->getType() ==
CLOZE_NUMERIC)
204 $answer = $question->object->gaps[$matches[1]]->getItem(0);
207 $answer->setLowerBound($value);
211 $answer->setUpperBound($value);
215 $answer->setAnswertext($value);
219 $answer->setPoints($value);
224 $question->object->gaps[$matches[1]]->setItemPoints($order, $value);
229 case "assMultipleChoice":
230 $answer = $question->object->getAnswer($order);
233 $answer->points = $value;
237 $answer->points_unchecked = $value;
242 if ($matches[1] == 1)
244 $question->object->setLowerLimit($value);
246 if ($matches[1] == 2)
248 $question->object->setUpperLimit($value);
250 if ($matches[1] == 0)
252 $question->object->points = $value;
256 case "assMatchingQuestion":
257 $query =
"UPDATE qpl_a_matching SET points= $value WHERE question_fi=$qid AND term_fi = $order";
262 case "assOrderingQuestion":
263 case "assOrderingHorizontal":
266 $question->object->setPoints($value);
268 elseif($order && is_numeric($value))
270 array_push($orderingItemPoints, $value);
275 case "assSingleChoice":
276 case "assTextSubset":
277 $answer = $question->object->getAnswer($order);
278 $answer->points = $value;
286 $logtext =
"Neu bewertete Frage";
287 $testObjId = $this->
object->_lookupTestObjIdForQuestionId($qid);
288 $originalId = $question->object->original_id;
289 include_once
"./Modules/Test/classes/class.ilObjAssessmentFolder.php";
294 $maxpoints = $question->object->getMaximumPoints();
295 $query =
"UPDATE qpl_questions SET points='$maxpoints' WHERE question_id=$qid";
298 if ($qtype ==
"assClozeTest")
300 $question->object->setIdenticalScoring(
$_POST[
"ident_scoring"]);
301 $question->object->setTextgapRating(
$_POST[
"textgap_rating"]);
303 if ($qtype ==
"assTextSubset")
305 $question->object->setTextRating(
$_POST[
"text_rating"]);
309 $question->object->SaveToDb();
311 $data =& $this->
object->getCompleteEvaluationData(FALSE);
312 $foundParticipants =&
$data->getParticipants();
313 foreach ($foundParticipants as $active_id => $userdata)
315 if ($qtype ==
"assOrderingQuestion" && count($orderingItemPoints) > 0)
322 $reached = $question->object->calculateReachedPoints($active_id);
339 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
340 array(
'integer',
'integer',
'integer'),
341 array($active_id, $q_id,
$pass)
343 $user_order = array();
344 while (
$data = $ilDB->fetchAssoc($result))
346 if ((strcmp(
$data[
"value1"],
"") != 0) && (strcmp(
$data[
"value2"],
"") != 0))
348 $user_order[
$data[
"value2"]] = $data[
"value1"];
352 $user_order = array_values($user_order);
354 foreach ($orderingItemPoints as $index => $value)
356 if (($index) == $user_order[$index])
374 $rec = $ilDB->queryF(
"SELECT distinct(value2) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND value1 = %s AND active_id = active_fi",
375 array(
'integer',
'text'),
376 array($a_qid, $a_par)
378 while (
$row = $ilDB->fetchAssoc($rec))
379 array_push($values,
$row[
"value2"]);
382 case "assMatchingQuestion":
383 $len = strlen($a_par);
384 if (strpos($a_par,
".jpg", ($len -4)))
387 $where =
"definition";
389 $select =
"SELECT * FROM qpl_a_mdef WHERE question_fi= %s AND $where = %s";
390 $rec = $ilDB->queryF($select,
391 array(
'integer',
'text'),
392 array($a_qid, $a_par)
394 $row = $ilDB->fetchAssoc($rec);
395 $value2 =
$row[
"morder"];
396 array_push($values, $value2);
397 $rec = $ilDB->queryF(
"SELECT distinct(value1) FROM tst_temp_solutions WHERE question_fi= %s AND value2 = %s",
398 array(
'integer',
'text'),
399 array($a_qid, $value2)
401 while (
$row = $ilDB->fetchAssoc($rec))
402 array_push($values,
$row[
"value1"]);
405 case "assMultipleChoice":
406 case "assSingleChoice":
407 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND value1 = %s AND active_id = active_fi",
408 array(
'integer',
'text'),
409 array($a_qid, $a_par)
411 while (
$row = $ilDB->fetchAssoc($rec))
412 array_push($values,
$row[
"value1"]);
415 case "assOrderingQuestion":
416 $rec = $ilDB->queryF(
"SELECT distinct(value2) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND value1 = %s AND active_id = active_fi",
417 array(
'integer',
'text'),
418 array($a_qid, $a_par)
420 while (
$row = $ilDB->fetchAssoc($rec))
421 array_push($values,
$row[
"value2"]);
424 case "assOrderingHorizontal":
425 $rec = $ilDB->queryF(
"SELECT distinct(value1) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND active_id = active_fi",
429 while (
$row = $ilDB->fetchAssoc($rec))
430 array_push($values,
$row[
"value1"]);
434 case "assTextSubset":
435 $rec = $ilDB->queryF(
"SELECT distinct(value1) FROM tst_temp_solutions, tst_active WHERE question_fi= %s AND active_id = active_fi ORDER BY value1",
439 while (
$row = $ilDB->fetchAssoc($rec))
442 array_push($values,
$row[
"value1"]);
454 $stat = array(
"count",
"val");
459 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions WHERE question_fi= %s AND value2= %s AND value1 =%s",
460 array(
"integer",
"text",
"text"),
461 array($a_qid, $par1, $par2)
463 $stat[
"count"] = $ilDB->numRows($rec);
464 $row = $ilDB->fetchAssoc($rec);
465 $stat[
"val"] =
$row[
"solution_id"];
468 case "assMatchingQuestion":
470 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions WHERE question_fi= %s AND value1= %s AND value2= %s",
471 array(
"integer",
"text",
"text"),
472 array($a_qid, $par1, $par2)
474 $rec1 = $ilDB->queryF(
"SELECT * FROM qpl_a_mterm WHERE question_fi= %s AND term_id=%s",
475 array(
"integer",
"integer"),
478 $row = $ilDB->fetchAssoc($rec1);
479 $stat[
"count"] = $ilDB->numRows($rec);
480 $stat[
"val"] =
$row[
"term"];
483 case "assOrderingQuestion":
484 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND value2=%s AND active_id = active_fi",
485 array(
"integer",
"text",
"text"),
486 array($a_qid, $par1, $par2)
488 $stat[
"count"] = $ilDB->numRows($rec);
491 case "assOrderingHorizontal":
492 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND active_id = active_fi",
493 array(
"integer",
"text"),
496 $stat[
"count"] = $ilDB->numRows($rec);
500 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND active_id = active_fi",
501 array(
"integer",
"text"),
504 $stat[
"count"] = $ilDB->numRows($rec);
507 case "assTextSubset":
508 $rec = $ilDB->queryF(
"SELECT * FROM tst_temp_solutions, tst_active WHERE question_fi=%s AND value1=%s AND active_id = active_fi",
509 array(
"integer",
"text"),
512 $row = $ilDB->fetchAssoc($rec);
513 $stat[
"count"] = $ilDB->numRows($rec);
514 $stat[
"val"] =
$row[
"solution_id"];
524 $question = & $a_question;
528 foreach($answerarray as $value)
530 $temp = split(
"_", $value);
533 $synonymArr = explode($syn_separator,$temp[0]);
534 for ($i = 0; $i < count($synonymArr); $i++)
536 $OK = $question->object->getTextgapPoints($userans, $synonymArr[$i], $temp[1]);
537 if (!$OK && ($userans == $synonymArr[$i]))
545 $OK = $question->object->getTextgapPoints($userans, $temp[0], $temp[1]);
546 if (!$OK && ($userans == $temp[0]))
564 $query =
"SELECT value2 FROM tst_temp_solutions WHERE solution_id=". $solutionId;
567 $answer =
$row[
"value2"];
570 case "assTextSubset":
571 $query =
"SELECT value1 FROM tst_temp_solutions WHERE solution_id = $solutionId";
574 $answer =
$row[
"value1"];