You are here

public function H5pActivityAnswer::getAnswerResultItemData in Opigno module 8

Same name and namespace in other branches
  1. 3.x ActivityTypes/opigno_h5p/src/Plugin/ActivityAnswer/H5pActivityAnswer.php \Drupal\opigno_h5p\Plugin\ActivityAnswer\H5pActivityAnswer::getAnswerResultItemData()

File

ActivityTypes/opigno_h5p/src/Plugin/ActivityAnswer/H5pActivityAnswer.php, line 106

Class

H5pActivityAnswer
Class H5pActivityAnswer.

Namespace

Drupal\opigno_h5p\Plugin\ActivityAnswer

Code

public function getAnswerResultItemData(OpignoAnswerInterface $answer) {
  $data = [];
  $response = $answer
    ->get('field_response')
    ->getValue();
  $correct_response = $answer
    ->get('field_correct_response')
    ->getValue();
  if ($response && $correct_response) {
    $data[] = [
      $response[0]['value'],
      $correct_response[0]['value'],
    ];
  }
  return $data;
}