当前位置: 首页>>代码示例>>PHP>>正文


PHP course_scale_used函数代码示例

本文整理汇总了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;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:54,代码来源:grade_scale.php

示例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;
}
开发者ID:riawarra,项目名称:moodle,代码行数:22,代码来源:moodlelib.php

示例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;
}
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:41,代码来源:backuplib.php

示例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;
}
开发者ID:evltuma,项目名称:moodle,代码行数:24,代码来源:deprecatedlib.php

示例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}&amp;scaleid={$scale->id}&amp;action=details\" " . "onclick=\"return openpopup('/course/scales.php?id={$course->id}\\&amp;scaleid={$scale->id}&amp;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}&amp;scaleid={$scale->id}&amp;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}&amp;scaleid={$scale->id}&amp;action=down&amp;sesskey={$USER->sesskey}\"><img" . " src=\"{$CFG->pixpath}/t/down.gif\" class=\"iconsmall\" alt=\"{$strdown}\" /></a> ";
            }
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:scales.php

示例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;
}
开发者ID:veritech,项目名称:pare-project,代码行数:51,代码来源:moodlelib.php


注:本文中的course_scale_used函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。