Talk:Moodle Activity Extensions Spec
From MoodleDocs
Tim Hunt raised: "It will be a classic performance failure (DB query in a loop)"
I think he's referring to the
if(isset($extension) && $extension == true) {
$cmdetail = extension::update_duedate($cmid, $USER->id, $cmdetail);
$cmdetail->extension = true;
}
bit...
You seem to be proposing that the activity object (regardless of the activity) is fetched and it's "deadline" attribute updated with the appropriate deadline taking into account any extension.
so wouldn't something like following be better for get_coursemodule_from_id():
$sql = "SELECT cm.*, m.name, md.name AS modname $sectionfield
FROM {course_modules} cm
JOIN {modules} md ON md.id = cm.module
JOIN {".$modulename."} m ON m.id = cm.instance
JOIN {extensions} ext ON ext.cm_id = cm.id
$sectionjoin
WHERE cm.id = :cmid
AND md.name = :modulename
AND ext.student_id = :userid
$courseselect";
This would return the cm object with additional fields for the (current) user. Of course runs into issues with then getting the coursemodule for the non-current user.... --Michael Hughes 22:05, 14 January 2013 (WST)