Skip to content
Snippets Groups Projects
Commit 1b70f17f authored by catch's avatar catch
Browse files

Issue #3492930: add xapi ActivityAnswer plugin.

parent 4beeb8b9
No related branches found
No related tags found
No related merge requests found
<?php
namespace Drupal\lms_xapi\Plugin\ActivityAnswer;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\lms\Attribute\ActivityAnswer;
use Drupal\lms\Entity\Answer;
use Drupal\lms\Plugin\ActivityAnswer\ActivityAnswerBase;
/**
* Xapi/TinCan activity plugin.
*/
#[ActivityAnswer(
id: 'xapi',
name: new TranslatableMarkup('Xapi / TinCan'),
)]
class Xapi extends ActivityAnswerBase {
/**
* {@inheritdoc}
*/
public function getScore(Answer $answer): float {
$lrs_service = \Drupal::service('lms_xapi.tincan');
$account = $answer->getOwner();
$score = $lrs_service->getScoreFromLrs($answer->id(), 'lms_answer', $account->id());
return $score ?? 0;
}
/**
* {@inheritdoc}
*/
public function evaluatedOnSave(Answer $answer): bool {
return FALSE;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment