MDL-38254 Assignment Module: add avaialble message to all assignment types
[moodle.git] / mod / assignment / type / online / assignment.class.php
CommitLineData
e7521559 1<?php
6cb1b93e 2require_once($CFG->libdir.'/formslib.php');
8ceabede 3require_once($CFG->libdir . '/portfoliolib.php');
67a87e7d 4require_once($CFG->dirroot . '/mod/assignment/lib.php');
99d19c13
PS
5require_once($CFG->libdir . '/filelib.php');
6
f77cfb73 7/**
8 * Extend the base assignment class for assignments where you upload a single file
9 *
10 */
11class assignment_online extends assignment_base {
12
6aac01ca
AB
13 var $filearea = 'submission';
14
7bddd4b7 15 function assignment_online($cmid='staticonly', $assignment=NULL, $cm=NULL, $course=NULL) {
16 parent::assignment_base($cmid, $assignment, $cm, $course);
0b5a80a1 17 $this->type = 'online';
f77cfb73 18 }
19
f77cfb73 20 function view() {
f8ffb97e 21 global $OUTPUT, $CFG, $USER, $PAGE;
6cb1b93e 22
23 $edit = optional_param('edit', 0, PARAM_BOOL);
24 $saved = optional_param('saved', 0, PARAM_BOOL);
25
01a67102 26 $context = context_module::instance($this->cm->id);
0468976c 27 require_capability('mod/assignment:view', $context);
6cb1b93e 28
f8ffb97e 29 $submission = $this->get_submission($USER->id, false);
1648afb2 30
2eac7ec1 31 //Guest can not submit nor edit an assignment (bug: 4604)
64f93798 32 if (!is_enrolled($this->context, $USER, 'mod/assignment:submit')) {
f8ffb97e 33 $editable = false;
6cb1b93e 34 } else {
2eac7ec1 35 $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
36 }
6cb1b93e 37 $editmode = ($editable and $edit);
f77cfb73 38
39 if ($editmode) {
f8ffb97e 40 // prepare form and process submitted data
e9de1cf4
RT
41 $editoroptions = array(
42 'noclean' => false,
43 'maxfiles' => EDITOR_UNLIMITED_FILES,
44 'maxbytes' => $this->course->maxbytes,
c469b396
MG
45 'context' => $this->context,
46 'return_types' => FILE_INTERNAL | FILE_EXTERNAL
e9de1cf4 47 );
f8ffb97e 48
39790bd8 49 $data = new stdClass();
f8ffb97e
PS
50 $data->id = $this->cm->id;
51 $data->edit = 1;
52 if ($submission) {
53 $data->sid = $submission->id;
54 $data->text = $submission->data1;
55 $data->textformat = $submission->data2;
56 } else {
57 $data->sid = NULL;
58 $data->text = '';
59 $data->textformat = NULL;
f7de5478 60 }
f77cfb73 61
6aac01ca 62 $data = file_prepare_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $data->sid);
cb59ca28 63
f8ffb97e 64 $mform = new mod_assignment_online_edit_form(null, array($data, $editoroptions));
f77cfb73 65
f8ffb97e
PS
66 if ($mform->is_cancelled()) {
67 redirect($PAGE->url);
6cb1b93e 68 }
6cb1b93e 69
f8ffb97e
PS
70 if ($data = $mform->get_data()) {
71 $submission = $this->get_submission($USER->id, true); //create the submission if needed & its id
72
6aac01ca 73 $data = file_postupdate_standard_editor($data, 'text', $editoroptions, $this->context, 'mod_assignment', $this->filearea, $submission->id);
f8ffb97e
PS
74
75 $submission = $this->update_submission($data);
5571b5f4 76
ca4fb814 77 //TODO fix log actions - needs db upgrade
f8ffb97e 78 add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
9bf660b3 79 $this->email_teachers($submission);
f8ffb97e 80
3e7bf58a 81 //redirect to get updated submission date and word count
f8ffb97e 82 redirect(new moodle_url($PAGE->url, array('saved'=>1)));
f77cfb73 83 }
6cb1b93e 84 }
85
f8ffb97e
PS
86 add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
87
6cb1b93e 88/// print header, etc. and display form if needed
89 if ($editmode) {
90 $this->view_header(get_string('editmysubmission', 'assignment'));
91 } else {
169348bc 92 $this->view_header();
6cb1b93e 93 }
94
95 $this->view_intro();
96
97 $this->view_dates();
98
99 if ($saved) {
3a003ead 100 echo $OUTPUT->notification(get_string('submissionsaved', 'assignment'), 'notifysuccess');
3e7bf58a 101 }
f77cfb73 102
c7bb34b6 103 if (is_enrolled($this->context, $USER)) {
61240489 104 if ($editmode) {
a6e1750a 105 echo $OUTPUT->box_start('generalbox', 'onlineenter');
6cb1b93e 106 $mform->display();
61240489 107 } else {
01e0da58 108 echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter', 'online');
728e1931 109 if ($submission && has_capability('mod/assignment:exportownsubmission', $this->context)) {
93d52d84 110 echo plagiarism_get_links(array('userid' => $USER->id,
cbbdc7db 111 'content' => trim(format_text($submission->data1, $submission->data2, array('context' => $context))),
93d52d84
KG
112 'cmid' => $this->cm->id,
113 'course' => $this->course,
114 'assignment' => $this->assignment));
6aac01ca 115 $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
367a75fa 116 echo format_text($text, $submission->data2, array('overflowdiv'=>true));
6afa5981
PL
117 if ($CFG->enableportfolios) {
118 require_once($CFG->libdir . '/portfoliolib.php');
119 $button = new portfolio_add_button();
37743241 120 $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), 'mod_assignment');
6afa5981 121 $fs = get_file_storage();
6aac01ca 122 if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
6afa5981
PL
123 $button->set_formats(PORTFOLIO_FORMAT_RICHHTML);
124 } else {
125 $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML);
126 }
127 $button->render();
df346604 128 }
61240489 129 } else if ($this->isopen()){ //fix for #4206
2612e21b
RW
130 echo $OUTPUT->heading(get_string('emptysubmission','assignment'), 3);
131 } else if ($this->assignment->timeavailable > time()) {
132 echo $OUTPUT->heading(get_string('futureaassignment','assignment'), 3);
61240489 133 }
61240489 134 }
01e0da58 135 echo $OUTPUT->box_end();
12dce253 136 if (!$editmode && $editable) {
8ceabede
RW
137 if (!empty($submission)) {
138 $submitbutton = "editmysubmission";
139 } else {
140 $submitbutton = "addsubmission";
141 }
12dce253 142 echo "<div style='text-align:center'>";
8ceabede 143 echo $OUTPUT->single_button(new moodle_url('view.php', array('id'=>$this->cm->id, 'edit'=>'1')), get_string($submitbutton, 'assignment'));
12dce253 144 echo "</div>";
145 }
6cb1b93e 146
61240489 147 }
f77cfb73 148
149 $this->view_feedback();
150
151 $this->view_footer();
152 }
153
3e7bf58a 154 /*
155 * Display the assignment dates
156 */
157 function view_dates() {
3a003ead 158 global $USER, $CFG, $OUTPUT;
3e7bf58a 159
160 if (!$this->assignment->timeavailable && !$this->assignment->timedue) {
161 return;
162 }
163
3a003ead 164 echo $OUTPUT->box_start('generalbox boxaligncenter', 'dates');
3e7bf58a 165 echo '<table>';
166 if ($this->assignment->timeavailable) {
167 echo '<tr><td class="c0">'.get_string('availabledate','assignment').':</td>';
168 echo ' <td class="c1">'.userdate($this->assignment->timeavailable).'</td></tr>';
169 }
170 if ($this->assignment->timedue) {
171 echo '<tr><td class="c0">'.get_string('duedate','assignment').':</td>';
172 echo ' <td class="c1">'.userdate($this->assignment->timedue).'</td></tr>';
173 }
174 $submission = $this->get_submission($USER->id);
175 if ($submission) {
176 echo '<tr><td class="c0">'.get_string('lastedited').':</td>';
177 echo ' <td class="c1">'.userdate($submission->timemodified);
1884f2a6 178 /// Decide what to count
179 if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
180 echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')</td></tr>';
181 } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
182 echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')</td></tr>';
183 }
3e7bf58a 184 }
185 echo '</table>';
3a003ead 186 echo $OUTPUT->box_end();
3e7bf58a 187 }
188
f77cfb73 189 function update_submission($data) {
74d7d735 190 global $CFG, $USER, $DB;
f77cfb73 191
192 $submission = $this->get_submission($USER->id, true);
193
39790bd8 194 $update = new stdClass();
6cb1b93e 195 $update->id = $submission->id;
196 $update->data1 = $data->text;
f8ffb97e 197 $update->data2 = $data->textformat;
0cbc1f11 198 $update->timemodified = time();
f77cfb73 199
9d749339 200 $DB->update_record('assignment_submissions', $update);
12dce253 201
202 $submission = $this->get_submission($USER->id);
203 $this->update_grade($submission);
93d52d84
KG
204 $fs = get_file_storage();
205 $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
206 // Let Moodle know that an assessable content was uploaded (eg for plagiarism detection)
207 $eventdata = new stdClass();
208 $eventdata->modulename = 'assignment';
209 $eventdata->name = 'update_submission';
210 $eventdata->cmid = $this->cm->id;
211 $eventdata->itemid = $update->id;
212 $eventdata->courseid = $this->course->id;
213 $eventdata->userid = $USER->id;
214 $eventdata->content = trim(format_text($update->data1, $update->data2));
215 if ($files) {
216 $eventdata->pathnamehashes = array_keys($files);
217 }
218 events_trigger('assessable_content_uploaded', $eventdata);
d2b6ee29 219 return $submission;
f77cfb73 220 }
221
222
9bf660b3 223 function print_student_answer($userid, $return=false){
f2a1963c 224 global $OUTPUT;
9bf660b3 225 if (!$submission = $this->get_submission($userid)) {
226 return '';
227 }
e7521559 228
9bf16314
PS
229 $link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}");
230 $action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580));
231 $popup = $OUTPUT->action_link($link, shorten_text(trim(strip_tags(format_text($submission->data1,$submission->data2))), 15), $action, array('title'=>get_string('submission', 'assignment')));
e7521559 232
9bf660b3 233 $output = '<div class="files">'.
559276b1 234 $OUTPUT->pix_icon(file_extension_icon('.htm'), 'html', 'moodle', array('class' => 'icon')).
a9573c08 235 $popup .
cbbdc7db 236 plagiarism_get_links(array('userid' => $userid,
93d52d84
KG
237 'content' => trim(format_text($submission->data1, $submission->data2)),
238 'cmid' => $this->cm->id,
239 'course' => $this->course,
240 'assignment' => $this->assignment)) .
9bf660b3 241 '</div>';
242 return $output;
243 }
6cb1b93e 244
e7755fc6
PS
245 function print_user_files($userid=0, $return=false) {
246 global $OUTPUT, $CFG, $USER;
247
248 if (!$userid) {
249 if (!isloggedin()) {
250 return '';
251 }
252 $userid = $USER->id;
253 }
6cb1b93e 254
f77cfb73 255 if (!$submission = $this->get_submission($userid)) {
256 return '';
257 }
e7521559 258
9bf16314
PS
259 $link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}");
260 $action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580));
291ee134 261 $popup = $OUTPUT->action_link($link, get_string('popupinnewwindow','assignment'), $action, array('title'=>get_string('submission', 'assignment')));
6cb1b93e 262
f77cfb73 263 $output = '<div class="files">'.
559276b1 264 $OUTPUT->pix_icon(file_extension_icon('.htm'), 'html', 'moodle', array('height' => 16, 'width' => 16)).
a9573c08 265 $popup .
f77cfb73 266 '</div>';
267
291ee134 268 $wordcount = '<p id="wordcount">'. $popup . '&nbsp;';
63d69d54 269 /// Decide what to count
270 if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
291ee134 271 $wordcount .= '('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')';
63d69d54 272 } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
291ee134 273 $wordcount .= '('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')';
63d69d54 274 }
d2b6ee29 275 $wordcount .= '</p>';
276
6aac01ca 277 $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
367a75fa 278 return $wordcount . format_text($text, $submission->data2, array('overflowdiv'=>true));
6cb1b93e 279
6cb1b93e 280
f77cfb73 281 }
f77cfb73 282
01e2fdfe 283 function preprocess_submission(&$submission) {
ea6432fe 284 if ($this->assignment->var1 && empty($submission->submissioncomment)) { // comment inline
47263937 285 if ($this->usehtmleditor) {
286 // Convert to html, clean & copy student data to teacher
ea6432fe 287 $submission->submissioncomment = format_text($submission->data1, $submission->data2);
6cb1b93e 288 $submission->format = FORMAT_HTML;
47263937 289 } else {
290 // Copy student data to teacher
ea6432fe 291 $submission->submissioncomment = $submission->data1;
6cb1b93e 292 $submission->format = $submission->data2;
47263937 293 }
01e2fdfe 294 }
295 }
296
436cfa9f 297 function setup_elements(&$mform) {
298 global $CFG, $COURSE;
299
300 $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
301
e66841b9
DM
302 $mform->addElement('select', 'resubmit', get_string('allowresubmit', 'assignment'), $ynoptions);
303 $mform->addHelpButton('resubmit', 'allowresubmit', 'assignment');
436cfa9f 304 $mform->setDefault('resubmit', 0);
305
e66841b9
DM
306 $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions);
307 $mform->addHelpButton('emailteachers', 'emailteachers', 'assignment');
436cfa9f 308 $mform->setDefault('emailteachers', 0);
309
e66841b9
DM
310 $mform->addElement('select', 'var1', get_string('commentinline', 'assignment'), $ynoptions);
311 $mform->addHelpButton('var1', 'commentinline', 'assignment');
436cfa9f 312 $mform->setDefault('var1', 0);
313
93d52d84 314 $coursecontext = context_course::instance($COURSE->id);
67fbfe8b 315 plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_assignment');
93d52d84 316
436cfa9f 317 }
318
67a87e7d 319 function portfolio_exportable() {
b0f5d070 320 return true;
67a87e7d 321 }
ffcfd8a7 322
df346604
PL
323 function portfolio_load_data($caller) {
324 $submission = $this->get_submission();
325 $fs = get_file_storage();
6aac01ca 326 if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
df346604
PL
327 $caller->set('multifiles', $files);
328 }
329 }
330
331 function portfolio_get_sha1($caller) {
332 $submission = $this->get_submission();
333 $textsha1 = sha1(format_text($submission->data1, $submission->data2));
334 $filesha1 = '';
335 try {
336 $filesha1 = $caller->get_sha1_file();
337 } catch (portfolio_caller_exception $e) {} // no files
338 return sha1($textsha1 . $filesha1);
ffcfd8a7 339 }
340
df346604
PL
341 function portfolio_prepare_package($exporter, $user) {
342 $submission = $this->get_submission($user->id);
7e514cd7 343 $options = portfolio_format_text_options();
d8c4a74e 344 $html = format_text($submission->data1, $submission->data2, $options);
6aac01ca 345 $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format'));
df346604
PL
346 if (in_array($exporter->get('formatclass'), array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) {
347 if ($files = $exporter->get('caller')->get('multifiles')) {
348 foreach ($files as $f) {
d94278c7 349 $exporter->copy_existing_file($f);
df346604
PL
350 }
351 }
352 return $exporter->write_new_file($html, 'assignment.html', !empty($files));
59dd457e
PL
353 } else if ($exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
354 $leapwriter = $exporter->get('format')->leap2a_writer();
df346604 355 $entry = new portfolio_format_leap2a_entry('assignmentonline' . $this->assignment->id, $this->assignment->name, 'resource', $html);
59dd457e 356 $entry->add_category('web', 'resource_type');
df346604
PL
357 $entry->published = $submission->timecreated;
358 $entry->updated = $submission->timemodified;
359 $entry->author = $user;
59dd457e 360 $leapwriter->add_entry($entry);
df346604 361 if ($files = $exporter->get('caller')->get('multifiles')) {
ebb7e782 362 $leapwriter->link_files($entry, $files, 'assignmentonline' . $this->assignment->id . 'file');
df346604
PL
363 foreach ($files as $f) {
364 $exporter->copy_existing_file($f);
df346604
PL
365 }
366 }
367 $exporter->write_new_file($leapwriter->to_xml(), $exporter->get('format')->manifest_name(), true);
59dd457e 368 } else {
df346604 369 debugging('invalid format class: ' . $exporter->get('formatclass'));
59dd457e 370 }
ea0de12f 371 }
47c96a77 372
373 function extend_settings_navigation($node) {
374 global $PAGE, $CFG, $USER;
375
376 // get users submission if there is one
377 $submission = $this->get_submission();
64f93798 378 if (is_enrolled($PAGE->cm->context, $USER, 'mod/assignment:submit')) {
47c96a77 379 $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
380 } else {
381 $editable = false;
382 }
383
384 // If the user has submitted something add a bit more stuff
385 if ($submission) {
386 // Add a view link to the settings nav
a6855934 387 $link = new moodle_url('/mod/assignment/view.php', array('id'=>$PAGE->cm->id));
47c96a77 388 $node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
389
390 if (!empty($submission->timemodified)) {
3406acde
SH
391 $submittednode = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified));
392 $submittednode->text = preg_replace('#([^,])\s#', '$1&nbsp;', $submittednode->text);
393 $submittednode->add_class('note');
47c96a77 394 if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
3406acde 395 $submittednode->add_class('early');
47c96a77 396 } else {
3406acde 397 $submittednode->add_class('late');
47c96a77 398 }
399 }
400 }
401
402 if (!$submission || $editable) {
403 // If this assignment is editable once submitted add an edit link to the settings nav
a6855934 404 $link = new moodle_url('/mod/assignment/view.php', array('id'=>$PAGE->cm->id, 'edit'=>1, 'sesskey'=>sesskey()));
47c96a77 405 $node->add(get_string('editmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
406 }
407 }
c561f44c 408
b861b609 409 public function send_file($filearea, $args, $forcedownload, array $options=array()) {
ff284987 410 global $USER;
c561f44c
SH
411 require_capability('mod/assignment:view', $this->context);
412
64f93798 413 $fullpath = "/{$this->context->id}/mod_assignment/$filearea/".implode('/', $args);
c561f44c 414
ff284987 415 $fs = get_file_storage();
c561f44c
SH
416 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
417 send_file_not_found();
418 }
419
420 if (($USER->id != $file->get_userid()) && !has_capability('mod/assignment:grade', $this->context)) {
421 send_file_not_found();
422 }
423
424 session_get_instance()->write_close(); // unlock session during fileserving
261cbbac
DM
425
426 send_stored_file($file, 60*60, 0, true, $options);
c561f44c 427 }
b37ce778
DM
428
429 /**
430 * creates a zip of all assignment submissions and sends a zip to the browser
431 */
432 public function download_submissions() {
433 global $CFG, $DB;
c0c75712 434
346c5887 435 raise_memory_limit(MEMORY_EXTRA);
f8ffb97e 436
b37ce778
DM
437 $submissions = $this->get_submissions('','');
438 if (empty($submissions)) {
14f001a9 439 print_error('errornosubmissions', 'assignment');
b37ce778
DM
440 }
441 $filesforzipping = array();
c0c75712
PS
442
443 //NOTE: do not create any stuff in temp directories, we now support unicode file names and that would not work, sorry
444
b37ce778
DM
445 //online assignment can use html
446 $filextn=".html";
447
a211a40c 448 $groupmode = groups_get_activity_groupmode($this->cm);
b37ce778
DM
449 $groupid = 0; // All users
450 $groupname = '';
14f001a9 451 if ($groupmode) {
a211a40c
DM
452 $groupid = groups_get_activity_group($this->cm, true);
453 $groupname = groups_get_group_name($groupid).'-';
b37ce778
DM
454 }
455 $filename = str_replace(' ', '_', clean_filename($this->course->shortname.'-'.$this->assignment->name.'-'.$groupname.$this->assignment->id.".zip")); //name of new zip file.
456 foreach ($submissions as $submission) {
457 $a_userid = $submission->userid; //get userid
458 if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) {
459 $a_assignid = $submission->assignment; //get name of this assignment for use in the file names.
460 $a_user = $DB->get_record("user", array("id"=>$a_userid),'id,username,firstname,lastname'); //get user firstname/lastname
c0c75712 461 $submissioncontent = "<html><body>". format_text($submission->data1, $submission->data2). "</body></html>"; //fetched from database
b37ce778 462 //get file name.html
902eca42 463 $fileforzipname = clean_filename(fullname($a_user) . "_" .$a_userid.$filextn);
c0c75712 464 $filesforzipping[$fileforzipname] = array($submissioncontent);
f8ffb97e 465 }
b37ce778 466 } //end of foreach
c0c75712 467
b37ce778 468 if ($zipfile = assignment_pack_files($filesforzipping)) {
b37ce778
DM
469 send_temp_file($zipfile, $filename); //send file and delete after sending.
470 }
471 }
f77cfb73 472}
473
f07b9627 474class mod_assignment_online_edit_form extends moodleform {
6cb1b93e 475 function definition() {
f8ffb97e
PS
476 $mform = $this->_form;
477
478 list($data, $editoroptions) = $this->_customdata;
6cb1b93e 479
480 // visible elements
f8ffb97e 481 $mform->addElement('editor', 'text_editor', get_string('submission', 'assignment'), null, $editoroptions);
c561f44c 482 $mform->setType('text_editor', PARAM_RAW); // to be cleaned before display
c561f44c 483 $mform->addRule('text_editor', get_string('required'), 'required', null, 'client');
6cb1b93e 484
6117edc7 485 // hidden params
f8ffb97e 486 $mform->addElement('hidden', 'id');
6cb1b93e 487 $mform->setType('id', PARAM_INT);
488
1628ba8b 489 $mform->addElement('hidden', 'edit');
f8ffb97e
PS
490 $mform->setType('edit', PARAM_INT);
491
6cb1b93e 492 // buttons
a23f0aaf 493 $this->add_action_buttons();
c561f44c 494
f8ffb97e 495 $this->set_data($data);
c561f44c 496 }
6cb1b93e 497}
498
e7521559 499