You are here

function opigno_tincan_api_quiz_statements_tincan_question_statement_scale_alter in Opigno TinCan API 7

File

modules/opigno_tincan_api_quiz_statements/opigno_tincan_api_quiz_statements.questions_alter.inc, line 187

Code

function opigno_tincan_api_quiz_statements_tincan_question_statement_scale_alter(TinCan\Statement &$statement, $question, $answers) {

  /******
   ** Set the result
   ***/
  _opigno_tincan_api_set_result($statement, null, null, $question->correct, $answers[0]['answer']);

  /******
   ** Set the interaction type properties
   ***/
  $choices = array();
  foreach ($question as $key => $value) {
    if (is_numeric($key) && !empty($value) && isset($value->id) && isset($value->answer)) {
      $choices[] = array(
        'id' => $value->id,
        'description' => array(
          'en-US' => $value->answer,
        ),
      );
    }
  }
  $objectDefinition = _opigno_tincan_api_get_object_definition($statement);
  $objectDefinition
    ->setInteractionType(OpignoTincanApiTinCanInteractionTypes::$choice);
  $objectDefinition
    ->setChoices($choices);
}