You are here

function opigno_tincan_activities_opigno_answer_insert in Opigno TinCan API 3.x

Same name and namespace in other branches
  1. 8 modules/opigno_tincan_activities/opigno_tincan_activities.module \opigno_tincan_activities_opigno_answer_insert()

Implements hook_ENTITY_TYPE_insert().

At this stage Tincan Api send statements after user answered activity.

File

modules/opigno_tincan_activities/opigno_tincan_activities.module, line 42
Contains opigno_tincan_activities.module.

Code

function opigno_tincan_activities_opigno_answer_insert(EntityInterface $entity) {

  // Check if Tincan PHP library is installed.
  $has_library = opigno_tincan_api_tincanphp_is_installed();
  if (!$has_library) {
    return;
  }
  $route = \Drupal::routeMatch();
  if ($route
    ->getRouteName() == 'opigno_module.group.answer_form') {
    $answer = $entity;

    // Create and send tincan statements.
    _opigno_tincan_activities_create_and_send_statements($answer);
  }
}