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

Update renderer.php #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

joe-baudisch
Copy link

@joe-baudisch joe-baudisch commented Nov 8, 2021

Fixing
#31

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.
I explicitly commented the lines of code only here.

        global $DB;
        // every question has its unique id
        $questionid = $qa->get_question_id();
        //   Because we have a multicoice question, it is either a single and therefore is rendered originally as radio-button
        //   or it is a not a single, because more than one answer is possible, then it is originally rendered as checkbox.
        //   the type can be retrieved from the database table  qtype_multichoice_options
        $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.

@timhunt
Copy link
Member

timhunt commented Nov 8, 2021

Please can you writea proper commit comment to explain what the fix is doing.

@joe-baudisch
Copy link
Author

Please can you writea proper commit comment to explain what the fix is doing.

Do you need more comments?
Thanks, Joe

dmitriim added a commit to dmitriim/moodle-quiz_answersheets that referenced this pull request Feb 28, 2023
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

Successfully merging this pull request may close these issues.

2 participants