
Joseph Rézeau
Joseph Rézeau的帖子
Moodle Cloze (embedded) questions can consist of a variety of types of sub-questions, including short answer, numerical and multiple choice.
If a Cloze question consists only of multiple choice questions, the "automatic feedback" given to the student upon checking their answer(s) is OK: You have correctly selected n. Where n is the number of correct selections.
However, it the Cloze question consists of short answer questions (or a mixture of short answer and multiple choice), then that same feedback text does not sound quite right. It should be something like You have correctly answered n.
Any ideas to improve this message?
You do not say so but, from your screenshot I guess you are using the so-called "short answer" question type in Moodle.
- Please note it's called short answer, not longish answer.
- You say you want to "resize the field for the feedback answer", but in fact you do not want to resize the feedback field but the student's answer input field.
- Even though that answer field is limited to displaying 80 characters at a time, its contents are not limited.
- Finally, from a pedagogical point of view I fail to understand what you are trying to achieve. I do not understand your instructions ("Direction"). Maybe you should look for another type of question or activity in Moodle to better achieve your aims.
Here is a sample extract from my form
1 $mychoices = array(0,1,2,3,4);
2 $mygroup = [];
3 $mygroup[] = $mform->createElement('select', 'myelement0', 'label myelement0', array(0,1,2,3,4));
4 $mygroup[] = $mform->createElement('advcheckbox', 'myelement1', 'label myelement1');
5 $mform->addGroup($mygroup, 'mygroup');
6 $mform->addHelpButton('mygroup', 'help');
7 $mform->addHelpButton('mygroup[myelement1]', 'help');
8 $mform->hideIf('mygroup[myelement1]', 'mygroup[myelement0]', 'neq', 0);
And the result:

It all works as expected, except for the $mform->addHelpButton('mygroup[myelement1]', 'help') which throws an error:
"Trying to add help buttons to non-existent form elements : mygroup[myelement1]"
What does not look logical is that the form element mygroup[myelement1] is indeed recognized in the hideIf instruction (line 8) but considered as "non-existent" in the addHelpButton (line 7).
Any ideas? Is this a bug in the forms API?
At https://docs.moodle.org/dev/lib/formslib.php_Form_Definition#addGroup the addGroup doc says:
"A 'group' in formslib is just a group of elements that will have a label and will be included on one line.
For example typical code to include a submit and cancel button on the same line :
$buttonarray=array();
$buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('savechanges'));
$buttonarray[] =& $mform->createElement('submit', 'cancel', get_string('cancel'));
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
You use the same arguments for createElement as you do for addElement. Any label for the element in the third argument is normally ignored (but not in the case of the submit buttons above where the third argument is not for a label but is the text for the button). "
Why is the label ignored? I do need it in that case. Any workaround?