forked from science-ation/science-ation
Properly do timeslot->project->jteam linking for special awards
This commit is contained in:
parent
8bc65e2a3f
commit
9a00ce4877
@ -357,6 +357,16 @@ $q = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='0' AND `year`='
|
|||||||
/* Loads judges_timeslots.id, .starttime, .endtime, .date, .name */
|
/* Loads judges_timeslots.id, .starttime, .endtime, .date, .name */
|
||||||
while($r = mysql_fetch_assoc($q)) {
|
while($r = mysql_fetch_assoc($q)) {
|
||||||
TRACE(" id:{$r['id']} type:{$r['type']} name:{$r['name']}\n");
|
TRACE(" id:{$r['id']} type:{$r['type']} name:{$r['name']}\n");
|
||||||
|
|
||||||
|
$qq = mysql_query("SELECT * FROM judges_timeslots WHERE round_id='{$r['id']}'");
|
||||||
|
if(mysql_num_rows($qq) == 0) {
|
||||||
|
echo "ERROR: Round type:{$r['type']} name:{$r['name']} has no judging timeslots! Abort.\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
while($rr = mysql_fetch_assoc($qq)) {
|
||||||
|
TRACE(" Timeslot: {$rr['starttime']}-{$rr['endtime']}\n");
|
||||||
|
$r['timeslots'][] = $rr;
|
||||||
|
}
|
||||||
$round[] = $r;
|
$round[] = $r;
|
||||||
|
|
||||||
if($r['type'] == 'divisional1') $round_divisional1 = $r;
|
if($r['type'] == 'divisional1') $round_divisional1 = $r;
|
||||||
@ -586,6 +596,7 @@ function judge_team_add_judge($team_id, $users_id)
|
|||||||
(users_id,judges_teams_id,captain,year)
|
(users_id,judges_teams_id,captain,year)
|
||||||
VALUES ('$users_id','$team_id','{$judges[$users_id]['willing_chair']}',
|
VALUES ('$users_id','$team_id','{$judges[$users_id]['willing_chair']}',
|
||||||
'{$config['FAIRYEAR']}')");
|
'{$config['FAIRYEAR']}')");
|
||||||
|
echo mysql_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -889,6 +900,13 @@ function judges_sa_cost_function($annealer, $bucket_id, $ids)
|
|||||||
if($bucket_id == 0) {
|
if($bucket_id == 0) {
|
||||||
/* This is the placeholder */
|
/* This is the placeholder */
|
||||||
$cost = count($ids) * 50;
|
$cost = count($ids) * 50;
|
||||||
|
/* But check for judges who should be on a special award */
|
||||||
|
for($x=0; $x<count($ids); $x++) {
|
||||||
|
$j =& $judges[$ids[$x]];
|
||||||
|
if($j['special_award_only'] == 'yes') {
|
||||||
|
$cost += 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
return $cost;
|
return $cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,6 +956,9 @@ function judges_sa_cost_function($annealer, $bucket_id, $ids)
|
|||||||
}
|
}
|
||||||
$cost += 5 * $apref;
|
$cost += 5 * $apref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TRACE("Team $bucket_id, cost is $cost\n");
|
// TRACE("Team $bucket_id, cost is $cost\n");
|
||||||
|
|
||||||
return $cost;
|
return $cost;
|
||||||
@ -998,15 +1019,14 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
|||||||
|
|
||||||
/* Construct an internal team for annealing, and create
|
/* Construct an internal team for annealing, and create
|
||||||
* a DB team too */
|
* a DB team too */
|
||||||
$pids = array_keys($projects);
|
|
||||||
$sa_jteam[$x]['num'] = next_judges_teams_number();
|
$sa_jteam[$x]['num'] = next_judges_teams_number();
|
||||||
$sa_jteam[$x]['id'] = judge_team_create($sa_jteam[$x]['num'], $i->name);
|
$sa_jteam[$x]['id'] = judge_team_create($sa_jteam[$x]['num'], $i->name);
|
||||||
/* Note, we use $x instead of the ID, because the DB id could be zero. */
|
/* Note, we use $x instead of the ID, because the DB id could be zero. */
|
||||||
$sa_jteam[$x]['projects'] = $pids;
|
$sa_jteam[$x]['projects'] = $projects;
|
||||||
$sa_jteam[$x]['round'] = NULL;
|
$sa_jteam[$x]['round'] = NULL;
|
||||||
$sa_jteam[$x]['sub'] = 0;
|
$sa_jteam[$x]['sub'] = 0;
|
||||||
$sa_jteam[$x]['langs'] = array();
|
$sa_jteam[$x]['langs'] = array();
|
||||||
$min = floor(count($pids) / $config['projects_per_special_award_judge']) + 1;
|
$min = floor(count($projects) / $config['projects_per_special_award_judge']) + 1;
|
||||||
$sa_jteam[$x]['min_judges'] = $min;
|
$sa_jteam[$x]['min_judges'] = $min;
|
||||||
$sa_jteam[$x]['max_judges'] = $min;
|
$sa_jteam[$x]['max_judges'] = $min;
|
||||||
$sa_jteam[$x]['award_ids'] = array($i->id);
|
$sa_jteam[$x]['award_ids'] = array($i->id);
|
||||||
@ -1018,7 +1038,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
|||||||
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year)
|
mysql_query("INSERT INTO judges_teams_awards_link (award_awards_id,judges_teams_id,year)
|
||||||
VALUES ('{$i->id}','{$sa_jteam[$x]['id']}','{$config['FAIRYEAR']}')");
|
VALUES ('{$i->id}','{$sa_jteam[$x]['id']}','{$config['FAIRYEAR']}')");
|
||||||
|
|
||||||
TRACE("Created Team: {$i->name}, $min judges needed (db id:{$sa_jteam[$x]['id']}) \n");
|
TRACE("Created Team: {$i->name}, ".count($projects)." projects => $min judges needed (db id:{$sa_jteam[$x]['id']}) \n");
|
||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
TRACE("Total Judges: $total_judges, Required: $required_judges\n");
|
TRACE("Total Judges: $total_judges, Required: $required_judges\n");
|
||||||
@ -1092,6 +1112,11 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
|||||||
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
|
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
|
||||||
TRACE("Pre-assigning Team {$jt['name']} to Round {$round_special_awards[$highest_offset]['name']}\n");
|
TRACE("Pre-assigning Team {$jt['name']} to Round {$round_special_awards[$highest_offset]['name']}\n");
|
||||||
$jt['assigned'] = true;
|
$jt['assigned'] = true;
|
||||||
|
|
||||||
|
/* If the max judges for the jteam is less than the max, update the max,
|
||||||
|
* this prevents the scheduler from trying to remove sa-only judges
|
||||||
|
* from the jteam because of the over-max cost penalty */
|
||||||
|
if($jt['max_judges'] < count($sa_judges)) $jt['max_judges'] = count($sa_judges);
|
||||||
}
|
}
|
||||||
unset($jt);
|
unset($jt);
|
||||||
|
|
||||||
@ -1122,6 +1147,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
|||||||
/* Assign this jteam id to the special award round */
|
/* Assign this jteam id to the special award round */
|
||||||
$round_special_awards[$highest_offset]['jteam_ids'][] = $x;
|
$round_special_awards[$highest_offset]['jteam_ids'][] = $x;
|
||||||
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
|
$round_special_awards[$highest_offset]['assigned_judges'] += $jt['min_judges'];
|
||||||
|
TRACE("Assigned Team {$jt['name']} to Round {$round_special_awards[$highest_offset]['name']}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, anneal in each special award round */
|
/* Now, anneal in each special award round */
|
||||||
@ -1160,6 +1186,19 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
|||||||
print("$langstr)");*/
|
print("$langstr)");*/
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
||||||
|
/* Do timeslot and project timeslot assignment */
|
||||||
|
mysql_query("INSERT INTO judges_teams_timeslots_link
|
||||||
|
(judges_teams_id,judges_timeslots_id,year)
|
||||||
|
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '{$config['FAIRYEAR']}')");
|
||||||
|
echo mysql_error();
|
||||||
|
|
||||||
|
foreach($t['projects'] as $proj) {
|
||||||
|
$pid = $proj['id'];
|
||||||
|
mysql_query("INSERT INTO judges_teams_timeslots_projects_link
|
||||||
|
(judges_teams_id,judges_timeslots_id,projects_id,year)
|
||||||
|
VALUES ('{$t['id']}', '{$r['timeslots'][0]['id']}', '$pid', '{$config['FAIRYEAR']}')");
|
||||||
|
echo mysql_error();
|
||||||
|
}
|
||||||
$ids = $a->bucket[$x];
|
$ids = $a->bucket[$x];
|
||||||
foreach($a->bucket[$x] as $jid) {
|
foreach($a->bucket[$x] as $jid) {
|
||||||
// pr_judge($t, $ids[$y]);
|
// pr_judge($t, $ids[$y]);
|
||||||
|
Loading…
Reference in New Issue
Block a user