In my cloze question type, ({1:MULTICHOICE:No Idea ~=True ~False}
)how can I replace the drop down menu with radio buttons?
That is, change
to look like this
о No Idea о True о False
(Displayed horizontally)
Thanks
Tieku
Tieku,
As far as I know there is no embedded radio button type question in CLOSE (I’m still on 1.6.3 but I don’t think this has changed). What you can do is add to the question your own radio buttons and set the onBlur event of those radio buttons to copy their value to the Moodle MULTICHOICE field which you can have either visible or hidden. See this post for how it can be done. The example works with SHORTANSWER and if you keep these fields hidden that it might be simpler to construct but you can do that also with the MULTICHOICE in which case you need to manipulate the selectedindex. Also in that example accessing the Moodle field requires to extract its id, but it can be done dynamically by navigating the DOM and you can find an example of that in this post.
Itamar,
I read the post but don't understand what to do. So what would be the equivalanet for
{1:MULTICHOICE:No Idea ~=True ~%-100%False} |
This is how I want the questions diplayed:
Question Here | oNo Idea oTrue oFalse |
Tieku
I will take a look at the code and see whether I can get it to work. How come I see the radio buttons and also the drop down?
The reason why I need “No Idea” is students are penalized for wrong responses. So a student should have an option not answer if he is not sure, or change answer from True or False. So here is how the points are awarded.
No Idea – 0
True +1 or -1
False +1 or -1
Hello Itamar,
Thanks for the help. I am not a programmer and I am not familiar with PHP coding, but if you let me know where exactly everything should be put, I should be able to do it.
Did you understand my explanation for needing radio a button for “No Idea”? I have a separate hack that subtracts a point for incorrect responses (to discourage guessing) so a student who does not want to risk losing a point when they are not sure should have the option of no answering, which is the “No idea” radio button. That is why in Multichoice I have {1:MULTICHOICE:No Idea ~=True ~%-100%False}and
{1:MULTICHOICE:No Idea ~%-100%True ~=False}
Please put all the steps in one reply for me (and where exactly they go):
For example where exactly do I it put the code below:
<script type="text/javascript">
<!--
var sel=document.getElementsByTagName("select");
for (i=0;i<sel.length;i++){
var ind=sel[i].selectedIndex;
if (sel[i].parentNode.parentNode.childNodes[ind].firstChild.type=="radio"){
sel[i].parentNode.parentNode.childNodes[ind].firstChild.checked=true;
}
}
-->
</script>
Tieku
Itamar,
Thanks for the step by step instructions. I will let you know how it goes. I like your suggestion for using Not Sure instead of No Idea.
Itamar,
I coud not get it to work. Please see attached Word file for screenshots. Here is my code for the cloze question:
<table cellspacing="0" cellpadding="0" border="0"><tbody>
<tr>
<td style="padding-right: 20px" valign="top">This is Queston 1
</td>
<td style="background-color: rgb(221,221,221)" valign="top"><input onclick="function anonymous() { function anonymous() { function anonymous() { function anonymous() { function anonymous() { function anonymous() { this.parentNode.parentNode.childNodes[4].firstChild.selectedIndex=1; } } } } } }" type="radio" name="QUE1" />Not Sure
</td>
<td style="background-color: rgb(221,221,221)" valign="top"><input onclick="function anonymous() { function anonymous() { function anonymous() { function anonymous() { function anonymous() { function anonymous() { this.parentNode.parentNode.childNodes[4].firstChild.selectedIndex=2; } } } } } }" type="radio" name="QUE1" />True
</td>
<td style="background-color: rgb(221,221,221)" valign="top"><input onclick="function anonymous() { function anonymous() { function anonymous() { function anonymous() { function anonymous() { function anonymous() { this.parentNode.parentNode.childNodes[4].firstChild.selectedIndex=3; } } } } } }" type="radio" name="QUE1" />False
</td>
<td style="visibility: hidden" valign="top">{:MULTICHOICE:Not Sure#~=True#~%-100%False#}
</td>
</tr></tbody>
</table>
No, I do not use function anonymous for my negative marks hack so I do not know whether it would be interfering with yours.
Here are the 2 files and functions I use:
File: moodle\lib\questionlib.php
function question_apply_penalty_and_timelimit(&$question, &$state, $attempt, $cmoptions) {
// deal with penalty
if ($cmoptions->penaltyscheme) {
$state->grade = $state->raw_grade - $state->sumpenalty;
$state->sumpenalty += (float) $state->penalty;
} else {
$state->grade = $state->raw_grade;
}
// deal with timelimit
if ($cmoptions->timelimit) {
// We allow for 5% uncertainty in the following test
if (($state->timestamp - $attempt->timestart) > ($cmoptions->timelimit * 63)) {
$state->grade = 0;
}
}
// deal with closing time
if ($cmoptions->timeclose and $state->timestamp > ($cmoptions->timeclose + 60) // allowing 1 minute lateness
and !$attempt->preview) { // ignore closing time for previews
$state->grade = 0;
}
/* negative marks hack start: commented the line below
// Ensure that the grade does not go down
$state->grade = max($state->grade, $state->last_graded->grade);
negative marks hack stop */
}
File: moodle\question\type\multichoice\questiontype.php
function grade_responses(&$question, &$state, $cmoptions) {
$answers = $question->options->answers;
$testedstate = clone($state);
$teststate = clone($state);
$state->raw_grade = 0;
foreach($answers as $answer) {
$teststate->responses = array('' => $answer->id);
if($question->options->single) {
if($this->compare_responses($question, $testedstate,
$teststate)) {
$state->raw_grade = $answer->fraction;
break;
}
} else {
foreach($state->responses as $response) {
$testedstate->responses = array('' => $response);
if($this->compare_responses($question, $testedstate,
$teststate)) {
$state->raw_grade += $answer->fraction;
break;
}
}
}
}
if (empty($state->raw_grade)) {
$state->raw_grade = 0;
}
/* negative marks hack start
// Make sure we don't assign negative or too high marks
$state->raw_grade = min(max((float) $state->raw_grade,
0.0), 1.0) * $question->maxgrade; */
$state->raw_grade = min((float) $state->raw_grade, 1.0) * $question->maxgrade;
// Negative marks hack stop
// Apply the penalty for this attempt
$state->penalty = $question->penalty * $question->maxgrade;
// mark the state as graded
$state->event = ($state->event == QUESTION_EVENTCLOSE) ? QUESTION_EVENTCLOSEANDGRADE : QUESTION_EVENTGRADE;
return true;
}
I tried it again from scratch. I realize that when i paste the code for the cloze question in html mode, make all changes (delete X and replace YYYY etc), close it the question editor, and open it again, the function anonymous appears on its own. Where is this coming from?
Looks like someone had the same problem:
http://moodle.org/mod/forum/discuss.php?d=8927
and why is the X put infront of onclick, only to be removed?
This is another question. In the drop down menu for multiple choice in cloze type questions, is there a way of letting the word “Choose…” show the way it does for Matching questions:
Multiple choice cloze:
/stroke>/f>/f>/f>/f>/f>/f>/f>/f>/f>/f>/f>/f>/formulas>/path>/lock>/shapetype>/imagedata>/shape>
Matching
/imagedata>/shape>
Tieku
Dears,
Itamar's solution (first part of it) worked fine with me. But, the 2nd part which should preserve the radio-buttons state didn't work so the radio state is lost after submitting the answer.
When I place the given javascript in a Description Question and let it run as directed in the solution it gives error. It looks that Description Questions don't accept javascrip ?? or some other unknown problem !
Itamar Tzadok replied to an email for me saying there was more work around for this issue was done outside this discussion and he asked me for the link of this discussion session (which I sent it) but no reply for this problem.
Any help !
Thanks,
Pierre,
where is the option in multichoice to format with radio buttons horizontally?
Tieku
Pierre,
I have read through this, but has this been actually implemented? I do not see the different display options (vertical, horizontal) when I go to create a multichoice question?
Thanks Piere, thanks Tieku,
I used the Demo site and the Multi-Choice Horizontal works fine as you can see below:
I used it for images questions as you see.The only problem is the background color. My images are all white and the options (table) background is colored. I want to change the table cells color to be white. The other thing is to remove these small cells that are reserved for the feedback.
Appreciating any help,
This is the demo site that I used:
Then I selected Moodle Features Demo link:
http://demo.moodle.org/course/view.php?id=2
It shows the MCH as I said earlier. But playing with colors might be a theme issue. Is that true?
Demo site - demo.moodle.org
Can i get a screen shot of the page where you specify the option for horizontal display of answer choices, or how to get there? Still can't find it.
Is this possible for cloze or multichoice type questions?
Thanks Pierre, looks like this is what i have been looking for. Will give it a try and see.
Pierre, so that worked. I have three questions:
Pierre, you wrote:
2. No. I don't want to get to more options than necessary because the Cloze syntax is already quite complex...
I am not asking for more options. For the sake of someone who does not need the numbering, could you leave this blank, so that those who need numbers type it in, and those wanting to use a another scheme have the flexibility to do so?
Thanks for your help.
Tieku
Pierre,
See attachment for what a typical cloze question using MCH will look like for me.
I am using a table with 3 columns and 5 rows.
Thanks.
Pierre, I am resending the document:
See attachment for what a typical cloze question using MCH will look like for me.
I am using a table with 3 columns and 5 rows.
Thanks.
I am the one Itamar helped to get this done. Here is the link:
http://moodle.org/mod/forum/discuss.php?d=96915
There is a lot of information there. So if you tell me specifically what your are trying to achieve, i might be able to help you since it has worked for me.
Tieku
Pierre,
I downloaded 1.9.3+ (Build: 20081119) yesterday with the updated MCH. Looks very good without the auto-numbering. Looking forward to the other changes just mentioned. Thanks.
Tieku
Pierre,
Thank you for your work on the MCH; it works very well. The current display is good and the changes I suggested are minor.
I will download tomorrow to see the changes you made to take away the extra space to the right.
Thanks.
This has been CVS down to 1.8? What does this mean?
Hello Pierre,
I noticed with a recent download of Moodle that the output for the MCH cloze question type is not transparent as it used to be. Can you revert back to using a transparent background so that I can apply background colors to the table cell I put the MCH in?
Tieku
Hello Pierre,
I noticed with a recent download of Moodle that the output for the MCH cloze question type is not transparent as it used to be. Can you revert back to using a transparent background so that I can apply background colors to the table cell I put the MCH in?
Tieku