<commit_before><?php
namespace Vispanlab\SiteBundle\Entity\Exercise;

use Doctrine\ORM\Mapping as ORM;

/**
 * @author <NAME> <<EMAIL>>
 * @ORM\Entity
 */
class MultipleChoice extends BaseExercise {
    /**
     * @ORM\Column (name="question", type="string", length=255)
     */
    protected $question;
    /**
     * @ORM\Column (name="answers", type="json")
     */
    protected $answers = array();
    /**
     * @ORM\Column (name="show_in_evaluation_test", type="integer")
     */
    protected $showInEvaluationTest;

    public function getQuestion() {
        return $this->question;
    }

    public function setQuestion($question) {
        $this->question = $question;
    }

    public function getAnswers() {
        return $this->answers;
    }

    public function setAnswers($answers) {
        $this->answers = $answers;
    }

    public function getCorrectAnswer() {
        foreach($this->answers as $i => $curAnswer) {
            if(isset($curAnswer['is_correct']) && $curAnswer['is_correct'] == true) {
                return ($i+1);
            }
        }
    }

    public function setCorrectAnswer($i) {
        foreach($this->answers as &$curAnswer) {
            unset($curAnswer['is_correct']);
        }
        if(!isset($this->answers[$i])) { echo 'Ο αριθμός της σωστής απάντησης δεν υπάρχει'; die(); }
        $this->answers[$i]['is_correct'] = true;
    }

    public function getShowInEvaluationTest() {
        return $this->showInEvaluationTest;
    }

    public function setShowInEvaluationTest($showInEvaluationTest) {
        $this->showInEvaluationTest = $showInEvaluationTest;
    }
<commit_msg>Multiple choice get correct answer fix<commit_after><?php
namespace Vispanlab\SiteBundle\Entity\Exercise;

use Doctrine\ORM\Mapping as ORM;

/**
 * @author <NAME> <<EMAIL>>
 * @ORM\Entity
 */
class MultipleChoice extends BaseExercise {
    /**
     * @ORM\Column (name="question", type="string", length=255)
     */
    protected $question;
    /**
     * @ORM\Column (name="answers", type="json")
     */
    protected $answers = array();
    /**
     * @ORM\Column (name="show_in_evaluation_test", type="integer")
     */
    protected $showInEvaluationTest;

    public function getQuestion() {
        return $this->question;
    }

    public function setQuestion($question) {
        $this->question = $question;
    }

    public function getAnswers() {
        return $this->answers;
    }

    public function setAnswers($answers) {
        $this->answers = $answers;
    }

    public function getCorrectAnswer() {
        foreach($this->answers as $i => $curAnswer) {
            if(isset($curAnswer['is_correct']) && $curAnswer['is_correct'] == true) {
                return $i;
            }
        }
    }

    public function setCorrectAnswer($i) {
        foreach($this->answers as &$curAnswer) {
            unset($curAnswer['is_correct']);
        }
        if(!isset($this->answers[$i])) { echo 'Ο αριθμός της σωστής απάντησης δεν υπάρχει'; die(); }
        $this->answers[$i]['is_correct'] = true;
    }

    public function getShowInEvaluationTest() {
        return $this->showInEvaluationTest;
    }

    public function setShowInEvaluationTest($showInEvaluationTest) {
        $this->showInEvaluationTest = $showInEvaluationTest;
    }

{'fraction_non_alphanumeric': 0.1450196790796246, 'fraction_numerical': 0.002119285498032092, 'mean_word_length': 2.6875, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1789821', 'n_tokens_mistral': 1106, 'n_tokens_neox': 993, 'n_words': 191}