From d01a3eede6f91c3c5f62b9a3b0e7209a76cbde9d Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 2 Aug 2006 07:36:21 +0000 Subject: [PATCH] - Delete the old divisional teams, links, award links, timeslot links earlier in the scheduler so we can only select judges that are NOT already part of a judging team - Fix a numbering issue where sometimes an divisional team created by the scheduler wouldn't get created because of conflicting team numbers. Now, use MAX(num) to find the highest team number and increment team numbers from that number. --- admin/judges_sa.php | 78 +++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/admin/judges_sa.php b/admin/judges_sa.php index 9d44c4a..d5ad484 100644 --- a/admin/judges_sa.php +++ b/admin/judges_sa.php @@ -27,16 +27,8 @@ require("judges.inc.php"); require("anneal.inc.php"); auth_required('admin'); -//equire("judges_schedulerconfig_check.inc.php"); send_header("Judging teams automatic scheduler"); -//ok=checkPrerequisites(); -//f(!$ok) -// -//cho error(i18n("Schduler cannot run until the above problems are resolved. Use the links below each error to resolve the problem")); -//end_footer(); -// exit; -// } echo i18n("The scheduler is running. Depending on the effort it may take several minutes to complete. It will generate a lot of output on this page, @@ -346,9 +338,37 @@ TRACE("There are ".(count($jteam) - 1)." judging teams\n"); $willing_chair_question_id = questions_find_question_id("judgereg", $config['FAIRYEAR'], "Willing Chair"); printf("Judge Willing Chair = Question ID $willing_chair_question_id\n"); +/* Clean out the judging teams that were autocreated */ +TRACE("Deleting existing judging teams:"); +$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}"); +while($r = mysql_fetch_object($q)) { + $jteam_id = $r->id; + print(" $jteam_id"); + /* Clean out the judges_teams_link */ + mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); + print mysql_error(); + /* Awards */ + mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); + print mysql_error(); + /* Timeslots */ + mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); + print mysql_error(); + /* Timeslots projects */ + mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); + print mysql_error(); +} +/* Findally, delete all the autocreated judges teams */ +mysql_query("DELETE FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}"); +print mysql_error(); +TRACE(" Done.\n"); + TRACE("Loading Judges...\n"); -$q=mysql_query("SELECT judges.* FROM judges,judges_years WHERE complete='yes' AND judges_years.year='{$config['FAIRYEAR']}' AND judges_years.judges_id=judges.id"); +$q=mysql_query("SELECT judges.* FROM judges,judges_years WHERE ". + "complete='yes' ". + " AND judges_years.year='{$config['FAIRYEAR']}' ". + " AND judges_years.judges_id=judges.id" + ); $judges=array(); @@ -410,29 +430,6 @@ $a = new annealer(count($jteam), 25, $e, 0.98, judges_cost_function, $judge_ids) $a->anneal(); -/* Clean out the judging teams that were autocreated */ -TRACE("Deleting existing judging teams:"); -$q = mysql_query("SELECT * FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}"); -while($r = mysql_fetch_object($q)) { - $jteam_id = $r->id; - print(" $jteam_id"); - /* Clean out the judges_teams_link */ - mysql_query("DELETE FROM judges_teams_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); - print mysql_error(); - /* Awards */ - mysql_query("DELETE FROM judges_teams_awards_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); - print mysql_error(); - /* Timeslots */ - mysql_query("DELETE FROM judges_teams_timeslots_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); - print mysql_error(); - /* Timeslots projects */ - mysql_query("DELETE FROM judges_teams_timeslots_projects_link WHERE judges_teams_id='$jteam_id' AND year={$config['FAIRYEAR']}"); - print mysql_error(); -} -/* Findally, delete all the autocreated judges teams */ -mysql_query("DELETE FROM judges_teams WHERE autocreate_type_id=1 AND year={$config['FAIRYEAR']}"); -print mysql_error(); -TRACE("Done.\n"); function pr_judge(&$jt, $jid) { @@ -461,9 +458,17 @@ function pr_judge(&$jt, $jid) } +/* Find the maximum judging team number */ +$q = mysql_query("SELECT MAX(num) as max FROM judges_teams"); +$r = mysql_fetch_object($q); +$max_jteam_num = $r->max; + +TRACE("Max Judging Team Number is currently $max_jteam_num\n"); + for($x=1;$xbucket_cost[$x]} "); + $num = $x + $max_jteam_num; + print("Judging Team $num: cost={$a->bucket_cost[$x]} "); print("langs=("); $langstr=""; for($y=0; $ybucket[$x]; for($y=0; $y