23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
79 $this->ranges = array();
93 if (($this->title) and ($this->author) and ($this->question) and (count($this->ranges)) and ($this->
getMaximumPoints() > 0))
121 $estw_time = sprintf(
"%02d:%02d:%02d", $estw_time[
'h'], $estw_time[
'm'], $estw_time[
's']);
133 include_once(
"./Services/RTE/classes/class.ilRTE.php");
139 $created = sprintf(
"%04d%02d%02d%02d%02d%02d", $now[
'year'], $now[
'mon'], $now[
'mday'], $now[
'hours'], $now[
'minutes'], $now[
'seconds']);
140 $query = sprintf(
"INSERT INTO qpl_questions (question_id, question_type_fi, obj_fi, title, comment, author, owner, question_text, points, working_time, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
141 $ilDB->quote($question_type),
142 $ilDB->quote($this->obj_id),
143 $ilDB->quote($this->title),
144 $ilDB->quote($this->comment),
145 $ilDB->quote($this->author),
146 $ilDB->quote($this->owner),
149 $ilDB->quote($estw_time),
150 $ilDB->quote(
"$complete"),
151 $ilDB->quote($created),
154 $result = $ilDB->query($query);
156 if (PEAR::isError($result))
159 $ilias->raiseError($result->getMessage());
163 $this->
id = $ilDB->getLastInsertId();
164 $query = sprintf(
"INSERT INTO qpl_question_numeric (question_fi, maxNumOfChars) VALUES (%s, %s)",
165 $ilDB->quote($this->id .
""),
168 $ilDB->query($query);
182 $query = sprintf(
"UPDATE qpl_questions SET obj_fi = %s, title = %s, comment = %s, author = %s, question_text = %s, points = %s, working_time=%s, complete = %s WHERE question_id = %s",
183 $ilDB->quote($this->obj_id.
""),
184 $ilDB->quote($this->title),
185 $ilDB->quote($this->comment),
186 $ilDB->quote($this->author),
189 $ilDB->quote($estw_time),
190 $ilDB->quote(
"$complete"),
191 $ilDB->quote($this->
id)
193 $result = $ilDB->query($query);
194 $query = sprintf(
"UPDATE qpl_question_numeric SET maxNumOfChars = %s WHERE question_fi = %s",
195 $ilDB->quote($this->getMaxChars() .
""),
196 $ilDB->quote($this->id .
"")
198 $result = $ilDB->query($query);
203 $ilias->raiseError(
$result->getMessage());
210 $query = sprintf(
"DELETE FROM qpl_numeric_range WHERE question_fi = %s",
211 $ilDB->quote($this->id)
213 $result = $ilDB->query($query);
216 foreach ($this->ranges as $key => $range)
218 $query = sprintf(
"INSERT INTO qpl_numeric_range (range_id, question_fi, lowerlimit, upperlimit, points, aorder, lastchange) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
219 $ilDB->quote($this->id),
220 $ilDB->quote($range->getLowerLimit()),
221 $ilDB->quote($range->getUpperLimit() .
""),
222 $ilDB->quote($range->getPoints() .
""),
223 $ilDB->quote($range->getOrder() .
"")
225 $answer_result = $ilDB->query($query);
244 $query = sprintf(
"SELECT qpl_questions.*, qpl_question_numeric.* FROM qpl_questions, qpl_question_numeric WHERE question_id = %s AND qpl_questions.question_id = qpl_question_numeric.question_fi",
245 $ilDB->quote($question_id)
247 $result = $ilDB->query($query);
248 if ($result->numRows() == 1)
250 $data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
251 $this->
id = $question_id;
252 $this->title =
$data->title;
253 $this->comment =
$data->comment;
254 $this->solution_hint =
$data->solution_hint;
255 $this->original_id =
$data->original_id;
256 $this->obj_id =
$data->obj_fi;
257 $this->author =
$data->author;
258 $this->owner =
$data->owner;
259 $this->points =
$data->points;
260 include_once(
"./Services/RTE/classes/class.ilRTE.php");
262 $this->maxchars =
$data->maxNumOfChars;
265 $query = sprintf(
"SELECT * FROM qpl_numeric_range WHERE question_fi = %s ORDER BY aorder ASC",
266 $ilDB->quote($question_id)
269 $result = $ilDB->query($query);
271 include_once
"./Modules/TestQuestionPool/classes/class.assNumericRange.php";
272 if ($result->numRows() > 0)
274 while (
$data = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
305 foreach ($this->ranges as $key => $range)
307 if ($range->getOrder() == $order)
312 include_once
"./Modules/TestQuestionPool/classes/class.assNumericRange.php";
317 array_push($this->ranges, $range);
318 for ($i = $found + 1; $i < count($this->ranges); $i++)
320 $this->ranges[$i] = $this->ranges[$i-1];
322 $this->ranges[$found] = $range;
328 array_push($this->ranges, $range);
347 $this_id = $this->
getId();
349 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
376 $clone->copyPageOfQuestion($this_id);
378 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
380 $clone->duplicateFeedbackGeneric($this_id);
401 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
404 $source_questionpool = $this->
getObjId();
405 $clone->setObjId($target_questionpool);
433 return count($this->ranges);
449 if ($index < 0)
return NULL;
450 if (count($this->ranges) < 1)
return NULL;
451 if ($index >= count($this->ranges))
return NULL;
453 return $this->ranges[$index];
468 if ($index < 0)
return;
469 if (count($this->ranges) < 1)
return;
470 if ($index >= count($this->ranges))
return;
471 unset($this->ranges[$index]);
472 $this->ranges = array_values($this->ranges);
473 for ($i = 0; $i < count($this->ranges); $i++)
475 if ($this->ranges[$i]->getOrder() > $index)
477 $this->ranges[$i]->setOrder($i);
492 $this->ranges = array();
506 foreach ($this->ranges as $key => $range)
508 if ($range->getPoints() > $max)
510 $max = $range->getPoints();
528 foreach ($this->ranges as $key => $range)
530 if ($range->getPoints() > $max)
532 $max = $range->getPoints();
554 $found_values = array();
559 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
560 $ilDB->quote($active_id .
""),
561 $ilDB->quote($this->
getId() .
""),
562 $ilDB->quote(
$pass .
"")
564 $result = $ilDB->query($query);
565 $data = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
567 $enteredvalue =
$data[
"value1"];
570 foreach ($this->ranges as $key => $range)
574 if ($range->contains($enteredvalue))
602 include_once
"./Modules/Test/classes/class.ilObjTest.php";
606 $numeric_result = str_replace(
",",
".",$_POST[
"numeric_result"]);
608 include_once
"./Services/Math/classes/class.EvalMath.php";
610 $math->suppress_errors = TRUE;
611 $result = $math->evaluate($numeric_result);
616 $returnvalue =
false;
618 $query = sprintf(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
619 $ilDB->quote($active_id .
""),
620 $ilDB->quote($this->
getId() .
""),
621 $ilDB->quote(
$pass .
"")
623 $result = $ilDB->query($query);
624 $row = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
625 $update = $row->solution_id;
628 if (strlen($numeric_result))
630 $query = sprintf(
"UPDATE tst_solutions SET value1 = %s WHERE solution_id = %s",
631 $ilDB->quote(trim($numeric_result)),
632 $ilDB->quote($update)
634 $result = $ilDB->query($query);
639 $query = sprintf(
"DELETE FROM tst_solutions WHERE solution_id = %s",
640 $ilDB->quote($update)
642 $result = $ilDB->query($query);
647 if (strlen($numeric_result))
649 $query = sprintf(
"INSERT INTO tst_solutions (solution_id, active_fi, question_fi, value1, value2, pass, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, %s, NULL)",
650 $ilDB->quote($active_id),
651 $ilDB->quote($this->
getId()),
652 $ilDB->quote(trim($numeric_result)),
653 $ilDB->quote(
$pass .
"")
655 $result = $ilDB->query($query);
661 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
669 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
729 return "qpl_question_numeric";
763 include_once (
"./classes/class.ilExcelUtils.php");
769 if (strlen($solutions[0][
"value1"]))
774 return $startrow + $i + 1;