truefalse.install in Quiz 6.4
Same filename and directory in other branches
The installer file for truefalse question type. *
File
question_types/truefalse/truefalse.installView source
<?php
/**
* @file
* The installer file for truefalse question type. *
*/
/**
* Implementation of hook_update_N
*
* truefalse has actually changed its name from true_false. We try to fix any problems this might result in here...
*/
function truefalse_update_6400() {
$results = array();
$results[] = update_sql("UPDATE {system} SET name = 'truefalse' WHERE name = 'true_false'");
$results[] = update_sql("UPDATE {node} SET type = 'truefalse' WHERE type = 'true_false'");
$results[] = update_sql("UPDATE {system} SET type = 'truefalse' WHERE type = 'true_false'");
$results[] = update_sql("UPDATE {vocabulary_node_types} SET type = 'truefalse' WHERE type = 'true_false'");
return $results;
}
/**
* Implementation of hook_install().
*/
function truefalse_install() {
if (!db_table_exists('quiz_truefalse_node')) {
drupal_install_schema('truefalse');
}
else {
db_query("UPDATE {system} SET name = 'truefalse' WHERE name = 'true_false'");
db_query("UPDATE {node} SET type = 'truefalse' WHERE type = 'true_false'");
db_query("UPDATE {system} SET type = 'truefalse' WHERE type = 'true_false'");
db_query("UPDATE {vocabulary_node_types} SET type = 'truefalse' WHERE type = 'true_false'");
}
variable_set('node_options_truefalse', array(
'status',
));
cache_clear_all('autoload:', 'cache');
}
/**
* Implementation of hook_uninstall().
*/
function truefalse_uninstall() {
drupal_uninstall_schema('truefalse');
}
/**
* Implementation of hook_schema().
*/
function truefalse_schema() {
//////////////////////
// TRUE/FALSE tables.
//////////////////////
// Extensions to nodes for T/F
$schema['quiz_truefalse_node'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'correct_answer' => array(
'description' => 'The correct answer for the user to give. 1 for true.',
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'default' => 0,
),
'feedback' => array(
'type' => 'text',
),
),
'primary key' => array(
'vid',
'nid',
),
);
// Place to store user answers for T/F questions
$schema['quiz_truefalse_user_answers'] = array(
'fields' => array(
'question_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'question_vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'result_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'answer' => array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'tiny',
'default' => 0,
),
'score' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'result_id',
'question_nid',
'question_vid',
),
);
return $schema;
}
Functions
Name![]() |
Description |
---|---|
truefalse_install | Implementation of hook_install(). |
truefalse_schema | Implementation of hook_schema(). |
truefalse_uninstall | Implementation of hook_uninstall(). |
truefalse_update_6400 | Implementation of hook_update_N |