- Fix an issue with the default import of judging questions

This commit is contained in:
dave 2007-01-16 19:32:40 +00:00
parent 6495dabf79
commit 14e8ee5ec9
3 changed files with 29 additions and 1 deletions

View File

@ -1 +1 @@
34 35

10
db/db.update.35.sql Normal file
View File

@ -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);

View File

@ -268,6 +268,24 @@ function questions_editor($section, $year, $array_name, $self)
* have to modify 2 questions to maintain the order */ * have to modify 2 questions to maintain the order */
$qs = questions_load_questions($section, $year); $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; $qdir = 0;
if($_GET['action']=="up" && $_GET['up']) { if($_GET['action']=="up" && $_GET['up']) {
$qid = $_GET['up']; $qid = $_GET['up'];