forked from science-ation/science-ation
BUGFIX From Just Reardon:
If specialawardnomination is set to "none" (fair doesnt use special award self-nominations) then the pick winners page will instead show all projects that are eligible for the award to choose a winner, instead of those that are nominated for it (which is none). Thanks Justin!
This commit is contained in:
parent
36bee33066
commit
fefd9c8e35
@ -25,9 +25,7 @@
|
|||||||
require("../common.inc.php");
|
require("../common.inc.php");
|
||||||
auth_required('admin');
|
auth_required('admin');
|
||||||
|
|
||||||
function TRACE()
|
function TRACE() { }
|
||||||
{
|
|
||||||
}
|
|
||||||
//function TRACE($str) { print($str); }
|
//function TRACE($str) { print($str); }
|
||||||
function TRACE_R()
|
function TRACE_R()
|
||||||
{
|
{
|
||||||
@ -68,25 +66,30 @@ function pick_random_move(&$team)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The cost function is:
|
/* The cost function is:
|
||||||
+ 200 * each judge below the min for each team
|
+ 20 * each judge below the min for each team
|
||||||
+ 100 * each judge above the max for each team
|
+ 10 * each judge above the max for each team
|
||||||
+ -20 * each level of preference away from the
|
+ 2 * each level of preference away from the
|
||||||
max level for each judge
|
max level for each judge
|
||||||
|
+ 50 if the team doesn't have a chair.
|
||||||
|
+ 25 for each memember on the team that can't speak the language
|
||||||
|
of the judging team
|
||||||
|
|
||||||
( ex: if a judge has selected LS->2, PS->0, CS->-1
|
( ex: if a judge has selected LS->2, PS->0, CS->-1
|
||||||
then matching that judge with a:
|
then matching that judge with a:
|
||||||
LS = -40,
|
LS = -4,
|
||||||
PS = 0,
|
PS = 0,
|
||||||
CS = -20,
|
CS = -2,
|
||||||
else = 0
|
else = 0
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Compute the cost of adding a judge to a team */
|
/* Compute the cost of adding a judge to a team */
|
||||||
|
|
||||||
function compute_team_cost(&$teams, &$judges, $team_id)
|
function compute_team_cost(&$teams, &$judges, $team_id)
|
||||||
{
|
{
|
||||||
$cost = 0;
|
$cost = 0;
|
||||||
|
$have_chair = 0;
|
||||||
|
|
||||||
$t =& $teams[$team_id];
|
$t =& $teams[$team_id];
|
||||||
|
|
||||||
/* Compute the over max / under min costs */
|
/* Compute the over max / under min costs */
|
||||||
@ -101,7 +104,7 @@ function compute_team_cost(&$teams, &$judges, $team_id)
|
|||||||
/* For each judge on the team, score their preferences */
|
/* For each judge on the team, score their preferences */
|
||||||
reset($t['judges']);
|
reset($t['judges']);
|
||||||
while( list($key, $judge_id) = each($t['judges']) ) {
|
while( list($key, $judge_id) = each($t['judges']) ) {
|
||||||
$j = $judges[$judge_id];
|
$j =& $judges[$judge_id];
|
||||||
|
|
||||||
/* Get the division, and see where it fits with this
|
/* Get the division, and see where it fits with this
|
||||||
* judges preferences */
|
* judges preferences */
|
||||||
@ -112,6 +115,20 @@ function compute_team_cost(&$teams, &$judges, $team_id)
|
|||||||
|
|
||||||
$cost += 2 * (-$dpref + 2);
|
$cost += 2 * (-$dpref + 2);
|
||||||
$cost += 2 * (-$cpref + 2);
|
$cost += 2 * (-$cpref + 2);
|
||||||
|
|
||||||
|
/* See if the judge is willing to chair a team */
|
||||||
|
if($j['willing_chair'] == 'yes') {
|
||||||
|
$have_chair = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check the language preferences */
|
||||||
|
if(!in_array($t['language'], $j['languages'])) {
|
||||||
|
$cost += 25;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Huge penalty for a team without a willing chair */
|
||||||
|
if(!$have_chair) {
|
||||||
|
$cost += 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Team $team_id, cost is $cost\n");
|
TRACE("Team $team_id, cost is $cost\n");
|
||||||
@ -382,7 +399,7 @@ foreach($div AS $d_id=>$d_val)
|
|||||||
$p = $jdivisions[$d_id][$c_id][$l_id][$x];
|
$p = $jdivisions[$d_id][$c_id][$l_id][$x];
|
||||||
TRACE(" project=$p \n\n");
|
TRACE(" project=$p \n\n");
|
||||||
|
|
||||||
TRACE("This projects has ".(count($data['projects'][$p]['timetable']))." judging teams\n");
|
TRACE("This project has ".(count($data['projects'][$p]['timetable']))." judging teams\n");
|
||||||
|
|
||||||
/* See if this project needs more judges */
|
/* See if this project needs more judges */
|
||||||
if(count($data['projects'][$p]['timetable']) == $data['num_times_judged']) {
|
if(count($data['projects'][$p]['timetable']) == $data['num_times_judged']) {
|
||||||
@ -426,7 +443,9 @@ foreach($div AS $d_id=>$d_val)
|
|||||||
if($j==$numteams) $j=0;
|
if($j==$numteams) $j=0;
|
||||||
}
|
}
|
||||||
$x++;
|
$x++;
|
||||||
if(count($teams_at_this_ts) == $numteams) {
|
/* If we've used all the judging temas, of we've assigned judges equal
|
||||||
|
* to the number of projects, it's time for the next timeslot */
|
||||||
|
if(count($teams_at_this_ts) == $numteams || count($teams_at_this_ts) == $num) {
|
||||||
$ts++;
|
$ts++;
|
||||||
$teams_at_this_ts = array();
|
$teams_at_this_ts = array();
|
||||||
if($ts > $max_ts) $max_ts = $ts;
|
if($ts > $max_ts) $max_ts = $ts;
|
||||||
@ -452,6 +471,7 @@ while($r=mysql_fetch_object($q))
|
|||||||
{
|
{
|
||||||
unset($divprefs);
|
unset($divprefs);
|
||||||
unset($catprefs);
|
unset($catprefs);
|
||||||
|
unset($langprefs);
|
||||||
|
|
||||||
//get category preferences
|
//get category preferences
|
||||||
$q2=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY projectcategories_id");
|
$q2=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY projectcategories_id");
|
||||||
@ -466,6 +486,12 @@ while($r=mysql_fetch_object($q))
|
|||||||
while($r2=mysql_fetch_object($q2))
|
while($r2=mysql_fetch_object($q2))
|
||||||
$divprefs[$r2->projectdivisions_id]=$r2->val-3;
|
$divprefs[$r2->projectdivisions_id]=$r2->val-3;
|
||||||
|
|
||||||
|
$langperfs = array();
|
||||||
|
$q3=mysql_query("SELECT * from judges_languages WHERE judges_id='$r->id'");
|
||||||
|
while($r3=mysql_fetch_object($q3))
|
||||||
|
$langprefs[]=$r3->languages_lang;
|
||||||
|
|
||||||
|
|
||||||
$judges[]=array(
|
$judges[]=array(
|
||||||
"judges_id"=>"$r->id",
|
"judges_id"=>"$r->id",
|
||||||
"name"=>"$r->firstname $r->lastname",
|
"name"=>"$r->firstname $r->lastname",
|
||||||
@ -474,7 +500,8 @@ while($r=mysql_fetch_object($q))
|
|||||||
"years_national"=>$r->years_national,
|
"years_national"=>$r->years_national,
|
||||||
"willing_chair"=>$r->willing_chair,
|
"willing_chair"=>$r->willing_chair,
|
||||||
"divprefs"=>$divprefs,
|
"divprefs"=>$divprefs,
|
||||||
"catprefs"=>$catprefs
|
"catprefs"=>$catprefs,
|
||||||
|
"languages"=>$langprefs
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,6 +552,7 @@ while(list($tn, $t) = each($team)) {
|
|||||||
$tn++;
|
$tn++;
|
||||||
|
|
||||||
print("Team $tn: ({$div[$t['division']]}({$t['division']}),{$cat[$t['category']]}({$t['category']})) ".
|
print("Team $tn: ({$div[$t['division']]}({$t['division']}),{$cat[$t['category']]}({$t['category']})) ".
|
||||||
|
"(lang:{$t['language']} ".
|
||||||
"(cost:{$t['cost']} )<br>\n");
|
"(cost:{$t['cost']} )<br>\n");
|
||||||
$totalcost+=$t['cost'];
|
$totalcost+=$t['cost'];
|
||||||
|
|
||||||
@ -536,7 +564,13 @@ while(list($tn, $t) = each($team)) {
|
|||||||
|
|
||||||
while(list($key, $j) = each($t['judges']) ) {
|
while(list($key, $j) = each($t['judges']) ) {
|
||||||
$judge = $judges[$j];
|
$judge = $judges[$j];
|
||||||
print(" {$judge['name']}<br>\n");
|
print(" {$judge['name']}");
|
||||||
|
if($judge['willing_chair']=='yes') print("(chair)");
|
||||||
|
while(list($k, $l) = each($judge['languages']) ) {
|
||||||
|
print(" $l ");
|
||||||
|
}
|
||||||
|
print("<br>\n");
|
||||||
|
|
||||||
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,captain,year) VALUES ('{$judge['judges_id']}','$team_id','{$judge['willing_chair']}','{$config['FAIRYEAR']}')");
|
mysql_query("INSERT INTO judges_teams_link (judges_id,judges_teams_id,captain,year) VALUES ('{$judge['judges_id']}','$team_id','{$judge['willing_chair']}','{$config['FAIRYEAR']}')");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user