You are here

public function UserModuleStatus::calculateScore in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Entity/UserModuleStatus.php \Drupal\opigno_module\Entity\UserModuleStatus::calculateScore()
2 calls to UserModuleStatus::calculateScore()
UserModuleStatus::finishAttempt in src/Entity/UserModuleStatus.php
Finish user attempt.
UserModuleStatus::getAttemptScore in src/Entity/UserModuleStatus.php
Get Attempt Score.

File

src/Entity/UserModuleStatus.php, line 243

Class

UserModuleStatus
Defines the User module status entity.

Namespace

Drupal\opigno_module\Entity

Code

public function calculateScore() {
  $score = 0;
  $answers = $this
    ->getAnswers();
  foreach ($answers as $answer) {

    /* @var $answer \Drupal\opigno_module\Entity\OpignoAnswer */
    $score += $answer
      ->getScore();
  }
  return $score;
}