3 // THIS FILE IS DEPRECATED! PLEASE DO NOT MAKE CHANGES TO IT!
5 // IT IS USED ONLY FOR UPGRADES FROM BEFORE MOODLE 1.7, ALL
6 // LATER CHANGES SHOULD USE upgrade.php IN THIS DIRECTORY.
8 function survey_upgrade($oldversion) {
9 // This function does anything necessary to upgrade
10 // older versions to match current functionality
14 if ($oldversion < 2004021601) {
15 modify_database("", "INSERT INTO `prefix_survey` (`course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73')");
16 modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '')");
17 modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '')");
18 modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '')");
19 modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '')");
20 modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '')");
23 if ($oldversion < 2004021602) {
24 table_column("survey_answers", "answer1", "answer1", "text", "", "", "");
25 table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
27 if ($oldversion < 2004021900) {
28 modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('survey', 'add', 'survey', 'name');");
29 modify_database("", "INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('survey', 'update', 'survey', 'name');");
32 if ($oldversion < 2004111200) {
33 execute_sql("DROP INDEX {$CFG->prefix}survey_course_idx;",false);
34 execute_sql("DROP INDEX {$CFG->prefix}survey_analysis_survey_idx;",false);
35 execute_sql("DROP INDEX {$CFG->prefix}survey_analysis_userid_idx;",false);
36 execute_sql("DROP INDEX {$CFG->prefix}survey_answers_userid_idx;",false);
37 execute_sql("DROP INDEX {$CFG->prefix}survey_answers_survey_idx;",false);
38 execute_sql("DROP INDEX {$CFG->prefix}survey_answers_question_idx;",false);
40 modify_database('','CREATE INDEX prefix_survey_course_idx ON prefix_survey (course);');
41 modify_database('','CREATE INDEX prefix_survey_analysis_survey_idx ON prefix_survey_analysis (survey);');
42 modify_database('','CREATE INDEX prefix_survey_analysis_userid_idx ON prefix_survey_analysis (userid);');
43 modify_database('','CREATE INDEX prefix_survey_answers_userid_idx ON prefix_survey_answers (userid);');
44 modify_database('','CREATE INDEX prefix_survey_answers_survey_idx ON prefix_survey_answers (survey);');
45 modify_database('','CREATE INDEX prefix_survey_answers_question_idx ON prefix_survey_answers (question);');
48 if ($oldversion < 2005031600) {
49 execute_sql('SELECT setval(\''.$CFG->prefix
.'survey_id_seq\', (select max(id) from '.$CFG->prefix
.'survey))');
50 execute_sql('SELECT setval(\''.$CFG->prefix
.'survey_questions_id_seq\', (select max(id) from '.$CFG->prefix
.'survey_questions))');
53 ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions.