diff --git a/db/db.code.version.txt b/db/db.code.version.txt index a7873645..8f92bfdd 100644 --- a/db/db.code.version.txt +++ b/db/db.code.version.txt @@ -1 +1 @@ -34 +35 diff --git a/db/db.update.35.sql b/db/db.update.35.sql new file mode 100644 index 00000000..be1fa538 --- /dev/null +++ b/db/db.update.35.sql @@ -0,0 +1,10 @@ +-- Clean up the multiple default questions.. And insert the 5 proper questions. +DELETE FROM `questions` WHERE year='-1'; + + +INSERT INTO `questions` (`id`, `year`, `section`, `db_heading`, `question`, `type`, `required`, `ord`) VALUES ('', -1, 'judgereg', 'Years School', 'Years of judging experience at a School level:', 'int', 'yes', 1); +INSERT INTO `questions` (`id`, `year`, `section`, `db_heading`, `question`, `type`, `required`, `ord`) VALUES ('', -1, 'judgereg', 'Years Regional', 'Years of judging experience at a Regional level:', 'int', 'yes', 2); +INSERT INTO `questions` (`id`, `year`, `section`, `db_heading`, `question`, `type`, `required`, `ord`) VALUES ('', -1, 'judgereg', 'Years National', 'Years of judging experience at a National (CWSF) level:', 'int', 'yes', 3); +INSERT INTO `questions` (`id`, `year`, `section`, `db_heading`, `question`, `type`, `required`, `ord`) VALUES ('', -1, 'judgereg', 'Attending Lunch', 'Will you be attending the Judge''s Lunch?', 'yesno', 'yes', 4); +INSERT INTO `questions` (`id`, `year`, `section`, `db_heading`, `question`, `type`, `required`, `ord`) VALUES ('', -1, 'judgereg', 'Willing Chair', 'Are you willing to be the lead for your judging team?', 'yesno', 'yes', 5); + diff --git a/questions.inc.php b/questions.inc.php index 2a365650..be0743f7 100644 --- a/questions.inc.php +++ b/questions.inc.php @@ -268,6 +268,24 @@ function questions_editor($section, $year, $array_name, $self) * have to modify 2 questions to maintain the order */ $qs = questions_load_questions($section, $year); + /* Sanity check the order DG -- This is there to fix a bug in the .22 + * database full import, anyone with a fresh install will see duplicate + * order items, anyone who doesn't, won't see this bug. Anyone who has + * already used the default question import will need this piece of + * code to return their system to sane. I have added a db.update + * script to fix the bug, but it won't fix any systems where the + * questions have already been imported. This code will. */ + $keys = array_keys($qs); + $x=1; + foreach($keys as $qid) { + if($qs[$qid]['ord'] != $x) { + $qs[$qid]['ord'] = $x; + questions_update_question($qs[$qid], $year); + } + $x++; + } + + $qdir = 0; if($_GET['action']=="up" && $_GET['up']) { $qid = $_GET['up'];