From: stronk7 Date: Sun, 16 May 2004 00:36:00 +0000 (+0000) Subject: Step 2 of Bug 1223 done. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2127fedda8645854dc7088e379fb627bd7847b8a;p=moodle.git Step 2 of Bug 1223 done. (http://moodle.org/bugs/bug.php?op=show&bugid=1223) --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index e9862593b7..2401f1c449 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2397,6 +2397,51 @@ function make_grades_menu($gradingtype) { return $grades; } +function course_scale_used($courseid,$scaleid) { +////This function returns the nummber of activities +////using scaleid in a courseid + + global $CFG; + + $return = 0; + + if (!empty($scaleid)) { + if ($cms = get_course_mods($courseid)) { + foreach ($cms as $cm) { + //Check cm->name/lib.php exists + if (file_exists($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php')) { + include_once($CFG->dirroot.'/mod/'.$cm->modname.'/lib.php'); + $function_name = $cm->modname.'_scale_used'; + if (function_exists($function_name)) { + if ($function_name($cm->instance,$scaleid)) { + $return++; + } + } + } + } + } + } + return $return; +} + +function site_scale_used($scaleid) { +////This function returns the nummber of activities +////using scaleid in the entire site + + global $CFG; + + $return = 0; + + if (!empty($scaleid)) { + if ($courses = get_courses()) { + foreach ($courses as $course) { + $return += course_scale_used($course->id,$scaleid); + } + } + } + return $return; +} + function make_unique_id_code($extra="") { $hostname = "unknownhost"; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index 36a754040d..a449100105 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -384,7 +384,7 @@ function assignment_scale_used ($assignmentid,$scaleid) { $rec = get_record("assignment","id","$assignmentid","grade","-$scaleid"); - if (!empty($rec)) { + if (!empty($rec) && !empty($scaleid)) { $return = true; } diff --git a/mod/forum/lib.php b/mod/forum/lib.php index d058a2de6f..ba778dfafc 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -591,7 +591,7 @@ function forum_scale_used ($forumid,$scaleid) { $rec = get_record("forum","id","$forumid","scale","-$scaleid"); - if (!empty($rec)) { + if (!empty($rec) && !empty($scaleid)) { $return = true; } diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 8ac26c3c71..71a40a8b05 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -369,7 +369,7 @@ function glossary_scale_used ($glossaryid,$scaleid) { $rec = get_record("glossary","id","$glossaryid","scale","-$scaleid"); - if (!empty($rec)) { + if (!empty($rec) && !empty($scaleid)) { $return = true; } diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 7e120f1d17..56d7843178 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -299,7 +299,7 @@ function journal_scale_used ($journalid,$scaleid) { $rec = get_record("journal","id","$journalid","assessed","-$scaleid"); - if (!empty($rec)) { + if (!empty($rec) && !empty($scaleid)) { $return = true; }