<?php

if (count($comments) > 0) {

    $cnt_average_com = 0;
    $cnt_count = count($comments);
    ?>
    <?php
    foreach ($comments as $comment) {
        $cnt_average_com += $comment->rating;
    }
    $res = $cnt_average_com / $cnt_count;

    $id = 'comment_rating_' . $model->id . rand(1, 9999);
    ?>
    <div class="rating-item-view rating-item-comment">
        <?php $this->widget('CStarRating',
            array(
                'name' => $id,
                'id' => $id,
                'value' => round($res),
                'readOnly' => true,
                'cssFile' => Yii::app()->theme->baseUrl . '/css/rating/rating.css',
                'minRating' => Comment::MIN_RATING,
                'maxRating' => Comment::MAX_RATING,
                'starCount' => Comment::STAR_COUNT,
            )
        );
        ?>
    </div>
<?php } ?>
