From 1dd573ab638f6e3b2b6772738adf777fe517cc5d Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 20 Dec 2007 01:14:21 +0000 Subject: [PATCH] - Add the tour annealer config/launcher --- admin/tours_sa_config.php | 132 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 admin/tours_sa_config.php diff --git a/admin/tours_sa_config.php b/admin/tours_sa_config.php new file mode 100644 index 0000000..d86c8a4 --- /dev/null +++ b/admin/tours_sa_config.php @@ -0,0 +1,132 @@ + + Copyright (C) 2005 James Grant + + 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 pr\n"; +ogram; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +?> +/dev/null 2>&1 &"); + usleep(1000000); // 1 second to allow the judges_sa to update the % status to 0% otherwise the status page will think its not running if it gets there too soon + header("Location: tours_sa_status.php"); + exit; + } + + + send_header("Automatic Tour Assignment Configuration", + array('Committee Main' => 'committee_main.php', + 'Administration' => 'admin/index.php', + 'Tours' => 'admin/tours.php') + ); + + config_editor("Tour Assigner", $config['FAIRYEAR'], "var", $_SERVER['PHP_SELF']); + + echo "
"; + + function tours_check_tours() + { + global $config; + $q = mysql_query("SELECT * FROM tours WHERE year='{$config['FAIRYEAR']}'"); + return mysql_num_rows($q); + } + + function tours_check_students() + { + global $config; + $q=mysql_query("SELECT students.id + FROM students + LEFT JOIN tours_choice ON (tours_choice.students_id=students.id) + LEFT JOIN registrations ON (registrations.id=students.registrations_id) + WHERE + students.year='{$config['FAIRYEAR']}' + AND tours_choice.year='{$config['FAIRYEAR']}' + AND registrations.status='complete' + ORDER BY + students.id, tours_choice.rank + "); + return mysql_num_rows($q); + } + + if($_GET['action']=="reset") { + mysql_query("UPDATE config SET `val`='-1' WHERE `var`='tours_assigner_percent' AND `year`=0"); + $config['tours_assigner_percent']=="-1"; + echo happy(i18n("Judge assigner status forcibly reset")); + } + +if($config['tours_assigner_percent']=="-1") { + $ok = 1; + + $tours = tours_check_tours(); + if($tours > 0) { + echo happy(i18n("There are %1 tours defined, good", array($tours))); + } else { + echo error(i18n("There are no tours defined.")); + $ok = 0; + } + + $x = tours_check_students(); + if($x > 0) { + echo happy(i18n("There are %1 student-tour rankings, good", array($x))); + } else { + echo error(i18n("There are no student-tour rankings.")); + $ok = 0; + } + + if($ok) { + echo i18n("Everything looks in order, we're ready to automatically + assign the students to the tours. Click link below to start the process. + Please be patient as it may take several minutes find a good solution."); + + echo "
"; + echo "
"; + + echo "".i18n("Automatically Assign Students to Tours").""; + } + + } else { + echo "
"; + echo ""; + echo i18n("Automatic assignemnts are currently in progress"); + echo ""; + echo "
"; + echo "
"; + echo "".i18n("Click here to check the tour assignment progress").""; + echo "
"; + echo "
"; + echo "
"; + echo i18n("If it is not running (and you are 100% sure that it is not!) click the link below to reset the status"); + echo "
"; + echo "".i18n("Reset automatic tour assignment status")."";; + } + +echo "
"; +echo "
"; +echo "
"; + + send_footer(); + + +?>