Update the judges automatic scheduler to honour filtering categories by divisions, so we only get teams for cat/div combos that we actually need

This commit is contained in:
james 2006-02-06 16:45:39 +00:00
parent cbfd619af7
commit d5fd002820
2 changed files with 31 additions and 1 deletions

View File

@ -327,6 +327,15 @@ $q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR'
while($r=mysql_fetch_object($q)) while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category; $cat[$r->id]=$r->category;
if($config['filterdivisionbycategory']=="yes")
{
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$catdiv[$r->projectcategories_id][]=$r->projectdivisions_id;
}
$langr = array(); $langr = array();
$q=mysql_query("SELECT * FROM languages WHERE active='Y'"); $q=mysql_query("SELECT * FROM languages WHERE active='Y'");
while($r=mysql_fetch_object($q)) while($r=mysql_fetch_object($q))
@ -368,6 +377,12 @@ foreach($div AS $d_id=>$d_val)
{ {
foreach($cat AS $c_id=>$c_val) foreach($cat AS $c_id=>$c_val)
{ {
//only make the teams for the ones that are needed
if($config['filterdivisionbycategory']=="yes")
{
if(!in_array($d_id,$catdiv[$c_id]))
continue;
}
foreach($langr AS $l_id) { foreach($langr AS $l_id) {
$num = count($jdivisions[$d_id][$c_id][$l_id]); $num = count($jdivisions[$d_id][$c_id][$l_id]);

View File

@ -22,7 +22,11 @@ function checkPrerequisites()
echo "<h3>$catr->category</h3>"; echo "<h3>$catr->category</h3>";
echo "<table>"; echo "<table>";
echo "<tr><th>Division</th><th>Projects</th><th>Teams</th></tr>"; echo "<tr><th>Division</th><th>Projects</th><th>Teams</th></tr>";
$divq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id"); if($config['filterdivisionbycategory']=="yes")
$divq=mysql_query("SELECT projectdivisions.* FROM projectdivisions,projectcategoriesdivisions_link WHERE projectdivisions.year='{$config['FAIRYEAR']}' AND projectcategoriesdivisions_link.projectcategories_id='$catr->id' AND projectcategoriesdivisions_link.projectdivisions_id=projectdivisions.id AND projectcategoriesdivisions_link.year='".$config['FAIRYEAR']."' ORDER BY id");
else
$divq=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
echo mysql_error();
while($divr=mysql_fetch_object($divq)) while($divr=mysql_fetch_object($divq))
{ {
$langq=mysql_query("SELECT * FROM languages WHERE active='Y'"); $langq=mysql_query("SELECT * FROM languages WHERE active='Y'");
@ -82,6 +86,12 @@ function checkPrerequisites()
while($r=mysql_fetch_object($q)) while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category; $cat[$r->id]=$r->category;
if($config['filterdivisionbycategory']=="yes")
{
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$catdiv[$r->projectcategories_id][]=$r->projectdivisions_id;
}
$foundawards=""; $foundawards="";
$notfoundawards=""; $notfoundawards="";
$foundteams=""; $foundteams="";
@ -89,6 +99,11 @@ function checkPrerequisites()
{ {
foreach($cat AS $c_id=>$c_category) foreach($cat AS $c_id=>$c_category)
{ {
if($config['filterdivisionbycategory']=="yes")
{
if(!in_array($d_id,$catdiv[$c_id]))
continue;
}
$q=mysql_query("SELECT award_awards.id FROM $q=mysql_query("SELECT award_awards.id FROM
award_awards, award_awards,
award_awards_projectcategories, award_awards_projectcategories,