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


PHP forum_get_user_grades函数代码示例

本文整理汇总了PHP中forum_get_user_grades函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_user_grades函数的具体用法?PHP forum_get_user_grades怎么用?PHP forum_get_user_grades使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forum_get_user_grades函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: forum_update_grades

/**
 * Update grades by firing grade_updated event
 *
 * @param object $forum null means all forums
 * @param int $userid specific user only, 0 mean all
 * @param boolean $nullifnone return null if grade does not exist
 * @return void
 */
function forum_update_grades($forum = null, $userid = 0, $nullifnone = true)
{
    global $CFG;
    if ($forum != null) {
        require_once $CFG->libdir . '/gradelib.php';
        if ($grades = forum_get_user_grades($forum, $userid)) {
            forum_grade_item_update($forum, $grades);
        } else {
            if ($userid and $nullifnone) {
                $grade = new object();
                $grade->userid = $userid;
                $grade->rawgrade = NULL;
                forum_grade_item_update($forum, $grade);
            } else {
                forum_grade_item_update($forum);
            }
        }
    } else {
        $sql = "SELECT f.*, cm.idnumber as cmidnumber\n                  FROM {$CFG->prefix}forum f, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m\n                 WHERE m.name='forum' AND m.id=cm.module AND cm.instance=f.id";
        if ($rs = get_recordset_sql($sql)) {
            while ($forum = rs_fetch_next_record($rs)) {
                if ($forum->assessed) {
                    forum_update_grades($forum, 0, false);
                } else {
                    forum_grade_item_update($forum);
                }
            }
            rs_close($rs);
        }
    }
}
开发者ID:r007,项目名称:PMoodle,代码行数:39,代码来源:lib.php

示例2: forum_update_grades

/**
 * Update activity grades
 *
 * @category grade
 * @param object $forum
 * @param int $userid specific user only, 0 means all
 * @param boolean $nullifnone return null if grade does not exist
 * @return void
 */
function forum_update_grades($forum, $userid=0, $nullifnone=true) {
    global $CFG, $DB;
    require_once($CFG->libdir.'/gradelib.php');

    if (!$forum->assessed) {
        forum_grade_item_update($forum);

    } else if ($grades = forum_get_user_grades($forum, $userid)) {
        forum_grade_item_update($forum, $grades);

    } else if ($userid and $nullifnone) {
        $grade = new stdClass();
        $grade->userid   = $userid;
        $grade->rawgrade = NULL;
        forum_grade_item_update($forum, $grade);

    } else {
        forum_grade_item_update($forum);
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:29,代码来源:lib.php

示例3: forum_grades

/**
 * Must return an array of grades, indexed by user, and a max grade.
 */
function forum_grades($forumid)
{
    if (!($forum = get_record("forum", "id", $forumid))) {
        return false;
    }
    if (!$forum->assessed) {
        return false;
    }
    $scalemenu = make_grades_menu($forum->scale);
    $currentuser = 0;
    $ratingsuser = array();
    if ($ratings = forum_get_user_grades($forumid)) {
        foreach ($ratings as $rating) {
            // Ordered by user
            if ($currentuser and $rating->userid != $currentuser) {
                if (!empty($ratingsuser)) {
                    if ($forum->scale < 0) {
                        $return->grades[$currentuser] = forum_get_ratings_mean(0, $scalemenu, $ratingsuser);
                        $return->grades[$currentuser] .= "<br />" . forum_get_ratings_summary(0, $scalemenu, $ratingsuser);
                    } else {
                        $total = 0;
                        $count = 0;
                        foreach ($ratingsuser as $ra) {
                            $total += $ra;
                            $count++;
                        }
                        $return->grades[$currentuser] = format_float($total / $count, 2);
                    }
                } else {
                    $return->grades[$currentuser] = "";
                }
                $ratingsuser = array();
            }
            $ratingsuser[] = $rating->rating;
            $currentuser = $rating->userid;
        }
        if (!empty($ratingsuser)) {
            if ($forum->scale < 0) {
                $return->grades[$currentuser] = forum_get_ratings_mean(0, $scalemenu, $ratingsuser);
                $return->grades[$currentuser] .= "<br />" . forum_get_ratings_summary(0, $scalemenu, $ratingsuser);
            } else {
                $total = 0;
                $count = 0;
                foreach ($ratingsuser as $ra) {
                    $total += $ra;
                    $count++;
                }
                $return->grades[$currentuser] = format_float((double) $total / (double) $count, 2);
            }
        } else {
            $return->grades[$currentuser] = "";
        }
    } else {
        $return->grades = array();
    }
    if ($forum->scale < 0) {
        $return->maxgrade = "";
    } else {
        $return->maxgrade = $forum->scale;
    }
    return $return;
}
开发者ID:njorth,项目名称:marginalia,代码行数:65,代码来源:lib.php


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