From 32222526a87519bed86a5ed4064e13655d649e8a Mon Sep 17 00:00:00 2001 From: james Date: Fri, 27 Mar 2009 20:31:57 +0000 Subject: [PATCH] Add judge language criteria to judge scheduler check before allowing the scheduler to run --- admin/judges_schedulerconfig_check.inc.php | 102 +++++++++++++++------ 1 file changed, 76 insertions(+), 26 deletions(-) diff --git a/admin/judges_schedulerconfig_check.inc.php b/admin/judges_schedulerconfig_check.inc.php index 6daac02..689e448 100644 --- a/admin/judges_schedulerconfig_check.inc.php +++ b/admin/judges_schedulerconfig_check.inc.php @@ -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("". - "". - ""); - $keys = array_keys($jdiv); - for($k=0; $k0) $t = $config['times_judged']; - $jdiv[$jdiv_id]['num_jteams'] = $t; - $totalteams+=$t; + $totalteams['total'] = 0; + echo "
".i18n("Projects")."".i18n("Required Teams")."
". + "". + ""; - print(""); + echo ""; + echo ""; + foreach($config['languages'] AS $lkey=>$lname) + echo ""; + echo ""; + echo "\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 ""; + echo ""; + $langstr=""; + foreach($config['languages'] AS $lkey=>$lname) { + $clang=($jd['num_projects'][$lkey]?$jd['num_projects'][$lkey]:0); + echo ""; + } + echo ""; + + echo ""; } - print("
".i18n("Projects")."".i18n("Required Teams")."
Judging Division Group $jdiv_id$c$t
".i18n("Total")."$lkey
Judging Division Group $jdiv_id$c$clang{$t['total']}
"); + echo ""; + echo "
"; echo ""; - echo "Total judging teams required: $totalteams"; + echo i18n("Total judging teams required: %1",array($totalteams['total'])); echo "
"; - $minjudges=($totalteams*$config['min_judges_per_team']); - $maxjudges=($totalteams*$config['max_judges_per_team']); - echo "Minimum number of judges required: $minjudges"; echo "
"; - 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']))."
"; + + foreach($config['languages'] AS $lkey=>$lname) { + $judgelanguagetotal[$lkey]=round($projectlanguagetotal[$lkey]/$projecttotal*$minjudges['total']); + echo "   ".i18n("Minimum number of %1 judges required: %2",array($lname,$judgelanguagetotal[$lkey]))."
"; + } + + echo i18n("Maximum number of judges needed: %1",array($maxjudges['total'])); + echo "
"; echo "
"; $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 "
"; - echo "
"; echo "
"; - if($currentjudges<$minjudges) - { - echo error(i18n("You do not have sufficient number of judges based on your parameters")); + echo "
"; + echo "
"; + 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 "".i18n("Current number of registered judges that can judge in %1: %2",array($lname,$currentjudges)).""; + echo "
"; + echo "
"; + 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 "  "; echo "".i18n("Update Scheduler Configuration")." (".i18n("or get more judges!").")"; - $ok=0; } else echo happy(i18n("You have a sufficient number of judges based on your parameters"));