Пример #1
0
function star_rating_update($pid)
{
    $output = '';
    $post_rate = post_rate_load($pid, $_SESSION['uid']);
    $output .= '<div id="rate_1_pid_' . $pid . '" class="ratings_stars no_cursor"></div>';
    $output .= '<div id="rate_2_pid_' . $pid . '" class="ratings_stars no_cursor"></div>';
    $output .= '<div id="rate_3_pid_' . $pid . '" class="ratings_stars no_cursor"></div>';
    $output .= '<div id="rate_4_pid_' . $pid . '" class="ratings_stars no_cursor"></div>';
    $output .= '<div id="rate_5_pid_' . $pid . '" class="ratings_stars no_cursor"></div>';
    $output .= '<span class="post_rate_text" id="rate_text_pid_' . $pid . '"></span>';
    $output .= '<div style="display: none;" id="user_rate_pid_' . $pid . '">' . $post_rate['PostRate'] . '</div>';
    $output .= '<script>
				var userRate = $("#user_rate_pid_' . $pid . '").text();
				if (userRate == 1) {
					$("#rate_1_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_text_pid_' . $pid . '").text("It is easy");
				} else if (userRate == 2) {
					$("#rate_1_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_2_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_text_pid_' . $pid . '").text("Not challenge");
				} else if (userRate == 3) {
					$("#rate_1_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_2_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_3_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_text_pid_' . $pid . '").text("Normal question");
				} else if (userRate == 4) {
					$("#rate_1_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_2_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_3_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_4_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_text_pid_' . $pid . '").text("A bit challenge");
				} else if (userRate == 5) {
					$("#rate_1_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_2_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_3_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_4_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_5_pid_' . $pid . '").attr("class","ratings_vote");
					$("#rate_text_pid_' . $pid . '").text("This is hard");
				}
				</script>';
    return $output;
}
Пример #2
0
<?php

//Update user rating
require_once '../includes/functions.inc.php';
require_once '../includes/admin.inc.php';
if (isset($_POST['pid']) && isset($_SESSION['uid'])) {
    $pid = $_POST['pid'];
    $uid = $_SESSION['uid'];
    $post_rate = post_rate_load($pid, $uid);
    print star_rating_update($pid);
}