protected function process_fblank($quest, &$questions) {
        $question = $this->process_common($quest);
        $question->qtype = 'shortanswer';
        $question->usecase = 0; // Ignore case.

        $answers = array();
        $fractions = array();
        $feedbacks = array();

        // Extract the feedback.
        $feedback = array();
        foreach ($quest->feedback as $fback) {
            if (isset($fback->ident)) {
                if ($fback->ident == 'correct' || $fback->ident == 'incorrect') {
                    $feedback[$fback->ident] = $fback->text;
                }
            }
        }

        foreach ($quest->responses as $response) {
            if (isset($response->title)) {
                if ($this->getpath($response->ident[0],
                        array('varequal', 0, '#'), false, false)) {
                    // For BB Fill in the Blank, only interested in correct answers.
                    if ($response->feedback = 'correct') {
                        $answers[] = $this->getpath($response->ident[0],
                                array('varequal', 0, '#'), '', true);
                        $fractions[] = 1;
                        if (isset($feedback['correct'])) {
                            $feedbacks[] = $this->cleaned_text_field($feedback['correct']);
                        } else {
                            $feedbacks[] = $this->text_field('');
                        }
                    }
                }

            }
        }

        // Adding catchall to so that students can see feedback for incorrect answers when they enter something,
        // the instructor did not enter.
        $answers[] = '*';
        $fractions[] = 0;
        if (isset($feedback['incorrect'])) {
            $feedbacks[] = $this->cleaned_text_field($feedback['incorrect']);
        } else {
            $feedbacks[] = $this->text_field('');
        }

        $question->answer = $answers;
        $question->fraction = $fractions;
        $question->feedback = $feedbacks; // Changed to assign $feedbacks to $question->feedback instead of.

        if (!empty($question)) {
            $questions[] = $question;
        }

    }
protected function process_fblank($quest, &$questions) {
        $question = $this->process_common($quest);
        $question->qtype = 'shortanswer';
        $question->usecase = 0; // Ignore case.

        $answers = array();
        $fractions = array();
        $feedbacks = array();

        // Extract the feedback.
        $feedback = array();
        foreach ($quest->feedback as $fback) {
            if (isset($fback->ident)) {
                if ($fback->ident == 'correct' || $fback->ident == 'incorrect') {
                    $feedback[$fback->ident] = $fback->text;
                }
            }
        }

        foreach ($quest->responses as $response) {
            if (isset($response->title)) {
                if ($this->getpath($response->ident[0],
                        array('varequal', 0, '#'), false, false)) {
                    // For BB Fill in the Blank, only interested in correct answers.
                    if ($response->feedback = 'correct') {
                        $answers[] = $this->getpath($response->ident[0],
                                array('varequal', 0, '#'), '', true);
                        $fractions[] = 1;
                        if (isset($feedback['correct'])) {
                            $feedbacks[] = $this->cleaned_text_field($feedback['correct']);
                        } else {
                            $feedbacks[] = $this->text_field('');
                        }
                    }
                }

            }
        }

        // Adding catchall to so that students can see feedback for incorrect answers when they enter something,
        // the instructor did not enter.
        $answers[] = '*';
        $fractions[] = 0;
        if (isset($feedback['incorrect'])) {
            $feedbacks[] = $this->cleaned_text_field($feedback['incorrect']);
        } else {
            $feedbacks[] = $this->text_field('');
        }

        $question->answer = $answers;
        $question->fraction = $fractions;
        $question->feedback = $feedbacks; // Changed to assign $feedbacks to $question->feedback instead of.

        if (!empty($question)) {
            $questions[] = $question;
        }

    }
protected function process_fblank ( $ quest , & $ questions ) { $ question = $ this -> process_common ( $ quest ) ; $ question -> qtype = 'shortanswer' ; $ question -> usecase = 0 ; // Ignore case. $ answers = array ( ) ; $ fractions = array ( ) ; $ feedbacks = array ( ) ; // Extract the feedback. $ feedback = array ( ) ; foreach ( $ quest -> feedback as $ fback ) { if ( isset ( $ fback -> ident ) ) { if ( $ fback -> ident == 'correct' || $ fback -> ident == 'incorrect' ) { $ feedback [ $ fback -> ident ] = $ fback -> text ; } } } foreach ( $ quest -> responses as $ response ) { if ( isset ( $ response -> title ) ) { if ( $ this -> getpath ( $ response -> ident [ 0 ] , array ( 'varequal' , 0 , '#' ) , false , false ) ) { // For BB Fill in the Blank, only interested in correct answers. if ( $ response -> feedback = 'correct' ) { $ answers [ ] = $ this -> getpath ( $ response -> ident [ 0 ] , array ( 'varequal' , 0 , '#' ) , '' , true ) ; $ fractions [ ] = 1 ; if ( isset ( $ feedback [ 'correct' ] ) ) { $ feedbacks [ ] = $ this -> cleaned_text_field ( $ feedback [ 'correct' ] ) ; } else { $ feedbacks [ ] = $ this -> text_field ( '' ) ; } } } } } // Adding catchall to so that students can see feedback for incorrect answers when they enter something, // the instructor did not enter. $ answers [ ] = '*' ; $ fractions [ ] = 0 ; if ( isset ( $ feedback [ 'incorrect' ] ) ) { $ feedbacks [ ] = $ this -> cleaned_text_field ( $ feedback [ 'incorrect' ] ) ; } else { $ feedbacks [ ] = $ this -> text_field ( '' ) ; } $ question -> answer = $ answers ; $ question -> fraction = $ fractions ; $ question -> feedback = $ feedbacks ; // Changed to assign $feedbacks to $question->feedback instead of. if ( ! empty ( $ question ) ) { $ questions [ ] = $ question ; } }
Process Fill in the Blank Questions
Parse a fillintheblank rawquestion and add the result
to the array of questions already parsed.
@param object $quest rawquestion
@param array $questions array of Moodle questions already done.
Process Fill in the Blank Questions Parse a fillintheblank rawquestion and add the result to the array of questions already parsed .