$view_form = 1; // action actions on create if ($action == "create") { echo $OUTPUT->heading(get_string('createcomment', 'mod_emarking')); //Creating form $newcommentform = new CommentForm(); //Form Display $newcommentform->display(); } if ($action == "created") { //Recration of the form $newcommentform = new CommentForm(); //Form result if ($newcommentform->is_cancelled()) { $action = "list"; } elseif ($fromform = $newcommentform->get_data()) { $record = new stdClass(); //Giving var record the necesary parameters $record->text = $fromform->comment["text"]; $record->emarkingid = $emarking->id; $record->markerid = $USER->id; //Creating record in moodle DB $DB->insert_record('emarking_predefined_comment', $record); $action = "list"; } } // action action on delete if ($action == "delete") { //geting record to delete $DB->delete_records('emarking_predefined_comment', array('id' => $deleteid)); $action = "list";