Step 2 of Bug 1223 done.
(http://moodle.org/bugs/bug.php?op=show&bugid=1223)
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user