You are here

function quiz_entity_extra_field_info in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 quiz.module \quiz_entity_extra_field_info()
  2. 6.x quiz.module \quiz_entity_extra_field_info()

Implements hook_field_extra_fields().

File

./quiz.module, line 207
Contains quiz.module

Code

function quiz_entity_extra_field_info() {
  $extra = array();
  $extra['quiz']['quiz'] = array(
    'display' => array(
      'take' => array(
        'label' => t('Take @quiz button', array(
          '@quiz' => _quiz_get_quiz_name(),
        )),
        'description' => t('The take button.'),
        'weight' => 10,
      ),
      'stats' => array(
        'label' => t('@quiz summary', array(
          '@quiz' => _quiz_get_quiz_name(),
        )),
        'description' => t('@quiz summary', array(
          '@quiz' => _quiz_get_quiz_name(),
        )),
        'weight' => 9,
      ),
    ),
  );

  // Allow for configurable feedback bits.
  $options = quiz_get_feedback_options();
  foreach (QuizResultAnswerType::loadMultiple() as $bundle) {
    $extra['quiz_result_answer'][$bundle
      ->id()]['display']['table'] = array(
      'label' => t('Feedback table'),
      'description' => t('A table of feedback.'),
      'weight' => 0,
      'visible' => TRUE,
    );
    foreach ($options as $option => $label) {
      $extra['quiz_result_answer'][$bundle
        ->id()]['display'][$option] = array(
        'label' => $label,
        'description' => t('Feedback for @label.', array(
          '@label' => $label,
        )),
        'weight' => 0,
        'visible' => FALSE,
      );
    }
  }
  $extra['quiz_result']['quiz_result']['display'] = array(
    'score' => array(
      'label' => t('Score'),
      'description' => t('The score of the result.'),
      'weight' => 1,
    ),
    'questions' => array(
      'label' => t('Questions'),
      'description' => t('The questions in this result.'),
      'weight' => 2,
    ),
    'summary' => array(
      'label' => t('Summary'),
      'description' => t('The summary and pass/fail text.'),
      'weight' => 3,
    ),
  );
  return $extra;
}