public function clear_wrong(question_attempt $qa, $reallyclear = true) {
        $question = $qa->get_question();
        $response = $qa->get_last_qt_data();

        if (!empty($response) && $reallyclear) {
            $cleanresponse = $question->clear_wrong_from_response($response);
        } else {
            $cleanresponse = $response;
        }

        $output = '';
        foreach ($question->places as $place => $group) {
            $fieldname = $question->field($place);
            if (array_key_exists($fieldname, $response)) {
                $value = (string) $response[$fieldname];
            } else {
                $value = '0';
            }
            if (array_key_exists($fieldname, $cleanresponse)) {
                $cleanvalue = (string) $cleanresponse[$fieldname];
            } else {
                $cleanvalue = '0';
            }
            if ($cleanvalue === $value) {
                // Normal case: just one hidden input, to store the
                // current value and be the value submitted.
                $output .= html_writer::empty_tag('input', array(
                        'type' => 'hidden',
                        'id' => $this->box_id($qa, 'p' . $place),
                        'class' => 'placeinput place' . $place . ' group' . $group,
                        'name' => $qa->get_qt_field_name($fieldname),
                        'value' => s($value)));
            } else {
                // The case, which only happens when the question is read-only, where
                // we want to show the drag item in a given place (first hidden input),
                // but when submitted, we want it to go to a different place (second input).
                $output .= html_writer::empty_tag('input', array(
                        'type' => 'hidden',
                        'id' => $this->box_id($qa, 'p' . $place),
                        'class' => 'placeinput place' . $place . ' group' . $group,
                        'value' => s($value))) .
                        html_writer::empty_tag('input', array(
                        'type' => 'hidden',
                        'name' => $qa->get_qt_field_name($fieldname),
                        'value' => s($cleanvalue)));
            }
        }
        return $output;
    }
public function clear_wrong(question_attempt $qa, $reallyclear = true) {
        $question = $qa->get_question();
        $response = $qa->get_last_qt_data();

        if (!empty($response) && $reallyclear) {
            $cleanresponse = $question->clear_wrong_from_response($response);
        } else {
            $cleanresponse = $response;
        }

        $output = '';
        foreach ($question->places as $place => $group) {
            $fieldname = $question->field($place);
            if (array_key_exists($fieldname, $response)) {
                $value = (string) $response[$fieldname];
            } else {
                $value = '0';
            }
            if (array_key_exists($fieldname, $cleanresponse)) {
                $cleanvalue = (string) $cleanresponse[$fieldname];
            } else {
                $cleanvalue = '0';
            }
            if ($cleanvalue === $value) {
                // Normal case: just one hidden input, to store the
                // current value and be the value submitted.
                $output .= html_writer::empty_tag('input', array(
                        'type' => 'hidden',
                        'id' => $this->box_id($qa, 'p' . $place),
                        'class' => 'placeinput place' . $place . ' group' . $group,
                        'name' => $qa->get_qt_field_name($fieldname),
                        'value' => s($value)));
            } else {
                // The case, which only happens when the question is read-only, where
                // we want to show the drag item in a given place (first hidden input),
                // but when submitted, we want it to go to a different place (second input).
                $output .= html_writer::empty_tag('input', array(
                        'type' => 'hidden',
                        'id' => $this->box_id($qa, 'p' . $place),
                        'class' => 'placeinput place' . $place . ' group' . $group,
                        'value' => s($value))) .
                        html_writer::empty_tag('input', array(
                        'type' => 'hidden',
                        'name' => $qa->get_qt_field_name($fieldname),
                        'value' => s($cleanvalue)));
            }
        }
        return $output;
    }
public function clear_wrong ( question_attempt $ qa , $ reallyclear = true ) { $ question = $ qa -> get_question ( ) ; $ response = $ qa -> get_last_qt_data ( ) ; if ( ! empty ( $ response ) && $ reallyclear ) { $ cleanresponse = $ question -> clear_wrong_from_response ( $ response ) ; } else { $ cleanresponse = $ response ; } $ output = '' ; foreach ( $ question -> places as $ place => $ group ) { $ fieldname = $ question -> field ( $ place ) ; if ( array_key_exists ( $ fieldname , $ response ) ) { $ value = ( string ) $ response [ $ fieldname ] ; } else { $ value = '0' ; } if ( array_key_exists ( $ fieldname , $ cleanresponse ) ) { $ cleanvalue = ( string ) $ cleanresponse [ $ fieldname ] ; } else { $ cleanvalue = '0' ; } if ( $ cleanvalue === $ value ) { // Normal case: just one hidden input, to store the // current value and be the value submitted. $ output .= html_writer :: empty_tag ( 'input' , array ( 'type' => 'hidden' , 'id' => $ this -> box_id ( $ qa , 'p' . $ place ) , 'class' => 'placeinput place' . $ place . ' group' . $ group , 'name' => $ qa -> get_qt_field_name ( $ fieldname ) , 'value' => s ( $ value ) ) ) ; } else { // The case, which only happens when the question is read-only, where // we want to show the drag item in a given place (first hidden input), // but when submitted, we want it to go to a different place (second input). $ output .= html_writer :: empty_tag ( 'input' , array ( 'type' => 'hidden' , 'id' => $ this -> box_id ( $ qa , 'p' . $ place ) , 'class' => 'placeinput place' . $ place . ' group' . $ group , 'value' => s ( $ value ) ) ) . html_writer :: empty_tag ( 'input' , array ( 'type' => 'hidden' , 'name' => $ qa -> get_qt_field_name ( $ fieldname ) , 'value' => s ( $ cleanvalue ) ) ) ; } } return $ output ; }
Actually, this question type abuses this method to always output the
hidden fields it needs.

@param question_attempt $qa the question attempt.
@param bool $reallyclear whether we are really clearing the responses, or just outputting them.
@return string HTML to output.
Actually this question type abuses this method to always output the hidden fields it needs .