/**
  * @param ilUserQuestionResult $result
  * @param string               $comperator
  * @param null					$index
  *
  * @return bool
  */
 public function checkResult($result, $comperator, $index = null)
 {
     $percentage = $result->getReachedPercentage();
     switch ($comperator) {
         case "<":
             return $percentage < $this->getNumericValue();
             break;
         case "<=":
             return $percentage <= $this->getNumericValue();
             break;
         case "=":
             return $percentage == $this->getNumericValue();
             break;
         case ">=":
             return $percentage >= $this->getNumericValue();
             break;
         case ">":
             return $percentage > $this->getNumericValue();
             break;
         case "<>":
             return $percentage != $this->getNumericValue();
             break;
         default:
             return false;
     }
 }
 /**
  * @param ilUserQuestionResult $result
  * @param string $comperator
  * @param null|int $index
  *
  * @return bool
  */
 public function checkResult($result, $comperator, $index = null)
 {
     if ($index == null) {
         switch ($comperator) {
             case "=":
                 return !$result->hasSolutions();
                 break;
             case "<>":
                 return $result->hasSolutions();
                 break;
             default:
                 return false;
         }
     } else {
         $solution = $result->getSolutionForKey($index);
         switch ($comperator) {
             case "=":
                 return $solution == null;
                 break;
             case "<>":
                 return $solution != null;
                 break;
             default:
                 return false;
         }
     }
 }
 /**
  * @param ilUserQuestionResult $result
  * @param string $comperator
  * @param null|int $index
  *
  * @return bool
  */
 public function checkResult($result, $comperator, $index = null)
 {
     $isTrue = false;
     if ($index == null) {
         $values = $result->getUserSolutionsByIdentifier("key");
         foreach ($values as $value) {
             $isTrue = $isTrue || $this->compare($comperator, $value);
         }
     } else {
         $solution = $result->getSolutionForKey($index);
         $isTrue = $this->compare($comperator, $solution["value"]);
     }
     return $isTrue;
 }
 /**
  * @param ilUserQuestionResult $result
  * @param string $comperator
  * @param null|int $index
  *
  * @return bool
  */
 public function checkResult($result, $comperator, $index = null)
 {
     $values = $result->getUserSolutionsByIdentifier("value");
     $exclusive = $this->getExclusive();
     sort($values);
     sort($exclusive);
     switch ($comperator) {
         case "=":
             return $values == $exclusive;
             break;
         case "<>":
             return $values != $exclusive;
             break;
         default:
             return false;
     }
 }
 /**
  * @param ilUserQuestionResult $result
  * @param string               $comperator
  * @param null|int				$index
  *
  * @return bool
  */
 public function checkResult($result, $comperator, $index = null)
 {
     $keys = $result->getUserSolutionsByIdentifier("key");
     $keys = array_filter($keys, function ($element) {
         return $element != null;
     });
     switch ($comperator) {
         case "=":
             return $keys == $this->getOrdering();
             break;
         case "<>":
             return $keys != $this->getOrdering();
             break;
         default:
             return false;
     }
 }
 /**
  * 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;
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
Exemplo n.º 8
0
 /**
  * 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);
     $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;
 }
Exemplo n.º 10
0
 /**
  * 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;
 }
 /**
  * @param ilUserQuestionResult $result
  * @param string               $comperator
  * @param null|int				$index
  *
  * @return bool
  */
 public function checkResult($result, $comperator, $index = null)
 {
     $solutions = $result->getSolutions();
     $isTrue = false;
     foreach ($solutions as $solution) {
         $isTrue = $isTrue || $this->compare($comperator, $solution["key"], $solution["value"]);
     }
     return $isTrue;
 }
Exemplo n.º 12
0
 /**
  * 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;
 }
Exemplo n.º 14
0
 /**
  * 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;
 }