Posts made by Itamar Tzadok

Here is one way to do it:

<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td valign="top">The answer to this question is true</td>
<td valign="top"><input name="yaynay" onclick="this.parentNode.parentNode.childNodes[3].firstChild.selectedIndex=1;" type="radio" />True</td>
<td valign="top"><input name="yaynay" onclick="this.parentNode.parentNode.childNodes[3].firstChild.selectedIndex=2;" type="radio" />False</td>
<td valign="top">{:MULTICHOICE:=True#~False#}</td>
</tr>
</tbody>
</table>

radio-cloze-before

On clicking one of the radio buttons the Moodle MULTICHOICE is set. If you change anything in the table structure you may need to change the DOM path from the radio button to the MULTICHOICE field (that's the onclick command string).

radio-cloze-result.jpg

You can see that the radio button values are not preserved after submission but with a little bit more work they can be restored and then you can hide the MULTICHOICE filed by setting the TD display style to none.

I hope that helps. Let me know if you need more details. smile

Itamar

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 smile


You can try adding some code to get the frame reference onBlur such that if the HTML editor have the focus just before you click the button, then when you click the button the frame reference will be stored in a variable that you can access from the button's function. If you have multiple editors you can run a code in onload which sets the frames' onblur to pass their references to that variable.