answer; } public function setAnswer($val) { $this->answer = $val; } public function getCorrect() { return $this->correct; } public function setCorrect($val) { $this->correct = $val; } public function getResult() { $score = 0; $tot = 0; foreach (split(":", $this->getCorrect()) as $correct_element) { if ($correct_element) { $score++; } $tot++; } $percent = round(100*$score/$tot); return $score." punkti ".$tot."-st, ".$percent."%"; } public function save() { global $kdb; $aid = $this->getAnswerID(); parent::save(); if ( $aid == null ) { $sql = "INSERT INTO ".$this->table." values(".$this->getAnswerID().", '".mysql_real_escape_string($this->answer)."', '".mysql_real_escape_string($this->correct)."')"; $kdb->query($sql); } else { // update answer } } } ?>