forked from science-ation/science-ation
- Remove the XML print from the stats upload, we can add that back in later as
something like "view/edit xml". - Add a master list of all the stats we understand - Map stats into YSF stats, so this file can be used as the YSF uploader too (going to need to convert the $config options into a fair user entry) - Enable downloading manual entry stats, so it all appears seamless. (note, we don't download auto-generated stats, like the number of students, well, we do, but we just overwrite it with what's in the local SFIAB, it would be a lot of work to keep it separate if it changes).
This commit is contained in:
parent
3d15473906
commit
0f450e4426
@ -26,6 +26,49 @@
|
|||||||
require_once('../user.inc.php');
|
require_once('../user.inc.php');
|
||||||
user_auth_required('committee', 'admin');
|
user_auth_required('committee', 'admin');
|
||||||
require_once('xml.inc.php');
|
require_once('xml.inc.php');
|
||||||
|
require_once('stats.inc.php');
|
||||||
|
|
||||||
|
function stats_to_xml($fair, $stats)
|
||||||
|
{
|
||||||
|
global $output;
|
||||||
|
if($fair['type'] == 'ysf') {
|
||||||
|
/* Map data into YSF tags */
|
||||||
|
$y=array();
|
||||||
|
$y["numschoolstotal"]=$stats['schools_total'];
|
||||||
|
$y["numschoolsactive"]=$stats['schools_active'];
|
||||||
|
$y["numstudents"]=$stats['students_total'];
|
||||||
|
$y["numk6m"]=$stats['male_1'] + $stats['male_4'];
|
||||||
|
$y["numk6f"]=$stats['female_1'] + $stats['female_4'];
|
||||||
|
$y["num78m"]=$stats['male_7'];
|
||||||
|
$y["num78f"]=$stats['female_7'];
|
||||||
|
$y["num910m"]=$stats['male_9'];
|
||||||
|
$y["num910f"]=$stats['female_9'];
|
||||||
|
$y["num11upm"]=$stats['male_11'];
|
||||||
|
$y["num11upf"]=$stats['female_11'];
|
||||||
|
$y["projk6"]=$stats['projects_1'] + $stats['projects_4'];
|
||||||
|
$y["proj78"]=$stats['projects_7'];
|
||||||
|
$y["proj910"]=$stats['projects_9'];
|
||||||
|
$y["proj11up"]=$stats['projects_11'];
|
||||||
|
$y["committee"]=$stats['committee_members'];
|
||||||
|
$y["judges"]=$stats['judges'];
|
||||||
|
$xmldata=array("affiliation"=>array(
|
||||||
|
"ysf_region_id"=>$fair['username'],
|
||||||
|
"ysf_region_password"=>$fair['password'],
|
||||||
|
"year"=>$year,
|
||||||
|
"stats"=>$y)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$xmldata=array("sfiab"=>array(
|
||||||
|
"username"=>$fair['username'],
|
||||||
|
"password"=>$fair['password'],
|
||||||
|
"stats"=>$stats));
|
||||||
|
}
|
||||||
|
|
||||||
|
$output="";
|
||||||
|
xmlCreateRecurse($xmldata);
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
send_header("Fair Stats",
|
send_header("Fair Stats",
|
||||||
array('Committee Main' => 'committee_main.php',
|
array('Committee Main' => 'committee_main.php',
|
||||||
@ -90,17 +133,24 @@
|
|||||||
$fair = mysql_fetch_assoc($q);
|
$fair = mysql_fetch_assoc($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$action = $_POST['action'];
|
||||||
|
|
||||||
|
if($action == 'sendstats') {
|
||||||
|
foreach(array_keys($stats_data) as $k) {
|
||||||
|
$stats[$k] = $_POST[$k];
|
||||||
|
}
|
||||||
|
$stats['year'] = $year;
|
||||||
|
$xml = stats_to_xml($fair, $stats);
|
||||||
|
|
||||||
|
|
||||||
if($_POST['action']=="sendstats" && $_POST['xml']) {
|
|
||||||
if(function_exists('curl_init')) {
|
if(function_exists('curl_init')) {
|
||||||
$r = curl_query($fair, $_POST['xml']);
|
$r = curl_query($fair, $xml);
|
||||||
if($r['error'][0] == 0)
|
if($r['error'][0] == 0)
|
||||||
echo happy(i18n("The %1 Server said:", array($fair['name'])).' '.$r['message'][0]);
|
echo happy(i18n("The %1 Server said:", array($fair['name'])).' '.$r['message'][0]);
|
||||||
else
|
else
|
||||||
echo error(i18n("The %1 Server said:", array($fair['name'])).' '.$r['message'][0]);
|
echo error(i18n("The %1 Server said:", array($fair['name'])).' '.$r['message'][0]);
|
||||||
$fairs_id = -1;
|
// $fairs_id = -1;
|
||||||
$year = $config['FAIRYEAR'];
|
// $year = $config['FAIRYEAR'];
|
||||||
} else {
|
} else {
|
||||||
echo error("CURL Support Missing");
|
echo error("CURL Support Missing");
|
||||||
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSF system as the regional coodinator and upload the XML data manually");
|
echo i18n("Your PHP installation does not support CURL. You will need to login to the YSF system as the regional coodinator and upload the XML data manually");
|
||||||
@ -139,9 +189,8 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo i18n('This server has requested the following stats:');
|
|
||||||
echo '<br /><br />';
|
|
||||||
|
|
||||||
|
echo notice(i18n('Getting statistics request and existing stats data from server %1', array($fair['url'])));
|
||||||
/* Query the server to see what stats we need */
|
/* Query the server to see what stats we need */
|
||||||
$xmldata=array("sfiab"=>array(
|
$xmldata=array("sfiab"=>array(
|
||||||
"username"=>$fair['username'],
|
"username"=>$fair['username'],
|
||||||
@ -160,6 +209,11 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo notice(i18n('Server said: Success'));
|
||||||
|
echo '<hr />';
|
||||||
|
echo i18n('This server has requested the following stats:');
|
||||||
|
echo '<br /><br />';
|
||||||
|
|
||||||
foreach($server_config as $k=>$v) {
|
foreach($server_config as $k=>$v) {
|
||||||
$server_config[$k] = $data['statconfig'][0][$k][0];
|
$server_config[$k] = $data['statconfig'][0][$k][0];
|
||||||
}
|
}
|
||||||
@ -174,6 +228,7 @@
|
|||||||
$stats[$k] = $v[0];
|
$stats[$k] = $v[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// print_r($data['stats'][0]);
|
||||||
|
|
||||||
/* And now, overwrite all the stuff we pulled down with stats we can compute */
|
/* And now, overwrite all the stuff we pulled down with stats we can compute */
|
||||||
|
|
||||||
@ -283,36 +338,42 @@
|
|||||||
$stats['judges'] = $r->num;
|
$stats['judges'] = $r->num;
|
||||||
|
|
||||||
|
|
||||||
/* Print all blocks the server requests */
|
/* All stats have been gathered, print them */
|
||||||
|
|
||||||
|
|
||||||
|
/* Print all blocks the server requests */
|
||||||
|
echo "<form method=\"POST\" action=\"$PHPSELF\">";
|
||||||
|
echo "<input type=\"hidden\" name=\"action\" value=\"sendstats\" />";
|
||||||
|
|
||||||
|
$manual_stats = array();
|
||||||
if($server_config['fair_stats_participation'] == 'yes') {
|
if($server_config['fair_stats_participation'] == 'yes') {
|
||||||
$rangemap = array(1=>'1-3', 4=>'4-6', 7=>'7-8', 9=>'9-10', 11=>'11-12');
|
$rangemap = array(1=>'1-3', 4=>'4-6', 7=>'7-8', 9=>'9-10', 11=>'11-12');
|
||||||
echo '<b>'.i18n('Fair participation').'</b><br />';
|
echo '<b>'.i18n('Fair participation').'</b><br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n("Number of students: %1", array($stats['students_total']));
|
echo i18n("Number of students").": <b>{$stats['students_total']}</b>";
|
||||||
echo '<table><tr><td></td><td></td><td></td><td align=\"center\">'.i18n('Grade').'</td><td></td><td></td></tr>';
|
echo '<table><tr><td></td><td></td><td></td><td align=\"center\">'.i18n('Grade').'</td><td></td><td></td></tr>';
|
||||||
echo '<tr><td></td>';
|
echo '<tr><td></td>';
|
||||||
foreach($rangemap as $k=>$v) echo "<td align=\"center\" width=\"50px\" >$v</td>";
|
foreach($rangemap as $k=>$v) echo "<td align=\"center\" width=\"50px\" >$v</td>";
|
||||||
echo '</tr><tr>';
|
echo '</tr><tr>';
|
||||||
echo '<td>'.i18n('Male').'</td>';
|
echo '<td>'.i18n('Male').'</td>';
|
||||||
foreach($rangemap as $k=>$v) echo "<td align=\"right\">{$stats["male_$k"]}</td>";
|
foreach($rangemap as $k=>$v) echo "<td align=\"right\"><b>{$stats["male_$k"]}</b></td>";
|
||||||
echo '</tr><tr>';
|
echo '</tr><tr>';
|
||||||
echo '<td>'.i18n('Female').'</td>';
|
echo '<td>'.i18n('Female').'</td>';
|
||||||
foreach($rangemap as $k=>$v) echo "<td align=\"right\">{$stats["female_$k"]}</td>";
|
foreach($rangemap as $k=>$v) echo "<td align=\"right\"><b>{$stats["female_$k"]}</b></td>";
|
||||||
echo '</tr><tr>';
|
echo '</tr><tr>';
|
||||||
echo '<td>'.i18n('Projects').'</td>';
|
echo '<td>'.i18n('Projects').'</td>';
|
||||||
foreach($rangemap as $k=>$v) echo "<td align=\"right\">{$stats["projects_$k"]}</td>";
|
foreach($rangemap as $k=>$v) echo "<td align=\"right\"><b>{$stats["projects_$k"]}</b></td>";
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n("Number of schools: %1",array($stats['schools_total']));
|
echo i18n("Number of schools").": <b>{$stats['schools_total']}</b>";
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n("Number of active schools: %1",array($stats['schools_active']));
|
echo i18n("Number of active schools").": <b>{$stats['schools_active']}</b>";
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n("Number of committee members: %1 (note: this is number of committee members who logged in to SFIAB for the year, anyone who was active but didn't log in to SFIAB will NOT be counted)",array($stats['committee_members']));
|
echo i18n("Number of committee members: <b>%1</b> (note: this is number of committee members who logged in to SFIAB for the year, anyone who was active but didn't log in to SFIAB will NOT be counted)",array($stats['committee_members']));
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n("Number of judges: %1",array($stats['judges']));
|
echo i18n("Number of judges").": <b>{$stats['judges']}</b>";
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
@ -321,16 +382,16 @@
|
|||||||
if($server_config['fair_stats_schools_ext'] == 'yes') {
|
if($server_config['fair_stats_schools_ext'] == 'yes') {
|
||||||
echo '<b>'.i18n('Extended School/Participant data').'</b><br />';
|
echo '<b>'.i18n('Extended School/Participant data').'</b><br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n('Public schools: %1 (%2 students).',array(
|
echo i18n('Public schools: <b>%1</b> (<b>%2</b> students).',array(
|
||||||
$stats['schools_public'], $stats['students_public']));
|
$stats['schools_public'], $stats['students_public']));
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n('Private/Independent schools: %1 (%2 students).',array(
|
echo i18n('Private/Independent schools: <b>%1</b> (<b>%2</b> students).',array(
|
||||||
$stats['schools_private'], $stats['students_private']));
|
$stats['schools_private'], $stats['students_private']));
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n('At-risk/inner city schools: %1 (%2 students).',array(
|
echo i18n('At-risk/inner city schools: <b>%1</b> (<b>%2</b> students).',array(
|
||||||
$stats['schools_atrisk'], $stats['students_atrisk']));
|
$stats['schools_atrisk'], $stats['students_atrisk']));
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo i18n('Number of school boards/distrcits: %1',array(
|
echo i18n('Number of school boards/distrcits: <b>%1</b>',array(
|
||||||
$stats['schools_districts']));
|
$stats['schools_districts']));
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
@ -368,41 +429,33 @@
|
|||||||
echo '<b>'.i18n('Misc. SFFBC Questions').'</b><br />';
|
echo '<b>'.i18n('Misc. SFFBC Questions').'</b><br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<table>';
|
echo '<table>';
|
||||||
echo '<tr><td>'.i18n('Number of Teachers supporting student projects: ');
|
echo '<tr><td>'.i18n('Number of Teachers supporting student projects');
|
||||||
echo ": </td><td><input type=\"text\" name=\"teacherssupporting\" value=\"{$stats['teacherssupporting']}\" size=\"5\" />";
|
echo ": </td><td><input type=\"text\" name=\"teacherssupporting\" value=\"{$stats['teacherssupporting']}\" size=\"5\" />";
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
echo '<tr><td>'.i18n('Number of Students indicating increased interest in science & technology: ');
|
echo '<tr><td>'.i18n('Number of Students indicating increased interest in science & technology');
|
||||||
echo ": </td><td><input type=\"text\" name=\"increasedinterest\" value=\"{$stats['increasedinterest']}\" size=\"5\" />";
|
echo ": </td><td><input type=\"text\" name=\"increasedinterest\" value=\"{$stats['increasedinterest']}\" size=\"5\" />";
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
echo '<tr><td>'.i18n('Number of Students considering careers in science & technology: ');
|
echo '<tr><td>'.i18n('Number of Students considering careers in science & technology');
|
||||||
echo ": </td><td><input type=\"text\" name=\"consideringcareer\" value=\"{$stats['consideringcareer']}\" size=\"5\" />";
|
echo ": </td><td><input type=\"text\" name=\"consideringcareer\" value=\"{$stats['consideringcareer']}\" size=\"5\" />";
|
||||||
echo '</td></tr>';
|
echo '</td></tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
echo '<br />';
|
echo '<br />';
|
||||||
/*Number of Teachers supporting student projects:
|
|
||||||
Number of Students indicating increased interest in science & technology:
|
|
||||||
Number of Students considering careers in science & technology:
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
echo "<br />";
|
$keys = array_keys($stats_data);
|
||||||
|
foreach($keys as $k) {
|
||||||
|
if($stats_data[$k]['manual'] == true) continue;
|
||||||
|
echo "<input type=\"hidden\" name=\"$k\" value=\"{$stats[$k]}\" />";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "<input type=\"submit\" value=\"".i18n('Send stats to')." {$fair['name']}\">";
|
||||||
|
echo '</form>';
|
||||||
|
echo "<br />";
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
|
|
||||||
/* Format XML output, and print it, last chance for the user to edit it */
|
/* Format XML output, and print it, last chance for the user to edit it */
|
||||||
|
/*
|
||||||
if($fair['type'] == 'ysf') {
|
$xml = stats_to_xml($fair, $stats);
|
||||||
/* Map data into YSF tags */
|
|
||||||
} else {
|
|
||||||
$xmldata=array("sfiab"=>array(
|
|
||||||
"username"=>$fair['username'],
|
|
||||||
"password"=>$fair['password'],
|
|
||||||
"stats"=>$stats));
|
|
||||||
}
|
|
||||||
|
|
||||||
$output="";
|
|
||||||
xmlCreateRecurse($xmldata);
|
|
||||||
$xml=$output;
|
|
||||||
|
|
||||||
echo '<hr />';
|
echo '<hr />';
|
||||||
echo "<h3>".i18n("The following data will be sent to")." {$fair['name']}</h3>";
|
echo "<h3>".i18n("The following data will be sent to")." {$fair['name']}</h3>";
|
||||||
@ -416,7 +469,7 @@ Number of Students considering careers in science & technology:
|
|||||||
echo "<br />";
|
echo "<br />";
|
||||||
echo "<input type=\"submit\" value=\"".i18n("Send stats to")." {$fair['name']}\">";
|
echo "<input type=\"submit\" value=\"".i18n("Send stats to")." {$fair['name']}\">";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
*/
|
||||||
|
|
||||||
echo "<hr /><pre>";
|
echo "<hr /><pre>";
|
||||||
print_r($fair);
|
print_r($fair);
|
||||||
@ -424,8 +477,5 @@ Number of Students considering careers in science & technology:
|
|||||||
print_r($stats);
|
print_r($stats);
|
||||||
echo "</pre>";
|
echo "</pre>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
?>
|
?>
|
||||||
|
62
admin/stats.inc.php
Normal file
62
admin/stats.inc.php
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?
|
||||||
|
|
||||||
|
$stats_data = array(
|
||||||
|
'start_date' => array(),
|
||||||
|
'end_date' => array(),
|
||||||
|
'address' => array(),
|
||||||
|
'budget' => array(),
|
||||||
|
'ysf_affiliation_complete' => array(),
|
||||||
|
'charity' => array(),
|
||||||
|
'male_1' => array(),
|
||||||
|
'male_4' => array(),
|
||||||
|
'male_7' => array(),
|
||||||
|
'male_9' => array(),
|
||||||
|
'male_11' => array(),
|
||||||
|
'female_1' => array(),
|
||||||
|
'female_4' => array(),
|
||||||
|
'female_7' => array(),
|
||||||
|
'female_9' => array(),
|
||||||
|
'female_11' => array(),
|
||||||
|
'projects_1' => array(),
|
||||||
|
'projects_4' => array(),
|
||||||
|
'projects_7' => array(),
|
||||||
|
'projects_9' => array(),
|
||||||
|
'projects_11' => array(),
|
||||||
|
'students_total' => array(),
|
||||||
|
'schools_total' => array(),
|
||||||
|
'schools_active' => array(),
|
||||||
|
'students_public' => array(),
|
||||||
|
'schools_public' => array(),
|
||||||
|
'students_private' => array(),
|
||||||
|
'schools_private' => array(),
|
||||||
|
'schools_districts' => array(),
|
||||||
|
'studentsvisiting' => array('manual' => true),
|
||||||
|
'publicvisiting' => array('manual' => true),
|
||||||
|
'firstnations' => array('manual' => true),
|
||||||
|
'students_atrisk' => array(),
|
||||||
|
'schools_atrisk' => array(),
|
||||||
|
'teacherssupporting' => array('manual' => true),
|
||||||
|
'increasedinterest' => array('manual' => true),
|
||||||
|
'consideringcareer' => array('manual' => true),
|
||||||
|
'committee_members' => array(),
|
||||||
|
'judges' => array(),
|
||||||
|
'next_chair_name' => array(),
|
||||||
|
'next_chairemail' => array(),
|
||||||
|
'next_chair_hphone' => array(),
|
||||||
|
'next_chair_bphone' => array(),
|
||||||
|
'next_chair_fax' => array(),
|
||||||
|
'scholarships' => array(),
|
||||||
|
'delegate1' => array(),
|
||||||
|
'delegate2' => array(),
|
||||||
|
'delegate3' => array(),
|
||||||
|
'delegate4' => array(),
|
||||||
|
'delegate1_email' => array(),
|
||||||
|
'delegate2_email' => array(),
|
||||||
|
'delegate3_email' => array(),
|
||||||
|
'delegate4_email' => array(),
|
||||||
|
'delegate1_size' => array(),
|
||||||
|
'delegate2_size' => array(),
|
||||||
|
'delegate3_size' => array(),
|
||||||
|
'delegate4_size' => array(),
|
||||||
|
);
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user