public function CourseCreditCertificateMapper::processMapping in Certificate 4.x
Check if the learner is eligible based on awarded credit in the course
Overrides CertificateMapperBase::processMapping
File
- src/
Plugin/ certificate/ CertificateMapper/ CourseCreditCertificateMapper.php, line 40
Class
- CourseCreditCertificateMapper
- Plugin annotation @CertificateMapper( id = "course_credit_awarded", label = @Translation("Awarded course credit"), description = @Translation("Using this mapping will award a certificate based on the credit type the user claimed after completing a…
Namespace
Drupal\certificate\Plugin\certificate\CertificateMapperCode
public function processMapping(ContentEntityInterface $entity, AccountInterface $account) {
if (Drupal::moduleHandler()
->moduleExists('course_credit')) {
$options = [];
$enrollment = $entity
->getEnrollment($account);
$awarded = $enrollment
->get('course_credit_awarded')
->referencedEntities();
foreach ($awarded as $credit) {
$credit_type = $credit
->get('type')
->referencedEntities()[0];
$options[] = $credit_type
->id();
}
return $options;
}
}