mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-57455 mod_data: added reset tags functionality
This commit is contained in:
parent
5623d18784
commit
80effa0faa
@ -306,6 +306,7 @@ $string['recorddeleted'] = 'Entry deleted';
|
||||
$string['recorddisapproved'] = 'Entry unapproved';
|
||||
$string['recordsnotsaved'] = 'No entry was saved. Please check the format of the uploaded file.';
|
||||
$string['recordssaved'] = 'entries saved';
|
||||
$string['removealldatatags'] = 'Remove all database tags';
|
||||
$string['requireapproval'] = 'Approval required';
|
||||
$string['requireapproval_help'] = 'If enabled, entries require approving by a teacher before they are viewable by everyone.';
|
||||
$string['required'] = 'Required';
|
||||
@ -348,6 +349,7 @@ $string['subplugintype_datapreset'] = 'Preset';
|
||||
$string['subplugintype_datapreset_plural'] = 'Presets';
|
||||
$string['tagarea_data_records'] = 'Data records';
|
||||
$string['tags'] = 'tags';
|
||||
$string['tagsdeleted'] = 'Database tags have been deleted';
|
||||
$string['teachersandstudents'] = '{$a->teachers} and {$a->students}';
|
||||
$string['templates'] = 'Templates';
|
||||
$string['templatesaved'] = 'Template saved';
|
||||
|
@ -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…
x
Reference in New Issue
Block a user