You are here

quizfileupload.install in Quiz File Upload 7

Code: logicmedia

quizfileupload Install (a quiz question type)

File

quizfileupload.install
View source
<?php

/**
 * Code: logicmedia
 *
 * @file
 * quizfileupload Install (a quiz question type)
 */

/**
 * Implementation of hook_install()
 */
function quizfileupload_install() {

  // Add body field to long answer node
  quiz_question_add_body_field('quizfileupload');
  cache_clear_all('autoload:', 'cache');
  variable_set('node_options_quizfileupload', array(
    'status',
  ));
}

/**
 * Implementation of hook_schema().
 */
function quizfileupload_schema() {

  // Stores the users answers to a question.
  $schema['quiz_fileupload_user_answers'] = array(
    'fields' => array(
      'answer_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'result_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'question_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'question_vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'score' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'answer_id',
    ),
    'indexes' => array(
      'answer_id' => array(
        'result_id',
        'question_nid',
        'question_vid',
      ),
    ),
  );

  // store node properties
  $schema['quiz_fileupload_node_properties'] = array(
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'filetypes' => array(
        'type' => 'text',
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_uninstall()
 */
function quizfileupload_uninstall() {
  cache_clear_all('variables', 'cache');
  drupal_set_message(t('The quiz file upload module has been uninstalled. Quiz file upload nodes may still exist, but they will not function properly.'));
}

Functions

Namesort descending Description
quizfileupload_install Implementation of hook_install()
quizfileupload_schema Implementation of hook_schema().
quizfileupload_uninstall Implementation of hook_uninstall()