diff --git a/db/db.code.version.txt b/db/db.code.version.txt
index a272009..425151f 100644
--- a/db/db.code.version.txt
+++ b/db/db.code.version.txt
@@ -1 +1 @@
-39
+40
diff --git a/db/db.update.40.sql b/db/db.update.40.sql
new file mode 100644
index 0000000..15e2ce9
--- /dev/null
+++ b/db/db.update.40.sql
@@ -0,0 +1,16 @@
+ALTER TABLE `judges` ADD `typepref` VARCHAR( 8 ) NOT NULL ;
+
+INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) VALUES ( 'judges_specialaward_enable', 'no', 'Judge Registration', 'yesno', '', '1000', 'Allow judges to specify their special award judging preferences (in addition to the divisional judging preferences)', '-1');
+INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) VALUES ( 'judges_specialaward_only_enable', 'no', 'Judge Registration', 'yesno', '', '1100', 'Allow judges to specify that they are a judge for a specific special award. If a judge selects this, it disables their divisional preference selection entirely', '-1');
+INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) VALUES ( 'judges_specialaward_min', '1', 'Judge Registration', 'number', '', '1200', 'Minimum number of special awards a judge must select when specifying special award preferences', '-1');
+INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year` ) VALUES ( 'judges_specialaward_max', '6', 'Judge Registration', 'number', '', '1300', 'Maximum number of special awards a judge must select when specifying special award preferences', '-1');
+
+CREATE TABLE `judges_specialaward_sel` (
+`id` INT NOT NULL AUTO_INCREMENT,
+`judges_id` INT NOT NULL ,
+`award_awards_id` INT NOT NULL ,
+`year` INT NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE = MyISAM ;
+
+
diff --git a/register_judges.inc.php b/register_judges.inc.php
index eb9603e..c18abc6 100644
--- a/register_judges.inc.php
+++ b/register_judges.inc.php
@@ -57,6 +57,21 @@ function personalStatus()
if($r->num==0)
return "incomplete";
+
+ //if it made it through without returning incomplete, then we must be complete
+ return "complete";
+}
+
+function expertiseStatus()
+{
+ global $config;
+
+ /* If the judging special awards are active, and the judge has
+ * selected "I am a special awards judge", then disable this */
+ if($config['judges_specialaward_only_enable'] == 'yes') {
+ return "complete";
+ }
+
//and they need to rank all of the age categories
$q=mysql_query("SELECT COUNT(id) AS num FROM projectcategories WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
@@ -69,20 +84,11 @@ function personalStatus()
if($numcats!=$numprefs)
return "incomplete";
-
-
- //if it made it through without returning incomplete, then we must be complete
- return "complete";
-}
-
-function expertiseStatus()
-{
- global $config;
//easiest check here is to check the number of divisions, then check the number of entries
//that they have in the judges_expertise table. If they are the same, then we're good to go
//if they are different, they forgot to fill one out (because it only gets inserted if a value)
//is choosen, and they are always ALL removed before each update
-
+
$q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q);
$numdivisions=$r->num;
@@ -95,8 +101,47 @@ function expertiseStatus()
return "complete";
else
return "incomplete";
+}
+function specialawardStatus()
+{
+ global $config;
+ /* Complete if:
+ * - judge has selected (none) "no special award preferences"
+ * - judge has selected (pref) "i would like to specify awards", and has
+ * selected between min and max preferences
+ * - judge has selected "i am a special awards judge, and has
+ * selected an award */
+
+ $q = mysql_query("SELECT typepref FROM judges WHERE
+ id='{$_SESSION['judges_id']}'");
+ $r = mysql_fetch_object($q);
+ if($r != 1) return "incomplete";
+
+ $qq = mysql_query("SELECT COUNT(id) AS num FROM judges_specialaward_sel
+ WHERE judges_id='{$_SESSION['judges_id']}'
+ AND year={$config['FAIRYEAR']}");
+ $rr = mysql_fetch_object($qq);
+ $awards_selected = $rr->num;
+
+ switch($r->typepref) {
+ case "speconly": /* Judge for special award */
+ /* They may judge more than one award, so don't limit them
+ * to one */
+ if($awards_selected >= 1) return "complete";
+ break;
+
+ case "pref": /* Special award preferences specified */
+ default:
+ if( ($awards_selected >= $config['judges_specialaward_min'])
+ &&($awards_selected <= $config['judges_specialaward_max']) ){
+ return "complete";
+ }
+ break;
+ }
+
+ return "incomplete";
}
diff --git a/register_judges_expertise.php b/register_judges_expertise.php
index 6376ecd..d992421 100644
--- a/register_judges_expertise.php
+++ b/register_judges_expertise.php
@@ -26,7 +26,7 @@
include "register_judges.inc.php";
//send the header
- send_header("Judges Registration - Areas of Expertise Information");
+ send_header("Judges Registration - Divisional Judging Preferences");
echo "<< ".i18n("Back to Judges Registration Summary")."
";
echo "
";
@@ -60,7 +60,19 @@
{
mysql_query("UPDATE judges SET expertise_other=NULL WHERE id='".$_SESSION['judges_id']."'");
}
- echo notice(i18n("Areas of Expertise successfully saved"));
+
+ mysql_query("DELETE FROM judges_catpref WHERE judges_id='".$_SESSION['judges_id']."'");
+
+ if(is_array($_POST['catpref']))
+ {
+ foreach($_POST['catpref'] AS $k=>$v)
+ {
+ if($v!="")
+ mysql_query("INSERT INTO judges_catpref (judges_id,projectcategories_id,rank,year) values ('".$_SESSION['judges_id']."','$k','$v','".$config['FAIRYEAR']."')");
+ }
+ }
+
+ echo notice(i18n("Preferences successfully saved"));
}
$q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
@@ -70,15 +82,57 @@
$newstatus=expertiseStatus();
if($newstatus!="complete")
{
- echo error(i18n("Areas of Expertise Information Incomplete"));
+ echo error(i18n("Divisional Judging Information Incomplete"));
}
else
{
- echo happy(i18n("Areas of Expertise Information Complete"));
+ echo happy(i18n("Divisional Judging Information Complete"));
}
+ if($judgeinfo->typepref == "speconly") {
+ echo i18n("You have specified that you are a judge for a specific special award. Divisional Judging preferences have been disabled because they do not apply to you.");
+ echo "
";
+ send_footer();
+ exit;
+ }
+
echo "