|
@ -28,6 +28,17 @@ function attforblock_supports($feature) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function att_add_default_statuses($attid) { |
|
|
|
|
|
global $DB; |
|
|
|
|
|
|
|
|
|
|
|
$statuses = $DB->get_records('attendance_statuses', array('attendanceid'=> 0), 'id'); |
|
|
|
|
|
foreach($statuses as $st) { |
|
|
|
|
|
$rec = $st; |
|
|
|
|
|
$rec->attendanceid = $attid; |
|
|
|
|
|
$DB->insert_record('attendance_statuses', $rec); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function attforblock_add_instance($attforblock) { |
|
|
function attforblock_add_instance($attforblock) { |
|
|
/// Given an object containing all the necessary data, |
|
|
/// Given an object containing all the necessary data, |
|
|
/// (defined by the form in mod.html) this function |
|
|
/// (defined by the form in mod.html) this function |
|
@ -40,12 +51,7 @@ function attforblock_add_instance($attforblock) { |
|
|
|
|
|
|
|
|
$attforblock->id = $DB->insert_record('attforblock', $attforblock); |
|
|
$attforblock->id = $DB->insert_record('attforblock', $attforblock); |
|
|
|
|
|
|
|
|
$statuses = $DB->get_records('attendance_statuses', array('attendanceid'=> 0), 'id'); |
|
|
att_add_default_statuses($attforblock->id); |
|
|
foreach($statuses as $st) { |
|
|
|
|
|
$rec = $st; |
|
|
|
|
|
$rec->attendanceid = $attforblock->id; |
|
|
|
|
|
$DB->insert_record('attendance_statuses', $rec); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
attforblock_grade_item_update($attforblock); |
|
|
attforblock_grade_item_update($attforblock); |
|
|
// attforblock_update_grades($attforblock); |
|
|
// attforblock_update_grades($attforblock); |
|
@ -138,24 +144,50 @@ function attforblock_reset_course_form_defaults($course) { |
|
|
function attforblock_reset_userdata($data) { |
|
|
function attforblock_reset_userdata($data) { |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
|
|
|
|
$status = array(); |
|
|
|
|
|
|
|
|
|
|
|
$attids = array_keys($DB->get_records('attforblock', array('course'=> $data->courseid), '', 'id')); |
|
|
|
|
|
|
|
|
if (!empty($data->reset_attendance_log)) { |
|
|
if (!empty($data->reset_attendance_log)) { |
|
|
$sess = $DB->get_records('attendance_sessions', array('courseid'=> $data->courseid), '', 'id'); |
|
|
$sess = $DB->get_records_list('attendance_sessions', 'attendanceid', $attids, '', 'id'); |
|
|
$slist = implode(',', array_keys($sess)); |
|
|
if (!empty($sess)) { |
|
|
$DB->delete_records_select('attendance_log', "sessionid IN ($slist)"); |
|
|
list($sql, $params) = $DB->get_in_or_equal(array_keys($sess)); |
|
|
$DB->set_field('attendance_sessions', 'lasttaken', 0, array('courseid' => $data->courseid)); |
|
|
$DB->delete_records_select('attendance_log', "sessionid $sql", $params); |
|
|
|
|
|
list($sql, $params) = $DB->get_in_or_equal($attids); |
|
|
|
|
|
$DB->set_field_select('attendance_sessions', 'lasttaken', 0, "attendanceid $sql", $params); |
|
|
|
|
|
|
|
|
|
|
|
$status[] = array( |
|
|
|
|
|
'component' => get_string('modulenameplural', 'attforblock'), |
|
|
|
|
|
'item' => get_string('attendancedata', 'attforblock'), |
|
|
|
|
|
'error' => false |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!empty($data->reset_attendance_statuses)) { |
|
|
if (!empty($data->reset_attendance_statuses)) { |
|
|
$DB->delete_records('attendance_statuses', array('courseid'=> $data->courseid)); |
|
|
$DB->delete_records_list('attendance_statuses', 'attendanceid', $attids); |
|
|
$statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id'); |
|
|
foreach($attids as $attid) { |
|
|
foreach($statuses as $stat) { |
|
|
att_add_default_statuses($attid); |
|
|
$rec = $stat; |
|
|
|
|
|
$rec->courseid = $data->courseid; |
|
|
|
|
|
$DB->insert_record('attendance_statuses', $rec); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$status[] = array( |
|
|
|
|
|
'component' => get_string('modulenameplural', 'attforblock'), |
|
|
|
|
|
'item' => get_string('sessions', 'attforblock'), |
|
|
|
|
|
'error' => false |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!empty($data->reset_attendance_sessions)) { |
|
|
if (!empty($data->reset_attendance_sessions)) { |
|
|
$DB->delete_records('attendance_sessions', array('courseid'=> $data->courseid)); |
|
|
$DB->delete_records_list('attendance_sessions', 'attendanceid', $attids); |
|
|
|
|
|
|
|
|
|
|
|
$status[] = array( |
|
|
|
|
|
'component' => get_string('modulenameplural', 'attforblock'), |
|
|
|
|
|
'item' => get_string('statuses', 'attforblock'), |
|
|
|
|
|
'error' => false |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $status; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function attforblock_user_outline($course, $user, $mod, $attforblock) { |
|
|
function attforblock_user_outline($course, $user, $mod, $attforblock) { |
|
|