本文整理汇总了PHP中course_scale_used函数的典型用法代码示例。如果您正苦于以下问题:PHP course_scale_used函数的具体用法?PHP course_scale_used怎么用?PHP course_scale_used使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了course_scale_used函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_used
/**
* Returns if scale used anywhere - activities, grade items, outcomes, etc.
* @return bool
*/
function is_used()
{
global $CFG;
// count grade items excluding the
$sql = "SELECT COUNT(id) FROM {$CFG->prefix}grade_items WHERE scaleid = {$this->id} AND outcomeid IS NULL";
if (count_records_sql($sql)) {
return true;
}
// count outcomes
$sql = "SELECT COUNT(id) FROM {$CFG->prefix}grade_outcomes WHERE scaleid = {$this->id}";
if (count_records_sql($sql)) {
return true;
}
$legacy_mods = false;
if ($mods = get_records('modules', 'visible', 1)) {
foreach ($mods as $mod) {
//Check cm->name/lib.php exists
if (file_exists($CFG->dirroot . '/mod/' . $mod->name . '/lib.php')) {
include_once $CFG->dirroot . '/mod/' . $mod->name . '/lib.php';
$function_name = $mod->name . '_scale_used_anywhere';
$old_function_name = $mod->name . '_scale_used';
if (function_exists($function_name)) {
if ($function_name($this->id)) {
return true;
}
} else {
if (function_exists($old_function_name)) {
$legacy_mods = true;
debugging('Please notify the developer of module "' . $mod->name . '" that new function module_scale_used_anywhere() should be implemented.', DEBUG_DEVELOPER);
break;
}
}
}
}
}
// some mods are missing the new xxx_scale_used_anywhere() - use the really slow old way
if ($legacy_mods) {
if (!empty($this->courseid)) {
if (course_scale_used($this->courseid, $this->id)) {
return true;
}
} else {
$courses = array();
if (site_scale_used($this->id, $courses)) {
return true;
}
}
}
return false;
}
示例2: site_scale_used
/**
* This function returns the number of activities using scaleid in the entire site
*
* @param int $scaleid
* @param array $courses
* @return int
*/
function site_scale_used($scaleid, &$courses)
{
$return = 0;
if (!is_array($courses) || count($courses) == 0) {
$courses = get_courses("all", false, "c.id, c.shortname");
}
if (!empty($scaleid)) {
if (is_array($courses) && count($courses) > 0) {
foreach ($courses as $course) {
$return += course_scale_used($course->id, $scaleid);
}
}
}
return $return;
}
示例3: backup_scales_info
function backup_scales_info($bf, $preferences)
{
global $CFG;
$status = true;
//Counter, points to current record
$counter = 0;
//Get scales (common and course scales)
$scales = get_records_sql("SELECT id, courseid, userid, name, scale, description, timemodified\n FROM {$CFG->prefix}scale\n WHERE courseid = 0 OR courseid = {$preferences->backup_course}");
//Copy only used scales to $backupscales. They will be in backup (unused no). See Bug 1223.
$backupscales = array();
if ($scales) {
foreach ($scales as $scale) {
if (course_scale_used($preferences->backup_course, $scale->id)) {
$backupscales[] = $scale;
}
}
}
//Pring scales header
if ($backupscales) {
//Pring scales header
fwrite($bf, start_tag("SCALES", 2, true));
//Iterate
foreach ($backupscales as $scale) {
//Begin scale tag
fwrite($bf, start_tag("SCALE", 3, true));
//Output scale tag
fwrite($bf, full_tag("ID", 4, false, $scale->id));
fwrite($bf, full_tag("COURSEID", 4, false, $scale->courseid));
fwrite($bf, full_tag("USERID", 4, false, $scale->userid));
fwrite($bf, full_tag("NAME", 4, false, $scale->name));
fwrite($bf, full_tag("SCALETEXT", 4, false, $scale->scale));
fwrite($bf, full_tag("DESCRIPTION", 4, false, $scale->description));
fwrite($bf, full_tag("TIMEMODIFIED", 4, false, $scale->timemodified));
//End scale tag
fwrite($bf, end_tag("SCALE", 3, true));
}
//End scales tag
$status = fwrite($bf, end_tag("SCALES", 2, true));
}
return $status;
}
示例4: site_scale_used
/**
* This function returns the number of activities using scaleid in the entire site
*
* @deprecated since Moodle 3.1
* @param int $scaleid
* @param array $courses
* @return int
*/
function site_scale_used($scaleid, &$courses)
{
$return = 0;
debugging('site_scale_used() is deprecated and never used, plugins can implement <modname>_scale_used_anywhere, ' . 'all implementations of <modname>_scale_used are now ignored', DEBUG_DEVELOPER);
if (!is_array($courses) || count($courses) == 0) {
$courses = get_courses("all", false, "c.id, c.shortname");
}
if (!empty($scaleid)) {
if (is_array($courses) && count($courses) > 0) {
foreach ($courses as $course) {
$return += course_scale_used($course->id, $scaleid);
}
}
}
return $return;
}
示例5: array
if ($scales) {
//Calculate the base path
$path = "{$CFG->wwwroot}/course";
$data = array();
$incustom = true;
foreach ($scales as $scale) {
//Check the separator
if (empty($scale->courseid) && $incustom) {
$incustom = false;
$line = "hr";
$data[] = $line;
}
$line = array();
$line[] = "<a target=\"scale\" title=\"{$scale->name}\" href=\"{$CFG->wwwroot}/course/scales.php?id={$course->id}&scaleid={$scale->id}&action=details\" " . "onclick=\"return openpopup('/course/scales.php?id={$course->id}\\&scaleid={$scale->id}&action=details', 'scale', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);\">" . $scale->name . "</a><br /><font size=\"-1\">" . str_replace(",", ", ", $scale->scale) . "</font>";
if (!empty($scale->courseid)) {
$scale_used = course_scale_used($course->id, $scale->id);
} else {
$scale_used = site_scale_used($scale->id, $courses);
}
$line[] = $scale_used ? get_string("yes") : get_string("no");
if ($incustom) {
$line[] = $strcustomscale;
} else {
$line[] = $strstandardscale;
}
$buttons = "";
if (!$scale_used && ($incustom || has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID)))) {
$buttons .= "<a title=\"{$stredit}\" href=\"{$path}/scales.php?id={$course->id}&scaleid={$scale->id}&action=edit\"><img" . " src=\"{$CFG->pixpath}/t/edit.gif\" class=\"iconsmall\" alt=\"{$stredit}\" /></a> ";
if ($incustom && has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
$buttons .= "<a title=\"{$strdown}\" href=\"{$path}/scales.php?id={$course->id}&scaleid={$scale->id}&action=down&sesskey={$USER->sesskey}\"><img" . " src=\"{$CFG->pixpath}/t/down.gif\" class=\"iconsmall\" alt=\"{$strdown}\" /></a> ";
}
示例6: site_scale_used
/**
* Returns true if a scale is in use anywhere on the site.
*
* @param int $scaleid The scale to be checked.
* @param array $courses The site courses, needed is the old way to check has to be used.
* @return boolean
*/
function site_scale_used($scaleid, &$courses)
{
if (empty($scaleid)) {
return false;
}
global $CFG;
$return = 0;
$legacy_mods = false;
if ($mods = get_records('modules', 'visible', 1)) {
foreach ($mods as $mod) {
//Check $mod->name/lib.php exists
if (file_exists($CFG->dirroot . '/mod/' . $mod->name . '/lib.php')) {
include_once $CFG->dirroot . '/mod/' . $mod->name . '/lib.php';
$function_name = $mod->name . '_scale_used_anywhere';
$old_function_name = $mod->name . '_scale_used';
if (function_exists($function_name)) {
if ($function_name($scaleid)) {
return true;
}
} else {
if (function_exists($old_function_name)) {
$legacy_mods = true;
debugging('Please notify the developer of module "' . $mod->name . '" that new function module_scale_used_anywhere() should be implemented.', DEBUG_DEVELOPER);
break;
}
}
}
}
}
// some mods are missing the new xxx_scale_used_anywhere() - use the really slow old way
if ($legacy_mods) {
if (!is_array($courses) || count($courses) == 0) {
$courses = get_courses("all", false, "c.id,c.shortname");
}
if (is_array($courses) && count($courses) > 0) {
foreach ($courses as $course) {
if (course_scale_used($course->id, $scaleid)) {
return true;
}
}
}
}
return false;
}