forked from science-ation/science-ation
Add highest cat pref selection (for LRSF). Pass the $field into the
report column function so the same function can be used for multiple fields with different return values.
This commit is contained in:
parent
5c8bbe16b6
commit
355447ac76
@ -774,7 +774,7 @@ foreach($report_stock as $n=>$v) {
|
||||
if(is_array($fields[$f]['value_map'])) {
|
||||
$v = $fields[$f]['value_map'][$i["C$o"]];
|
||||
} else if(is_callable($fields[$f]['exec_function'])) {
|
||||
$v = call_user_func_array($fields[$f]['exec_function'], array($report, $i["C$o"]));
|
||||
$v = call_user_func_array($fields[$f]['exec_function'], array($report, $f, $i["C$o"]));
|
||||
// } else if(isset($fields[$f]['exec_code'])) {
|
||||
// Somethign like this, how do we pass $i["C$o"] in?
|
||||
// $v = exec($fields[$f]['exec_code']);
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
/* Take the language array in users_fundraising, unserialize it, and join it
|
||||
* with a space */
|
||||
function report_fundraisings_languages(&$report, $text)
|
||||
function report_fundraisings_languages(&$report, $field, $text)
|
||||
{
|
||||
$l = unserialize($text);
|
||||
return join(' ', $l);
|
||||
|
@ -24,24 +24,25 @@
|
||||
|
||||
/* Take the language array in users_judge, unserialize it, and join it
|
||||
* with a space */
|
||||
function report_judges_languages(&$report, $text)
|
||||
function report_judges_languages(&$report, $field, $text)
|
||||
{
|
||||
$l = unserialize($text);
|
||||
return join(' ', $l);
|
||||
}
|
||||
|
||||
$report_judges_divs = array();
|
||||
function report_judges_5_div(&$report, $text)
|
||||
function report_judges_5_div(&$report, $field, $text)
|
||||
{
|
||||
global $report_judges_divs;
|
||||
|
||||
/* Text is users_judge.div_prefs */
|
||||
$year = $report['year'];
|
||||
$divprefs = unserialize($text);
|
||||
if(!is_array($divprefs)) return '';
|
||||
|
||||
/* Load divisions, only once */
|
||||
if(count($report_judges_divs) == 0) {
|
||||
$q = mysql_query("SELECT * FROM projectdivisions WHERE year='$year'");
|
||||
$q = mysql_query("SELECT * FROM projectdivisions WHERE year='$year'");
|
||||
while(($d = mysql_fetch_assoc($q))) {
|
||||
$report_judges_divs[$d['id']] = $d;
|
||||
}
|
||||
@ -49,41 +50,50 @@ function report_judges_5_div(&$report, $text)
|
||||
|
||||
/* Find all 5-expert selections, and add them to the return */
|
||||
$ret = array();
|
||||
$retl = array();
|
||||
foreach($divprefs as $div_id=>$sel) {
|
||||
if($sel != 5) continue;
|
||||
$ret[] = $report_judges_divs[$div_id]['division_shortform'];
|
||||
$retl[] = $report_judges_divs[$div_id]['division'];
|
||||
}
|
||||
/* Join it all together with spaces */
|
||||
return join(' ', $ret);
|
||||
if($field == 'div_prefs_5')
|
||||
return join(' ', $ret);
|
||||
return join(', ', $retl);
|
||||
}
|
||||
function report_judges_5_div_long(&$report, $text)
|
||||
|
||||
$report_judges_cats = array();
|
||||
function report_judges_highest_cat(&$report, $field, $text)
|
||||
{
|
||||
global $report_judges_divs;
|
||||
global $report_judges_cats;
|
||||
|
||||
/* Text is users_judge.div_prefs */
|
||||
/* Text is users_judge.cat_prefs */
|
||||
$year = $report['year'];
|
||||
$divprefs = unserialize($text);
|
||||
$catprefs = unserialize($text);
|
||||
if(!is_array($catprefs)) return '';
|
||||
|
||||
/* 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;
|
||||
if(count($report_judges_cats) == 0) {
|
||||
$q = mysql_query("SELECT * FROM projectcategories WHERE year='$year'");
|
||||
while(($c = mysql_fetch_assoc($q))) {
|
||||
$report_judges_cats[$c['id']] = $c;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find all 5-expert selections, and add them to the return */
|
||||
|
||||
/* Find all 2-highest 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'];
|
||||
$retl = array();
|
||||
foreach($catprefs as $cat_id=>$sel) {
|
||||
if($sel != 2) continue;
|
||||
$ret[] = $report_judges_cats[$cat_id]['category_shortform'];
|
||||
$retl[] = $report_judges_cats[$cat_id]['category'];
|
||||
}
|
||||
/* Join it all together with spaces */
|
||||
return join(', ', $ret);
|
||||
if($field == 'cat_prefs_highest')
|
||||
return join(' ', $ret);
|
||||
return join(', ', $retl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Components: languages, teams */
|
||||
|
||||
$report_judges_fields = array(
|
||||
@ -226,7 +236,23 @@ $report_judges_fields = array(
|
||||
'header' => 'Expert Div',
|
||||
'width' => 1.5,
|
||||
'table' => 'users_judge.div_prefs',
|
||||
'exec_function' => 'report_judges_5_div_long',
|
||||
'exec_function' => 'report_judges_5_div', /* Yes, the same function as div_prefs_5 */
|
||||
'components' => array('users_judge')),
|
||||
|
||||
'cat_prefs_highest' => array(
|
||||
'name' => 'Judge -- Age Categories Selected as Highest Preference (Shortform)',
|
||||
'header' => 'Pref Cat',
|
||||
'width' => 0.8,
|
||||
'table' => 'users_judge.cat_prefs',
|
||||
'exec_function' => 'report_judges_highest_cat',
|
||||
'components' => array('users_judge')),
|
||||
|
||||
'cat_prefs_highest_long' => array(
|
||||
'name' => 'Judge -- Age Categories Selected as Highest Preference (Full category names)',
|
||||
'header' => 'Pref Cat',
|
||||
'width' => 1.2,
|
||||
'table' => 'users_judge.cat_prefs',
|
||||
'exec_function' => 'report_judges_highest_cat', /* Yes, the same function as cat_prefs_highest */
|
||||
'components' => array('users_judge')),
|
||||
|
||||
'special_award_only' => array(
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
|
||||
function reports_schools_principal(&$report, $text)
|
||||
function reports_schools_principal(&$report, $field, $text)
|
||||
{
|
||||
$year = $report['year'];
|
||||
if($text > 0) { /* text is the uid */
|
||||
@ -31,7 +31,7 @@ function reports_schools_principal(&$report, $text)
|
||||
}
|
||||
return '';
|
||||
}
|
||||
function reports_schools_sciencehead(&$report, $text)
|
||||
function reports_schools_sciencehead(&$report, $field, $text)
|
||||
{
|
||||
$year = $report['year'];
|
||||
if($text > 0) { /* text is the uid */
|
||||
@ -41,7 +41,7 @@ function reports_schools_sciencehead(&$report, $text)
|
||||
return '';
|
||||
}
|
||||
|
||||
function reports_schools_shphone(&$report, $text)
|
||||
function reports_schools_shphone(&$report, $field, $text)
|
||||
{
|
||||
$year = $report['year'];
|
||||
if($text > 0) { /* text is the uid */
|
||||
@ -51,7 +51,7 @@ function reports_schools_shphone(&$report, $text)
|
||||
return '';
|
||||
}
|
||||
|
||||
function reports_schools_shemail(&$report, $text)
|
||||
function reports_schools_shemail(&$report, $field, $text)
|
||||
{
|
||||
$year = $report['year'];
|
||||
if($text > 0) { /* text is the uid */
|
||||
|
@ -21,12 +21,12 @@
|
||||
Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
function report_students_i18n_fr(&$report, $text)
|
||||
function report_students_i18n_fr(&$report, $field, $text)
|
||||
{
|
||||
return i18n($text, array(), array(), 'fr');
|
||||
}
|
||||
|
||||
function reports_students_numstudents(&$report, $text)
|
||||
function reports_students_numstudents(&$report, $field, $text)
|
||||
{
|
||||
$year = $report['year'];
|
||||
$q = mysql_query("SELECT students.id FROM students
|
||||
@ -35,7 +35,7 @@ function reports_students_numstudents(&$report, $text)
|
||||
return mysql_num_rows($q);
|
||||
}
|
||||
|
||||
function reports_students_award_selfnom_num(&$report, $text, $n)
|
||||
function reports_students_award_selfnom_num(&$report, $field, $text, $n)
|
||||
{
|
||||
$year = $report['year'];
|
||||
$q = mysql_query("SELECT award_awards.name FROM
|
||||
@ -50,25 +50,25 @@ function reports_students_award_selfnom_num(&$report, $text, $n)
|
||||
$i = mysql_fetch_assoc($q);
|
||||
return $i['name'];
|
||||
}
|
||||
function reports_students_award_selfnom_1(&$report, $text)
|
||||
function reports_students_award_selfnom_1(&$report, $field, $text)
|
||||
{
|
||||
return reports_students_award_selfnom_num(&$report, $text, 0);
|
||||
return reports_students_award_selfnom_num(&$report, $field, $text, 0);
|
||||
}
|
||||
function reports_students_award_selfnom_2(&$report, $text)
|
||||
function reports_students_award_selfnom_2(&$report, $field, $text)
|
||||
{
|
||||
return reports_students_award_selfnom_num(&$report, $text, 1);
|
||||
return reports_students_award_selfnom_num(&$report, $field, $text, 1);
|
||||
}
|
||||
function reports_students_award_selfnom_3(&$report, $text)
|
||||
function reports_students_award_selfnom_3(&$report, $field, $text)
|
||||
{
|
||||
return reports_students_award_selfnom_num(&$report, $text, 2);
|
||||
return reports_students_award_selfnom_num(&$report, $field, $text, 2);
|
||||
}
|
||||
function reports_students_award_selfnom_4(&$report, $text)
|
||||
function reports_students_award_selfnom_4(&$report, $field, $text)
|
||||
{
|
||||
return reports_students_award_selfnom_num(&$report, $text, 3);
|
||||
return reports_students_award_selfnom_num(&$report, $field, $text, 3);
|
||||
}
|
||||
function reports_students_award_selfnom_5(&$report, $text)
|
||||
function reports_students_award_selfnom_5(&$report, $field, $text)
|
||||
{
|
||||
return reports_students_award_selfnom_num(&$report, $text, 4);
|
||||
return reports_students_award_selfnom_num(&$report, $field, $text, 4);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user