mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-57455 mod_data: added reset tags functionality
This commit is contained in:
parent
5623d18784
commit
80effa0faa
2 changed files with 25 additions and 0 deletions
|
@ -2794,6 +2794,9 @@ function data_reset_course_form_definition(&$mform) {
|
|||
|
||||
$mform->addElement('checkbox', 'reset_data_comments', get_string('deleteallcomments'));
|
||||
$mform->disabledIf('reset_data_comments', 'reset_data', 'checked');
|
||||
|
||||
$mform->addElement('checkbox', 'reset_data_tags', get_string('removealldatatags', 'data'));
|
||||
$mform->disabledIf('reset_data_tags', 'reset_data', 'checked');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2878,6 +2881,8 @@ function data_reset_userdata($data) {
|
|||
|
||||
$ratingdeloptions->contextid = $datacontext->id;
|
||||
$rm->delete_ratings($ratingdeloptions);
|
||||
|
||||
core_tag_tag::delete_instances('mod_data', null, $datacontext->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2920,6 +2925,8 @@ function data_reset_userdata($data) {
|
|||
}
|
||||
$notenrolled[$record->userid] = true;
|
||||
|
||||
core_tag_tag::remove_all_item_tags('mod_data', 'data_records', $record->id);
|
||||
|
||||
$DB->delete_records('comments', array('itemid' => $record->id, 'commentarea' => 'database_entry'));
|
||||
$DB->delete_records('data_content', array('recordid' => $record->id));
|
||||
$DB->delete_records('data_records', array('id' => $record->id));
|
||||
|
@ -2957,6 +2964,22 @@ function data_reset_userdata($data) {
|
|||
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
|
||||
}
|
||||
|
||||
// Remove all the tags.
|
||||
if (!empty($data->reset_data_tags)) {
|
||||
if ($datas = $DB->get_records_sql($alldatassql, array($data->courseid))) {
|
||||
foreach ($datas as $dataid => $unused) {
|
||||
if (!$cm = get_coursemodule_from_instance('data', $dataid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$context = context_module::instance($cm->id);
|
||||
core_tag_tag::delete_instances('mod_data', null, $context->id);
|
||||
|
||||
}
|
||||
}
|
||||
$status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'data'), 'error' => false);
|
||||
}
|
||||
|
||||
// updating dates - shift may be negative too
|
||||
if ($data->timeshift) {
|
||||
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue