1) Properly handle "filterdivisionbycategory" checks for divisional awards

2) Properly handle cases where there's MORE than one award for a certain div/cat combo
This commit is contained in:
james 2007-12-10 19:21:21 +00:00
parent b146a9c773
commit 7bbea6351a
2 changed files with 25 additions and 9 deletions

View File

@ -70,14 +70,14 @@ if($config['judge_scheduler_percent']=="-1")
$missing_awards = judges_scheduler_check_awards();
if(count($missing_awards) == 0) {
echo happy(i18n("There is a divisional award for each division, good"));
echo happy(i18n("There is a single divisional award for each division/category, good"));
} else {
echo "<br />The following awards are missing:<br /><ul>";
echo "<br />The following divisional awards problems were identified:<br /><ul>";
for($x=0; $x<count($missing_awards); $x++) {
print($missing_awards[$x]."<br />");
}
echo "</ul>";
echo error(i18n("There are missing divisional awards"));
echo error(i18n("There needs to be exactly one award for each division/category"));
$ok = 0;
}

View File

@ -27,10 +27,28 @@ function judges_scheduler_check_awards()
$dkeys = array_keys($div);
$ckeys = array_keys($cat);
if($config['filterdivisionbycategory']=="yes") {
$q=mysql_query("SELECT * FROM projectcategoriesdivisions_link WHERE year='".$config['FAIRYEAR']."' ORDER BY projectdivisions_id,projectcategories_id");
$divcat=array();
while($r=mysql_fetch_object($q)) {
$divcat[]=array("c"=>$r->projectcategories_id,"d"=>$r->projectdivisions_id);
}
}
else {
$divcat=array();
foreach($dkeys AS $d) {
foreach($ckeys AS $c) {
$divcat[]=array("c"=>$c,"d"=>$d);
}
}
}
$missing_awards = array();
foreach($dkeys as $d) {
reset($ckeys);
foreach ($ckeys as $c) {
foreach($divcat AS $dc) {
$d=$dc['d'];
$c=$dc['c'];
$q=mysql_query("SELECT award_awards.id FROM
award_awards,
award_awards_projectcategories,
@ -47,12 +65,10 @@ function judges_scheduler_check_awards()
");
echo mysql_error();
if(mysql_num_rows($q)!=1) {
$missing_awards[] = "{$cat[$c]} - {$div[$d]}";
$missing_awards[] = "{$cat[$c]} - {$div[$d]} (".i18n("%1 found",array(mysql_num_rows($q))).")";
}
}
}
return $missing_awards;
}