correct; } public function setCorrect($val) { $this->correct = $val; } public function getAnswer() { return $this->answer; } public function getAnswerArray() { return unserialize($this->answer); } public function setAnswer($val) { $this->answer = $val; } /*public function getAnswerById($aid) { foreach (split(";", $this->getAnswer()) as $answer_element){ $a = split(":", $answer_element); if (is_array($a)){ if ($a[0]==$aid){ if ($a[1]==""){return "_";} return $a[1]; } } } return false; }*/ /*public function getCorrectById($cid) { foreach (split(";", $this->getCorrect()) as $correct_element){ $a = split(":", $correct_element); if (is_array($a)){ if ($a[0]==$cid){ return $a[1]; } } } return false; }*/ public function getResult() { $aData = unserialize($this->getAnswer()); $score = $aData['points']; $tot = $aData['rows']; $percent = round(100*$score/$tot); return $score." punkti ".$tot."-st, ".$percent."%"; } public function save() { global $kdb; $aid = $this->getAnswerID(); parent::save(); if ( $aid == null ) { $aData = $this->getAnswer(); $aPoints = $aData['points']; $sql = "INSERT INTO ".$this->table." values(".$this->getAnswerID().", '".serialize($aData)."', '".$aPoints."')"; $kdb->query($sql); } else { // update answer } } } ?>