public function SlideActivityAnswer::getScore in Opigno module 8
Same name and namespace in other branches
- 3.x src/Plugin/ActivityAnswer/SlideActivityAnswer.php \Drupal\opigno_module\Plugin\ActivityAnswer\SlideActivityAnswer::getScore()
Score logic for specified activity.
Overrides ActivityAnswerPluginBase::getScore
File
- src/
Plugin/ ActivityAnswer/ SlideActivityAnswer.php, line 28
Class
- SlideActivityAnswer
- Class SlideActivityAnswer.
Namespace
Drupal\opigno_module\Plugin\ActivityAnswerCode
public function getScore(OpignoAnswerInterface $answer) {
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$score = 0;
$activity = $answer
->getActivity();
$score_query = $db_connection
->select('opigno_module_relationship', 'omr')
->fields('omr', [
'max_score',
])
->condition('omr.parent_id', $answer
->getModule()
->id())
->condition('omr.parent_vid', $answer
->getModule()
->getRevisionId())
->condition('omr.child_id', $activity
->id())
->condition('omr.child_vid', $activity
->getRevisionId());
$score_result = $score_query
->execute()
->fetchObject();
if ($score_result) {
$score = $score_result->max_score;
}
return $score;
}