forked from science-ation/science-ation
138 lines
5.5 KiB
PHP
138 lines
5.5 KiB
PHP
<?php
|
|
/*
|
|
This file is a plug-in to the 'Science Fair In A Box' project
|
|
SFIAB Website: http://www.sfiab.ca
|
|
|
|
Copyright (C) 2011 At Work Software (dennis@spanogle.net>
|
|
Copyright (C) 2011 Dennis Spanogle <dennis@spanogle.net>
|
|
|
|
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.
|
|
*/
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
|
<head><title>SFIAB Evaluations setup</title>
|
|
</head>
|
|
<body>
|
|
|
|
<?php
|
|
include "sfiab_common.inc.php"; // check SFIAB install and get config etc.
|
|
//do not include "eval_common.inc.php"; // check Evaluations setup and get eval_config
|
|
//include "eval_menu_inc.php";
|
|
|
|
// Set up SFIAB for the correct configuration
|
|
// enter var = score_entry_enable; val = yes in config table
|
|
if($config['score_entry_enable'] != 'yes') {
|
|
$q= mysql_query("SELECT * FROM config WHERE var = 'score_entry_enable'");
|
|
if ( mysql_num_rows($q) > 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'<br /> ";
|
|
echo "Please resolve this ('none' or 'one' record is required to proceed)<br />";
|
|
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 "<br />Table 'config': ".$actn." var = 'score_entry_enable', val = 'yes'<br />";
|
|
}
|
|
else {
|
|
echo "Good! SFIAB is already configured with config table entry var = 'score_entry_enable' val = 'yes'<br />";
|
|
}
|
|
// 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<br />";
|
|
}
|
|
else {
|
|
echo "Good! SFIAB table `judges_teams_timeslots_projects_link` already has field 'score' <br />";
|
|
}
|
|
// 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;
|
|
}
|
|
echo "<br /><br />Evaluations Setup is Complete! Next, set up Schemes, Criteria and Values for your specific requirements. <br /><br />";
|
|
if(mysql_num_rows($q)>0) {
|
|
echo "Schemes already has records!<br />";
|
|
echo " - To load a different preset Scheme, select one from the list below (TBD?)<br />";
|
|
echo " - Or, use the appropriate Scheme, Criteria and Values editors in the Evaluations main menu to set up your specific requirements.<br />";
|
|
echo "<a href=\"index.php\">Return to Evaluations Main Menu</a><br />";
|
|
exit;
|
|
}
|
|
|
|
echo "For now, Eval will be loaded with a preset ISEF scoring scheme.<br /> - Several other preset schemes may be added in the future.<br />";
|
|
echo "<a href=docs\"eval_help.html\">Click here for help</a><br />";
|
|
// 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 "<a href=\"index.php\">Return to Evaluations Main Page</a><br />";
|
|
exit;
|
|
}
|
|
// code to load a pre-existing setup file.
|
|
echo "<b>db/db.eval.full.$evaldbcodeversion.sql found</b><br />";
|
|
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('<br/>Error performing query!<br/>'.$templine.'<br/> mysqlerror: '.mysql_error().'<br /><br />');
|
|
$exit_code = -1; // do we bail out here or keep going? keep going for now, get all errors
|
|
}
|
|
$templine = '';
|
|
}
|
|
}
|
|
echo "<br/><br />";
|
|
if($exit_code != 0) {
|
|
$error_count += 1;
|
|
echo "<br /><b>mysql failed to execute query(s) without error!<b><br />";
|
|
}
|
|
echo "<br />";
|
|
if ($error_count > 0){
|
|
echo "<b>THERE WERE ERRORS! The setup was not created correctly!</b><br />";
|
|
}
|
|
else{
|
|
echo "<b>SETUP for $setupfile CREATED SUCCESSFULLY!</b><br />";
|
|
}
|
|
echo "<a href=\"index.php\">Return to Evaluations Main Menu</a><br />";
|
|
|
|
?>
|
|
</body>
|