science-ation/admin/judges_schedulerconfig_check.inc.php

144 lines
4.0 KiB
PHP

<?
function judges_scheduler_check_timeslots()
{
global $config;
$q=mysql_query("SELECT * FROM judges_timeslots WHERE ".
" year='".$config['FAIRYEAR']."'".
" AND allowdivisional='yes'" );
$rows = mysql_num_rows($q);
return $rows;
}
function judges_scheduler_check_awards()
{
global $config;
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$div[$r->id]=$r->division;
$q=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' ORDER BY id");
while($r=mysql_fetch_object($q))
$cat[$r->id]=$r->category;
$dkeys = array_keys($div);
$ckeys = array_keys($cat);
$missing_awards = array();
foreach($dkeys as $d) {
reset($ckeys);
foreach ($ckeys as $c) {
$q=mysql_query("SELECT award_awards.id FROM
award_awards,
award_awards_projectcategories,
award_awards_projectdivisions
WHERE
award_awards.year='{$config['FAIRYEAR']}'
AND award_awards_projectcategories.year='{$config['FAIRYEAR']}'
AND award_awards_projectdivisions.year='{$config['FAIRYEAR']}'
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
AND award_awards_projectcategories.projectcategories_id='$c'
AND award_awards_projectdivisions.projectdivisions_id='$d'
AND award_awards.award_types_id='1'
");
echo mysql_error();
if(mysql_num_rows($q)!=1) {
$missing_awards[] = "{$cat[$c]} - {$div[$d]}";
}
}
}
return $missing_awards;
}
function judges_scheduler_check_jdivs()
{
global $config;
$q=mysql_query("SELECT DISTINCT jdiv_id FROM judges_jdiv ");
$rows = mysql_num_rows($q);
return $rows;
}
function judges_scheduler_check_judges()
{
global $config;
$ok = 1;
$data = judges_scheduler_load_config();
$jdiv = array();
$q=mysql_query("SELECT * FROM judges_jdiv");
while($r=mysql_fetch_object($q)) {
$d = $r->projectdivisions_id;
$c = $r->projectcategories_id;
$l = $r->lang;
$qp = mysql_query("SELECT COUNT(id) as cnt FROM projects WHERE ".
" year='".$config['FAIRYEAR']."' AND ".
" projectdivisions_id='$d' AND ".
" projectcategories_id='$c' AND ".
" language='$l' "
);
$qr = mysql_fetch_object($qp);
$jdiv[$r->jdiv_id]['num_projects'] += $qr->cnt;
}
$totalteams = 0;
print("<table width=75%><tr><th></th>".
"<th>".i18n("Projects")."</th>".
"<th>".i18n("Required Teams")."</th></tr>");
$keys = array_keys($jdiv);
for($k=0; $k<count($keys); $k++) {
$jdiv_id = $keys[$k];
$c = $jdiv[$jdiv_id]['num_projects'];
$t=ceil($c/$data['max_projects_per_team']*$data['times_judged']);
if($t < $data['times_judged']) $t = $data['times_judged'];
$jdiv[$jdiv_id]['num_jteams'] = $t;
$totalteams+=$t;
print("<tr><td>Judging Division Group $jdiv_id</td><td align=center>$c</td><td align=center>$t</td></tr>");
}
print("</table>");
echo "<b>";
echo "Total judging teams required: $totalteams";
echo "<br />";
$minjudges=($totalteams*$data['min_judges_per_team']);
$maxjudges=($totalteams*$data['max_judges_per_team']);
echo "Minimum number of judges required: $minjudges";
echo "<br />";
echo "Maximum number of judges acceptable: $maxjudges";
echo "<br />";
$jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id");
$jr=mysql_fetch_object($jq);
$currentjudges=$jr->num;
echo "Current number of registered judges: $currentjudges";
echo "<br />";
echo "<br />";
if($currentjudges<$minjudges)
{
echo error(i18n("You do not have sufficient number of judges based on your parameters"));
echo "&nbsp;&nbsp;";
echo "<a href=\"judges_data.php\">".i18n("Update Scheduler Configuration")."</a> (".i18n("or get more judges!").")";
$ok=0;
}
else
echo happy(i18n("You have a sufficient number of judges based on your parameters"));
//now check if we can find a divisional award for each division and category
return $ok;
}
?>