From 3a212ae5d51ae72a240e1ad12290f3b1060147d4 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 7 Dec 2004 14:20:42 +0000 Subject: [PATCH] - refactor duplicate code in main, create an ouputStatus function to do the work - add participants project file - add checks for project completeness - add new status 'empty' for if the section has not been started yet --- common.inc.php | 1 + register_participants.inc.php | 58 +++++++++++++++++++++++++++++++ register_participants_main.php | 28 ++++++--------- register_participants_project.php | 39 +++++++++++++++++++++ 4 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 register_participants_project.php diff --git a/common.inc.php b/common.inc.php index 35acd5c..fbb88f3 100644 --- a/common.inc.php +++ b/common.inc.php @@ -168,6 +168,7 @@ echo "

".i18n($config['fairname'])."

";
diff --git a/register_participants.inc.php b/register_participants.inc.php index 9fdbb07..9e46277 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -1,4 +1,32 @@ "; + $ret.= i18n("Incomplete"); + $ret.= "
"; + break; + case 'complete': + $ret.= "
"; + $ret.= i18n("Complete"); + $ret.= "
"; + break; + case 'empty': + $ret.="
"; + $ret.= i18n("Empty"); + $ret.= "
"; + break; + + default: + $ret.=i18n("Unknown"); + break; + } + return $ret; +} + function studentStatus() { global $config; @@ -6,6 +34,36 @@ function studentStatus() $q=mysql_query("SELECT * FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); + //if we dont have the minimum, return incomplete + if(mysql_num_rows($q)<$config['minstudentsperproject']) + return "incomplete"; + + while($r=mysql_fetch_object($q)) + { + foreach ($required_fields AS $req) + { + if(!$r->$req) + { + return "incomplete"; + } + } + } + + //if it made it through without returning incomplete, then we must be complete + return "complete"; +} + +function projectStatus() +{ + global $config; + $required_fields=array("title","projectcategories_id","projectdivisions_id","summary","language"); + + $q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'"); + + //if we dont have a project entry yet, return empty + if(!mysql_num_rows($q)) + return "empty"; + while($r=mysql_fetch_object($q)) { foreach ($required_fields AS $req) diff --git a/register_participants_main.php b/register_participants_main.php index a0ca9ac..c59c160 100644 --- a/register_participants_main.php +++ b/register_participants_main.php @@ -48,28 +48,22 @@ echo ""; echo i18n("Student Information"); echo ""; echo ""; -$status=studentStatus(); -switch($status) -{ - case 'incomplete': - echo "
"; - echo i18n("Incomplete"); - echo "
"; - break; - case 'complete': - echo "
"; - echo i18n("Complete"); - echo "
"; - break; - default: - break; -} //check to see if its complete +$status=studentStatus(); +echo outputStatus($status); echo ""; //project information -echo "".i18n("Project Information").""; +echo ""; +echo ""; +echo "".i18n("Project Information"); +echo ""; +echo ""; //check to see if its complete +$status=projectStatus(); +echo outputStatus($status); + + echo ""; //safety information diff --git a/register_participants_project.php b/register_participants_project.php new file mode 100644 index 0000000..acf9ea0 --- /dev/null +++ b/register_participants_project.php @@ -0,0 +1,39 @@ +<< ".i18n("Back to Participant Registration Summary")."
"; + echo "

"; + + + send_footer(); +?>