mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-48473 mod_lesson: fill in the blank shortanswer option
This commit is contained in:
parent
8f06fffbe1
commit
cb9af73037
1 changed files with 18 additions and 8 deletions
|
@ -350,21 +350,31 @@ class lesson_display_answer_form_shortanswer extends moodleform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$placeholder = false;
|
||||||
|
if (preg_match('/_____+/', $contents, $matches)) {
|
||||||
|
$placeholder = $matches[0];
|
||||||
|
$contentsparts = explode( $placeholder, $contents, 2);
|
||||||
|
$attrs['size'] = round(strlen($placeholder) * 1.1);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('header', 'pageheader');
|
$mform->addElement('header', 'pageheader');
|
||||||
|
|
||||||
$mform->addElement('html', $OUTPUT->container($contents, 'contents'));
|
|
||||||
|
|
||||||
$options = new stdClass;
|
|
||||||
$options->para = false;
|
|
||||||
$options->noclean = true;
|
|
||||||
|
|
||||||
$mform->addElement('hidden', 'id');
|
$mform->addElement('hidden', 'id');
|
||||||
$mform->setType('id', PARAM_INT);
|
$mform->setType('id', PARAM_INT);
|
||||||
|
|
||||||
$mform->addElement('hidden', 'pageid');
|
$mform->addElement('hidden', 'pageid');
|
||||||
$mform->setType('pageid', PARAM_INT);
|
$mform->setType('pageid', PARAM_INT);
|
||||||
|
|
||||||
$mform->addElement('text', 'answer', get_string('youranswer', 'lesson'), $attrs);
|
if ($placeholder) {
|
||||||
|
$contentsgroup = array();
|
||||||
|
$contentsgroup[] = $mform->createElement('static', '', '', $contentsparts[0]);
|
||||||
|
$contentsgroup[] = $mform->createElement('text', 'answer', '', $attrs);
|
||||||
|
$contentsgroup[] = $mform->createElement('static', '', '', $contentsparts[1]);
|
||||||
|
$mform->addGroup($contentsgroup, '', '', '', false);
|
||||||
|
} else {
|
||||||
|
$mform->addElement('html', $OUTPUT->container($contents, 'contents'));
|
||||||
|
$mform->addElement('text', 'answer', get_string('youranswer', 'lesson'), $attrs);
|
||||||
|
|
||||||
|
}
|
||||||
$mform->setType('answer', PARAM_TEXT);
|
$mform->setType('answer', PARAM_TEXT);
|
||||||
|
|
||||||
if ($hasattempt) {
|
if ($hasattempt) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue