/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $data = $ilDB->queryF("SELECT value1+1 as value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (\n\t\t\t\tSELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s\n\t\t\t)", array("integer", "integer", "integer", "integer", "integer", "integer"), array($active_id, $pass, $this->getId(), $active_id, $pass, $this->getId())); while ($row = $ilDB->fetchAssoc($data)) { $result->addKeyValue($row["value1"], $row["value1"]); } $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $maxStep = $this->lookupMaxStep($active_id, $pass); if ($maxStep !== null) { $data = $ilDB->queryF("SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s", array("integer", "integer", "integer", 'integer'), array($active_id, $pass, $this->getId(), $maxStep)); } else { $data = $ilDB->queryF("SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s", array("integer", "integer", "integer"), array($active_id, $pass, $this->getId())); } while ($row = $ilDB->fetchAssoc($data)) { if (strstr($row["value1"], '$r') && $row["value2"] != null) { $result->addKeyValue(str_replace('$r', "", $row["value1"]), $row["value2"]); } } $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $maxStep = $this->lookupMaxStep($active_id, $pass); if ($maxStep !== null) { $data = $ilDB->queryF("SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s ORDER BY solution_id", array("integer", "integer", "integer", "integer"), array($active_id, $pass, $this->getId(), $maxStep)); } else { $data = $ilDB->queryF("SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s ORDER BY solution_id", array("integer", "integer", "integer"), array($active_id, $pass, $this->getId())); } for ($index = 1; $index <= $ilDB->numRows($data); ++$index) { $row = $ilDB->fetchAssoc($data); $result->addKeyValue($index, $row["value1"]); } $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $data = $ilDB->queryF("SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (\n\t\t\t\tSELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s\n\t\t\t) ORDER BY value1 ASC ", array("integer", "integer", "integer", "integer", "integer", "integer"), array($active_id, $pass, $this->getId(), $active_id, $pass, $this->getId())); $elements = array(); while ($row = $ilDB->fetchAssoc($data)) { $newKey = explode(":", $row["value2"]); foreach ($this->getAnswers() as $key => $answer) { if ($this->getOrderingType() == OQ_TERMS) { if ($key == $row["value1"]) { $elements[$key] = $row["value2"]; break; } } else { if ($answer->getRandomId() == $newKey[0]) { $elements[$key] = $row["value1"]; break; } } } } ksort($elements); foreach (array_values($elements) as $element) { $result->addKeyValue($element, $element); } $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $data = $ilDB->queryF("SELECT morder FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id", array("integer"), array($this->getId())); $definitions = array(); for ($index = 1; $index <= $ilDB->numRows($data); ++$index) { $row = $ilDB->fetchAssoc($data); $definitions[$row["morder"]] = $index; } $data = $ilDB->queryF("SELECT term_id FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id", array("integer"), array($this->getId())); $terms = array(); for ($index = 1; $index <= $ilDB->numRows($data); ++$index) { $row = $ilDB->fetchAssoc($data); $terms[$row["term_id"]] = $index; } $maxStep = $this->lookupMaxStep($active_id, $pass); if ($maxStep !== null) { $data = $ilDB->queryF("SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s", array("integer", "integer", "integer", "integer"), array($active_id, $pass, $this->getId(), $maxStep)); } else { $data = $ilDB->queryF("SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s", array("integer", "integer", "integer"), array($active_id, $pass, $this->getId())); } while ($row = $ilDB->fetchAssoc($data)) { if ($row["value1"] > 0) { $result->addKeyValue($definitions[$row["value2"]], $terms[$row["value1"]]); } } $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { $result = new ilUserQuestionResult($this, $active_id, $pass); $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $data = $ilDB->queryF("SELECT value1 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = (\n\t\t\t\tSELECT MAX(step) FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s\n\t\t\t)", array("integer", "integer", "integer", "integer", "integer", "integer"), array($active_id, $pass, $this->getId(), $active_id, $pass, $this->getId())); $row = $ilDB->fetchAssoc($data); $answer_elements = $this->splitAndTrimOrderElementText($row["value1"], $this->answer_separator); $elements = $this->getOrderingElements(); $solutions = array(); foreach ($answer_elements as $answer) { foreach ($elements as $key => $element) { if ($element == $answer) { $result->addKeyValue($key + 1, $answer); } } } $glue = " "; if ($this->answer_separator = '{::}') { $glue = ""; } $result->addKeyValue(null, join($glue, $answer_elements)); $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }
/** * Get the user solution for a question by active_id and the test pass * * @param int $active_id * @param int $pass * * @return ilUserQuestionResult */ public function getUserQuestionResult($active_id, $pass) { /** @var ilDB $ilDB */ global $ilDB; $result = new ilUserQuestionResult($this, $active_id, $pass); $maxStep = $this->lookupMaxStep($active_id, $pass); if ($maxStep !== null) { $data = $ilDB->queryF("SELECT sol.value1+1 as val, sol.value2, cloze.cloze_type FROM tst_solutions sol INNER JOIN qpl_a_cloze cloze ON cloze.gap_id = value1 AND cloze.question_fi = sol.question_fi WHERE sol.active_fi = %s AND sol.pass = %s AND sol.question_fi = %s AND sol.step = %s GROUP BY sol.solution_id", array("integer", "integer", "integer", "integer"), array($active_id, $pass, $this->getId(), $maxStep)); } else { $data = $ilDB->queryF("SELECT sol.value1+1 as val, sol.value2, cloze.cloze_type FROM tst_solutions sol INNER JOIN qpl_a_cloze cloze ON cloze.gap_id = value1 AND cloze.question_fi = sol.question_fi WHERE sol.active_fi = %s AND sol.pass = %s AND sol.question_fi = %s GROUP BY sol.solution_id", array("integer", "integer", "integer"), array($active_id, $pass, $this->getId())); } while ($row = $ilDB->fetchAssoc($data)) { if ($row["cloze_type"] == 1) { $row["value2"]++; } $result->addKeyValue($row["val"], $row["value2"]); } $points = $this->calculateReachedPoints($active_id, $pass); $max_points = $this->getMaximumPoints(); $result->setReachedPercentage($points / $max_points * 100); return $result; }