Support Highest, High, Indiffernt (short and long), and expertise 5,4,3

(short and long) all with the same two functions.
This commit is contained in:
dave 2010-02-04 17:55:07 +00:00
parent 510d4a7e5f
commit faa3742bda
3 changed files with 101 additions and 24 deletions

View File

@ -60,10 +60,15 @@ function report_judges_load_cats($year)
}
function report_judges_5_div(&$report, $field, $text)
/* Return all divisions rated at expertise level x */
function report_judges_divs_at_exp(&$report, $field, $text)
{
global $report_judges_divs;
/* field is divs_at_exp_x[_long] */
$exp = substr($field, 12,1);
$long = (strlen($field) == 13) ? false : true;
/* Text is users_judge.div_prefs */
$year = $report['year'];
$divprefs = unserialize($text);
@ -71,23 +76,27 @@ function report_judges_5_div(&$report, $field, $text)
report_judges_load_divs($year);
/* Find all 5-expert selections, and add them to the return */
/* Find all the requested selections, and add them to the return */
$ret = array();
$retl = array();
foreach($divprefs as $div_id=>$sel) {
if($sel != 5) continue;
if($sel != $exp) continue;
$ret[] = $report_judges_divs[$year][$div_id]['division_shortform'];
$retl[] = $report_judges_divs[$year][$div_id]['division'];
}
/* Join it all together with spaces */
if($field == 'div_prefs_5')
return join(' ', $ret);
if($long == false) return join(' ', $ret);
return join(', ', $retl);
}
function report_judges_highest_cat(&$report, $field, $text)
function report_judges_cats_at_pref(&$report, $field, $text)
{
global $report_judges_cats;
$prefs = array('H' => 2, 'h' => 1, 'i' => 0, 'l' => -1, 'L' => -2);
/* field is cats_at_pref_x[_long] */
$pref = $prefs[substr($field, 13,1)];
$long = (strlen($field) == 14) ? false : true;
/* Text is users_judge.cat_prefs */
$year = $report['year'];
@ -100,13 +109,12 @@ function report_judges_highest_cat(&$report, $field, $text)
$ret = array();
$retl = array();
foreach($catprefs as $cat_id=>$sel) {
if($sel != 2) continue;
if($sel != $pref) continue;
$ret[] = $report_judges_cats[$year][$cat_id]['category_shortform'];
$retl[] = $report_judges_cats[$year][$cat_id]['category'];
}
/* Join it all together with spaces */
if($field == 'cat_prefs_highest')
return join(' ', $ret);
if($long == false) return join(' ', $ret);
return join(', ', $retl);
}
@ -292,20 +300,52 @@ $report_judges_fields = array(
/* Headers for Division Expertise/Preference Selection */
'div_prefs_5' => array(
'name' => 'Judge -- Divisions Selected as 5-Expert (Shortform)',
'divs_at_exp_5' => array(
'name' => 'Judge -- Divisions Selected as Expertise 5-Expert (Shortform)',
'header' => 'Expert Div',
'width' => 1,
'table' => 'users_judge.div_prefs',
'exec_function' => 'report_judges_5_div',
'exec_function' => 'report_judges_divs_at_exp',
'components' => array('users_judge')),
'div_prefs_5_long' => array(
'name' => 'Judge -- Divisions Selected as 5-Expert (Full division names)',
'divs_at_exp_5_long' => array(
'name' => 'Judge -- Divisions Selected as Expertise 5-Expert (Full division names)',
'header' => 'Expert Div',
'width' => 1.5,
'table' => 'users_judge.div_prefs',
'exec_function' => 'report_judges_5_div', /* Yes, the same function as div_prefs_5 */
'exec_function' => 'report_judges_divs_at_exp', /* Yes, the same function as divs_at_exp_5 */
'components' => array('users_judge')),
'divs_at_exp_4' => array(
'name' => 'Judge -- Divisions Selected as Expertise 4 (Shortform)',
'header' => '4 Div',
'width' => 1,
'table' => 'users_judge.div_prefs',
'exec_function' => 'report_judges_divs_at_exp',
'components' => array('users_judge')),
'divs_at_exp_4_long' => array(
'name' => 'Judge -- Divisions Selected as Expertise 4 (Full division names)',
'header' => '4 Div',
'width' => 1.5,
'table' => 'users_judge.div_prefs',
'exec_function' => 'report_judges_divs_at_exp', /* Yes, the same function as divs_at_exp_5 */
'components' => array('users_judge')),
'divs_at_exp_3' => array(
'name' => 'Judge -- Divisions Selected as Expertise 3 (Shortform)',
'header' => '3 Div',
'width' => 1,
'table' => 'users_judge.div_prefs',
'exec_function' => 'report_judges_divs_at_exp',
'components' => array('users_judge')),
'divs_at_exp_3_long' => array(
'name' => 'Judge -- Divisions Selected as Expertise 3 (Full division names)',
'header' => '3 Div',
'width' => 1.5,
'table' => 'users_judge.div_prefs',
'exec_function' => 'report_judges_divs_at_exp', /* Yes, the same function as divs_at_exp_5 */
'components' => array('users_judge')),
'div_exp_1' => array(
@ -391,20 +431,52 @@ $report_judges_fields = array(
/* Category preferences */
'cat_prefs_highest' => array(
'name' => 'Judge -- Age Categories Selected as Highest Preference (Shortform)',
'header' => 'Pref Cat',
'cats_at_pref_H' => array(
'name' => 'Judge -- Age Categories Selected as Preference: Highest (Shortform)',
'header' => 'Highest',
'width' => 0.8,
'table' => 'users_judge.cat_prefs',
'exec_function' => 'report_judges_highest_cat',
'exec_function' => 'report_judges_cats_at_pref',
'components' => array('users_judge')),
'cat_prefs_highest_long' => array(
'name' => 'Judge -- Age Categories Selected as Highest Preference (Full category names)',
'header' => 'Pref Cat',
'cats_at_pref_H_long' => array(
'name' => 'Judge -- Age Categories Selected as Preference: Highest (Full category names)',
'header' => 'Highest',
'width' => 1.2,
'table' => 'users_judge.cat_prefs',
'exec_function' => 'report_judges_highest_cat', /* Yes, the same function as cat_prefs_highest */
'exec_function' => 'report_judges_cats_at_pref',/* Yes, the same function as cats_at_pref_H */
'components' => array('users_judge')),
'cats_at_pref_h' => array(
'name' => 'Judge -- Age Categories Selected as Preference: High (Shortform)',
'header' => 'High',
'width' => 0.8,
'table' => 'users_judge.cat_prefs',
'exec_function' => 'report_judges_cats_at_pref',
'components' => array('users_judge')),
'cats_at_pref_h_long' => array(
'name' => 'Judge -- Age Categories Selected as Preference: High (Full category names)',
'header' => 'High',
'width' => 1.2,
'table' => 'users_judge.cat_prefs',
'exec_function' => 'report_judges_cats_at_pref',/* Yes, the same function as cats_at_pref_H */
'components' => array('users_judge')),
'cats_at_pref_i' => array(
'name' => 'Judge -- Age Categories Selected as Preference: Indifferent (Shortform)',
'header' => 'Indifferent',
'width' => 0.8,
'table' => 'users_judge.cat_prefs',
'exec_function' => 'report_judges_cats_at_pref',
'components' => array('users_judge')),
'cats_at_pref_i_long' => array(
'name' => 'Judge -- Age Categories Selected as Preference: Indifferent (Full category names)',
'header' => 'Indifferent',
'width' => 1.2,
'table' => 'users_judge.cat_prefs',
'exec_function' => 'report_judges_cats_at_pref',/* Yes, the same function as cats_at_pref_H */
'components' => array('users_judge')),
'cat_pref_1' => array(

View File

@ -1 +1 @@
159
160

5
db/db.update.160.sql Normal file
View File

@ -0,0 +1,5 @@
UPDATE `reports_items` SET `field`='cats_at_pref_H' WHERE `field`='cat_prefs_highest';
UPDATE `reports_items` SET `field`='cats_at_pref_H_long' WHERE `field`='cat_prefs_highest_long';
UPDATE `reports_items` SET `field`='divs_at_exp_5' WHERE `field`='div_prefs_5';
UPDATE `reports_items` SET `field`='divs_at_exp_5_long' WHERE `field`='div_prefs_5_long';