You are here

function _opigno_tincan_api_context_set_parents in Opigno TinCan API 7

Parameters

\TinCan\Context $context The context to add the parents:

array() $parents_nids The nodes IDs to add as parents:

5 calls to _opigno_tincan_api_context_set_parents()
opigno_tincan_api_in_house_training_statements_opigno_in_house_training_finished in modules/opigno_tincan_api_in_house_training_statements/opigno_tincan_api_in_house_training_statements.module
Implements hook_opigno_in_house_training_finished().
opigno_tincan_api_opigno_statements_opigno_course_passed in modules/opigno_tincan_api_opigno_statements/opigno_tincan_api_opigno_statements.module
opigno_tincan_api_quiz_begin in modules/opigno_tincan_api_quiz_statements/opigno_tincan_api_quiz_statements.module
_opigno_tincan_api_send_questions_results in modules/opigno_tincan_api_quiz_statements/opigno_tincan_api_quiz_statements.module
_opigno_tincan_api_send_quiz_results in modules/opigno_tincan_api_quiz_statements/opigno_tincan_api_quiz_statements.module

File

includes/opigno_tincan_api.statements_func.inc, line 109

Code

function _opigno_tincan_api_context_set_parents(TinCan\Context &$context, $parents_nids, $definition_type = NULL) {
  if (!_opigno_tincan_api_tincanphp_is_installed()) {
    return false;
  }
  $parents = array();
  foreach ($parents_nids as $parent_nid) {
    $parent = array();
    $parent['id'] = url('node/' . $parent_nid, array(
      'absolute' => true,
    ));
    if (!empty($definition_type)) {
      $parent['definition'] = array(
        'type' => $definition_type,
      );
    }
    $parents[] = $parent;
  }
  if (!empty($parents)) {
    $context
      ->getContextActivities()
      ->setParent($parents);
  }
}