Copyright (C) 2011 Dennis Spanogle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ?> SFIAB Evaluations setup 0){ if ( mysql_num_rows($q) ==1){ $reslt = mysql_query("UPDATE config SET val = 'yes' WHERE var = 'score_entry_enable'"); echo mysql_error(); $actn = "Updated"; } else { echo "Un-expected condition. table config has more than one entry with val = 'score_entry_enable'
"; echo "Please resolve this ('none' or 'one' record is required to proceed)
"; exit; } } else { // no entry WHERE var = 'score_entry_enable'"); $reslt = mysql_query("INSERT INTO config SET var = 'score_entry_enable', val = 'yes' "); echo mysql_error(); $actn = "Added"; } echo "
Table 'config': ".$actn." var = 'score_entry_enable', val = 'yes'
"; } else { echo "Good! SFIAB is already configured with config table entry var = 'score_entry_enable' val = 'yes'
"; } // See if score is a field in `judges_teams_timeslots_projects_link` //ALTER TABLE `judges_teams_timeslots_projects_link` ADD `score` FLOAT( 5.2 ) NULL ; $q=mysql_query("SELECT score FROM `judges_teams_timeslots_projects_link`"); if (!$q) { $reslt = mysql_query("ALTER TABLE `judges_teams_timeslots_projects_link` ADD `score` FLOAT( 5,2 ) NULL"); echo mysql_error(); echo "Field 'score' added to `judges_teams_timeslots_projects_link` table
"; } else { echo "Good! SFIAB table `judges_teams_timeslots_projects_link` already has filed 'score'
"; } // more work needed after this point - if no scheme need to add a scheme editor, criteria editor, and values editor ... perhaps different files. // check if table eval_schemes is setup and if has records.... $q=mysql_query("SELECT * FROM eval_schemes"); if(!$q){ echo "Error: The table eval_Schemes did not get created correctly!"; exit; } if(mysql_num_rows($q)>0) { echo "Schemes already has records!
"; echo " - To load a preset Scheme, first delete all data in schemes, criteria and levels then re-run this script.
"; echo " - Or, use the appropriate manual entry process to edit the existing data. (In development)
"; echo "Return to Evaluations Main Page
"; exit; } echo "For now, Eval will be loaded with a preset ISEF scoring scheme.
- To change that you must configure Evaluations using phpmyadmin.php - editing the data in each of the tables.
"; echo "Click here for help
"; // add code and forms etc to select a setup file from those existing in the db folder // files will have the form db.eval.setup.xxxx.sql // for now this is hard coded. $setupfile = "ISEF"; // if(!file_exists("db/db.eval.setup.$setupfile.sql")) { echo "Wops, the setup file db/db.eval.setup.$setupfile.sql does not exist!"; echo "Return to Evaluations Main Page
"; exit; } // code to load a pre-existing setup file. echo "db/db.eval.full.$evaldbcodeversion.sql found
"; echo "Setting up database tables... "; $exit_code = 0; $filename = 'db/db.eval.setup.'.$setupfile.'.sql'; $templine = ''; $lines = file($filename); foreach ($lines as $line) { if (substr($line, 0, 2) == '--' || $line == '') continue; $templine .= $line; if (substr(trim($line), -1, 1) == ';') { if(!mysql_query($templine)){ echo('
Error performing query!
'.$templine.'
mysqlerror: '.mysql_error().'

'); $exit_code = -1; // do we bail out here or keep going? keep going for now, get all errors } $templine = ''; } } echo "

"; if($exit_code != 0) { $error_count += 1; echo "
mysql failed to execute query(s) without error!
"; } echo "
"; if ($error_count > 0){ echo "THERE WERE ERRORS! The setup was not created correctly!
"; } else{ echo "SETUP for $setupfile CREATED SUCCESSFULLY!
"; } echo "Return to Evaluations Main Page
"; ?>