本文整理汇总了PHP中moodleform::repeat_elements方法的典型用法代码示例。如果您正苦于以下问题:PHP moodleform::repeat_elements方法的具体用法?PHP moodleform::repeat_elements怎么用?PHP moodleform::repeat_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类moodleform
的用法示例。
在下文中一共展示了moodleform::repeat_elements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_form_fragment
/**
* @param moodleform $combinedform
* @param MoodleQuickForm $mform
* @param $repeatenabled
*/
public function add_form_fragment(moodleform $combinedform, MoodleQuickForm $mform, $repeatenabled)
{
$mform->addElement('advcheckbox', $this->form_field_name('shuffleanswers'), get_string('shuffle', 'qtype_gapselect'));
$answerel = array($mform->createElement('text', $this->form_field_name('answer'), get_string('choicex', 'qtype_gapselect'), array('size' => 57, 'class' => 'tweakcss')));
if ($this->questionrec !== null) {
$countanswers = count($this->questionrec->options->answers);
} else {
$countanswers = 0;
}
if ($repeatenabled) {
$defaultstartnumbers = QUESTION_NUMANS_START * 2;
$repeatsatstart = max($defaultstartnumbers, $countanswers + QUESTION_NUMANS_ADD);
} else {
$repeatsatstart = $countanswers;
}
$combinedform->repeat_elements($answerel, $repeatsatstart, array(), $this->form_field_name('noofchoices'), $this->form_field_name('morechoices'), QUESTION_NUMANS_ADD, get_string('addmorechoiceblanks', 'qtype_gapselect'), true);
$mform->setType($this->form_field_name('answer'), PARAM_RAW_TRIMMED);
}