本文整理汇总了PHP中rating类的典型用法代码示例。如果您正苦于以下问题:PHP rating类的具体用法?PHP rating怎么用?PHP rating使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rating类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSave
/**
* Set the position value automatically when a new sortable object is created
*
* @param Doctrine_Event $event
* @return void
* @author Travis Black
*/
public function postSave(Doctrine_Event $event)
{
$object = $event->getInvoker();
$added_rating = Doctrine_Template_Rateable::get_rating($object);
foreach ($added_rating as $rated) {
$rating = new rating();
$rating->setClass(get_class($object));
$rating->setObjectId($object->getId());
$rating->setRating($rated);
$rating->save();
}
}
示例2: rating_form
function rating_form($table)
{
$ip = $_SERVER["REMOTE_ADDR"];
if (!isset($table) && isset($_GET['table'])) {
$table = $_GET['table'];
}
$rating = new rating($table);
$status = "<div class='score'>\n\t\t\t\t<a class='score1' href='?score=1&table={$table}&user={$ip}'>1</a>\n\t\t\t\t<a class='score2' href='?score=2&table={$table}&user={$ip}'>2</a>\n\t\t\t\t<a class='score3' href='?score=3&table={$table}&user={$ip}'>3</a>\n\t\t\t\t<a class='score4' href='?score=4&table={$table}&user={$ip}'>4</a>\n\t\t\t\t<a class='score5' href='?score=5&table={$table}&user={$ip}'>5</a>\n\t\t\t</div>\n\t";
if (isset($_GET['score'])) {
$score = $_GET['score'];
if (is_numeric($score) && $score <= 5 && $score >= 1 && $table == $_GET['table'] && isset($_GET["user"]) && $ip == $_GET["user"]) {
$rating->set_score($score, $ip);
$status = $rating->status;
}
}
if (!isset($_GET['update'])) {
echo "<div class='rating_wrapper'>";
}
?>
<div class="sp_rating">
<div class="rating">Rating:</div>
<div class="base"><div class="average" style="width:<?php
echo $rating->average;
?>
%"><?php
echo $rating->average;
?>
</div></div>
<div class="votes"><?php
echo $rating->votes;
?>
votes</div>
<div class="status">
<?php
echo $status;
?>
</div>
</div>
<?php
if (!isset($_GET['update'])) {
echo "</div>";
}
}
示例3: __construct
/**
* Constructor.
*
* @param stdClass $options {
* context => context context to use for the rating [required]
* component => component using ratings ie mod_forum [required]
* ratingarea => ratingarea to associate this rating with [required]
* itemid => int the id of the associated item (forum post, glossary item etc) [required]
* scaleid => int The scale in use when the rating was submitted [required]
* userid => int The id of the user who submitted the rating [required]
* settings => Settings for the rating object [optional]
* id => The id of this rating (if the rating is from the db) [optional]
* aggregate => The aggregate for the rating [optional]
* count => The number of ratings [optional]
* rating => The rating given by the user [optional]
* }
*/
public function __construct($options)
{
parent::__construct($options);
if (isset($options->avgratings)) {
$this->ratingavg = $options->avgratings;
}
if (isset($options->maxratings)) {
$this->ratingmax = $options->maxratings;
}
if (isset($options->avgratings)) {
$this->ratingmin = $options->minratings;
}
if (isset($options->avgratings)) {
$this->ratingsum = $options->sumratings;
}
}
示例4: get_string
if (!$rm->check_rating_is_valid($params)) {
echo $OUTPUT->header();
echo get_string('ratinginvalid', 'rating');
echo $OUTPUT->footer();
die;
}
}
if ($userrating != RATING_UNSET_RATING) {
$ratingoptions = new stdClass();
$ratingoptions->context = $context;
$ratingoptions->component = $component;
$ratingoptions->ratingarea = $ratingarea;
$ratingoptions->itemid = $itemid;
$ratingoptions->scaleid = $scaleid;
$ratingoptions->userid = $USER->id;
$rating = new rating($ratingoptions);
$rating->update_rating($userrating);
} else {
//delete the rating if the user set to Rate...
$options = new stdClass();
$options->contextid = $context->id;
$options->component = $component;
$options->ratingarea = $ratingarea;
$options->userid = $USER->id;
$options->itemid = $itemid;
$rm->delete_ratings($options);
}
//todo add a setting to turn grade updating off for those who don't want them in gradebook
//note that this needs to be done in both rate.php and rate_ajax.php
if (!empty($cm) && $context->contextlevel == CONTEXT_MODULE) {
//tell the module that its grades have changed
示例5: teams
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/teams.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/notes.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/commune.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/rating.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/user_langs.php';
$recoms = new teams();
$additinfo = $user->GetAdditInfo($user->login, $error);
$languages = users::GetUserLangs($user->uid);
if ($rating && $rating instanceof rating && $rating->data['user_id'] == $user->uid) {
$rating_total = rating::round($rating->data['total']);
} else {
$rating_total = rating::round($additinfo['rating']);
}
$info_for_reg = unserialize($user->info_for_reg);
$reg_string = 'только для <A class="blue" href="/registration/">зарегистрированных</A>';
if ($_SESSION['uid']) {
$note = notes::GetNotes($_SESSION['uid'], null, $error);
if (count($note) > 0) {
foreach ($note as $key => $value) {
$notes[$value['to_id']] = $value;
}
}
}
$stop_words = new stop_words(hasPermissions('users'));
?>
<!-- NEW -->
示例6: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
require_once 'functions/functions.php';
$user_id = $_SESSION['userinfo']->id != '' ? $_SESSION['userinfo']->id : 0;
$renderObj = new rating();
$lead_list = $renderObj->get_all_lead($user_id);
if ($lead_list == 0) {
header('Location: profile.php?chk=1');
}
$request_list = $renderObj->get_user_request_details($user_id, '0');
require_once 'header.php';
?>
<div id="error_container"><div class="error-red"><div class="close_alert_rateme"></div></div></div>
<div class="overlay" id="overlay_rateme"></div>
<div class="mid-col-12">
<div class="mid-col-4">
<div class="mid-col-top relative">
<div class="gallery-wrap">
<div class="gallery clearfix">
<?php
$i = 0;
foreach ($lead_list as $user) {
$profile_pic = $user['google_picture_link'] != '' ? $user['google_picture_link'] . "?sz=100" : "images/user.png";
$i++;
?>
<div class="gallery__item" id="manager_<?php
echo $user['manager_id'];
?>
">
示例7: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
$search_request = new rating();
$page_number = (int) (!isset($_GET['page']) ? 1 : $_GET['page']);
$user_id = $_SESSION['userinfo']->id != '' ? $_SESSION['userinfo']->id : 0;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
//echo "<pre>";print_r($_POST);die;
$record = $search_request->pagination("get_manager_work_list_paginate", $page_number, $user_id, $_POST);
}
示例8: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
$renderObj = new rating();
//$renderObj->sample_get_book_details_id(1);
$session_val = $renderObj->check_session();
//echo "<pre>";print_r($status_flag);exit;
$limit = 20;
//how many items to show per page
$page = $_GET["page"];
if ($session_val == 1) {
$user_count = $renderObj->get_work_count($_SESSION['userinfo']->id);
if ($page) {
$start = ($page - 1) * $limit;
} else {
$start = 0;
}
//if no page var is given, set start to
if ($page == 0) {
$page = 1;
}
//if no page var is given, default to 1.
$prev = $page - 1;
//previous page is page - 1
$next = $page + 1;
//next page is page + 1
$lastpage = ceil($user_count / $limit);
//lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1;
//last page minus 1
示例9:
//check for default rating value
if($crid!=$rid)
{
if($chk > $min)
{
$qry = "delete from $rating where r_id='$rid'";
$db_object->insert($qry);
}
else
{
echo $err['cSorrymin']." ".$min;
}
}
else
{
echo $err['cSorryYoucont'];
}
}//end delete
}//end class
$ob = new rating;
if($rid!="")
{
$ob->delete($db_object,$common,$default,$user_id,$rid,$gbl_min_rating,$error_msg,$gbl_met_value);
}
$ob->view_form($db_object,$common,$default,$user_id);
include_once("footer.php");
?>
示例10: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
$renderObj = new rating();
//$renderObj->sample_get_book_details_id(1);
$session_val = $renderObj->check_session();
$limit = 5;
//how many items to show per page
$page = $_GET["page"];
if ($session_val == 1) {
//echo "<pre>";print_r($_SESSION);exit('priyesh');
$user_count = $renderObj->get_allrequest_count($_SESSION['userinfo']->id);
if ($page) {
$start = ($page - 1) * $limit;
} else {
$start = 0;
}
//if no page var is given, set start to
if ($page == 0) {
$page = 1;
}
//if no page var is given, default to 1.
$prev = $page - 1;
//previous page is page - 1
$next = $page + 1;
//next page is page + 1
$lastpage = ceil($user_count / $limit);
//lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1;
//last page minus 1
示例11: GetRating
function GetRating($type, $login = null, $width = null)
{
session_start();
$objResponse = new xajaxResponse();
$login = change_q_x($login, TRUE);
$user = new users();
$user->GetUser($login);
$uid = $user->uid;
if (!$uid) {
$uid = get_uid(false);
}
if (!$uid) {
$objResponse->script('this.document.location.reload();');
return $objResponse;
}
$user->GetUserByUID($uid);
$rating = new rating();
switch ($type) {
case 'year':
$TIME = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
$pro_periods_date = date('Y-01-01', $TIME);
$res = $rating->getRatingByYear($uid, date('Y', $TIME));
$periods = rating::getMonthParts(date('Y-01-01'));
$data = array();
if ($res) {
foreach ($periods as $m => $mm) {
if ($m < date('m')) {
foreach ($mm as $d) {
if ($d > time() || $d < strtotime($user->reg_date)) {
continue;
}
$data[$m][date('Y-m-d', $d)] = null;
if ($d >= strtotime($user->reg_date)) {
$data[$m][date('Y-m-d', $d)] = 0;
}
}
}
}
}
$start_r = null;
if ($res) {
if (date('Y', strtotime($res[0]['_date'])) == date('Y') - 1) {
$start_r = $res[0]['rating'];
if (isset($res[1]) && strtotime($res[1]['_date']) != $periods[0][0]) {
$res[0]['_date'] = date('Y-m-d', $periods[0][0]);
} else {
$res = array_slice($res, 1);
}
}
} else {
$res = array();
}
$verify_factor = 0;
$verify_date = rating::GetVerifyDate($uid);
foreach ($res as $row) {
$t = strtotime($row['_date']);
$m = (int) date('m', $t);
$verify_factor = 0;
if ($row['is_verify'] == 't') {
if ($verify_date) {
if (strtotime($verify_date) < $t) {
$verify_factor = 0.2;
}
} else {
$verify_factor = 0.2;
}
}
$data[$m - 1][date('Y-m-d', $t)] = array('rating' => floatval($row['rating']), 'verify' => floatval($row['rating'] * $verify_factor), 'pro' => 0);
}
$lastval = null;
foreach ($data as $i => $mon) {
foreach ($mon as $d => $prt) {
$vl = !$prt ? $lastval : $prt;
$data[$i][$d] = $vl;
// if($prt !== null)
$lastval = $vl;
}
}
$pro_periods = promotion::GetUserProPeriods($uid, $pro_periods_date, TRUE);
if ($pro_periods) {
$pro = array();
foreach ($pro_periods as $p => $period) {
if (date('Y', strtotime($period['from_time'])) > date('Y', $TIME) && date('Y', strtotime($period['to_time']) > date('Y', $TIME))) {
continue;
}
$d1 = (int) date('z', strtotime($period['from_time']));
$d2 = (int) date('z', strtotime($period['to_time']));
if (date('Y', strtotime($period['from_time'])) < date('Y', $TIME)) {
$d1 = 0;
}
if (date('Y', strtotime($period['to_time'])) > date('Y', $TIME)) {
$d2 = (int) date('z', mktime(0, 0, 0, 12, 31, date('Y')));
}
$_factor = 0.2;
if ($period['is_profi'] == 1) {
$_factor = 0.4;
}
foreach ($data as $mon => $val) {
foreach ($val as $per => $r) {
$day = (int) date('z', strtotime($per));
//.........这里部分代码省略.........
示例12: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
$save_manager_work = new rating();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
//echo "<pre>";print_r($_POST);die;
$record = $save_manager_work->save_manager_work($_POST);
if ($record == true) {
header('Location: work_list_tab2.php?chk=6');
}
}
示例13: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
require_once 'functions/functions.php';
$renderObj = new rating();
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
$record = $renderObj->saveWorkManager($_POST);
}
$user_id = $_SESSION['userinfo']->id != '' ? $_SESSION['userinfo']->id : 0;
$alphaValue = $_POST['alphaValue'] != '' ? $_POST['alphaValue'] : 0;
if ($alphaValue == 'All') {
$alphaValue = '';
}
$team_member = $renderObj->get_all_sub_employee_list($user_id);
$rating_dashboard = $renderObj->rating_dashboard($employeeList, $alphaValue);
$rating_dashboard = sortByRating($rating_dashboard);
if (!empty($rating_dashboard)) {
$i = 0;
foreach ($rating_dashboard as $key => $val) {
$i++;
$user_id = $val['id'];
$profile_pic = $val['google_picture_link'] ? $val['google_picture_link'] . "?sz=100" : 'images/user.png';
?>
<div class="mid-col-4">
<div class="mid-col-top">
<div class="mid-col-img"><a href="./profile.php?id=<?php
echo $val['id'];
?>
&edit_comment=true"><img src="<?php
echo $profile_pic;
?>
示例14: rating
<?php
require_once 'config.php';
require_once 'class/rating.php';
if (isset($_POST['Login'])) {
$email = $_REQUEST['email'];
$password = $_REQUEST['password'];
$renderObj = new rating();
$status = $renderObj->admin_login($email, $password);
if (isset($_SESSION['userinfo']) && $_SESSION['userinfo']->role_id == 8) {
header('Location: user_list_page.php');
} else {
header('Location: admin.php?err=1');
}
}
require_once 'header.php';
?>
<?php
require_once "error.php";
?>
<div class="mid-col-12">
<?php
if ($_GET['err'] != '') {
?>
<div class="alert alert-danger">
<strong>Opps !</strong> Please Login with given credentials.
</div>
<?php
}
?>
示例15: test_rating
public function test_rating()
{
global $USER, $DB;
$this->resetAfterTest();
$generator = $this->getDataGenerator()->get_plugin_generator('mod_forumng');
$course = $this->get_new_course();
$course2 = $this->get_new_course();
$suser = $this->get_new_user('student', $course->id);
$this->setAdminUser();
$forum = $this->get_new_forumng($course->id, array('name' => 'TEST', 'intro' => 'abc123', 'enableratings' => mod_forumng::FORUMNG_STANDARD_RATING, 'ratingscale' => 10));
$forum2 = $this->get_new_forumng($course->id, array('name' => 'TEST2', 'intro' => 'abc123', 'enableratings' => mod_forumng::FORUMNG_NO_RATING));
$forum3 = $this->get_new_forumng($course2->id, array('name' => 'TEST', 'intro' => 'abc123', 'enableratings' => mod_forumng::FORUMNG_STANDARD_RATING, 'ratingscale' => 10));
$did1 = $generator->create_discussion(array('course' => $course, 'forum' => $forum->get_id(), 'userid' => $suser->id));
$did2 = $generator->create_discussion(array('course' => $course, 'forum' => $forum->get_id(), 'userid' => $suser->id));
$did3 = $generator->create_discussion(array('course' => $course, 'forum' => $forum->get_id(), 'userid' => $suser->id));
$did4 = $generator->create_discussion(array('course' => $course, 'forum' => $forum->get_id(), 'userid' => $suser->id));
// Add rating to all 3 discussions.
$rm = new rating_manager();
$params = new stdClass();
$params->context = $forum->get_context();
$params->component = 'mod_forumng';
$params->ratingarea = 'post';
$params->scaleid = $forum->get_rating_scale();
$params->userid = $USER->id;
$params->itemid = $did1[1];
$rating = new rating($params);
$rating->update_rating(5);
$params->itemid = $did2[1];
$rating = new rating($params);
$rating->update_rating(5);
$params->itemid = $did3[1];
$rating = new rating($params);
$rating->update_rating(5);
// Check rating object gets added where expected.
$post = mod_forumng_post::get_from_id($did1[1], mod_forumng::CLONE_DIRECT, false, false);
$ratings = $post->get_ratings();
$this->assertNotNull($ratings);
$this->assertEquals($did1[1], $ratings->itemid);
$post = mod_forumng_post::get_from_id($did1[1], mod_forumng::CLONE_DIRECT, true, false);
$ratings = $post->get_ratings();
$this->assertNotNull($ratings);
$this->assertEquals($did1[1], $ratings->itemid);
$post = mod_forumng_post::get_from_id($did1[1], mod_forumng::CLONE_DIRECT, true, true);
$ratings = $post->get_ratings();
$this->assertNotNull($ratings);
$this->assertEquals($did1[1], $ratings->itemid);
$ratedposts = $forum->get_all_posts_by_user($suser->id, null, 'fp.id', null, null, true);
$this->assertCount(3, $ratedposts);
$allposts = $forum->get_all_posts_by_user($suser->id, null);
$this->assertCount(4, $allposts);
$this->assertNotNull($allposts[$did1[1]]->get_ratings());
// Update grades (does nothing).
$forum->update_grades();
// Enable rating grading, forumng_update_instance() should update grades.
forumng_update_instance((object) array('instance' => $forum->get_id(), 'grading' => mod_forumng::GRADING_SUM));
$grades = grade_get_grades($course->id, 'mod', 'forumng', $forum->get_id(), $suser->id);
// Note sum is set to 10 not 15 as max grade is 10.
$this->assertEquals(10, abs($grades->items[0]->grades[$suser->id]->grade));
// Enable rating grading, forumng_update_instance() should update grades.
forumng_update_instance((object) array('instance' => $forum->get_id(), 'grading' => mod_forumng::GRADING_COUNT));
$grades = grade_get_grades($course->id, 'mod', 'forumng', $forum->get_id(), $suser->id);
$this->assertEquals(3, abs($grades->items[0]->grades[$suser->id]->grade));
// Check get_rated_posts_by_user.
$extrapost = $generator->create_post(array('discussionid' => $did1[0], 'parentpostid' => $did1[1], 'userid' => $suser->id, 'created' => 1388589745));
$extraposts = $forum->get_rated_posts_by_user($forum, $suser->id, -1, 'fp.id', null, null);
$this->assertCount(0, $extraposts);
$extraposts = $forum->get_rated_posts_by_user($forum, $USER->id, -1, 'fp.id', null, null);
$this->assertCount(3, $extraposts);
$params->itemid = $extrapost->id;
$rating = new rating($params);
$rating->update_rating(10);
$extraposts = $forum->get_rated_posts_by_user($forum, $USER->id, -1, 'fp.id', null, null);
$this->assertCount(4, $extraposts);
// Now filter out the 'old' extrapost.
$extraposts = $forum->get_rated_posts_by_user($forum, $USER->id, -1, 'fp.id', null, null, 1388600000);
$this->assertCount(3, $extraposts);
// Check discussion delete.
$discuss = mod_forumng_discussion::get_from_id($did1[0], mod_forumng::CLONE_DIRECT);
$discuss->permanently_delete();
$rating = $DB->get_record('rating', array('itemid' => $did1[1]));
$this->assertFalse($rating);
$grades = grade_get_grades($course->id, 'mod', 'forumng', $forum->get_id(), $suser->id);
$this->assertEquals(2, abs($grades->items[0]->grades[$suser->id]->grade));
// Check discussion move.
$discuss = mod_forumng_discussion::get_from_id($did2[0], mod_forumng::CLONE_DIRECT);
$discuss->move($forum2, 0);
$grades = grade_get_grades($course->id, 'mod', 'forumng', $forum->get_id(), $suser->id);
$this->assertEquals(1, abs($grades->items[0]->grades[$suser->id]->grade));
forumng_update_instance((object) array('instance' => $forum2->get_id(), 'grading' => mod_forumng::GRADING_COUNT, 'enableratings' => mod_forumng::FORUMNG_STANDARD_RATING, 'ratingscale' => 10));
$grades = grade_get_grades($course->id, 'mod', 'forumng', $forum2->get_id(), $suser->id);
$this->assertEquals(1, abs($grades->items[0]->grades[$suser->id]->grade));
$rating = $DB->get_record('rating', array('itemid' => $did2[1]));
$this->assertNotEmpty($rating);
$this->assertEquals($forum2->get_context(true)->id, $rating->contextid);
// Check discussion copy.
$discuss = mod_forumng_discussion::get_from_id($did3[0], mod_forumng::CLONE_DIRECT);
$discuss->copy($forum3, 0);
$grades = grade_get_grades($course->id, 'mod', 'forumng', $forum->get_id(), $suser->id);
$this->assertEquals(1, abs($grades->items[0]->grades[$suser->id]->grade));
// Check rating didn't copy as forum in another course.
//.........这里部分代码省略.........