About Multiple Choice Questions (v1.9+)

About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -
Number of replies: 18

I want to create a question in multiple choice format. There are some problems i can't solve:

  • There is not any option for unselect the selected option.
  • When student has empty value for a question, end of quiz moodle displaying it's value as "wrong response" but it's not wrong, it must be empty.
  • There is not any option for negative values for i saw in the forum it has discussed a lot of time but not solved any of Moodle expert. But it must and must be.

Thanks.

Average of ratings: -
In reply to MERT DOĞAN

Re: About Multiple Choice Questions (v1.9+)

by Adriane Boyd -
Regarding your first two points:

Short answer: you can get around these problems by adding a "none of the above" option to your questions.

Long answer: for all question types, you need to check/select/edit something in the question so that the quiz will recognize that you attempted the question and then know that it should grade it. Otherwise, as you saw, you always get no credit for the question. Because of this, a non-response isn't a valid response for a question in moodle. This helps reduce the server load because moodle can skip grading for questions that you haven't attempted.

You shouldn't be able to add a multiple choice question to the question bank unless it's possible for the student to get 100% with some combination of answers. How did you add questions where all answers give 0%? It's possible there's a bug in one of the import formats that let you import questions like this. (Or maybe the import functions aren't intended to do this check? I'm not totally sure.)

The issue with not being to deselect radio buttons happens in all HTML forms, not just moodle. Once you have a "none of the above" option, it shouldn't be a problem if a student accidentally clicks on one of the options because they can always change their answer to some option that gives 100%, whether it's the "none of the above" one or one of the other answers.

Hope this helps,
Adriane
In reply to Adriane Boyd

Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

Ok but i have another question set about "none of above":

  • When i set "none of other" choice, it's still getting result page "wrong answer". Isn't it true or may i do something wrong?
  • I have questions that they have 5 options for choice. I want to set 6. option for "none of above" option and i want it selected default. How can i do that?

Thanks.

In reply to MERT DOĞAN

Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Adriane Boyd -
I don't think I understand what you're trying to describe in your first point. A screenshot might help clarify if you're still having trouble.

There's no built-in way to have a particular option selected as the default. If you're willing to modify multiple choice questions for your whole moodle site, it's probably not too hard to have a response that matches a particular string like "none of the above" selected by default. You'd need to make sure that if the student had already selected something, you don't accidentally change switch it back to "none of the above", but it's certainly doable. I don't know if you're a programmer, but if you are, check out how $checked is defined for $a->control in the for loop around line 282 of questiontype.php.

-Adriane
In reply to MERT DOĞAN

Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
MERT

When i set "none of other" choice, it's still getting result page "wrong answer". Isn't it true or may i do something wrong?

That is not possible. Of course when you create your question you must set "None of the above" as the only correct answer, worth 100% of the score. Did you do that? See attached example.
Joseph
Attachment image01.jpg
In reply to Joseph Rézeau

Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

U don't understood me. I don't want like this.

My question have to look like this:

What is moodle?

a. animal
b. LMS
c. car
(clear selection)

Student selected an option by mistake but he don't knows correct answer and he want to clear his selection. And he will select (clear selection) but this answer musn't be correct option. It must be only empty.

Hope this ok?

In reply to MERT DOĞAN

Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by hon wai lau -
What do you want to do actually? When you click the none-of-above, it has the exactly same effect of clearing all the option above.

The main different between a selected button or a non-selected button is whether the students have clicked something intentionally (i.e. whether it is answered).

If you want to allow correct answer as something non-selected, the student can get marks without seeing any question surprise. It is not much different from a quiz without all MC prefilled with random options and students get 20% marks for doing nothing.

Even if he don't know the correct answer, he will still randomly click one of them. What is the point of allowing them to click the clear button (almost the same as none of above)? Well, I think the only reason is that you want to give an option for the students to get 0 mark by unchecking all of them.
In reply to hon wai lau

Ynt: Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

Do you know "Feedback" module? When you a add multiple choice question to activity, it automatically adds an option named "not selected" to the top of the question. I want a feature like this.

In reply to MERT DOĞAN

Re: Ynt: Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi MERT,
We understand what you want but... we do not understand why you want it. Please explain your rationale.
Joseph
In reply to Joseph Rézeau

Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

Hi Joseph. I want this because our students are selecting an option by mistake and then they want to unselect their selected radio button option.

But when nobody unswered this question, i've solved my problem myself. Thanks again, our students can easily unselect their selected radio button now.

In reply to MERT DOĞAN

Re: Ynt: Re: Ynt: Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Timothy Zuellig -
The problem, Mert, is that radio buttons are toggles (on/off) only. So, if they select "A" and it is the wrong answer, clicking on it again doesn't turn off that they selected "A." Clicking on another radio button answer (say, "C") will turn off answer A and select answer C. If none of the above (A,B,C, or D, for example) are correct, people are telling you that the only correct answer can be "E," None of the Above. So, the student has to select something. All they need to do if they select the incorrect answer first by accident is click on the correct answer.
In reply to Adriane Boyd

