function multichoice_install in Quiz 5.2
Same name and namespace in other branches
- 8.4 question_types/multichoice/multichoice.install \multichoice_install()
- 6.6 question_types/multichoice/multichoice.install \multichoice_install()
- 6.2 multichoice.install \multichoice_install()
- 6.3 question_types/multichoice/multichoice.install \multichoice_install()
- 6.4 question_types/multichoice/multichoice.install \multichoice_install()
- 6.5 question_types/multichoice/multichoice.install \multichoice_install()
- 7.6 question_types/multichoice/multichoice.install \multichoice_install()
- 7 question_types/multichoice/multichoice.install \multichoice_install()
- 7.4 question_types/multichoice/multichoice.install \multichoice_install()
- 7.5 question_types/multichoice/multichoice.install \multichoice_install()
Implementation of hook_install()
File
- ./
multichoice.install, line 6
Code
function multichoice_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
/**
* Stores correct answers for multichoice quiz.
*/
// Create the quiz node user answers multichoice table.
db_query("CREATE TABLE {quiz_multichoice_user_answers} (\n question_nid INTEGER UNSIGNED NOT NULL,\n question_vid INTEGER UNSIGNED NOT NULL,\n result_id INTEGER UNSIGNED NOT NULL,\n answer_id INTEGER UNSIGNED NOT NULL,\n PRIMARY KEY(result_id, question_nid, question_vid, answer_id)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
/**
* Stores user answers for multichoice quiz.
*/
// Create the quiz node answers multichoice table.
db_query("CREATE TABLE {quiz_multichoice_answers} (\n answer_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\n nid INTEGER UNSIGNED NOT NULL,\n vid INTEGER UNSIGNED NOT NULL,\n answer varchar(255) NOT NULL,\n feedback LONGTEXT,\n result_option INTEGER UNSIGNED DEFAULT 0,\n is_correct TINYINT UNSIGNED DEFAULT 0,\n PRIMARY KEY(answer_id)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
/**
* Stores correct answers for multichoice quiz.
*/
// Create the quiz node user answers multichoice table.
db_query("CREATE TABLE {quiz_multichoice_user_answers} (\n question_nid int_unsigned NOT NULL,\n question_vid int_unsigned NOT NULL,\n result_id int_unsigned NOT NULL,\n answer_id int_unsigned NOT NULL,\n PRIMARY KEY(result_id, question_nid, question_vid, answer_id)\n );");
/**
* Stores user answers for multichoice quiz.
*/
// Create the quiz node answers multichoice table.
db_query("CREATE TABLE {quiz_multichoice_answers} (\n answer_id SERIAL,\n nid int_unsigned NOT NULL,\n vid int_unsigned NOT NULL,\n answer varchar(255) NOT NULL,\n feedback text,\n result_option int_unsigned DEFAULT 0,\n is_correct smallint_unsigned DEFAULT 0,\n PRIMARY KEY(answer_id)\n );");
break;
}
// Default the "Show Author and Date" for this question type to OFF.
$temp_array = variable_get('theme_settings', $default);
$temp_array['toggle_node_info_multichoice'] = 0;
variable_set('theme_settings', $temp_array);
}