From: skodak Date: Fri, 1 Feb 2008 08:15:38 +0000 (+0000) Subject: MDL-7547 yet more speed improvements in rebuild_course_cache() ; merged from MOODLE_1... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1ea543df62ae26673679bfa43b5c81259f7bab28;p=moodle.git MDL-7547 yet more speed improvements in rebuild_course_cache() ; merged from MOODLE_19_STABLE --- diff --git a/course/lib.php b/course/lib.php index 8f0c9dd3e6..10748800f1 100644 --- a/course/lib.php +++ b/course/lib.php @@ -974,7 +974,6 @@ function get_array_of_activities($courseid) { $mod[$seq]->cm = $rawmods[$seq]->id; $mod[$seq]->mod = $rawmods[$seq]->modname; $mod[$seq]->section = $section->section; - $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance)); $mod[$seq]->visible = $rawmods[$seq]->visible; $mod[$seq]->groupmode = $rawmods[$seq]->groupmode; $mod[$seq]->groupingid = $rawmods[$seq]->groupingid; @@ -994,8 +993,14 @@ function get_array_of_activities($courseid) { if (!empty($info->icon)) { $mod[$seq]->icon = $info->icon; } + if (!empty($info->name)) { + $mod[$seq]->name = urlencode($info->name); + } } } + if (!isset($mod[$seq]->name)) { + $mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance)); + } } } } diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 59ab2386ab..96127a5184 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -2744,20 +2744,26 @@ function assignment_get_all_submissions($assignment, $sort="", $dir="DESC") { function assignment_get_coursemodule_info($coursemodule) { global $CFG; - if (! $type = get_field('assignment', 'assignmenttype', 'id', $coursemodule->instance)) { + if (! $assignment = get_record('assignment', 'id', $coursemodule->instance, '', '', '', '', 'id, assignmenttype, name')) { return false; } - $libfile = "$CFG->dirroot/mod/assignment/type/$type/assignment.class.php"; + $libfile = "$CFG->dirroot/mod/assignment/type/$assignment->assignmenttype/assignment.class.php"; if (file_exists($libfile)) { require_once($libfile); - $assignmentclass = "assignment_$type"; + $assignmentclass = "assignment_$assignment->assignmenttype"; $ass = new $assignmentclass('staticonly'); - return $ass->get_coursemodule_info($coursemodule); + if ($result = $ass->get_coursemodule_info($coursemodule)) { + return $result; + } else { + $info = new object(); + $info->name = $assignment->name; + return $info; + } } else { - debugging('Incorrect assignment type: '.$type); + debugging('Incorrect assignment type: '.$assignment->assignmenttype); return false; } } diff --git a/mod/label/lib.php b/mod/label/lib.php index e4425f2682..fbfa48b160 100644 --- a/mod/label/lib.php +++ b/mod/label/lib.php @@ -71,9 +71,10 @@ function label_get_participants($labelid) { * See get_array_of_activities() in course/lib.php */ function label_get_coursemodule_info($coursemodule) { - if ($content = get_field('label', 'content', 'id', $coursemodule->instance)) { + if ($label = get_record('label', 'id', $coursemodule->instance, '', '', '', '', 'id, content, name')) { $info = new object(); - $info->extra = urlencode($content); + $info->extra = urlencode($label->content); + $info->name = urlencode($label->name); return $info; } else { return null; diff --git a/mod/resource/lib.php b/mod/resource/lib.php index e89605dbd7..3cc8b2d62c 100644 --- a/mod/resource/lib.php +++ b/mod/resource/lib.php @@ -349,8 +349,9 @@ function resource_get_coursemodule_info($coursemodule) { $info = NULL; - if ($resource = get_record("resource", "id", $coursemodule->instance, '', '', '', '', 'id, popup, reference, type')) { + if ($resource = get_record("resource", "id", $coursemodule->instance, '', '', '', '', 'id, popup, reference, type, name')) { $info = new object(); + $info->name = $resource->name; if (!empty($resource->popup)) { $info->extra = urlencode("onclick=\"this.target='resource$resource->id'; return ". "openpopup('/mod/resource/view.php?inpopup=true&id=".