Re: About Multiple Choice Questions (v1.9+)

by Venkat V -
I have actually seen some websites which were developed using moodle, where deselection of radio button happens on double click of the button.

That is,

First click on the radio button selects it and the second click deselects it instead of retaining the selected state.

Ex: careerlauncher.com

Please let me know if there is anyway of doing it in my website.

Thanks
In reply to Venkat V

Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

I've solved my problem myself with playing with source code.

in questiontypes -> multichoice folder:

display.html

...
...
...
<div class="ablock clearfix">
  <div class="prompt">
    <?php echo $answerprompt; ?>
  </div>
  <table class="answer">
  <caption><i>Double click selected option for unselect.</i></caption>
    <?php $row = 1; foreach ($anss as $answer) { ?>
      <tr class="<?php echo 'r'.$row = $row ? 0 : 1; ?>">
        <td class="c0 control">
          <?php echo $answer->control; ?>
        </td>
        <td class="c1 text <?php echo $answer->class ?>">
          <label for="<?php echo $answer->id ?>">
            <?php echo $answer->text; ?>
            <?php echo $answer->feedbackimg; ?>
...
...
...


in questiontype.php

...
...
...
        $answerprompt = ($question->options->single) ? get_string('singleanswer', 'quiz') :
            get_string('multipleanswers', 'quiz');
        // Print each answer in a separate row
        foreach ($state->options->order as $key => $aid) {
            $answer = &$answers[$aid];
            $checked = '';
            $chosen = false;
            if ($question->options->single) {
                $type = 'type="radio"';
                $name   = "name=\"{$question->name_prefix}\"";
    $unchecktext='onDblClick="this.checked=false;"';
                if (isset($state->responses['']) and $aid == $state->responses['']) {
                    $checked = 'checked="checked"';
                    $chosen = true;
                }
            } else {
                $type = ' type="checkbox" ';
                $name   = "name=\"{$question->name_prefix}{$aid}\"";
                $unchecktext='';
    if (isset($state->responses[$aid])) {
                    $checked = 'checked="checked"';
                    $chosen = true;
                }
            }
            $a = new stdClass;
            $a->id   = $question->name_prefix . $aid;
            $a->class = '';
            $a->feedbackimg = '';
   
            // Print the control
            $a->control = "<input $readonly id=\"$a->id\" $name $checked $type $unchecktext value=\"$aid\" />";
            if ($options->correct_responses && $answer->fraction > 0) {
                $a->class = question_get_feedback_class(1);
            }
            if (($options->feedback && $chosen) || $options->correct_responses) {
                if ($type == ' type="checkbox" ') {
                    $a->feedbackimg = question_get_feedback_image($answer->fraction > 0 ? 1 : 0, $chosen && $options->feedback);
                } else {
                    $a->feedbackimg = question_get_feedback_image($answer->fraction, $chosen && $options->feedback);
                }
            }
...
...
...

bold areas are my changes.

I hope this have to help.

In reply to MERT DOĞAN

Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Venkat V -
Hi,

Thanks for your help but it does not seem to be working for me. I do get the changes whcih you have made in display but the important change which is the deselction of radio buttons on double click is not working for me. Have you tested it already? if yes, have you missed out something in the post here?

Please help ASAP.

Thanks
Venkat
In reply to Venkat V

Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Venkat V -
Guys, I also have another question. Dint know where to post. So postingit here. In the quiz navigation panel, we generate hyperlinks for various pages + next link for the next page + previous link for the previous page. My question is how do i convert the next and previous hyperlinks to buttons like "Submit all and finish" button.

Thanks
Venkat
In reply to Venkat V

Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

No! I don't missed any file.

If you have some trouble, contact me with my personal e-mail address mertdogan at hotmail.com ; i can help you.

In reply to MERT DOĞAN

Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by MERT DOĞAN -

I have a problem in my code:

$unchecktext='XonDblClick="this.checked=false;"';

must be

$unchecktext='onDblClick="this.checked=false;"';

the X character is obselete.

In reply to MERT DOĞAN

Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Ram M -

I had the same issue.

The basic idea is to use a button which will reset the form

This was the HTML code I used:

<button type='reset'>Clear my Response</button>

Hope it helps!

In reply to Ram M

Re: Ynt: Re: Ynt: Re: About Multiple Choice Questions (v1.9+)

by Ankush K -
Hey Ram, This sounds as the most sincere and simple solution.

Can you please tell me, where you exactly inserted this (which files to edit), this might very well be the temporary fix to MDL-5311