forked from science-ation/science-ation
Updates to the exhibit hall annealer (still no front end so no one can use it )
This commit is contained in:
parent
536fec616f
commit
3597f83ee9
@ -31,8 +31,13 @@ if($_SERVER['SERVER_ADDR']) {
|
||||
}
|
||||
|
||||
$action = '';
|
||||
if($argv[1] == '--images') {
|
||||
switch($argv[1]) {
|
||||
case '--images':
|
||||
$action = 'images';
|
||||
break;
|
||||
case '--pn':
|
||||
$action = 'pn';
|
||||
break;
|
||||
}
|
||||
|
||||
//function TRACE() { }
|
||||
@ -187,7 +192,6 @@ while(($r = mysql_fetch_assoc($q))) {
|
||||
}
|
||||
TRACE(count($objects)." objects loaded.\n");
|
||||
|
||||
|
||||
/* Compute stuff */
|
||||
foreach($objects as $oid=>$o) {
|
||||
$objects[$oid]['w2'] = $o['w']/2;
|
||||
@ -204,6 +208,76 @@ $grid_size /= 2;
|
||||
|
||||
TRACE("Grid size: {$grid_size}m\n");
|
||||
|
||||
|
||||
//print_r($exhibithall);
|
||||
|
||||
//print_r($objects);
|
||||
|
||||
$div = array();
|
||||
TRACE("Loading Project Divisions...\n");
|
||||
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
$divshort[$r->id]=$r->division_shortform;
|
||||
$div[$r->id]=$r->division;
|
||||
TRACE(" {$r->id} - {$div[$r->id]}\n");
|
||||
}
|
||||
|
||||
TRACE("Loading Project Age Categories...\n");
|
||||
$cat = array();
|
||||
$q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
$catshort[$r->id]=$r->category_shortform;
|
||||
$cat[$r->id]=$r->category;
|
||||
TRACE(" {$r->id} - {$r->category}\n");
|
||||
}
|
||||
|
||||
TRACE("Loading Projects...\n");
|
||||
$projects = array();
|
||||
$q = mysql_query("SELECT projects.* FROM projects, registrations
|
||||
WHERE
|
||||
projects.year='{$config['FAIRYEAR']}'
|
||||
AND registrations.id = projects.registrations_id
|
||||
".getJudgingEligibilityCode());
|
||||
while($p = mysql_fetch_object($q)) {
|
||||
$qq = mysql_query("SELECT grade,schools_id FROM students WHERE registrations_id='{$p->registrations_id}'");
|
||||
$num_students = mysql_num_rows($qq);
|
||||
$grade = 0;
|
||||
$schools_id = 0;
|
||||
while($s = mysql_fetch_assoc($qq)) {
|
||||
if($s['grade'] > $grade) {
|
||||
$grade = $s['grade'];
|
||||
$schools_id = $s['schools_id'];
|
||||
}
|
||||
}
|
||||
$projects[$p->id] = array(
|
||||
'projects_id' => $p->id,
|
||||
'div' => $p->projectdivisions_id,
|
||||
'cat' => $p->projectcategories_id,
|
||||
'grade' => $grade,
|
||||
'schools_id' => $schools_id,
|
||||
'req_electricity' => $p->req_electricity,
|
||||
'projectnumber' => $p->projectnumber,
|
||||
'floornumber' => $p->floornumber,
|
||||
'num_students' => $num_students);
|
||||
}
|
||||
TRACE(count($projects)." projects loaded.\n");
|
||||
|
||||
if($action == 'pn') {
|
||||
TRACE("Generating Project Numbers from Floor Locations...\n");
|
||||
foreach($projects as $p) {
|
||||
$c = $catshort[$p['cat']];
|
||||
$d = $divshort[$p['div']];
|
||||
$n = sprintf("%03d", $p['floornumber']);
|
||||
$pn = "$c $n $d";
|
||||
TRACE("Project {$p['projects_id']} at loc {$p['floornumber']}: $pn\n");
|
||||
mysql_query("UPDATE projects SET projectnumber='$pn' WHERE id='{$p['projects_id']}'");
|
||||
}
|
||||
TRACE("Done.\n");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/* Assign objects to grid locations */
|
||||
foreach($exhibithall as &$i_eh) {
|
||||
TRACE("Assigning objects to grid locations for {$i_eh['name']}...\n");
|
||||
@ -236,8 +310,6 @@ foreach($exhibithall as &$i_eh) {
|
||||
}
|
||||
TRACE("Done.\n");
|
||||
|
||||
//print_r($exhibithall);
|
||||
|
||||
function distance($x1,$y1,$x2,$y2)
|
||||
{
|
||||
return sqrt( ($x1-$x2)*($x1-$x2)+($y1-$y2)*($y1-$y2) );
|
||||
@ -305,58 +377,6 @@ foreach($objects as $oid=>$o) {
|
||||
}
|
||||
TRACE("Done.\n");
|
||||
|
||||
//print_r($objects);
|
||||
|
||||
$div = array();
|
||||
TRACE("Loading Project Divisions...\n");
|
||||
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
$divshort[$r->id]=$r->division_shortform;
|
||||
$div[$r->id]=$r->division;
|
||||
TRACE(" {$r->id} - {$div[$r->id]}\n");
|
||||
}
|
||||
|
||||
TRACE("Loading Project Age Categories...\n");
|
||||
$cat = array();
|
||||
$q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY id");
|
||||
while($r=mysql_fetch_object($q)) {
|
||||
$cat[$r->id]=$r->category;
|
||||
TRACE(" {$r->id} - {$r->category}\n");
|
||||
}
|
||||
|
||||
TRACE("Loading Projects...\n");
|
||||
$projects = array();
|
||||
$q = mysql_query("SELECT projects.* FROM projects, registrations
|
||||
WHERE
|
||||
projects.year='{$config['FAIRYEAR']}'
|
||||
AND registrations.id = projects.registrations_id
|
||||
".getJudgingEligibilityCode());
|
||||
while($p = mysql_fetch_object($q)) {
|
||||
$qq = mysql_query("SELECT grade,schools_id FROM students WHERE registrations_id='{$p->registrations_id}'");
|
||||
$num_students = mysql_num_rows($qq);
|
||||
$grade = 0;
|
||||
$schools_id = 0;
|
||||
while($s = mysql_fetch_assoc($qq)) {
|
||||
if($s['grade'] > $grade) {
|
||||
$grade = $s['grade'];
|
||||
$schools_id = $s['schools_id'];
|
||||
}
|
||||
}
|
||||
$projects[$p->id] = array(
|
||||
'projects_id' => $p->id,
|
||||
'div' => $p->projectdivisions_id,
|
||||
'cat' => $p->projectcategories_id,
|
||||
'grade' => $grade,
|
||||
'schools_id' => $schools_id,
|
||||
'req_electricity' => $p->req_electricity,
|
||||
'projectnumber' => $p->projectnumber,
|
||||
'floornumber' => $p->floornumber,
|
||||
'num_students' => $num_students);
|
||||
}
|
||||
TRACE(count($projects)." projects loaded.\n");
|
||||
|
||||
|
||||
switch($action) {
|
||||
case 'images':
|
||||
exhibithall_images();
|
||||
|
Loading…
x
Reference in New Issue
Block a user