protected function validate_question_data($question) {
        $this->validate_text($question->questiontext); // Yes, really no ['text'].

        if (isset($question->generalfeedback['text'])) {
            $this->validate_text($question->generalfeedback['text']);
        } else if (isset($question->generalfeedback)) {
            $this->validate_text($question->generalfeedback); // Because question import is weird.
        }

        foreach ($question->answer as $key => $answer) {
            $this->validate_answer($answer);
            $this->validate_text($question->feedback[$key]['text']);
        }
    }
protected function validate_question_data($question) {
        $this->validate_text($question->questiontext); // Yes, really no ['text'].

        if (isset($question->generalfeedback['text'])) {
            $this->validate_text($question->generalfeedback['text']);
        } else if (isset($question->generalfeedback)) {
            $this->validate_text($question->generalfeedback); // Because question import is weird.
        }

        foreach ($question->answer as $key => $answer) {
            $this->validate_answer($answer);
            $this->validate_text($question->feedback[$key]['text']);
        }
    }
protected function validate_question_data ( $ question ) { $ this -> validate_text ( $ question -> questiontext ) ; // Yes, really no ['text']. if ( isset ( $ question -> generalfeedback [ 'text' ] ) ) { $ this -> validate_text ( $ question -> generalfeedback [ 'text' ] ) ; } else if ( isset ( $ question -> generalfeedback ) ) { $ this -> validate_text ( $ question -> generalfeedback ) ; // Because question import is weird. } foreach ( $ question -> answer as $ key => $ answer ) { $ this -> validate_answer ( $ answer ) ; $ this -> validate_text ( $ question -> feedback [ $ key ] [ 'text' ] ) ; } }
Validate data before save.
@param stdClass $question data from the form / import file.
Validate data before save .