예제 #1
0
파일: lib.php 프로젝트: r007/PMoodle
/**
 * Print the multiple ratings on a post given to the current user by others.
 * Forumid prevents the double lookup of the forumid in discussion to determine the aggregate type
 * Scale is an array of ratings
 */
function forum_print_ratings($postid, $scale, $aggregatetype, $link = true, $ratings = null)
{
    $strratings = '';
    switch ($aggregatetype) {
        case FORUM_AGGREGATE_AVG:
            $agg = forum_get_ratings_mean($postid, $scale, $ratings);
            $strratings = get_string("aggregateavg", "forum");
            break;
        case FORUM_AGGREGATE_COUNT:
            $agg = forum_get_ratings_count($postid, $scale, $ratings);
            $strratings = get_string("aggregatecount", "forum");
            break;
        case FORUM_AGGREGATE_MAX:
            $agg = forum_get_ratings_max($postid, $scale, $ratings);
            $strratings = get_string("aggregatemax", "forum");
            break;
        case FORUM_AGGREGATE_MIN:
            $agg = forum_get_ratings_min($postid, $scale, $ratings);
            $strratings = get_string("aggregatemin", "forum");
            break;
        case FORUM_AGGREGATE_SUM:
            $agg = forum_get_ratings_sum($postid, $scale, $ratings);
            $strratings = get_string("aggregatesum", "forum");
            break;
    }
    if ($agg !== "") {
        if (empty($strratings)) {
            $strratings = get_string("ratings", "forum");
        }
        echo "{$strratings}: ";
        if ($link) {
            link_to_popup_window("/mod/forum/report.php?id={$postid}", "ratings", $agg, 400, 600);
        } else {
            echo "{$agg} ";
        }
    }
}
예제 #2
0
파일: lib.php 프로젝트: ajv/Offline-Caching
/**
 * Print the multiple ratings on a post given to the current user by others.
 * Forumid prevents the double lookup of the forumid in discussion to determine the aggregate type
 * Scale is an array of ratings
 *
 * @uses FORUM_AGGREGATE_AVG
 * @uses FORUM_AGGREGATE_COUNT
 * @uses FORUM_AGGREGATE_MAX
 * @uses FORUM_AGGREGATE_MIN
 * @uses FORUM_AGGREGATE_SUM
 * @param int $postid
 * @param array $scale
 * @param int $aggregatetype
 * @param bool $link
 * @param array $ratings
 * @param bool $return
 * @return string|void
 */
function forum_print_ratings($postid, $scale, $aggregatetype, $link = true, $ratings = null, $return = false)
{
    global $OUTPUT;
    $strratings = '';
    switch ($aggregatetype) {
        case FORUM_AGGREGATE_AVG:
            $agg = forum_get_ratings_mean($postid, $scale, $ratings);
            $strratings = get_string("aggregateavg", "forum");
            break;
        case FORUM_AGGREGATE_COUNT:
            $agg = forum_get_ratings_count($postid, $scale, $ratings);
            $strratings = get_string("aggregatecount", "forum");
            break;
        case FORUM_AGGREGATE_MAX:
            $agg = forum_get_ratings_max($postid, $scale, $ratings);
            $strratings = get_string("aggregatemax", "forum");
            break;
        case FORUM_AGGREGATE_MIN:
            $agg = forum_get_ratings_min($postid, $scale, $ratings);
            $strratings = get_string("aggregatemin", "forum");
            break;
        case FORUM_AGGREGATE_SUM:
            $agg = forum_get_ratings_sum($postid, $scale, $ratings);
            $strratings = get_string("aggregatesum", "forum");
            break;
    }
    if ($agg !== "") {
        if (empty($strratings)) {
            $strratings = get_string("ratings", "forum");
        }
        $strratings .= ': ';
        if ($link) {
            $link = html_link::make("/mod/forum/report.php?id={$postid}", $agg);
            $link->add_action(new popup_action('click', $link->url, 'ratings', array('height' => 400, 'width' => 600)));
            $strratings .= $OUTPUT->link($link);
        } else {
            $strratings .= "{$agg} ";
        }
        if ($return) {
            return $strratings;
        } else {
            echo $strratings;
        }
    }
}