|
@ -457,10 +457,11 @@ class sessions { |
|
|
|
|
|
|
|
|
foreach ($sessions as $index => $sess) { |
|
|
foreach ($sessions as $index => $sess) { |
|
|
// Check for duplicate sessions. |
|
|
// Check for duplicate sessions. |
|
|
if ($this->session_exists($sess)) { |
|
|
if ($this->session_exists($sess, $att->id)) { |
|
|
mod_attendance_notifyqueue::notify_message(get_string('sessionduplicate', 'attendance', (array( |
|
|
mod_attendance_notifyqueue::notify_message(get_string('sessionduplicate', 'attendance', (array( |
|
|
'course' => $session->course, |
|
|
'course' => $session->course, |
|
|
'activity' => $cm->name |
|
|
'activity' => $cm->name, |
|
|
|
|
|
'date' => construct_session_full_date_time($sess->sessdate, $sess->duration) |
|
|
)))); |
|
|
)))); |
|
|
unset($sessions[$index]); |
|
|
unset($sessions[$index]); |
|
|
} else { |
|
|
} else { |
|
@ -504,19 +505,16 @@ class sessions { |
|
|
* Check if an identical session exists. |
|
|
* Check if an identical session exists. |
|
|
* |
|
|
* |
|
|
* @param stdClass $session |
|
|
* @param stdClass $session |
|
|
|
|
|
* @param int $attid |
|
|
* @return boolean |
|
|
* @return boolean |
|
|
*/ |
|
|
*/ |
|
|
private function session_exists(stdClass $session) { |
|
|
private function session_exists(stdClass $session, $attid) { |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
|
$check = clone $session; |
|
|
$check = ['attendanceid' => $attid, |
|
|
|
|
|
'sessdate' => $session->sessdate, |
|
|
// Remove the properties that aren't useful to check. |
|
|
'duration' => $session->duration, |
|
|
unset($check->description); |
|
|
'groupid' => $session->groupid]; |
|
|
unset($check->descriptionitemid); |
|
|
|
|
|
unset($check->timemodified); |
|
|
|
|
|
$check = (array) $check; |
|
|
|
|
|
|
|
|
|
|
|
if ($DB->record_exists('attendance_sessions', $check)) { |
|
|
if ($DB->record_exists('attendance_sessions', $check)) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|