2006-01-31 22:34:04 +00:00
< ?
2006-08-01 19:43:15 +00:00
function judges_scheduler_check_timeslots ()
2006-01-31 22:34:04 +00:00
{
2006-08-01 19:43:15 +00:00
global $config ;
2006-01-31 22:34:04 +00:00
2006-08-01 19:43:15 +00:00
$q = mysql_query ( " SELECT * FROM judges_timeslots WHERE " .
" year=' " . $config [ 'FAIRYEAR' ] . " ' " .
" AND allowdivisional='yes' " );
$rows = mysql_num_rows ( $q );
2006-01-31 22:34:04 +00:00
2006-08-01 19:43:15 +00:00
return $rows ;
}
2006-01-31 22:34:04 +00:00
2006-08-01 19:43:15 +00:00
function judges_scheduler_check_awards ()
{
global $config ;
2006-01-31 22:34:04 +00:00
$q = mysql_query ( " SELECT * FROM projectdivisions WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY id " );
while ( $r = mysql_fetch_object ( $q ))
$div [ $r -> id ] = $r -> division ;
$q = mysql_query ( " SELECT * FROM projectcategories WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY id " );
while ( $r = mysql_fetch_object ( $q ))
$cat [ $r -> id ] = $r -> category ;
2006-08-01 19:43:15 +00:00
$dkeys = array_keys ( $div );
$ckeys = array_keys ( $cat );
2007-12-10 19:21:21 +00:00
if ( $config [ 'filterdivisionbycategory' ] == " yes " ) {
$q = mysql_query ( " SELECT * FROM projectcategoriesdivisions_link WHERE year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY projectdivisions_id,projectcategories_id " );
$divcat = array ();
while ( $r = mysql_fetch_object ( $q )) {
$divcat [] = array ( " c " => $r -> projectcategories_id , " d " => $r -> projectdivisions_id );
}
}
else {
$divcat = array ();
foreach ( $dkeys AS $d ) {
foreach ( $ckeys AS $c ) {
$divcat [] = array ( " c " => $c , " d " => $d );
}
}
}
2006-08-01 19:43:15 +00:00
$missing_awards = array ();
2007-12-10 19:21:21 +00:00
foreach ( $divcat AS $dc ) {
$d = $dc [ 'd' ];
$c = $dc [ 'c' ];
2006-01-31 22:34:04 +00:00
$q = mysql_query ( " SELECT award_awards.id FROM
award_awards ,
award_awards_projectcategories ,
award_awards_projectdivisions
WHERE
award_awards . year = '{$config[' FAIRYEAR ']}'
AND award_awards_projectcategories . year = '{$config[' FAIRYEAR ']}'
AND award_awards_projectdivisions . year = '{$config[' FAIRYEAR ']}'
AND award_awards . id = award_awards_projectcategories . award_awards_id
AND award_awards . id = award_awards_projectdivisions . award_awards_id
2006-08-01 19:43:15 +00:00
AND award_awards_projectcategories . projectcategories_id = '$c'
AND award_awards_projectdivisions . projectdivisions_id = '$d'
2006-01-31 22:34:04 +00:00
AND award_awards . award_types_id = '1'
" );
echo mysql_error ();
2006-08-01 19:43:15 +00:00
if ( mysql_num_rows ( $q ) != 1 ) {
2007-12-10 19:21:21 +00:00
$missing_awards [] = " { $cat [ $c ] } - { $div [ $d ] } ( " . i18n ( " %1 found " , array ( mysql_num_rows ( $q ))) . " ) " ;
2006-01-31 22:34:04 +00:00
}
}
2006-08-01 19:43:15 +00:00
return $missing_awards ;
}
function judges_scheduler_check_jdivs ()
{
global $config ;
$q = mysql_query ( " SELECT DISTINCT jdiv_id FROM judges_jdiv " );
$rows = mysql_num_rows ( $q );
return $rows ;
}
function judges_scheduler_check_judges ()
{
2006-08-11 21:10:33 +00:00
global $config ;
$ok = 1 ;
2006-08-01 19:43:15 +00:00
$jdiv = array ();
2007-12-20 15:53:11 +00:00
$q = mysql_query ( " SELECT * FROM judges_jdiv ORDER BY jdiv_id " );
2006-08-01 19:43:15 +00:00
while ( $r = mysql_fetch_object ( $q )) {
$d = $r -> projectdivisions_id ;
$c = $r -> projectcategories_id ;
$l = $r -> lang ;
2006-08-12 18:05:38 +00:00
$qp = mysql_query ( " SELECT COUNT(projects.id) as cnt FROM projects, registrations WHERE " .
" projects.year=' " . $config [ 'FAIRYEAR' ] . " ' AND " .
2006-08-01 19:43:15 +00:00
" projectdivisions_id=' $d ' AND " .
" projectcategories_id=' $c ' AND " .
2006-08-12 18:05:38 +00:00
" language=' $l ' AND " .
" registrations.id = projects.registrations_id " .
getJudgingEligibilityCode ()
2006-08-01 19:43:15 +00:00
);
$qr = mysql_fetch_object ( $qp );
$jdiv [ $r -> jdiv_id ][ 'num_projects' ] += $qr -> cnt ;
2006-01-31 22:34:04 +00:00
}
2006-08-01 19:43:15 +00:00
$totalteams = 0 ;
print ( " <table width=75%><tr><th></th> " .
" <th> " . i18n ( " Projects " ) . " </th> " .
" <th> " . i18n ( " Required Teams " ) . " </th></tr> " );
$keys = array_keys ( $jdiv );
for ( $k = 0 ; $k < count ( $keys ); $k ++ ) {
$jdiv_id = $keys [ $k ];
$c = $jdiv [ $jdiv_id ][ 'num_projects' ];
2006-08-11 21:10:33 +00:00
$t = ceil ( $c / $config [ 'max_projects_per_team' ] * $config [ 'times_judged' ]);
if ( $t < $config [ 'times_judged' ]) $t = $config [ 'times_judged' ];
2006-08-01 19:43:15 +00:00
$jdiv [ $jdiv_id ][ 'num_jteams' ] = $t ;
$totalteams += $t ;
print ( " <tr><td>Judging Division Group $jdiv_id </td><td align=center> $c </td><td align=center> $t </td></tr> " );
}
print ( " </table> " );
2006-01-31 22:34:04 +00:00
2006-08-01 19:43:15 +00:00
echo " <b> " ;
echo " Total judging teams required: $totalteams " ;
echo " <br /> " ;
2006-08-11 21:10:33 +00:00
$minjudges = ( $totalteams * $config [ 'min_judges_per_team' ]);
$maxjudges = ( $totalteams * $config [ 'max_judges_per_team' ]);
2006-08-01 19:43:15 +00:00
echo " Minimum number of judges required: $minjudges " ;
echo " <br /> " ;
echo " Maximum number of judges acceptable: $maxjudges " ;
echo " <br /> " ;
2006-01-31 22:34:04 +00:00
2006-08-01 19:43:15 +00:00
$jq = mysql_query ( " SELECT COUNT(judges.id) AS num FROM judges,judges_years WHERE complete='yes' 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 " <br /> " ;
echo " <br /> " ;
2006-10-25 03:19:54 +00:00
echo " </b> " ;
2006-08-01 19:43:15 +00:00
if ( $currentjudges < $minjudges )
2006-01-31 22:34:04 +00:00
{
2006-08-01 19:43:15 +00:00
echo error ( i18n ( " You do not have sufficient number of judges based on your parameters " ));
echo " " ;
2007-12-20 15:58:07 +00:00
echo " <a href= \" judges_schedulerconfig.php \" > " . i18n ( " Update Scheduler Configuration " ) . " </a> ( " . i18n ( " or get more judges! " ) . " ) " ;
2006-08-01 19:43:15 +00:00
$ok = 0 ;
2006-01-31 22:34:04 +00:00
}
else
2006-08-01 19:43:15 +00:00
echo happy ( i18n ( " You have a sufficient number of judges based on your parameters " ));
2006-01-31 22:34:04 +00:00
2006-08-01 19:43:15 +00:00
//now check if we can find a divisional award for each division and category
2006-01-31 22:34:04 +00:00
return $ok ;
}
?>