Get rating

If no "rating" value has been set, this method will
set and return a default "rating" value,
if any such value is available

@see getDefaultRating()

@return float|null rating or null if no rating has been set
323494
public function getRating() : ?float 
    {
        if ( ! $this->hasRating()) {
            $this->setRating($this->getDefaultRating());
        }
        return $this->rating;
    }
325450
public function getRevision() : ?string 
    {
        if ( ! $this->hasRevision()) {
            $this->setRevision($this->getDefaultRevision());
        }
        return $this->revision;
    }
661328
public function getDefaultValue()
    {
        return is_array($this->default_value) ? $this->default_value : [
            Carbon::now()->subWeek()->format('Y-m-d'),
            Carbon::now()->format('Y-m-d'),
        ];
    }
834016
public function get_default_value() {
        $defaultvalue = $this->get_field()->get_configdata_property('defaultvalue');
        if ('' . $defaultvalue !== '') {
            $options = field_controller::get_options_array($this->get_field());
            $key = array_search($defaultvalue, $options);
            if ($key !== false) {
                return $key;
            }
        }
        return 0;
    }
513338
public function getDefaultValue()
    {
        if ($this->hasOption(self::OPTION_DEFAULT_VALUE)) {
            return $this->getSanitizedValue(
                $this->getOption(self::OPTION_DEFAULT_VALUE, $this->getNullValue())
            );
        }

        return $this->getNullValue();
    }
316587
public function getRank() : ?int 
    {
        if ( ! $this->hasRank()) {
            $this->setRank($this->getDefaultRank());
        }
        return $this->rank;
    }
976156
public function getValue()
    {
        $value = $this->getModelValue();
        if (is_null($value)) {
            $value = $this->getDefaultValue();
        }

        return $value;
    }
793774
public function getDefaultSorting()
    {
        $sorting = parent::getDefaultSorting();
        $activeCategory = $this->getActiveCategory();

        if ($this->getListType() != 'search' && $activeCategory && $activeCategory instanceof \OxidEsales\Eshop\Application\Model\Category) {
            if ($categorySorting = $activeCategory->getDefaultSorting()) {
                $sortingDirection = ($activeCategory->getDefaultSortingMode()) ? "desc" : "asc";
                $sorting = ['sortby' => $categorySorting, 'sortdir' => $sortingDirection];
            }
        }

        return $sorting;
    }
263200
public function getInitialValue()
    {
        if ($this->hasDefaultValue) {
            return $this->defaultValue;
        }

        return $this->isNullable ? null : $this->dataType->getInitialValue();
    }
993954
public function getDefaultTitle()
    {
        if (empty($this->title_default)) {
            return $this->config->get('defaults.title', null);
        }

        return $this->title_default;
    }
667817
public function get_defaultsetting() {
        global $CFG;

        if (during_initial_install()) {
            return null;
        }
        $result = array();
        foreach($this->types as $archetype) {
            if ($caproles = get_archetype_roles($archetype)) {
                foreach ($caproles as $caprole) {
                    $result[$caprole->id] = 1;
                }
            }
        }
        return $result;
    }
1114268
public function getRating($recalculate = false)
    {
        if ($recalculate || null === $this->rating) {
            $sum = 0;
            $count = 0;
            foreach ($this->getComments() as $comment) {
                $sum += $comment->getRating()->getAverage();
                $count += 1;
            }
            $this->rating = 0 == $count ? 0 : round($sum / $count);
        }
        return $this->rating;
    }
892148
public function getDefaultSorting()
    {
        $aSorting = parent::getDefaultSorting();

        $oCategory = $this->getActiveCategory();

        if ($this->getListType() != 'search' && $oCategory && $oCategory instanceof \OxidEsales\Eshop\Application\Model\Category) {
            if ($sSortBy = $oCategory->getDefaultSorting()) {
                $sSortDir = ($oCategory->getDefaultSortingMode()) ? "desc" : "asc";
                $aSorting = ['sortby' => $sSortBy, 'sortdir' => $sSortDir];
            }
        }

        return $aSorting;
    }
1209293
public function get_grade() {
        $grade = $this->get_rubric_filling();

        if (!($scores = $this->get_controller()->get_min_max_score()) || $scores['maxscore'] <= $scores['minscore']) {
            return -1;
        }

        $graderange = array_keys($this->get_controller()->get_grade_range());
        if (empty($graderange)) {
            return -1;
        }
        sort($graderange);
        $mingrade = $graderange[0];
        $maxgrade = $graderange[sizeof($graderange) - 1];

        $curscore = 0;
        foreach ($grade['criteria'] as $id => $record) {
            $curscore += $this->get_controller()->get_definition()->rubric_criteria[$id]['levels'][$record['levelid']]['score'];
        }

        $allowdecimals = $this->get_controller()->get_allow_grade_decimals();
        $options = $this->get_controller()->get_options();

        if ($options['lockzeropoints']) {
            // Grade calculation method when 0-level is locked.
            $grade = max($mingrade, $curscore / $scores['maxscore'] * $maxgrade);
            return $allowdecimals ? $grade : round($grade, 0);
        } else {
            // Alternative grade calculation method.
            $gradeoffset = ($curscore - $scores['minscore']) / ($scores['maxscore'] - $scores['minscore']) * ($maxgrade - $mingrade);
            return ($allowdecimals ? $gradeoffset : round($gradeoffset, 0)) + $mingrade;
        }
    }
899343
private function getDefaultStoreView()
    {
        $store = $this->storeManager->getDefaultStoreView();
        if (null === $store) {
            // Occurs when current user does not have access to default website (due to AdminGWS ACLS on Magento EE).
            $store = current($this->storeManager->getWebsites())->getDefaultStore();
        }

        return $store;
    }
1022220
public function canRate()
    {
        if ($this->_blRate === null) {
            $this->_blRate = false;
            if (($oActObject = $this->_getActiveObject()) && ($oRevUser = $this->getReviewUser())) {
                $oRating = oxNew(\OxidEsales\Eshop\Application\Model\Rating::class);
                $this->_blRate = $oRating->allowRating(
                    $oRevUser->getId(),
                    $this->_getActiveType(),
                    $oActObject->getId()
                );
            }
        }

        return $this->_blRate;
    }
1058817
public function getRatingAverage()
    {
        $ratingTotal = $this->ratingTotal;

        $rating = $ratingTotal ? $ratingTotal->rating : 0;
        $rater = $ratingTotal ? $ratingTotal->raters : 0;

        return $rating > 0 ? $rating / $rater : 0;
    }