- $DB->update_record('data', $newtemplate);
- echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess');
+ // if disableeditor or enableeditor buttons click, don't save instance
+ if (empty($disableeditor) && empty($enableeditor)) {
+ $DB->update_record('data', $newtemplate);
+ echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess');
+ add_to_log($course->id, 'data', 'templates saved', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id);
+ }