Wow I dont even know what all is in this commit: few things i do know:

1) add (preliminary) special awards nominations for students
2) add css right-margin to summarytable class
3) add new table for projets-specialawards-link
4) move projects.inc.php from admin/ to / (so particpant registration can use it)
This commit is contained in:
james 2005-05-11 04:13:27 +00:00
parent b1810d05a2
commit ed663e77eb
8 changed files with 386 additions and 94 deletions

View File

@ -25,7 +25,7 @@
require("../common.inc.php"); require("../common.inc.php");
auth_required('admin'); auth_required('admin');
require("judges.inc.php"); require("judges.inc.php");
require("projects.inc.php"); require("../projects.inc.php");
send_header("Judging Teams Projects"); send_header("Judging Teams Projects");
?> ?>
@ -343,7 +343,7 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
foreach($teams AS $team) foreach($teams AS $team)
{ {
echo "<tr>"; echo "<tr>";
echo "<td>"; echo "<td width=\"200\">";
echo "<b>".$team['name']." (#".$team['num'].")</b><br />"; echo "<b>".$team['name']." (#".$team['num'].")</b><br />";
$memberlist=""; $memberlist="";
foreach($team['members'] AS $member) foreach($team['members'] AS $member)
@ -383,7 +383,7 @@ if( ($action=="edit" || $action=="assign" ) && $edit)
while($r=mysql_fetch_object($q)) while($r=mysql_fetch_object($q))
{ {
echo "<tr><td>"; echo "<tr><td width=\"150\" align=\"center\">";
echo "<nobr>"; echo "<nobr>";
if($show_date) if($show_date)

View File

@ -23,7 +23,7 @@
?> ?>
<? <?
require("../common.inc.php"); require("../common.inc.php");
require("projects.inc.php"); require("../projects.inc.php");
auth_required('admin'); auth_required('admin');
send_header("Administration - Award Winners"); send_header("Administration - Award Winners");

View File

@ -7,3 +7,10 @@ CREATE TABLE `judges_teams_awards_link` (
); );
ALTER TABLE judges_teams_awards_link ADD UNIQUE (award_awards_id,judges_teams_id,year); ALTER TABLE judges_teams_awards_link ADD UNIQUE (award_awards_id,judges_teams_id,year);
ALTER TABLE `judges_teams` CHANGE `name` `name` VARCHAR( 255 ) NOT NULL; ALTER TABLE `judges_teams` CHANGE `name` `name` VARCHAR( 255 ) NOT NULL;
CREATE TABLE `project_specialawards_link` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`award_awards_id` INT UNSIGNED NOT NULL ,
`projects_id` INT UNSIGNED NOT NULL ,
`year` INT NOT NULL ,
PRIMARY KEY ( `id` )
);

View File

@ -76,11 +76,89 @@ function getProjectsEligibleForAwards($awards_ids_array)
return $projects; return $projects;
} }
function getAwardsEligibleForProject($projectnumber) function getSpecialAwardsEligibleForProject($projectid)
{ {
global $config; global $config;
$prjq=mysql_query("SELECT $awardsq=mysql_query("SELECT
award_awards.id,
award_awards.name,
award_awards.criteria,
award_awards_projectcategories.projectcategories_id,
award_awards_projectdivisions.projectdivisions_id,
projects.id AS projects_id
FROM
award_awards,
award_awards_projectcategories,
award_awards_projectdivisions,
award_types,
projects
WHERE
award_types.type='Special'
AND award_types.id=award_awards.award_types_id
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
AND projects.projectcategories_id=award_awards_projectcategories.projectcategories_id
AND projects.projectdivisions_id=award_awards_projectdivisions.projectdivisions_id
AND award_awards.id is not null
AND projects.year='".$config['FAIRYEAR']."'
AND projects.id='$projectid'
ORDER BY
award_awards.name
");
$awards=array();
echo mysql_error();
while($r=mysql_fetch_object($awardsq))
{
$awards[$r->id]=array(
"id"=>$r->id,
"criteria"=>$r->criteria,
"name"=>$r->name
);
}
return $awards;
}
function getSpecialAwardsNominatedForProject($projectid)
{
global $config;
//FIXME: this query isnt done yet, its still a copy from above
$awardsq=mysql_query("SELECT
award_awards.id,
award_awards.name,
award_awards.criteria,
projects.id AS projects_id
FROM
award_awards,
project_specialawards_link,
projects
WHERE
project_specialawards_link.projects_id='$projectid'
AND project_specialawards_link.award_awards_id=award_awards.id
AND projects.year='".$config['FAIRYEAR']."'
AND projects.id='$projectid'
ORDER BY
award_awards.name
");
$awards=array();
echo mysql_error();
while($r=mysql_fetch_object($awardsq))
{
$awards[$r->id]=array(
"id"=>$r->id,
"criteria"=>$r->criteria,
"name"=>$r->name
);
}
return $awards;
}
function getSpecialAwardsNominatedByRegistrationID($id)
{
global $config;
$awardq=mysql_query("SELECT
award_awards.id, award_awards.id,
award_awards.name, award_awards.name,
award_awards_projectcategories.projectcategories_id, award_awards_projectcategories.projectcategories_id,
@ -112,20 +190,9 @@ function getAwardsEligibleForProject($projectnumber)
); );
} }
return $projects; return $projects;
} }
function getAwardsEligibleForProjects($awards_ids_array)
{
$projects=array();
foreach($awards_ids_array AS $award_id)
{
$awardprojects=array();
$awardprojects=getProjectsEligibleForAward($award_id);
//this will just overwrite ones that already exist, but still keep things in order because the main key is the projectnumber (i hope)
foreach($awardprojects AS $proj)
$projects[$proj['projectnumber']]=$proj;
}
return $projects;
}
?> ?>

