From 0e80b0b0fa5bb9a5a82134958b628837fb3582d1 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 29 Nov 2013 14:45:29 +1300 Subject: [PATCH] update grade_items and capability tables --- locallib.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/locallib.php b/locallib.php index 1975b0b..987181a 100644 --- a/locallib.php +++ b/locallib.php @@ -1395,6 +1395,24 @@ function attforblock_upgrade() { $module->name = 'attendance'; $DB->update_record('modules', $module); + // Now convert grade items to 'attendance' + $sql = "UPDATE {grade_items} + SET itemmodule = ? + WHERE itemmodule = ?"; + $DB->execute($sql, array('attendance', 'attforblock')); + + $sql = "UPDATE {grade_items_history} + SET itemmodule = 'attendance' + WHERE itemmodule = 'attforblock'"; + $DB->execute($sql); + + // Now convert role capabilities to 'attendance' + $sql = "UPDATE {role_capabilities} + SET capability = REPLACE(capability, ?, ?) + WHERE " . $DB->sql_like('capability', '?'); + $params = array("mod/attforblock:", "mod/attendance:", "mod/attforblock:%"); + $DB->execute($sql, $params); + // Clear cache for courses with attendances. $attendances = $DB->get_recordset('attendance', array(), '', 'course'); foreach ($attendances as $attendance) {