You are here

quiz_question.install in Quiz 7.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
 */

/**
 * Implements hook_install().
 */
function quiz_question_install() {
}

/**
 * Implements 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;
}

/**
 * Implements hook_uninstall().
 */
function quiz_question_uninstall() {
}

/**
 * Implements hook_update_N()
 */

/**
 * Make the question body visible by default for the question view mode
 */
function quiz_question_update_7401() {
  $question_types = array_keys(_quiz_question_get_implementations());
  foreach ($question_types as $question_type) {
    $instance = field_read_instance('node', 'body', $question_type);
    if ($instance === FALSE) {
      continue;
    }
    $instance['display']['question'] = array(
      'label' => 'hidden',
      'type' => 'text_default',
      'weight' => 1,
      'settings' => array(),
      'module' => 'text',
    );
    field_update_instance($instance);
  }
}

/**
 * Rebuild the node_access table.
 */
function quiz_question_update_7402() {
  node_access_rebuild(TRUE);
}

/**
 * Make sure the matching question has finished its update before starting this one
 */
function quiz_question_update_dependencies() {
  $dependencies = array();
  if (module_exists("matching")) {
    $dependencies['quiz_question'][7402] = array(
      'matching' => 7400,
    );
  }
  return $dependencies;
}

Functions

Namesort descending Description
quiz_question_install Implements hook_install().
quiz_question_schema Implements hook_schema().
quiz_question_uninstall Implements hook_uninstall().
quiz_question_update_7401 Make the question body visible by default for the question view mode
quiz_question_update_7402 Rebuild the node_access table.
quiz_question_update_dependencies Make sure the matching question has finished its update before starting this one