View File

@ -185,5 +185,31 @@ function safetyStatus($reg_id="")
} }
function spawardStatus($reg_id="")
{
if($reg_id) $rid=$reg_id;
else $rid=$_SESSION['registration_id'];
return false;
//grab all of their answers
$q=mysql_query("SELECT * FROM safety WHERE registrations_id='$rid'");
while($r=mysql_fetch_object($q))
{
$safetyanswers[$r->safetyquestions_id]=$r->answer;
}
//now grab all the questions
$q=mysql_query("SELECT * FROM safetyquestions ORDER BY ord");
while($r=mysql_fetch_object($q))
{
if($r->required=="yes" && !$safetyanswers[$r->id])
{
return "incomplete";
}
}
return "complete";
}
?> ?>

View File

@ -84,93 +84,117 @@ echo mysql_error();
echo "<br />"; echo "<br />";
echo "<br />"; echo "<br />";
echo "<table class=\"summarytable\">"; echo "<table><tr><td>";
echo "<tr><th>".i18n("Registration Item")."</th><th>".i18n("Status")."</th></tr>";
//participant information echo "<table class=\"summarytable\">";
echo "<tr><td>"; echo "<tr><th>".i18n("Registration Item")."</th><th>".i18n("Status")."</th></tr>";
echo "<a href=\"register_participants_students.php\">";
echo i18n("Student Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusstudent=studentStatus();
echo outputStatus($statusstudent);
echo "</td></tr>";
//participant emergency contact information //participant information
echo "<tr><td>"; echo "<tr><td>";
if($statusstudent=="complete") echo "<a href=\"register_participants_students.php\">";
echo "<a href=\"register_participants_emergencycontact.php\">"; echo i18n("Student Information");
echo i18n("Emergency Contact Information");
if($statusstudent=="complete")
echo "</a>"; echo "</a>";
echo "</td><td>"; echo "</td><td>";
//check to see if its complete //check to see if its complete
$statusemergencycontact=emergencycontactStatus(); $statusstudent=studentStatus();
echo outputStatus($statusemergencycontact); echo outputStatus($statusstudent);
echo "</td></tr>"; echo "</td></tr>";
//project information - project requires students, so only show the link if the students is complete //participant emergency contact information
echo "<tr><td>"; echo "<tr><td>";
if($statusstudent=="complete") if($statusstudent=="complete")
echo "<a href=\"register_participants_project.php\">"; echo "<a href=\"register_participants_emergencycontact.php\">";
echo i18n("Project Information"); echo i18n("Emergency Contact Information");
if($statusstudent=="complete") if($statusstudent=="complete")
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusemergencycontact=emergencycontactStatus();
echo outputStatus($statusemergencycontact);
echo "</td></tr>";
//project information - project requires students, so only show the link if the students is complete
echo "<tr><td>";
if($statusstudent=="complete")
echo "<a href=\"register_participants_project.php\">";
echo i18n("Project Information");
if($statusstudent=="complete")
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusproject=projectStatus();
echo outputStatus($statusproject);
echo "</td></tr>";
//mentor information
echo "<tr><td>";
echo "<a href=\"register_participants_mentor.php\">";
echo i18n("Mentor Information");
echo "</a>"; echo "</a>";
echo "</td><td>"; echo "</td><td>";
//check to see if its complete //check to see if its complete
$statusproject=projectStatus(); $statusmentor=mentorStatus();
echo outputStatus($statusproject); echo outputStatus($statusmentor);
echo "</td></tr>"; echo "</td></tr>";
//mentor information //safety information
echo "<tr><td>"; echo "<tr><td>";
echo "<a href=\"register_participants_mentor.php\">"; echo "<a href=\"register_participants_safety.php\">";
echo i18n("Mentor Information"); echo i18n("Safety Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statusmentor=mentorStatus();
echo outputStatus($statusmentor);
echo "</td></tr>";
//safety information
echo "<tr><td>";
echo "<a href=\"register_participants_safety.php\">";
echo i18n("Safety Information");
echo "</a>";
echo "</td><td>";
//check to see if its complete
$statussafety=safetyStatus();
echo outputStatus($statussafety);
echo "</td></tr>";
//signature page
echo "<tr><td>";
if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete")
echo "<a href=\"register_participants_signature.php\">";
echo i18n("Signature Page");
if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete")
echo "</a>"; echo "</a>";
echo "</td><td>"; echo "</td><td>";
echo i18n("Print"); //check to see if its complete
//check to see if its complete $statussafety=safetyStatus();
echo "</td></tr>"; echo outputStatus($statussafety);
echo "</td></tr>";
//received information //signature page
echo "<tr><td>".i18n("Signature Page Received")."</td><td>"; echo "<tr><td>";
if(registrationFormsReceived()) if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete")
echo outputStatus("complete"); echo "<a href=\"register_participants_signature.php\">";
else echo i18n("Signature Page");
echo outputStatus("incomplete"); if($statusstudent=="complete" && $statusproject=="complete" && $statusmentor=="complete" && $statussafety=="complete")
echo "</a>";
echo "</td><td>";
echo i18n("Print");
//check to see if its complete
echo "</td></tr>";
//check to see if its complete //received information
echo "</td></tr>"; echo "<tr><td>".i18n("Signature Page Received")."</td><td>";
if(registrationFormsReceived())
echo outputStatus("complete");
else
echo outputStatus("incomplete");
//check to see if its complete
echo "</td></tr>";
echo "</table>" ;
echo "</td>";
echo "<td align=\"left\" width=\"50%\">";
if($config['specawardnom']!="none")
{
echo "<table class=\"summarytable\">";
echo "<tr><th>".i18n("Special Award Nominations")."</th></tr>";
if(registrationFormsReceived())
{
echo "<tr><td><a href=\"register_participants_spawards.php\">".i18n("Self-nominate for special awards")."</a></td></tr>";
// $awards=getSpecialAwardsNominatedByRegistrationID($_SESSION['registration_id']);
}
else
{
echo "<tr><td>".error(i18n("We must receive your signature form before you can nominate yourself for special awards"),"inline")."</td></tr>";
}
echo "</table>";
}
echo "</td></tr>";
echo "</table>"; echo "</table>";
echo "<br /><br />"; echo "<br /><br />";
echo "<h3>".i18n("Registration Instructions")."</h3>"; echo "<h3>".i18n("Registration Instructions")."</h3>";

View File

@ -0,0 +1,167 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
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.
*/
?>
<?
require("common.inc.php");
include "register_participants.inc.php";
include "projects.inc.php";
//authenticate based on email address and registration number from the SESSION
if(!$_SESSION['email'])
{
header("Location: register_participants.php");
exit;
}
if(!$_SESSION['registration_number'])
{
header("Location: register_participants.php");
exit;
}
$q=mysql_query("SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students ".
"WHERE students.email='".$_SESSION['email']."' ".
"AND registrations.num='".$_SESSION['registration_number']."' ".
"AND registrations.id='".$_SESSION['registration_id']."' ".
"AND students.registrations_id=registrations.id ".
"AND registrations.year=".$config['FAIRYEAR']." ".
"AND students.year=".$config['FAIRYEAR']);
echo mysql_error();
if(mysql_num_rows($q)==0)
{
header("Location: register_participants.php");
exit;
}
$authinfo=mysql_fetch_object($q);
$q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."'");
$project=mysql_fetch_object($q);
//send the header
send_header("Participant Registration - Self-Nomination for Special Awards");
echo "<a href=\"register_participants_main.php\">&lt;&lt; ".i18n("Back to Participant Registration Summary")."</a><br />";
echo "<br />";
if($_POST['action']=="save")
{
//FIXME: check the date when they have to have this in by and dont let them submit after that date
// if(registrationFormsReceived())
// {
// echo error(i18n("Cannot make changes to forms once they have been received by the fair"));
// }
// else
// {
//first we will delete all their old answer, its easier to delete and re-insert in this case then it would be to find the corresponding answers and update them
mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='$project->id' AND year='".$config['FAIRYEAR']."'");
$count=0;
foreach($_POST['spaward'] AS $spaward)
{
mysql_query("INSERT INTO project_specialawards_link (award_awards_id,projects_id,year) VALUES (".
"'$spaward', ".
"'$project->id', ".
"'".$config['FAIRYEAR']."')");
echo mysql_error();
$count++;
}
echo happy(i18n("Successfully registered for %1 special awards",array($count)));
// }
}
//output the current status
$newstatus=spawardStatus();
if($newstatus!="complete")
{
echo error(i18n("Special Awards Self-Nomination Incomplete"));
}
else if($newstatus=="complete")
{
echo happy(i18n("Safety Awards Self-Nomination Complete"));
}
echo "<form method=\"post\" action=\"register_participants_spawards.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<table>\n";
$q=mysql_query("SELECT * FROM safety WHERE registrations_id='".$_SESSION['registration_id']."'");
while($r=mysql_fetch_object($q))
{
$safetyanswers[$r->safetyquestions_id]=$r->answer;
}
$eligibleawards=getSpecialAwardsEligibleForProject($project->id);
$nominatedawards=getSpecialAwardsNominatedForProject($project->id);
echo "eligible awards <br>";
echo nl2br(print_r($eligibleawards,true));
echo "nominated awards <br>";
echo nl2br(print_r($nominatedawards,true));
$nominatedawards_list=array();
foreach($nominatedawards AS $naward)
{
$nominatedawards_list[]=$naward['id'];
}
echo "<table>";
foreach($eligibleawards AS $eaward)
{
echo "<tr><td rowspan=\"2\">";
if(in_array($eaward['id'],$nominatedawards_list)) $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"spaward[]\" value=\"".$eaward['id']."\" />";
echo "</td><td>";
echo "<b>".$eaward['name']."</b>";
echo "</td></tr>";
echo "<tr><td>";
echo $eaward['criteria'];
echo "<br /><br />";
echo "</td></tr>";
}
echo "</table>";
/*
$num=1;
while($r=mysql_fetch_object($q))
{
echo "<tr><td><b>$num</b>. </td><td>".i18n($r->question)."</td>";
echo "<td>";
if($r->type=="check")
{
if($safetyanswers[$r->id]=="checked") $ch="checked=\"checked\""; else $ch="";
echo "<input $ch type=\"checkbox\" name=\"safety[$r->id]\" value=\"checked\" />";
}
echo "</td>";
echo "</tr>";
$num++;
}
echo "</table>";
*/
echo "<input type=\"submit\" value=\"".i18n("Save Safety Information")."\" />\n";
echo "</form>";
send_footer();
?>

View File

@ -142,6 +142,7 @@ a {
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
margin-left: 30px; margin-left: 30px;
margin-right: 30px;
} }