public function H5PReportXAPIData::saveXAPIData in Opigno module 3.x
Same name and namespace in other branches
- 8 ActivityTypes/opigno_h5p/src/H5PReportXAPIData.php \Drupal\opigno_h5p\H5PReportXAPIData::saveXAPIData()
Recursive save of xAPI data.
File
- ActivityTypes/
opigno_h5p/ src/ H5PReportXAPIData.php, line 247
Class
- H5PReportXAPIData
- Class H5PReportXAPIData.
Namespace
Drupal\opigno_h5pCode
public function saveXAPIData() {
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
// Save statement data.
$dataID = $db_connection
->insert('opigno_h5p_user_answer_results')
->fields([
'parent_id' => $this
->getParentID(),
'question_id' => $this->question
->id(),
'question_vid' => $this->question
->getLoadedRevisionId(),
'answer_id' => $this->answer
->id(),
'answer_vid' => $this->answer
->getLoadedRevisionId(),
'score_scaled' => $this
->getScoreScaled(),
'score_raw' => $this
->getScoreRaw(),
'score_min' => $this
->getScoreMin(),
'score_max' => $this
->getScoreMax(),
'interaction_type' => $this
->getInteractionType(),
'description' => $this
->getDescription(),
'correct_responses_pattern' => $this
->getCorrectResponsesPattern(),
'response' => $this
->getResponse(),
'additionals' => $this
->getAdditionals(),
])
->execute();
// Save sub content statements data.
if ($this
->isCompound()) {
foreach ($this
->getChildren($dataID) as $subData) {
$subData
->saveXAPIData();
}
}
}