public function ContentTypeMeeting::getUserScore in Opigno Moxtra 8
Same name and namespace in other branches
- 3.x src/Plugin/OpignoGroupManagerContentType/ContentTypeMeeting.php \Drupal\opigno_moxtra\Plugin\OpignoGroupManagerContentType\ContentTypeMeeting::getUserScore()
Get the score of the user for a specific entity.
Parameters
int $user_id: The user ID.
int $entity_id: The entity ID.
Return value
float|false The score between 0 and 1. FALSE if no score found.
Overrides ContentTypeInterface::getUserScore
File
- src/
Plugin/ OpignoGroupManagerContentType/ ContentTypeMeeting.php, line 38
Class
- ContentTypeMeeting
- Class ContentTypeMeeting.
Namespace
Drupal\opigno_moxtra\Plugin\OpignoGroupManagerContentTypeCode
public function getUserScore($user_id, $entity_id) {
/** @var \Drupal\opigno_moxtra\MeetingResultInterface[] $results */
$results = \Drupal::entityTypeManager()
->getStorage('opigno_moxtra_meeting_result')
->loadByProperties([
'user_id' => $user_id,
'meeting' => $entity_id,
]);
$best_score = 0;
foreach ($results as $result) {
$score = $result
->getScore();
if ($score > $best_score) {
$best_score = $score;
}
}
return $best_score / 100;
}