science-ation/register_judges_expertise.php
dave 50b4e146bd - Move the judging age preferences to the expertise page... and rename that
page to "Divisional Preferences"
- Add the ability for the judges to select special awards they would like to
  judge
- Add the ability for a judge to specify that they are a judge for a specific
  (one or more) award, and disable the divisional selection for them
2007-01-30 06:12:11 +00:00

215 lines
7.4 KiB
PHP

<?
/*
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 <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
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.
*/
?>
<?
require("common.inc.php");
include "register_judges.inc.php";
//send the header
send_header("Judges Registration - Divisional Judging Preferences");
echo "<a onclick=\"return confirmChanges();\" href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
echo "<br />";
if($_POST['action']=="save")
{
//first delete all their old associations for this year..
mysql_query("DELETE FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
if(!is_array($_POST['division']))
$_POST['division']=array();
if(!is_array($_POST['subdivision']))
$_POST['subdivision']=array();
foreach($_POST['division'] AS $key=>$val)
{
mysql_query("INSERT INTO judges_expertise (judges_id, projectdivisions_id, val, year) VALUES ('".$_SESSION['judges_id']."','$key','$val','".$config['FAIRYEAR']."')");
}
foreach($_POST['subdivision'] AS $key=>$val)
{
mysql_query("INSERT INTO judges_expertise (judges_id, projectsubdivisions_id, val, year) VALUES ('".$_SESSION['judges_id']."','$key','$val','".$config['FAIRYEAR']."')");
}
if($_POST['expertise_other'])
{
mysql_query("UPDATE judges SET expertise_other='".mysql_escape_string(stripslashes($_POST['expertise_other']))."' WHERE id='".$_SESSION['judges_id']."'");
}
else
{
mysql_query("UPDATE judges SET expertise_other=NULL WHERE id='".$_SESSION['judges_id']."'");
}
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);
updateJudgeCompleteStatus($judgeinfo);
//output the current status
$newstatus=expertiseStatus();
if($newstatus!="complete")
{
echo error(i18n("Divisional Judging Information Incomplete"));
}
else
{
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 "<br />";
send_footer();
exit;
}
echo "<form name=\"expertiseform\" method=\"post\" action=\"register_judges_expertise.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\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 "<h3>".i18n("Age Category Preferences")."</h3><br>";
echo "<table>";
while($r=mysql_fetch_object($q))
{
echo "<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;";
echo i18n("%1 (Grades %2-%3)",array(i18n($r->category),$r->mingrade,$r->maxgrade));
echo "</td>";
echo "<td>";
echo "<select name=\"catpref[$r->id]\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
foreach($preferencechoices AS $val=>$str)
{
if($catprefs[$r->id]==$val && $catprefs[$r->id]!="") $sel="selected=\"selected\""; else $sel="";
echo "<option $sel value=\"$val\">".i18n($str)."</option>\n";
}
echo "</select>".REQUIREDFIELD;
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo "<br />";
echo "<h3>".i18n("Division Expertise")."</h3><br>";
echo "<table>";
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 "<br />";
echo "<br />";
echo i18n("Once you save, any division that you specified as 3 or more might offer sub-divisions for you to choose from.");
echo "<br />";
echo "<br />";
$q=mysql_query("SELECT * FROM judges_expertise WHERE judges_id='".$_SESSION['judges_id']."' AND year='".$config['FAIRYEAR']."'");
while($r=mysql_fetch_object($q))
{
if($r->projectdivisions_id)
$expertise[$r->projectdivisions_id]=$r->val;
else if($r->projectsubdivisions_id)
$subexpertise[$r->projectsubdivisions_id]=$r->val;
}
// echo "<table>\n";
//query all of the categories
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY division");
while($r=mysql_fetch_object($q))
{
echo "<tr><td></td><td colspan=\"2\">".i18n("Novice")."</td><td colspan=\"3\" align=\"right\">".i18n("Expert")."</td></tr>";
echo "<tr><th></th>";
for($x=1;$x<=5;$x++)
echo "<th>$x</th>";
echo "<th></th>";
echo "</tr>";
echo "<tr><td><b>".i18n($r->division)."</b></td>";
for($x=1;$x<=5;$x++)
{
if($expertise[$r->id]==$x) $sel="checked=\"checked\""; else $sel="";
echo "<td width=\"30\"><input onclick=\"fieldChanged()\" $sel type=\"radio\" name=\"division[$r->id]\" value=\"$x\" /></td>";
}
echo "<td width=\"100\"></td>";
echo "</tr>";
//only show the sub-divisions if the 'main' division is scored >=3
if($expertise[$r->id]>=3)
{
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE projectdivisions_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY subdivision");
while($subr=mysql_fetch_object($subq))
{
echo "<tr>";
echo "<td>&nbsp;</td>";
if($subexpertise[$subr->id]) $ch="checked=\"checked\""; else $ch="";
echo "<td><input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"subdivision[$subr->id]\" value=\"1\" /></td>";
echo "<td colspan=\"5\">";
echo "$subr->subdivision";
echo "</td>";
echo "</tr>";
}
}
echo "<tr><td colspan=\"7\">&nbsp;</td></tr>";
}
echo "</table>";
echo "<br />";
echo "<h3>".i18n("Other Areas of Expertise not listed above")."</h3>";
$q=mysql_query("SELECT expertise_other FROM judges WHERE id='".$_SESSION['judges_id']."'");
$judgeinfo=mysql_fetch_object($q);
echo "<textarea name=\"expertise_other\" rows=\"4\" cols=\"60\">".htmlspecialchars($judgeinfo->expertise_other)."</textarea>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Judging Preferences")."\" />\n";
echo "</form>";
echo "<br />";
echo "<a onclick=\"return confirmChanges();\" href=\"register_judges_main.php\">&lt;&lt; ".i18n("Back to Judges Registration Summary")."</a><br />";
send_footer();
?>