本文整理汇总了PHP中rating_manager::get_user_grades方法的典型用法代码示例。如果您正苦于以下问题:PHP rating_manager::get_user_grades方法的具体用法?PHP rating_manager::get_user_grades怎么用?PHP rating_manager::get_user_grades使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rating_manager
的用法示例。
在下文中一共展示了rating_manager::get_user_grades方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_get_user_grades
/**
* Return grade for given user or all users.
*
* @global object
* @global object
* @param object $forum
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
function forum_get_user_grades($forum, $userid = 0) {
global $CFG;
require_once($CFG->dirroot.'/rating/lib.php');
$ratingoptions = new stdClass;
$ratingoptions->component = 'mod_forum';
$ratingoptions->ratingarea = 'post';
//need these to work backwards to get a context id. Is there a better way to get contextid from a module instance?
$ratingoptions->modulename = 'forum';
$ratingoptions->moduleid = $forum->id;
$ratingoptions->userid = $userid;
$ratingoptions->aggregationmethod = $forum->assessed;
$ratingoptions->scaleid = $forum->scale;
$ratingoptions->itemtable = 'forum_posts';
$ratingoptions->itemtableusercolumn = 'userid';
$rm = new rating_manager();
return $rm->get_user_grades($ratingoptions);
}
示例2: glossary_get_user_grades
/**
* Return grade for given user or all users.
*
* @global object
* @param int $glossaryid id of glossary
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
function glossary_get_user_grades($glossary, $userid = 0)
{
/*global $DB;
$params = array('userid'=>$userid, 'gid'=>$glossary->id);
$user = $userid ? "AND u.id = :userid" : "";
$sql = "SELECT u.id, u.id AS userid, avg(gr.rating) AS rawgrade
FROM {user} u, {glossary_entries} ge, {glossary_ratings} gr
WHERE u.id = ge.userid AND ge.id = gr.entryid
AND gr.userid != u.id AND ge.glossaryid = :gid
$user
GROUP BY u.id";
return $DB->get_records_sql($sql, $params);*/
global $CFG;
require_once $CFG->dirroot . '/rating/lib.php';
$rm = new rating_manager();
$ratingoptions = new stdclass();
//need these to work backwards to get a context id. Is there a better way to get contextid from a module instance?
$ratingoptions->modulename = 'glossary';
$ratingoptions->moduleid = $glossary->id;
$ratingoptions->userid = $userid;
$ratingoptions->aggregationmethod = $glossary->assessed;
$ratingoptions->scaleid = $glossary->scale;
$ratingoptions->itemtable = 'glossary_entries';
$ratingoptions->itemtableusercolumn = 'userid';
return $rm->get_user_grades($ratingoptions);
}
示例3: data_get_user_grades
/**
* Return grade for given user or all users.
*
* @global object
* @param object $data
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
function data_get_user_grades($data, $userid=0) {
global $CFG;
require_once($CFG->dirroot.'/rating/lib.php');
$ratingoptions = new stdClass;
$ratingoptions->component = 'mod_data';
$ratingoptions->ratingarea = 'entry';
$ratingoptions->modulename = 'data';
$ratingoptions->moduleid = $data->id;
$ratingoptions->userid = $userid;
$ratingoptions->aggregationmethod = $data->assessed;
$ratingoptions->scaleid = $data->scale;
$ratingoptions->itemtable = 'data_records';
$ratingoptions->itemtableusercolumn = 'userid';
$rm = new rating_manager();
return $rm->get_user_grades($ratingoptions);
}
示例4: glossary_get_user_grades
/**
* Return grade for given user or all users.
*
* @global object
* @param int $glossaryid id of glossary
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
function glossary_get_user_grades($glossary, $userid = 0)
{
global $CFG;
require_once $CFG->dirroot . '/rating/lib.php';
$rm = new rating_manager();
$ratingoptions = new stdclass();
//need these to work backwards to get a context id. Is there a better way to get contextid from a module instance?
$ratingoptions->modulename = 'glossary';
$ratingoptions->moduleid = $glossary->id;
$ratingoptions->userid = $userid;
$ratingoptions->aggregationmethod = $glossary->assessed;
$ratingoptions->scaleid = $glossary->scale;
$ratingoptions->itemtable = 'glossary_entries';
$ratingoptions->itemtableusercolumn = 'userid';
return $rm->get_user_grades($ratingoptions);
}