moodleou / moodle-quiz_answersheets

A Moodle quiz report to allow quiz attempts to be exported
8 stars 15 forks source link

Multichoice questions render only with radio buttons as qtype_multichoice_single_renderer #31

Open leozelion opened 3 years ago

leozelion commented 3 years ago

Hi! The class qtype_multichoice_override_renderer extends core qtype_multichoice_single_renderer and can only render multichoice question with single right answer, so every question renders with radio-inputs. As an option, you can extend qtype_multichoice_multi_renderer class below and add condition in utils::get_question_renderer()

timhunt commented 3 years ago

Yes, this is a bug, and the necessary fix will be something like that. Patches welcome if you have time.

joe-baudisch commented 2 years ago

mod/quiz/report/answersheets/classes/output/multichoice/renderer.php inherits from qtype_multichoice_single_renderer

but you can overwrite the question type if you insert following lines, right after you get the input attributes:

        global $DB;
        $questionid = $qa->get_question_id();
        $specific_type = $DB->get_record('qtype_multichoice_options', ['questionid' => $questionid], 'single', MUST_EXIST);
        if ($specific_type->single == 0){
            $inputattributes['type'] = 'checkbox';
        }

This fix renders a radio button if it is a single multichoice and renders a checkbox if it is not a single multichoice.

I created a pull request on this issue: https://github.com/moodleou/moodle-quiz_answersheets/pull/32