function course_update_7135 in Course 7.2
Same name and namespace in other branches
- 7 course.install \course_update_7135()
Update format for grade-based access
File
- ./
course.install, line 1139 - course.install Install and update functions for Courses.
Code
function course_update_7135() {
$sql = "SELECT * FROM {course_outline}";
$result = db_query($sql);
while ($row = $result
->fetch()) {
$data = unserialize($row->data);
if (isset($data['plugins']['access']['grade']['course_grade']) && (!empty($data['plugins']['access']['grade']['course_grade']) || $data['plugins']['access']['grade']['course_grade'] == '0')) {
// Get old value
$course_grade = $data['plugins']['access']['grade']['course_grade'];
// Remove old value
unset($data['plugins']['access']['grade']['course_grade']);
// Set new format
$data['plugins']['access']['grade']['course_grade_range'] = array(
'low' => $course_grade,
'high' => 100,
);
$row->data = serialize($data);
// Save
db_update('course_outline')
->fields(array(
'data' => $row->data,
))
->condition('coid', $row->coid)
->execute();
}
}
return t('Updated format for grade-based access.');
}