diff --git a/admin/judges_info.php b/admin/judges_info.php
index 0d51a77..7fee71d 100644
--- a/admin/judges_info.php
+++ b/admin/judges_info.php
@@ -25,6 +25,8 @@
//this file is meant to be used as a popup from the judging teams page to view the judge info
//it needs the judge ID passed into it.
//thus, we do not need the normal header and footer
+ require("../questions.inc.php");
+
require("../common.inc.php");
auth_required('admin');
@@ -123,31 +125,7 @@ while($r=mysql_fetch_object($q))
echo " \n";
echo "\n";
- echo "
\n";
- echo "
".i18n("Judging experience at school/local level")."
\n";
- echo "
$judgeinfo->years_school ".i18n("years")."
\n";
- echo "
\n";
-
- echo "
\n";
- echo "
".i18n("Judging experience at regional level")."
\n";
- echo "
$judgeinfo->years_regional ".i18n("years")."
\n";
- echo "
\n";
-
- echo "
\n";
- echo "
".i18n("Judging experience at national level")."
\n";
- echo "
$judgeinfo->years_national ".i18n("years")."
\n";
- echo "
\n";
-
- echo "
\n";
- echo "
".i18n("Willing to act as a division chair?")."
\n";
- echo "
$judgeinfo->willing_chair";
- echo "
\n";
-
- echo "
\n";
- echo "
".i18n("Attending lunch?")."
\n";
- echo "
$judgeinfo->attending_lunch";
- echo "
\n";
-
+ questions_print_answers('judgereg',$judgeinfo->id, $config['FAIRYEAR']);
echo "";
diff --git a/admin/reports_judges.php b/admin/reports_judges.php
index b31d97c..cef7894 100644
--- a/admin/reports_judges.php
+++ b/admin/reports_judges.php
@@ -26,6 +26,7 @@
auth_required('admin');
require("../lpdf.php");
require("../lcsv.php");
+ require("../questions.inc.php");
if(!$_GET['type']) $type="csv";
else $type=$_GET['type'];
@@ -63,13 +64,15 @@ $table['header']=array( i18n("ID"),
i18n("Postal Code"),
i18n("Highest PostSecDeg"),
i18n("Professional Quals"),
- i18n("Years School"),
- i18n("Years Regional"),
- i18n("Years National"),
- i18n("Willing Chair"),
- i18n("Attending Lunch"),
i18n("Expertise Other"));
+/* Append headers for all the custom questions */
+$qs=questions_load_questions('judgereg', $config['FAIRYEAR']);
+$keys = array_keys($qs);
+foreach($keys as $qid) {
+ $table['header'][] = i18n($qs[$qid]['db_heading']);
+}
+
//grab the list of divisions, because the last fields of the table will be the sub-divisions
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
@@ -190,6 +193,13 @@ while($r=mysql_fetch_object($q))
// print_r($judge_divs);
// print_r($judge_subdivs);
+ $qarray = array();
+ $qans = questions_load_answers('judgereg', $r->id, $config['FAIRYEAR']);
+ $keys = array_keys($qans);
+ foreach($keys as $qid) {
+ $qarray[] = $qans[$qid];
+ }
+
$tmp=array(
$r->id,
$r->lastname,
@@ -208,13 +218,9 @@ while($r=mysql_fetch_object($q))
$r->postalcode,
$r->highest_psd,
$r->professional_quals,
- $r->years_school,
- $r->years_regional,
- $r->years_national,
- $r->willing_chair,
- $r->attending_lunch,
$expertise_other
);
+ $tmp = array_merge($tmp, $qarray);
$extradata=array_merge($catdata,$divdata);
$table['data'][]=array_merge($tmp,$extradata);
diff --git a/config/index.php b/config/index.php
index 3998fca..86ce090 100644
--- a/config/index.php
+++ b/config/index.php
@@ -34,6 +34,7 @@
echo "".i18n("Project Sub-Divisions")." ";
echo "".i18n("Page Texts")." ";
echo "".i18n("Exhibitor Signature Page")." ";
+ echo "".i18n("Judge Registration Questions")." ";
echo "".i18n("Project Safety Questions")." ";
echo "".i18n("Images (Fair Logo)")." ";
echo "";
diff --git a/config/rollover.php b/config/rollover.php
index 146d130..aeb6a1d 100644
--- a/config/rollover.php
+++ b/config/rollover.php
@@ -249,6 +249,19 @@
'".mysql_escape_string($r->registration_password)."',
'".mysql_escape_string($newfairyear)."')");
+ echo i18n("Rolling questions")." ";
+ $q = mysql_query("SELECT * FROM questions WHERE year='$currentfairyear'");
+ while($r=mysql_fetch_object($q))
+ mysql_query("INSERT INTO questions (id,year,section,db_heading,question,type,required,ord) VALUES (
+ '',
+ '$newfairyear',
+ '".mysql_escape_string($r->section)."',
+ '".mysql_escape_string($r->db_heading)."',
+ '".mysql_escape_string($r->question)."',
+ '".mysql_escape_string($r->type)."',
+ '".mysql_escape_string($r->required)."',
+ '".mysql_escape_string($r->ord)."')");
+
echo " ";
echo " ";
mysql_query("UPDATE config SET val='$newfairyear' WHERE var='FAIRYEAR' AND year=0");
diff --git a/db/db.code.version.txt b/db/db.code.version.txt
index b6a7d89..3c03207 100644
--- a/db/db.code.version.txt
+++ b/db/db.code.version.txt
@@ -1 +1 @@
-16
+18
diff --git a/questions.inc.php b/questions.inc.php
new file mode 100644
index 0000000..73eef3c
--- /dev/null
+++ b/questions.inc.php
@@ -0,0 +1,419 @@
+
+/*
+ This file is part of the 'Science Fair In A Box' project
+ SFIAB Website: http://www.sfiab.ca
+
+ Copyright (C) 2005 Sci-Tech Ontario Inc
+ Copyright (C) 2005 James Grant
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation, version 2.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+?>
+
+
+
+function questions_load_answers($section, $id, $year)
+{
+ $q = mysql_query('SELECT question_answers.*, questions.* '.
+ 'FROM question_answers '.
+ 'LEFT JOIN questions ON questions.id=question_answers.questions_id '.
+ "WHERE question_answers.year='$year' ".
+ " AND registrations_id='$id' ".
+ " AND questions.section='$section' ".
+ 'ORDER BY questions.ord ASC');
+
+ $ans = array();
+ while($r=mysql_fetch_object($q)) {
+ $ans[$r->questions_id] = $r->answer;
+ }
+ return $ans;
+}
+
+function questions_load_questions($section, $year)
+{
+ $q = mysql_query('SELECT * FROM questions '.
+ "WHERE year='$year' ".
+ " AND section='$section' ".
+ 'ORDER BY ord ASC');
+ print(mysql_error());
+
+ $qs = array();
+ while($r=mysql_fetch_object($q)) {
+ $qs[$r->id]['id'] = $r->id;
+ $qs[$r->id]['ord'] = $r->ord;
+ $qs[$r->id]['section'] = $r->section;
+ $qs[$r->id]['db_heading'] = $r->db_heading;
+ $qs[$r->id]['type'] = $r->type;
+ $qs[$r->id]['required'] = $r->required;
+ $qs[$r->id]['question'] = $r->question;
+ }
+ return $qs;
+}
+
+function questions_save_answers($section, $id, $year, $answers)
+{
+ $qs = questions_load_questions($section, $year);
+ $keys = array_keys($answers);
+ $query = "DELETE FROM question_answers ".
+ "WHERE registrations_id='$id' ".
+ " AND year='$year' AND (";
+ $n = 0;
+ foreach($keys as $qid) {
+ if($n == 1) $query .= " OR ";
+ $n = 1;
+ $query .= " questions_id='$qid'";
+ }
+ $query .= ')';
+ mysql_query($query);
+
+ $keys = array_keys($answers);
+ foreach($keys as $qid) {
+ /* Poll key */
+ mysql_query("INSERT INTO question_answers ".
+ "(year,registrations_id,questions_id,answer) VALUES(".
+ "'$year','$id','$qid',".
+ "'".mysql_escape_string($answers[$qid])."'".
+ ")" );
+ }
+}
+
+
+function questions_print_answer_editor($section, $id, $year, $array_name)
+{
+ $ans = questions_load_answers($section, $id, $year);
+ $qs = questions_load_questions($section, $year);
+
+ $keys = array_keys($qs);
+ foreach($keys as $qid) {
+ print("