protected function question_survey_display($data, $descendantsdata, $blankquestionnaire = false) { $output = ''; // Essay. // Columns and rows default values. $cols = 80; $rows = 15; // Use HTML editor or not? if ($this->precise == 0) { $canusehtmleditor = true; $rows = $this->length == 0 ? $rows : $this->length; } else { $canusehtmleditor = false; // Prior to version 2.6, "precise" was used for rows number. $rows = $this->precise > 1 ? $this->precise : $this->length; } $name = 'q' . $this->id; if (isset($data->{'q' . $this->id})) { $value = $data->{'q' . $this->id}; } else { $value = ''; } if ($canusehtmleditor) { $editor = editors_get_preferred_editor(); $editor->use_editor($name, questionnaire_get_editor_options($this->context)); $texteditor = html_writer::tag('textarea', $value, array('id' => $name, 'name' => $name, 'rows' => $rows, 'cols' => $cols)); } else { $editor = FORMAT_PLAIN; $texteditor = html_writer::tag('textarea', $value, array('id' => $name, 'name' => $name, 'rows' => $rows, 'cols' => $cols)); } $output .= $texteditor; return $output; }
} } if (has_capability('mod/questionnaire:message', $context)) { // Message editor. // Prepare data. echo '<fieldset class="clearfix">'; if ($action == 'sendmessage' && (empty($subject) || empty($message))) { echo $OUTPUT->notification(get_string('allfieldsrequired')); } echo '<legend class="ftoggler">' . get_string('send_message', 'questionnaire') . '</legend>'; $id = 'message' . '_id'; $subjecteditor = ' <input type="text" id="questionnaire_subject" size="65" maxlength="255" name="subject" value="' . $subject . '" />'; $format = ''; $editor = editors_get_preferred_editor(); $editor->use_editor($id, questionnaire_get_editor_options($context)); $texteditor = html_writer::tag('div', html_writer::tag('textarea', $message, array('id' => $id, 'name' => "message", 'rows' => '10', 'cols' => '60'))); echo '<input type="hidden" name="format" value="' . FORMAT_HTML . '" />'; // Print editor. $table = new html_table(); $table->align = array('left', 'left'); $table->data[] = array('<strong>' . get_string('subject', 'questionnaire') . '</strong>', $subjecteditor); $table->data[] = array('<strong>' . get_string('messagebody') . '</strong>', $texteditor); echo html_writer::table($table); // Send button. echo $OUTPUT->box_start('mdl-left'); echo '<div class="buttons">'; echo '<input type="submit" name="send_message" value="' . get_string('send', 'questionnaire') . '" />'; echo '</div>'; echo $OUTPUT->box_end(); echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
private function essay_survey_display($data) { // Essay. $cols = $this->length; $rows = $this->precise; $str = ''; // If NO cols or rows specified: use HTML editor (if available in this context). if (!$cols || !$rows) { $cols = 60; $rows = 5; $canusehtmleditor = $this->usehtmleditor; // If cols & rows specified, do not use HTML editor but plain text box // use default (60 cols and 5 rows) OR user-specified values. } else { $canusehtmleditor = false; } $name = 'q' . $this->id; if (isset($data->{'q' . $this->id})) { $value = $data->{'q' . $this->id}; } else { $value = ''; } if ($canusehtmleditor) { $editor = editors_get_preferred_editor(); $editor->use_editor($name, questionnaire_get_editor_options($this->context)); $texteditor = html_writer::tag('textarea', $value, array('id' => $name, 'name' => $name, '', '')); echo $texteditor; } else { $str .= '<textarea class="form-textarea" id="edit-' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . s($value) . '</textarea>'; echo $str; } }