Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multichoice questions render only with radio buttons as qtype_multichoice_single_renderer #31

Open
leozelion opened this issue Jun 23, 2021 · 2 comments

Comments

@leozelion
Copy link

leozelion commented Jun 23, 2021

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
Copy link
Member

timhunt commented Jun 23, 2021

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

joe-baudisch pushed a commit to joe-baudisch/moodle-quiz_answersheets that referenced this issue Nov 8, 2021
@joe-baudisch
Copy link

joe-baudisch commented Nov 8, 2021

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:
#32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants