function opigno_tincan_api_quiz_begin in Opigno TinCan API 7
File
- modules/
opigno_tincan_api_quiz_statements/ opigno_tincan_api_quiz_statements.module, line 10
Code
function opigno_tincan_api_quiz_begin($quiz, $rid) {
/**
* - When user start a quiz
* Actor: user
* Verb: xAPI/launched
* Object: xAPI/lesson
* Result:
* Context: Course
*/
/////
// Statement creation
$statement = _opigno_tincan_api_statement_base_creation(OpignoTincanApiTinCanVerbs::$launched, OpignoTincanApiTinCanActivityDefinitionTypes::$lesson, $quiz);
if ($statement === false) {
return;
}
/////
// Context creation
$context = new TinCan\Context();
// If there is a parent, set it
if (isset($quiz->og_group_ref[LANGUAGE_NONE])) {
$parent_courses_nids = array_map(function ($e) {
return $e['target_id'];
}, $quiz->og_group_ref[LANGUAGE_NONE]);
_opigno_tincan_api_context_set_parents($context, $parent_courses_nids);
}
_opigno_tincan_api_context_set_language($context, $quiz->language);
$statement
->setContext($context);
/////
// Sending statement
_opigno_tincan_api_send_statement($statement);
}