You are here

function _quiz_get_question_types in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 quiz.module \_quiz_get_question_types()
  2. 5.2 quiz.module \_quiz_get_question_types()
  3. 5 quiz.module \_quiz_get_question_types()
  4. 6.6 quiz.module \_quiz_get_question_types()
  5. 6.2 quiz.module \_quiz_get_question_types()
  6. 6.3 quiz.module \_quiz_get_question_types()
  7. 6.5 quiz.module \_quiz_get_question_types()
  8. 7 quiz.module \_quiz_get_question_types()
  9. 7.4 quiz.module \_quiz_get_question_types()

Retrieve list of question types.

Return value

Array of question types.

9 calls to _quiz_get_question_types()
quiz_get_questions in ./quiz.module
Retrieve list of published questions assigned to quiz.
quiz_questions_form in ./quiz.admin.inc
Handles "manage questions" tab.
quiz_questions_form_validate in ./quiz.admin.inc
Validate that the supplied questions are real.
quiz_question_module_for_type in ./quiz.module
quiz_take_quiz in ./quiz.module
Handles quiz taking.

... See full list

File

./quiz.module, line 3260
Quiz Module

Code

function _quiz_get_question_types() {
  static $to_return = array();

  // We vastly improves performance by statically caching the question types.
  if (!empty($to_return)) {
    return $to_return;
  }

  // Get question types from the modules that defines them..
  $to_return = module_invoke_all('quiz_question_info');
  if (empty($to_return)) {
    drupal_set_message(t('You need to install and enable at least one question type(multichoice for instance) to use quiz.'), 'warning', FALSE);
    return array();
  }

  // We must make sure names and descriptions are customizable and
  // translationable
  $types = array();
  $placeholders = array();
  foreach ($to_return as $key => $value) {
    $types[] = $key;
  }
  $sql = "SELECT type, name, description\n          FROM {node_type}\n          WHERE type IN ('" . implode("', '", $types) . "')";
  $res = db_query($sql, $types);
  while ($res_o = db_fetch_object($res)) {
    $to_return[$res_o->type]['name'] = check_plain($res_o->name);
    $to_return[$res_o->type]['description'] = check_markup($res_o->description);
  }
  return $to_return;
}