forked from science-ation/science-ation
- 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.
This commit is contained in:
parent
e7d726355d
commit
d01a3eede6
@ -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;$x<count($jteam); $x++) {
|
||||
$t =& $jteam[$x];
|
||||
print("Judging Team $x: cost={$a->bucket_cost[$x]} ");
|
||||
$num = $x + $max_jteam_num;
|
||||
print("Judging Team $num: cost={$a->bucket_cost[$x]} ");
|
||||
print("langs=(");
|
||||
$langstr="";
|
||||
for($y=0; $y<count($t['langs']); $y++) {
|
||||
@ -491,10 +496,15 @@ for($x=1;$x<count($jteam); $x++) {
|
||||
/* Add this judging team to the database */
|
||||
$tn = $catstr." ".$divstr." (".$langstr.") ".($t['sub']+1);
|
||||
mysql_query("INSERT INTO judges_teams (num,name,autocreate_type_id,year) ".
|
||||
" VALUES ('$x','$tn','1','{$config['FAIRYEAR']}')");
|
||||
" VALUES ('$num','$tn','1','{$config['FAIRYEAR']}')");
|
||||
|
||||
$team_id=mysql_insert_id();
|
||||
$t['team_id'] = $team_id;
|
||||
|
||||
if($team_id == 0) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$ids = $a->bucket[$x];
|
||||
for($y=0; $y<count($ids); $y++) {
|
||||
pr_judge($t, $ids[$y]);
|
||||
|
Loading…
Reference in New Issue
Block a user