Browse Source

Now deleting module will delete all attendance data (sessions, statuses, log)

MOODLE_23_STABLE
Artem Andreev 14 years ago
parent
commit
f036bcf54c
  1. 1
      lang/en/attforblock.php
  2. 1
      lang/ru/attforblock.php
  3. 13
      lib.php
  4. 2
      mod_form.php

1
lang/en/attforblock.php

@ -94,7 +94,6 @@ $string['includeall'] = 'Select all sessions';
$string['includenottaken'] = 'Include not taken sessions'; $string['includenottaken'] = 'Include not taken sessions';
$string['indetail'] = 'In detail...'; $string['indetail'] = 'In detail...';
$string['jumpto'] = 'Jump to'; $string['jumpto'] = 'Jump to';
$string['moduledescription'] = 'Removal of this module will not entail removal of the data!';
$string['modulename'] = 'Attendance'; $string['modulename'] = 'Attendance';
$string['modulenameplural'] = 'Attendances'; $string['modulenameplural'] = 'Attendances';
$string['months'] = 'Months'; $string['months'] = 'Months';

1
lang/ru/attforblock.php

@ -80,7 +80,6 @@ $string['includeall'] = 'Выбрать все занятия';
$string['includenottaken'] = 'Включить не прошедшие занятия'; $string['includenottaken'] = 'Включить не прошедшие занятия';
$string['indetail'] = 'Подробнее...'; $string['indetail'] = 'Подробнее...';
$string['jumpto'] = 'Перейти к занятию '; $string['jumpto'] = 'Перейти к занятию ';
$string['moduledescription'] = 'Удаление этого модуля не повлечет удаление данных о посещаемости!';
$string['modulename'] = 'Посещаемость'; $string['modulename'] = 'Посещаемость';
$string['modulenameplural'] = 'Посещаемость'; $string['modulenameplural'] = 'Посещаемость';
$string['months'] = 'Месяц'; $string['months'] = 'Месяц';

13
lib.php

@ -102,16 +102,23 @@ function attforblock_delete_instance($id) {
return false; return false;
} }
$result = $DB->delete_records('attforblock', array('id'=> $id)); if ($sess = $DB->get_records('attendance_sessions', array('attendanceid'=> $id), '', 'id')) {
$slist = implode(',', array_keys($sess));
$DB->delete_records_select('attendance_log', "sessionid IN ($slist)");
$DB->delete_records('attendance_sessions', array('attendanceid'=> $id));
}
$DB->delete_records('attendance_statuses', array('attendanceid'=> $id));
$DB->delete_records('attforblock', array('id'=> $id));
attforblock_grade_item_delete($attforblock); attforblock_grade_item_delete($attforblock);
return $result; return true;
} }
function attforblock_delete_course($course, $feedback=true){ function attforblock_delete_course($course, $feedback=true){
global $DB; global $DB;
if ($sess = $DB->get_records('attendance_sessions', array('courseid'=> $course->id), '', 'id')) { if ($sess = $DB->get_records('attendance_sessions', array('courseid'=> $course->id), '', 'id')) {
$slist = implode(',', array_keys($sess)); $slist = implode(',', array_keys($sess));

2
mod_form.php

@ -21,8 +21,6 @@ class mod_attforblock_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', null, 'required', null, 'client');
$mform->setDefault('name', get_string('modulename', 'attforblock')); $mform->setDefault('name', get_string('modulename', 'attforblock'));
$mform->addElement('static', 'attdescription', '', get_string('moduledescription', 'attforblock'));
$mform->addElement('modgrade', 'grade', get_string('grade')); $mform->addElement('modgrade', 'grade', get_string('grade'));
$mform->setDefault('grade', 100); $mform->setDefault('grade', 100);

Loading…
Cancel
Save