Revert "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
a96eb3a5 130 echo '<div style="text-align:center">'.get_string('emptysubmission', 'assignment').'</div>';
61240489 131 }
61240489 132 }
01e0da58 133 echo $OUTPUT->box_end();
12dce253 134 if (!$editmode && $editable) {
8ceabede
RW
135 if (!empty($submission)) {
136 $submitbutton = "editmysubmission";
137 } else {
138 $submitbutton = "addsubmission";
139 }
12dce253 140 echo "<div style='text-align:center'>";
8ceabede 141 echo $OUTPUT->single_button(new moodle_url('view.php', array('id'=>$this->cm->id, 'edit'=>'1')), get_string($submitbutton, 'assignment'));
12dce253 142 echo "</div>";
143 }
6cb1b93e 144
61240489 145 }
f77cfb73 146
147 $this->view_feedback();
148
149 $this->view_footer();
150 }
151
3e7bf58a 152 /*
153 * Display the assignment dates
154 */
155 function view_dates() {
3a003ead 156 global $USER, $CFG, $OUTPUT;
3e7bf58a 157
158 if (!$this->assignment->timeavailable && !$this->assignment->timedue) {
159 return;
160 }
161
3a003ead 162 echo $OUTPUT->box_start('generalbox boxaligncenter', 'dates');
3e7bf58a 163 echo '<table>';
164 if ($this->assignment->timeavailable) {
165 echo '<tr><td class="c0">'.get_string('availabledate','assignment').':</td>';
166 echo ' <td class="c1">'.userdate($this->assignment->timeavailable).'</td></tr>';
167 }
168 if ($this->assignment->timedue) {
169 echo '<tr><td class="c0">'.get_string('duedate','assignment').':</td>';
170 echo ' <td class="c1">'.userdate($this->assignment->timedue).'</td></tr>';
171 }
172 $submission = $this->get_submission($USER->id);
173 if ($submission) {
174 echo '<tr><td class="c0">'.get_string('lastedited').':</td>';
175 echo ' <td class="c1">'.userdate($submission->timemodified);
1884f2a6 176 /// Decide what to count
177 if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
178 echo ' ('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')</td></tr>';
179 } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
180 echo ' ('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')</td></tr>';
181 }
3e7bf58a 182 }
183 echo '</table>';
3a003ead 184 echo $OUTPUT->box_end();
3e7bf58a 185 }
186
f77cfb73 187 function update_submission($data) {
74d7d735 188 global $CFG, $USER, $DB;
f77cfb73 189
190 $submission = $this->get_submission($USER->id, true);
191
39790bd8 192 $update = new stdClass();
6cb1b93e 193 $update->id = $submission->id;
194 $update->data1 = $data->text;
f8ffb97e 195 $update->data2 = $data->textformat;
0cbc1f11 196 $update->timemodified = time();
f77cfb73 197
9d749339 198 $DB->update_record('assignment_submissions', $update);
12dce253 199
200 $submission = $this->get_submission($USER->id);
201 $this->update_grade($submission);
93d52d84
KG
202 $fs = get_file_storage();
203 $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
204 // Let Moodle know that an assessable content was uploaded (eg for plagiarism detection)
205 $eventdata = new stdClass();
206 $eventdata->modulename = 'assignment';
207 $eventdata->name = 'update_submission';
208 $eventdata->cmid = $this->cm->id;
209 $eventdata->itemid = $update->id;
210 $eventdata->courseid = $this->course->id;
211 $eventdata->userid = $USER->id;
212 $eventdata->content = trim(format_text($update->data1, $update->data2));
213 if ($files) {
214 $eventdata->pathnamehashes = array_keys($files);
215 }
216 events_trigger('assessable_content_uploaded', $eventdata);
d2b6ee29 217 return $submission;
f77cfb73 218 }
219
220
9bf660b3 221 function print_student_answer($userid, $return=false){
f2a1963c 222 global $OUTPUT;
9bf660b3 223 if (!$submission = $this->get_submission($userid)) {
224 return '';
225 }
e7521559 226
9bf16314
PS
227 $link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}");
228 $action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580));
229 $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 230
9bf660b3 231 $output = '<div class="files">'.
559276b1 232 $OUTPUT->pix_icon(file_extension_icon('.htm'), 'html', 'moodle', array('class' => 'icon')).
a9573c08 233 $popup .
cbbdc7db 234 plagiarism_get_links(array('userid' => $userid,
93d52d84
KG
235 'content' => trim(format_text($submission->data1, $submission->data2)),
236 'cmid' => $this->cm->id,
237 'course' => $this->course,
238 'assignment' => $this->assignment)) .
9bf660b3 239 '</div>';
240 return $output;
241 }
6cb1b93e 242
e7755fc6
PS
243 function print_user_files($userid=0, $return=false) {
244 global $OUTPUT, $CFG, $USER;
245
246 if (!$userid) {
247 if (!isloggedin()) {
248 return '';
249 }
250 $userid = $USER->id;
251 }
6cb1b93e 252
f77cfb73 253 if (!$submission = $this->get_submission($userid)) {
254 return '';
255 }
e7521559 256
9bf16314
PS
257 $link = new moodle_url("/mod/assignment/type/online/file.php?id={$this->cm->id}&userid={$submission->userid}");
258 $action = new popup_action('click', $link, 'file'.$userid, array('height' => 450, 'width' => 580));
291ee134 259 $popup = $OUTPUT->action_link($link, get_string('popupinnewwindow','assignment'), $action, array('title'=>get_string('submission', 'assignment')));
6cb1b93e 260
f77cfb73 261 $output = '<div class="files">'.
559276b1 262 $OUTPUT->pix_icon(file_extension_icon('.htm'), 'html', 'moodle', array('height' => 16, 'width' => 16)).
a9573c08 263 $popup .
f77cfb73 264 '</div>';
265
291ee134 266 $wordcount = '<p id="wordcount">'. $popup . '&nbsp;';
63d69d54 267 /// Decide what to count
268 if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_WORDS) {
291ee134 269 $wordcount .= '('.get_string('numwords', '', count_words(format_text($submission->data1, $submission->data2))).')';
63d69d54 270 } else if ($CFG->assignment_itemstocount == ASSIGNMENT_COUNT_LETTERS) {
291ee134 271 $wordcount .= '('.get_string('numletters', '', count_letters(format_text($submission->data1, $submission->data2))).')';
63d69d54 272 }
d2b6ee29 273 $wordcount .= '</p>';
274
6aac01ca 275 $text = file_rewrite_pluginfile_urls($submission->data1, 'pluginfile.php', $this->context->id, 'mod_assignment', $this->filearea, $submission->id);
367a75fa 276 return $wordcount . format_text($text, $submission->data2, array('overflowdiv'=>true));
6cb1b93e 277
6cb1b93e 278
f77cfb73 279 }
f77cfb73 280
01e2fdfe 281 function preprocess_submission(&$submission) {
ea6432fe 282 if ($this->assignment->var1 && empty($submission->submissioncomment)) { // comment inline
47263937 283 if ($this->usehtmleditor) {
284 // Convert to html, clean & copy student data to teacher
ea6432fe 285 $submission->submissioncomment = format_text($submission->data1, $submission->data2);
6cb1b93e 286 $submission->format = FORMAT_HTML;
47263937 287 } else {
288 // Copy student data to teacher
ea6432fe 289 $submission->submissioncomment = $submission->data1;
6cb1b93e 290 $submission->format = $submission->data2;
47263937 291 }
01e2fdfe 292 }
293 }
294
436cfa9f 295 function setup_elements(&$mform) {
296 global $CFG, $COURSE;
297
298 $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
299
e66841b9
DM
300 $mform->addElement('select', 'resubmit', get_string('allowresubmit', 'assignment'), $ynoptions);
301 $mform->addHelpButton('resubmit', 'allowresubmit', 'assignment');
436cfa9f 302 $mform->setDefault('resubmit', 0);
303
e66841b9
DM
304 $mform->addElement('select', 'emailteachers', get_string('emailteachers', 'assignment'), $ynoptions);
305 $mform->addHelpButton('emailteachers', 'emailteachers', 'assignment');
436cfa9f 306 $mform->setDefault('emailteachers', 0);
307
e66841b9
DM
308 $mform->addElement('select', 'var1', get_string('commentinline', 'assignment'), $ynoptions);
309 $mform->addHelpButton('var1', 'commentinline', 'assignment');
436cfa9f 310 $mform->setDefault('var1', 0);
311
93d52d84 312 $coursecontext = context_course::instance($COURSE->id);
67fbfe8b 313 plagiarism_get_form_elements_module($mform, $coursecontext, 'mod_assignment');
93d52d84 314
436cfa9f 315 }
316
67a87e7d 317 function portfolio_exportable() {
b0f5d070 318 return true;
67a87e7d 319 }
ffcfd8a7 320
df346604
PL
321 function portfolio_load_data($caller) {
322 $submission = $this->get_submission();
323 $fs = get_file_storage();
6aac01ca 324 if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', $this->filearea, $submission->id, "timemodified", false)) {
df346604
PL
325 $caller->set('multifiles', $files);
326 }
327 }
328
329 function portfolio_get_sha1($caller) {
330 $submission = $this->get_submission();
331 $textsha1 = sha1(format_text($submission->data1, $submission->data2));
332 $filesha1 = '';
333 try {
334 $filesha1 = $caller->get_sha1_file();
335 } catch (portfolio_caller_exception $e) {} // no files
336 return sha1($textsha1 . $filesha1);
ffcfd8a7 337 }
338
df346604
PL
339 function portfolio_prepare_package($exporter, $user) {
340 $submission = $this->get_submission($user->id);
7e514cd7 341 $options = portfolio_format_text_options();
d8c4a74e 342 $html = format_text($submission->data1, $submission->data2, $options);
6aac01ca 343 $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format'));
df346604
PL
344 if (in_array($exporter->get('formatclass'), array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) {
345 if ($files = $exporter->get('caller')->get('multifiles')) {
346 foreach ($files as $f) {
d94278c7 347 $exporter->copy_existing_file($f);
df346604
PL
348 }
349 }
350 return $exporter->write_new_file($html, 'assignment.html', !empty($files));
59dd457e
PL
351 } else if ($exporter->get('formatclass') == PORTFOLIO_FORMAT_LEAP2A) {
352 $leapwriter = $exporter->get('format')->leap2a_writer();
df346604 353 $entry = new portfolio_format_leap2a_entry('assignmentonline' . $this->assignment->id, $this->assignment->name, 'resource', $html);
59dd457e 354 $entry->add_category('web', 'resource_type');
df346604
PL
355 $entry->published = $submission->timecreated;
356 $entry->updated = $submission->timemodified;
357 $entry->author = $user;
59dd457e 358 $leapwriter->add_entry($entry);
df346604 359 if ($files = $exporter->get('caller')->get('multifiles')) {
ebb7e782 360 $leapwriter->link_files($entry, $files, 'assignmentonline' . $this->assignment->id . 'file');
df346604
PL
361 foreach ($files as $f) {
362 $exporter->copy_existing_file($f);
df346604
PL
363 }
364 }
365 $exporter->write_new_file($leapwriter->to_xml(), $exporter->get('format')->manifest_name(), true);
59dd457e 366 } else {
df346604 367 debugging('invalid format class: ' . $exporter->get('formatclass'));
59dd457e 368 }
ea0de12f 369 }
47c96a77 370
371 function extend_settings_navigation($node) {
372 global $PAGE, $CFG, $USER;
373
374 // get users submission if there is one
375 $submission = $this->get_submission();
64f93798 376 if (is_enrolled($PAGE->cm->context, $USER, 'mod/assignment:submit')) {
47c96a77 377 $editable = $this->isopen() && (!$submission || $this->assignment->resubmit || !$submission->timemarked);
378 } else {
379 $editable = false;
380 }
381
382 // If the user has submitted something add a bit more stuff
383 if ($submission) {
384 // Add a view link to the settings nav
a6855934 385 $link = new moodle_url('/mod/assignment/view.php', array('id'=>$PAGE->cm->id));
47c96a77 386 $node->add(get_string('viewmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
387
388 if (!empty($submission->timemodified)) {
3406acde
SH
389 $submittednode = $node->add(get_string('submitted', 'assignment') . ' ' . userdate($submission->timemodified));
390 $submittednode->text = preg_replace('#([^,])\s#', '$1&nbsp;', $submittednode->text);
391 $submittednode->add_class('note');
47c96a77 392 if ($submission->timemodified <= $this->assignment->timedue || empty($this->assignment->timedue)) {
3406acde 393 $submittednode->add_class('early');
47c96a77 394 } else {
3406acde 395 $submittednode->add_class('late');
47c96a77 396 }
397 }
398 }
399
400 if (!$submission || $editable) {
401 // If this assignment is editable once submitted add an edit link to the settings nav
a6855934 402 $link = new moodle_url('/mod/assignment/view.php', array('id'=>$PAGE->cm->id, 'edit'=>1, 'sesskey'=>sesskey()));
47c96a77 403 $node->add(get_string('editmysubmission', 'assignment'), $link, navigation_node::TYPE_SETTING);
404 }
405 }
c561f44c 406
b861b609 407 public function send_file($filearea, $args, $forcedownload, array $options=array()) {
ff284987 408 global $USER;
c561f44c
SH
409 require_capability('mod/assignment:view', $this->context);
410
64f93798 411 $fullpath = "/{$this->context->id}/mod_assignment/$filearea/".implode('/', $args);
c561f44c 412
ff284987 413 $fs = get_file_storage();
c561f44c
SH
414 if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
415 send_file_not_found();
416 }
417
418 if (($USER->id != $file->get_userid()) && !has_capability('mod/assignment:grade', $this->context)) {
419 send_file_not_found();
420 }
421
422 session_get_instance()->write_close(); // unlock session during fileserving
261cbbac
DM
423
424 send_stored_file($file, 60*60, 0, true, $options);
c561f44c 425 }
b37ce778
DM
426
427 /**
428 * creates a zip of all assignment submissions and sends a zip to the browser
429 */
430 public function download_submissions() {
431 global $CFG, $DB;
c0c75712 432
346c5887 433 raise_memory_limit(MEMORY_EXTRA);
f8ffb97e 434
b37ce778
DM
435 $submissions = $this->get_submissions('','');
436 if (empty($submissions)) {
14f001a9 437 print_error('errornosubmissions', 'assignment');
b37ce778
DM
438 }
439 $filesforzipping = array();
c0c75712
PS
440
441 //NOTE: do not create any stuff in temp directories, we now support unicode file names and that would not work, sorry
442
b37ce778
DM
443 //online assignment can use html
444 $filextn=".html";
445
a211a40c 446 $groupmode = groups_get_activity_groupmode($this->cm);
b37ce778
DM
447 $groupid = 0; // All users
448 $groupname = '';
14f001a9 449 if ($groupmode) {
a211a40c
DM
450 $groupid = groups_get_activity_group($this->cm, true);
451 $groupname = groups_get_group_name($groupid).'-';
b37ce778
DM
452 }
453 $filename = str_replace(' ', '_', clean_filename($this->course->shortname.'-'.$this->assignment->name.'-'.$groupname.$this->assignment->id.".zip")); //name of new zip file.
454 foreach ($submissions as $submission) {
455 $a_userid = $submission->userid; //get userid
456 if ((groups_is_member($groupid,$a_userid)or !$groupmode or !$groupid)) {
457 $a_assignid = $submission->assignment; //get name of this assignment for use in the file names.
458 $a_user = $DB->get_record("user", array("id"=>$a_userid),'id,username,firstname,lastname'); //get user firstname/lastname
c0c75712 459 $submissioncontent = "<html><body>". format_text($submission->data1, $submission->data2). "</body></html>"; //fetched from database
b37ce778 460 //get file name.html
902eca42 461 $fileforzipname = clean_filename(fullname($a_user) . "_" .$a_userid.$filextn);
c0c75712 462 $filesforzipping[$fileforzipname] = array($submissioncontent);
f8ffb97e 463 }
b37ce778 464 } //end of foreach
c0c75712 465
b37ce778 466 if ($zipfile = assignment_pack_files($filesforzipping)) {
b37ce778
DM
467 send_temp_file($zipfile, $filename); //send file and delete after sending.
468 }
469 }
f77cfb73 470}
471
f07b9627 472class mod_assignment_online_edit_form extends moodleform {
6cb1b93e 473 function definition() {
f8ffb97e
PS
474 $mform = $this->_form;
475
476 list($data, $editoroptions) = $this->_customdata;
6cb1b93e 477
478 // visible elements
f8ffb97e 479 $mform->addElement('editor', 'text_editor', get_string('submission', 'assignment'), null, $editoroptions);
c561f44c 480 $mform->setType('text_editor', PARAM_RAW); // to be cleaned before display
c561f44c 481 $mform->addRule('text_editor', get_string('required'), 'required', null, 'client');
6cb1b93e 482
6117edc7 483 // hidden params
f8ffb97e 484 $mform->addElement('hidden', 'id');
6cb1b93e 485 $mform->setType('id', PARAM_INT);
486
1628ba8b 487 $mform->addElement('hidden', 'edit');
f8ffb97e
PS
488 $mform->setType('edit', PARAM_INT);
489
6cb1b93e 490 // buttons
a23f0aaf 491 $this->add_action_buttons();
c561f44c 492
f8ffb97e 493 $this->set_data($data);
c561f44c 494 }
6cb1b93e 495}
496
e7521559 497