Add judge language criteria to judge scheduler check before allowing the scheduler to run

This commit is contained in:
james 2009-03-27 20:31:57 +00:00
parent 4185558e4b
commit 32222526a8

View File

@ -108,50 +108,100 @@ function judges_scheduler_check_judges()
);
$qr = mysql_fetch_object($qp);
$jdiv[$r->jdiv_id]['num_projects'] += $qr->cnt;
$jdiv[$r->jdiv_id]['num_projects']['total'] += $qr->cnt;
$jdiv[$r->jdiv_id]['num_projects'][$l] += $qr->cnt;
$projectlanguagetotal[$l]+=$qr->cnt;
$projecttotal+=$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/$config['max_projects_per_team']*$config['times_judged']);
if($t < $config['times_judged'] && $c>0) $t = $config['times_judged'];
$jdiv[$jdiv_id]['num_jteams'] = $t;
$totalteams+=$t;
$totalteams['total'] = 0;
echo "<table border=1 width=\"85%\"><tr><th></th>".
"<th colspan=\"".(count($config['languages'])+1)."\">".i18n("Projects")."</th>".
"<th>".i18n("Required Teams")."</th></tr>";
print("<tr><td>Judging Division Group $jdiv_id</td><td align=center>$c</td><td align=center>$t</td></tr>");
echo "<tr>";
echo "<th></th><th>".i18n("Total")."</th>";
foreach($config['languages'] AS $lkey=>$lname)
echo "<th>$lkey</th>";
echo "<th></th>";
echo "</tr>\n";
foreach($jdiv AS $jdiv_id=>$jd) {
$c = $jd['num_projects']['total'];
//total judge teams calculation
$t['total']=ceil($c/$config['max_projects_per_team']*$config['times_judged']);
if($t['total'] < $config['times_judged'] && $c>0) $t['total'] = $config['times_judged'];
$jdiv[$jdiv_id]['num_jteams']['total'] = $t['total'];
$totalteams['total']+=$t['total'];
echo "<tr><td>Judging Division Group $jdiv_id</td>";
echo "<td align=\"center\">$c</td>";
$langstr="";
foreach($config['languages'] AS $lkey=>$lname) {
$clang=($jd['num_projects'][$lkey]?$jd['num_projects'][$lkey]:0);
echo "<td align=\"center\">$clang</td>";
}
echo "<td align=\"center\">{$t['total']}</td>";
echo "</tr>";
}
print("</table>");
echo "</table>";
echo "<br />";
echo "<b>";
echo "Total judging teams required: $totalteams";
echo i18n("Total judging teams required: %1",array($totalteams['total']));
echo "<br />";
$minjudges=($totalteams*$config['min_judges_per_team']);
$maxjudges=($totalteams*$config['max_judges_per_team']);
echo "Minimum number of judges required: $minjudges";
echo "<br />";
echo "Maximum number of judges acceptable: $maxjudges";
$minjudges['total']=($totalteams['total']*$config['min_judges_per_team']);
$maxjudges['total']=($totalteams['total']*$config['max_judges_per_team']);
echo i18n("Minimum number of judges required: %1",array($minjudges['total']))."<br />";
foreach($config['languages'] AS $lkey=>$lname) {
$judgelanguagetotal[$lkey]=round($projectlanguagetotal[$lkey]/$projecttotal*$minjudges['total']);
echo "&nbsp;&nbsp; ".i18n("Minimum number of %1 judges required: %2",array($lname,$judgelanguagetotal[$lkey]))."<br />";
}
echo i18n("Maximum number of judges needed: %1",array($maxjudges['total']));
echo "<br />";
echo "<br />";
$jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' AND deleted='no' 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 />";
echo "</b>";
if($currentjudges<$minjudges)
{
echo error(i18n("You do not have sufficient number of judges based on your parameters"));
echo "<br />";
echo "<br />";
if($currentjudges<$minjudges) {
echo error(i18n("You do not have sufficient number of total judges based on your parameters"));
$ok=false;
}
foreach($config['languages'] AS $lkey=>$lname) {
$jq=mysql_query("SELECT COUNT(judges.id) AS num FROM judges,judges_years,judges_languages WHERE complete='yes' AND deleted='no' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id AND judges_languages.languages_lang='$lkey' AND judges_languages.judges_id=judges.id");
echo mysql_error();
$jr=mysql_fetch_object($jq);
$currentjudges=$jr->num;
echo "<b>".i18n("Current number of registered judges that can judge in %1: %2",array($lname,$currentjudges))."</b>";
echo "<br />";
echo "<br />";
if($currentjudges<$judgelanguagetotal[$lkey]) {
echo error(i18n("You do not have sufficient number of %1 judges based on your parameters",array($lname)));
$ok=false;
}
}
if(!$ok) {
echo "&nbsp;&nbsp;";
echo "<a href=\"judges_schedulerconfig.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"));