You are here

quiz_question.install in Quiz 6.4

The installer file for quiz_question.

File

question_types/quiz_question/quiz_question.install
View source
<?php

/**
 * The installer file for quiz_question.
 * @file
 */

/**
 * Implementation of hook_install
 */
function quiz_question_install() {
  drupal_install_schema('quiz_question');
}

/**
 * Implementation of hook_schema
 */
function quiz_question_schema() {
  $schema = array();
  $schema['quiz_question_properties'] = array(
    'description' => 'Properties common for all quizzes',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'max_score' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  $schema['quiz_question_latest_quizzes'] = array(
    'description' => 'Stores the latest quizzes each user has been involved in',
    'fields' => array(
      'quiz_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_update_N()
 */
function quiz_question_update_6400() {
  drupal_rebuild_theme_registry();
  return array();
}

/**
 * Implementation of hook_update_N()
 *
 * In 6.x-3.x truefalse was a part of quiz question. In 4.x it has been separated out into
 * its own module. We automatically installs this module to avoid issues with truefalse questions
 * that aren't working anymore because the module haven't been installed.
 */
function quiz_question_update_6401() {
  if (!module_exists('truefalse') && db_table_exists('quiz_truefalse_node')) {
    drupal_install_modules(array(
      'truefalse',
    ));
  }
  return array();
}

/**
 * Implementation of hook_update_N
 *
 * Add table for storing info on the latest quizzes each user has been involved in editing
 */
function quiz_question_update_6402() {
  $results = array();
  db_create_table($results, 'quiz_question_latest_quizzes', array(
    'fields' => array(
      'quiz_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  ));
  return $results;
}

/**
 * Implementation of hook_uninstall
 */
function quiz_question_uninstall() {
  drupal_uninstall_schema('quiz_question');
}

Functions

Namesort descending Description
quiz_question_install Implementation of hook_install
quiz_question_schema Implementation of hook_schema
quiz_question_uninstall Implementation of hook_uninstall
quiz_question_update_6400 Implementation of hook_update_N()
quiz_question_update_6401 Implementation of hook_update_N()
quiz_question_update_6402 Implementation of hook_update_N