|
@ -54,7 +54,7 @@ function attendance_supports($feature) { |
|
|
function att_add_default_statuses($attid) { |
|
|
function att_add_default_statuses($attid) { |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
|
$statuses = $DB->get_recordset('attendance_statuses', array('attendanceid'=> 0), 'id'); |
|
|
$statuses = $DB->get_recordset('attendance_statuses', array('attendanceid' => 0), 'id'); |
|
|
foreach ($statuses as $st) { |
|
|
foreach ($statuses as $st) { |
|
|
$rec = $st; |
|
|
$rec = $st; |
|
|
$rec->attendanceid = $attid; |
|
|
$rec->attendanceid = $attid; |
|
@ -97,17 +97,17 @@ function attendance_update_instance($attendance) { |
|
|
function attendance_delete_instance($id) { |
|
|
function attendance_delete_instance($id) { |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
|
if (! $attendance = $DB->get_record('attendance', array('id'=> $id))) { |
|
|
if (! $attendance = $DB->get_record('attendance', array('id' => $id))) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($sessids = array_keys($DB->get_records('attendance_sessions', array('attendanceid'=> $id), '', 'id'))) { |
|
|
if ($sessids = array_keys($DB->get_records('attendance_sessions', array('attendanceid' => $id), '', 'id'))) { |
|
|
$DB->delete_records_list('attendance_log', 'sessionid', $sessids); |
|
|
$DB->delete_records_list('attendance_log', 'sessionid', $sessids); |
|
|
$DB->delete_records('attendance_sessions', array('attendanceid'=> $id)); |
|
|
$DB->delete_records('attendance_sessions', array('attendanceid' => $id)); |
|
|
} |
|
|
} |
|
|
$DB->delete_records('attendance_statuses', array('attendanceid'=> $id)); |
|
|
$DB->delete_records('attendance_statuses', array('attendanceid' => $id)); |
|
|
|
|
|
|
|
|
$DB->delete_records('attendance', array('id'=> $id)); |
|
|
$DB->delete_records('attendance', array('id' => $id)); |
|
|
|
|
|
|
|
|
attendance_grade_item_delete($attendance); |
|
|
attendance_grade_item_delete($attendance); |
|
|
|
|
|
|
|
@ -117,7 +117,7 @@ function attendance_delete_instance($id) { |
|
|
function attendance_delete_course($course, $feedback=true) { |
|
|
function attendance_delete_course($course, $feedback=true) { |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
|
$attids = array_keys($DB->get_records('attendance', array('course'=> $course->id), '', 'id')); |
|
|
$attids = array_keys($DB->get_records('attendance', array('course' => $course->id), '', 'id')); |
|
|
$sessids = array_keys($DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id')); |
|
|
$sessids = array_keys($DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id')); |
|
|
if ($sessids) { |
|
|
if ($sessids) { |
|
|
$DB->delete_records_list('attendance_log', 'sessionid', $sessids); |
|
|
$DB->delete_records_list('attendance_log', 'sessionid', $sessids); |
|
@ -126,7 +126,7 @@ function attendance_delete_course($course, $feedback=true) { |
|
|
$DB->delete_records_list('attendance_statuses', 'attendanceid', $attids); |
|
|
$DB->delete_records_list('attendance_statuses', 'attendanceid', $attids); |
|
|
$DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); |
|
|
$DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); |
|
|
} |
|
|
} |
|
|
$DB->delete_records('attendance', array('course'=> $course->id)); |
|
|
$DB->delete_records('attendance', array('course' => $course->id)); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
@ -154,7 +154,7 @@ function attendance_reset_course_form_definition(&$mform) { |
|
|
* Course reset form defaults. |
|
|
* Course reset form defaults. |
|
|
*/ |
|
|
*/ |
|
|
function attendance_reset_course_form_defaults($course) { |
|
|
function attendance_reset_course_form_defaults($course) { |
|
|
return array('reset_attendance_log'=>0, 'reset_attendance_statuses'=>0, 'reset_attendance_sessions'=>0); |
|
|
return array('reset_attendance_log' => 0, 'reset_attendance_statuses' => 0, 'reset_attendance_sessions' => 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function attendance_reset_userdata($data) { |
|
|
function attendance_reset_userdata($data) { |
|
@ -162,7 +162,7 @@ function attendance_reset_userdata($data) { |
|
|
|
|
|
|
|
|
$status = array(); |
|
|
$status = array(); |
|
|
|
|
|
|
|
|
$attids = array_keys($DB->get_records('attendance', array('course'=> $data->courseid), '', 'id')); |
|
|
$attids = array_keys($DB->get_records('attendance', array('course' => $data->courseid), '', 'id')); |
|
|
|
|
|
|
|
|
if (!empty($data->reset_attendance_log)) { |
|
|
if (!empty($data->reset_attendance_log)) { |
|
|
$sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); |
|
|
$sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); |
|
@ -283,16 +283,16 @@ function attendance_grade_item_update($attendance, $grades=null) { |
|
|
if (!isset($attendance->courseid)) { |
|
|
if (!isset($attendance->courseid)) { |
|
|
$attendance->courseid = $attendance->course; |
|
|
$attendance->courseid = $attendance->course; |
|
|
} |
|
|
} |
|
|
if (! $course = $DB->get_record('course', array('id'=> $attendance->course))) { |
|
|
if (! $course = $DB->get_record('course', array('id' => $attendance->course))) { |
|
|
error("Course is misconfigured"); |
|
|
error("Course is misconfigured"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!empty($attendance->cmidnumber)) { |
|
|
if (!empty($attendance->cmidnumber)) { |
|
|
$params = array('itemname'=>$attendance->name, 'idnumber'=>$attendance->cmidnumber); |
|
|
$params = array('itemname' => $attendance->name, 'idnumber' => $attendance->cmidnumber); |
|
|
} else { |
|
|
} else { |
|
|
// MDL-14303. |
|
|
// MDL-14303. |
|
|
$cm = get_coursemodule_from_instance('attendance', $attendance->id); |
|
|
$cm = get_coursemodule_from_instance('attendance', $attendance->id); |
|
|
$params = array('itemname'=>$attendance->name/*, 'idnumber'=>$attendance->id*/); |
|
|
$params = array('itemname' => $attendance->name/*, 'idnumber'=>$attendance->id*/); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($attendance->grade > 0) { |
|
|
if ($attendance->grade > 0) { |
|
@ -330,7 +330,7 @@ function attendance_grade_item_delete($attendance) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return grade_update('mod/attendance', $attendance->courseid, 'mod', 'attendance', |
|
|
return grade_update('mod/attendance', $attendance->courseid, 'mod', 'attendance', |
|
|
$attendance->id, 0, null, array('deleted'=>1)); |
|
|
$attendance->id, 0, null, array('deleted' => 1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function attendance_get_participants($attendanceid) { |
|
|
function attendance_get_participants($attendanceid) { |
|
|