From 626191987876012c5f411c179ad7cf89c77b9ce3 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 1 Feb 2010 06:30:48 +0000 Subject: [PATCH] Add two columns for all divisions the judge selected 5-expert for --- admin/reports_judges.inc.php | 72 +++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/admin/reports_judges.inc.php b/admin/reports_judges.inc.php index f7765ed..e094e55 100644 --- a/admin/reports_judges.inc.php +++ b/admin/reports_judges.inc.php @@ -26,8 +26,60 @@ * with a space */ function report_judges_languages(&$report, $text) { - $l = unserialize($text); - return join(' ', $l); + $l = unserialize($text); + return join(' ', $l); +} + +$report_judges_divs = array(); +function report_judges_5_div(&$report, $text) +{ + global $report_judges_divs; + + /* Text is users_judge.div_prefs */ + $year = $report['year']; + $divprefs = unserialize($text); + + /* Load divisions, only once */ + if(count($report_judges_divs) == 0) { + $q = mysql_query("SELECT * FROM projectdivisions WHERE year='$year'"); + while(($d = mysql_fetch_assoc($q))) { + $report_judges_divs[$d['id']] = $d; + } + } + + /* Find all 5-expert selections, and add them to the return */ + $ret = array(); + foreach($divprefs as $div_id=>$sel) { + if($sel != 5) continue; + $ret[] = $report_judges_divs[$div_id]['division_shortform']; + } + /* Join it all together with spaces */ + return join(' ', $ret); +} +function report_judges_5_div_long(&$report, $text) +{ + global $report_judges_divs; + + /* Text is users_judge.div_prefs */ + $year = $report['year']; + $divprefs = unserialize($text); + + /* Load divisions, only once */ + if(count($report_judges_divs) == 0) { + $q = mysql_query("SELECT * FROM projectdivisions WHERE year='$year'"); + while(($d = mysql_fetch_assoc($q))) { + $report_judges_divs[$d['id']] = $d; + } + } + + /* Find all 5-expert selections, and add them to the return */ + $ret = array(); + foreach($divprefs as $div_id=>$sel) { + if($sel != 5) continue; + $ret[] = $report_judges_divs[$div_id]['division']; + } + /* Join it all together with spaces */ + return join(', ', $ret); } @@ -161,6 +213,22 @@ $report_judges_fields = array( 'table' => 'users_judge.highest_psd', 'components' => array('users_judge')), + 'div_prefs_5' => array( + 'name' => 'Judge -- Divisions Selected as 5-Expert (Shortform)', + 'header' => 'Expert Div', + 'width' => 1, + 'table' => 'users_judge.div_prefs', + 'exec_function' => 'report_judges_5_div', + 'components' => array('users_judge')), + + 'div_prefs_5_long' => array( + 'name' => 'Judge -- Divisions Selected as 5-Expert (Full division names)', + 'header' => 'Expert Div', + 'width' => 1.5, + 'table' => 'users_judge.div_prefs', + 'exec_function' => 'report_judges_5_div_long', + 'components' => array('users_judge')), + 'typepref' => array( 'name' => 'Judge -- Type Preference', 'header' => 'Type Pref',