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 "
\n"; echo "\n"; + + $q=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'"); + $catprefs=array(); + while($r=mysql_fetch_object($q)) + $catprefs[$r->projectcategories_id]=$r->rank; + + $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade"); + echo "

".i18n("Age Category Preferences")."


"; + echo ""; + while($r=mysql_fetch_object($q)) + { + echo ""; + echo ""; + echo ""; + } + echo "
    "; + echo i18n("%1 (Grades %2-%3)",array(i18n($r->category),$r->mingrade,$r->maxgrade)); + echo ""; + echo "".REQUIREDFIELD; + + echo "
"; + echo "
"; + echo "
"; + echo "

".i18n("Division Expertise")."


"; + echo ""; + + + echo i18n("Please rank the following divisions according to the amount of knowledge you have of each subject. A '1' indicates very little knowledge, and a '5' indicates you are very knowledgeable of the subject"); echo "
"; echo "
"; @@ -94,7 +148,7 @@ else else if($r->projectsubdivisions_id) $subexpertise[$r->projectsubdivisions_id]=$r->val; } - echo "
\n"; +// echo "
\n"; //query all of the categories @@ -150,7 +204,7 @@ else echo "
"; echo "
"; - echo "\n"; + echo "\n"; echo ""; echo "
"; echo "<< ".i18n("Back to Judges Registration Summary")."
"; diff --git a/register_judges_main.php b/register_judges_main.php index 4151b3c..6c83ec2 100644 --- a/register_judges_main.php +++ b/register_judges_main.php @@ -126,6 +126,21 @@ echo outputStatus($statusexpertise); if($statusexpertise!="complete") $overallstatus="incomplete"; echo ""; + + // special awards + if($config['judges_specialaward_enable'] == 'yes') { + echo ""; + } + echo ""; echo "\n"; echo ""; -echo ""; -echo "\n"; -echo " "; - -$q=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'"); -$catprefs=array(); -while($r=mysql_fetch_object($q)) - $catprefs[$r->projectcategories_id]=$r->rank; - -$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY mingrade"); -echo ""; echo "";
"; + echo ""; + echo i18n("Special Award Preferences"); + echo ""; + echo ""; + //check to see if its complete + $statusspecialawards=specialawardStatus(); + echo outputStatus($statusspecialawards); + if($statusspecialawards!="complete") $overallstatus="incomplete"; + echo "

".i18n("Overall Status").""; diff --git a/register_judges_personal.php b/register_judges_personal.php index a5f503a..0fff039 100644 --- a/register_judges_personal.php +++ b/register_judges_personal.php @@ -49,7 +49,8 @@ "phonecell='".mysql_escape_string(stripslashes($_POST['phonecell']))."', ". "organization='".mysql_escape_string(stripslashes($_POST['organization']))."', ". "highest_psd='".mysql_escape_string(stripslashes($_POST['highest_psd']))."', ". - "professional_quals='".mysql_escape_string(stripslashes($_POST['professional_quals']))."' ". + "professional_quals='".mysql_escape_string(stripslashes($_POST['professional_quals']))."', ". + "typepref='".mysql_escape_string(stripslashes($_POST['typepref']))."' ". "WHERE id='".$_SESSION['judges_id']."'"); echo mysql_error(); @@ -69,17 +70,6 @@ questions_save_answers('judgereg', $_SESSION['judges_id'], $config['FAIRYEAR'], $ans); - 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("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname']))); } $q=mysql_query("SELECT * FROM judges WHERE email='".$_SESSION['email']."' AND id='".$_SESSION['judges_id']."'"); @@ -130,43 +120,17 @@ echo " ".i18n("Organization")."".i18n("Phone (Cell)")."phonecell\" />

".i18n("Age category preferences")."
"; -echo ""; -//echo ""; - echo ""; - echo ""; +if($config['judges_specialaward_only_enable'] == 'yes') { + echo ""; + echo "\n"; + echo " "; + if($judgeinfo->typepref == "speconly") $ch = "checked=checked"; + else $ch=""; + echo " "; + echo "\n"; } -//echo ""; -echo "
    "; - echo i18n("%1 (Grades %2-%3)",array(i18n($r->category),$r->mingrade,$r->maxgrade)); - echo ""; - echo "".REQUIREDFIELD; - - echo "

".i18n("I am a judge for a specific special award")."
(".i18n("Check this box if you are supposed to judge a specific special award, and please select that award on the Special Award Preferences page.").")
"; + echo "
"; -echo "