From 239f977cf3770214f681d1c521cea9028d2a628d Mon Sep 17 00:00:00 2001 From: Artem Andreev Date: Fri, 17 Jun 2011 14:41:40 +0400 Subject: [PATCH] Fixed bug with adding new attendance instance: now attendanceid for statuses is filled correctly --- lib.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib.php b/lib.php index 7205dda..791100d 100644 --- a/lib.php +++ b/lib.php @@ -57,15 +57,13 @@ function attforblock_add_instance($attforblock) { $attforblock->id = $DB->insert_record('attforblock', $attforblock); - //Copy statuses for new instance from defaults - //if (!$DB->get_records('attendance_statuses', array('courseid'=> $attforblock->course))) { - $statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id'); - foreach($statuses as $stat) { - $rec = $stat; - $rec->courseid = $attforblock->course; - $DB->insert_record('attendance_statuses', $rec); - } - //} + $statuses = $DB->get_records('attendance_statuses', array('courseid'=> 0), 'id'); + foreach($statuses as $st) { + $rec = $st; + $rec->courseid = $attforblock->course; + $rec->attendanceid = $attforblock->id; + $DB->insert_record('attendance_statuses', $rec); + } // attforblock_grade_item_update($attforblock); // attforblock_update_grades($attforblock);