2011-04-14 21:32:18 +00:00
< ? 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 " >
< head >
< meta http - equiv = " Content-Type " content = " text/html; charset=utf-8 " />
2011-05-01 22:33:56 +00:00
< title > SFIAB Evaluations Entry </ title >
2011-04-14 21:32:18 +00:00
</ head >
< body >
< ? php
include " sfiab_common.inc.php " ; // check SFIAB install and get config etc.
include " eval_common.inc.php " ; // check Evaluations setup and get eval_config
include " eval_menu_inc.php " ;
2011-05-01 22:33:56 +00:00
echo " <h2>Judges' Project Evaluations</h2><br /><br /> " ;
2011-04-14 21:32:18 +00:00
/*
This is an evaluation form ( s ) for a team . Here the team can evaluate each project assigned to the team .
* First input the team number
* Verify one of the team members is signed in and accessing this page ( TBD )
* Fill in a drop down with project numbers and project titles ( TBD for now just a list and manual input )
* Select a project number from the drop down box . ( TBD )
* Create the evaluation form - pre fill with any current evaluation entries .
* Enter the evaluation ( button )
* Select another project
* continue untill ...
* Exit the page
*/
2011-05-01 22:33:56 +00:00
$newteam = false ;
2011-04-14 21:32:18 +00:00
if ( $_POST [ 'enter' ] == " evals " ) { // come here if have an evaluation entry for a given team and project
// get the values saved in the form.
2011-05-01 22:33:56 +00:00
$oktoupdate = true ; // RFU
2011-04-14 21:32:18 +00:00
$project_id = $_POST [ 'project_id' ]; // save in form
$project_num = $_POST [ 'project_num' ]; // saved in form
$team_num = $_POST [ 'team_num' ]; // saved in form
$judges_team_name = $_POST [ 'team_name' ];
$judges_teams_id = $_POST [ 'team_id' ];
2011-05-01 22:33:56 +00:00
if ( $oktoupdate ){
/*
* for each possible critera for the project see if it was entered ( will not be a POST entry if slection was made for the post )
* the posts have names CR_nnn where nnn is the criteria number . The values are the 'selected' level_id ( stored in evals_projects_entries )
* if a selection , save it in the database if not set a flag not complete .
* return to the form
*/
$q = mysql_query ( " SELECT * FROM eval_projects WHERE project_id = ' " . $project_id . " ' " );
if ( ! $q OR mysql_num_rows ( $q ) == 0 ){
// what to do here? Should not happen
}
while ( $r = mysql_fetch_object ( $q )) {
$scheme_id = $r -> scheme_id ;
}
$q = mysql_query ( " SELECT * FROM eval_criteria WHERE scheme_id = ' " . $scheme_id . " ' " );
if ( ! $q OR mysql_num_rows ( $q ) == 0 ){
// what to do here? Should not happen
}
while ( $r = mysql_fetch_object ( $q )) {
// skip those that have criteria weight == 0 (compatibility with Apperson Scanner export/import)
if ( $r -> criteria_weight > 0 ){
$criteria_id = $r -> criteria_id ;
$postname = " CR_ " . $criteria_id ;
if ( $_POST [ $postname ]){
$value_id = $_POST [ $postname ];
// now save this one in the database
$status = mysql_query ( " UPDATE eval_projects_entries SET level_id = ' " . $value_id . " ' WHERE judges_teams_id = ' " . $judges_teams_id . " ' AND project_id = ' " . $project_id . " ' AND criteria_id = ' " . $criteria_id . " ' " );
// should work but need check if $status == false
2011-04-14 21:32:18 +00:00
}
2011-05-01 22:33:56 +00:00
}
2011-04-14 21:32:18 +00:00
}
2011-05-01 22:33:56 +00:00
}
2011-04-14 21:32:18 +00:00
}
2011-05-01 22:33:56 +00:00
if ( $_POST [ 'enter' ] == " project_team " || $_POST [ 'selection' ] == " team_num " ) {
// Changed the project number and or team number
$team_num = $_POST [ 'team_num' ];
if ( $_POST [ 'prev_team_num' ] != $team_num ){
$newteam = true ;
}
2011-04-14 21:32:18 +00:00
}
if ( $team_num == 0 )
{
echo " <form method= \" post \" action= \" eval_webentry.php \" > " ;
echo " <input type= \" hidden \" name= \" selection \" value= \" team_num \" /> " ;
echo " <table> " ;
echo " <tr><td>Team Number</td><td><input size= \" 5 \" type= \" text \" name= \" team_num \" value= \" $team_num\ " ></ td >< td >< input type = \ " submit \" value= \" Enter Team Number \" ></td></tr> " ;
echo " </table> " ;
echo " </form> " ;
echo " </body></html> " ;
exit ;
}
2011-05-01 22:33:56 +00:00
// have a team number if get here next gets the selected project from the drop down list
if ( $_POST [ 'project' ]){
$project_num = $_POST [ 'project' ];
}
if ( $newteam ) {
$project_num = 0 ;
}
//echo "<br /> Have team number data: Number: ".$team_num." Id=",$judges_teams_id." name=".$judges_team_name."<br />";
echo " <form id='form1' name='form1' method= \" post \" action= \" eval_webentry.php \" > " ;
echo " <input type= \" hidden \" name= \" enter \" value= \" project_team \" /> " ;
2011-04-14 21:32:18 +00:00
echo " <input type= \" hidden \" name= \" team_id \" value= \" $judges_teams_id\ " /> " ;
echo " <input type= \" hidden \" name= \" team_name \" value= \" $judges_team_name\ " /> " ;
2011-05-01 22:33:56 +00:00
echo " <input type= \" hidden \" name= \" prev_team_num \" value= \" $team_num\ " /> " ;
echo " <input type= \" hidden \" name= \" prev_project_num \" value= \" $project_num\ " /> " ;
2011-04-14 21:32:18 +00:00
echo " <table> " ;
2011-05-01 22:33:56 +00:00
echo " <tr><td>Team Number</td><td><input size= \" 5 \" type= \" text \" name= \" team_num \" value= \" $team_num\ " ></ td ></ tr > " ;
//echo "<tr><td>Project Number</td><td><input size=\"5\" type=\"text\" name=\"project_num\" value=\"$project_num\"></td><td><input type=\"submit\" value=\"Enter Project Number\"></td></tr>";
2011-04-14 21:32:18 +00:00
echo " </table> " ;
2011-05-01 22:33:56 +00:00
$qstr_prjs = " SELECT judges_teams_timeslots_projects_link.`year`, judges_teams_timeslots_projects_link.judges_teams_id, judges_teams.num, " .
" judges_teams.name, projects.projectnumber, projects.floornumber, projects.title, projects.shorttitle, projects.`language` " .
" FROM judges_teams, judges_teams_timeslots_projects_link, projects " .
" WHERE judges_teams.id = judges_teams_timeslots_projects_link.judges_teams_id " .
" AND judges_teams_timeslots_projects_link.projects_id = projects.id " .
" AND judges_teams.num = ' $team_num ' " ;
$qprjs = mysql_query ( $qstr_prjs );
if ( $qprjs ) {
$num_projects = mysql_num_rows ( $qprjs );
if ( $num_projects > 0 ){
$cnt = 0 ;
//echo "<form>";
echo " <select name= \" project \" ><br /> " ;
while ( $rprjs = mysql_fetch_object ( $qprjs )) {
if ( $cnt == 0 ){
$judges_teams_id = $rprjs -> judges_teams_id ;
$judges_team_name = $rprjs -> name ;
$cnt = 1 ;
}
// fill in the dropdownbox
echo " <option value = \" " . $rprjs -> projectnumber . " \" " ;
if ( $project_num == $rprjs -> projectnumber ) {
echo " selected= \" yes \" " ;
}
echo " > " . $rprjs -> projectnumber . " : " . $rprjs -> title . " </option> " ;
//echo "<br />project number ".$rprjs->projectnumber." ".$rprjs->title."floor number=".$rprjs->floornumber;
}
echo " </select> " ;
echo " <input type= \" submit \" value= \" Select Project or Change Team \" ><br /> " ;
echo " </form> " ;
}
else {
// no projects assigned or incorrect team number.
}
}
if ( $project_num == 0 ) { // if first selection of team number or if changed the team number.
2011-04-14 21:32:18 +00:00
echo " </body></html> " ;
exit ;
}
// have team id and project number
$q = mysql_query ( " SELECT * FROM projects WHERE projectnumber = ' " . $project_num . " ' " );
if ( ! $q OR mysql_num_rows ( $q ) == 0 ){
echo " <br /><b>No such project number! Start over:</b><br /> " ;
$project_num = 0 ;
echo " <form method= \" post \" action= \" eval_webentry.php \" > " ;
echo " <input type= \" hidden \" name= \" selection \" value= \" team_num \" /> " ;
echo " <table> " ;
echo " <tr><td>Team Number</td><td><input size= \" 5 \" type= \" text \" name= \" team_num \" value= \" $team_num\ " ></ td >< td >< input type = \ " submit \" value= \" Enter Team Number \" ></td></tr> " ;
echo " </table> " ;
echo " </form> " ;
echo " </body></html> " ;
exit ;
}
$r = mysql_fetch_object ( $q );
$project_id = $r -> id ;
// double check this project is assigned to this team
$q = mysql_query ( " SELECT * FROM judges_teams_timeslots_projects_link WHERE projects_id = ' " . $project_id . " ' AND judges_teams_id = ' " . $judges_teams_id . " ' " );
if ( ! $q OR mysql_num_rows ( $q ) == 0 ){
echo " <br /><b>Project NOT assigned to the selected team! Start over:</b><br /> " ;
$project_num = 0 ;
echo " <form method= \" post \" action= \" eval_webentry.php \" > " ;
echo " <input type= \" hidden \" name= \" selection \" value= \" team_num \" /> " ;
echo " <table> " ;
echo " <tr><td>Team Number</td><td><input size= \" 5 \" type= \" text \" name= \" team_num \" value= \" $team_num\ " ></ td >< td >< input type = \ " submit \" value= \" Enter Team Number \" ></td></tr> " ;
echo " </table> " ;
echo " </form> " ;
echo " </body></html> " ;
exit ;
}
2011-05-01 22:33:56 +00:00
// At this point we have all the data necessary to create the entry form
2011-04-14 21:32:18 +00:00
// Get project information for display
$qst = " SELECT projects.projectdivisions_id, projectdivisions.division, projectdivisions.division_shortform, projectcategories.category, " .
" projectcategories.category_shortform, projects.projectnumber, projects.floornumber, projects.title, projects.shorttitle, " .
" projects.`language`, eval_projects.scheme_id, eval_projects.team " .
" FROM projects, eval_projects, projectcategories, projectdivisions " .
" WHERE projects.id = eval_projects.project_id AND projects.projectcategories_id = projectcategories.id " .
" AND projects.projectdivisions_id = projectdivisions.id AND projects.id = ' " . $project_id . " ' " ;
$q = mysql_query ( $qst );
if ( $q ) {
while ( $r = mysql_fetch_object ( $q )) {
$ptitle = $r -> title ;
$pshort_title = $r -> shorttitle ;
$category = $r -> category ;
$division = $r -> division ;
$shortcategory = $r -> category_shortform ;
$division_shortform = $r -> division_shortform ;
$language = $r -> language ;
$scheme_id = $r -> scheme_id ;
$team = $r -> team ;
}
}
2011-05-01 22:33:56 +00:00
echo " <br /><b>Current Evaluation is for:<br /> " ;
echo " Team number: " . $team_num . " <br /> " ;
2011-04-14 21:32:18 +00:00
$IsTeam = " " ;
if ( $team == " yes " ){ $IsTeam = " (Team Project) " ;}
2011-05-01 22:33:56 +00:00
echo " Project number: " . $project_num . " Title: " . $ptitle . $IsTeam . " </b><br /> " ;
echo " Project Category: " . $category . " <br /> " ;
echo " Project Division: " . $division . " <br /> " ;
echo " Language: " . $language . " <br /> " ;
2011-04-14 21:32:18 +00:00
// this is for test only at this time. will be used in the Apperson Scanner export and import.
// to create the file necessary to preslug the score forms.
// Barcode = 1 or 2 for team, 4 digits exn, 4 digits team number, 2 digits checksum?
2011-05-01 22:33:56 +00:00
//$tempprnum = substr($project_num , 1);
//if ( strlen($tempprnum) < 4 )
// {
// $tempprnum = "0".$tempprnum;
// }
//echo "<br /> Scanner Project number: ".$tempprnum;
echo " <br /> " ;
2011-04-14 21:32:18 +00:00
$errors = 0 ;
$criteria_row = 0 ;
// First find the longest string in criteria and level names so the table will look nice
$maxstrlen = 0 ;
$qcr = mysql_query ( " SELECT * FROM eval_criteria WHERE scheme_id = ' $scheme_id ' Order by 'criteria_id' " );
if ( $qcr ) {
while ( $rcr = mysql_fetch_object ( $qcr )) {
if ( strlen ( $rcr -> criteria_name ) > $maxstrlen ) {
$maxstrlen = strlen ( $rcr -> criteria_name );
}
}
}
$qlv = mysql_query ( " SELECT * FROM eval_levels WHERE scheme_id = $scheme_id " .
" AND spec_use = 'no' ORDER BY level_value DESC " );
if ( $qlv ) {
while ( $rlv = mysql_fetch_object ( $qlv )){
if ( strlen ( $rlv -> level_name ) > $maxstrlen ) {
$maxstrlen = strlen ( $rlv -> level_name );
}
}
}
echo " <form id='form2' name='form2' method='post' action='eval_webentry.php' > " ;
// Build the table **************************************************************
echo " <table style='width:67%%; font-family: 'Courier New', Courier, monospace;' border='1' align='left'> " ;
// build the top row criteria labels. If a criteria weight == 0 do not put in form (for compatibilbity with Apperson Scanners)
$qcr = mysql_query ( " SELECT * FROM eval_criteria WHERE scheme_id = ' $scheme_id ' Order by 'criteria_id' " );
echo " <tr> " ;
if ( $qcr ) {
$total_crits = mysql_num_rows ( $qcr ); // used to check if all criteria have a selection
$count_crits = 0 ;
while ( $rcr = mysql_fetch_object ( $qcr )) {
if ( $rcr -> criteria_weight > 0 ){
$nam = $rcr -> criteria_name ;
if ( strlen ( $nam ) < $maxstrlen ){
$addn = $maxstrlen - strlen ( $nam ) + 5 ;
for ( $icnt = 1 ; $icnt <= $addn ; $icnt += 1 ) {
$nam = $nam . " " ;
}
}
echo " <td> " . $nam . " </td> " ;
}
else {
$total_crits -= 1 ; // reduce the number of needed criteria marks for each criteria wiht weight = 0
}
}
}
echo " </tr> " ;
// Now add the row with the levels to select as a radio button list *********************
// ** important to order the same as above query ***
$qcr = mysql_query ( " SELECT * FROM eval_criteria WHERE scheme_id = ' $scheme_id ' Order by 'criteria_id' " );
echo " <tr> " ;
if ( $qcr ) {
while ( $rcr = mysql_fetch_object ( $qcr )) {
// for each, add a colunm with the input list
// except.. if the criteria weight is 0 then do not add to the form (Special case for compatibility with Export / Apperson scanners)
if ( $rcr -> criteria_weight > 0 ){
echo " <td> " ;
$qlv = mysql_query ( " SELECT * FROM eval_levels WHERE scheme_id = $scheme_id " .
" AND spec_use = 'no' ORDER BY level_value DESC " );
if ( $qlv ) {
while ( $rlv = mysql_fetch_object ( $qlv )){
// see if this level for this criteria is already set in the tables
$qset = mysql_query ( " SELECT * FROM eval_projects_entries WHERE judges_teams_id = ' " . $judges_teams_id . " ' AND project_id = ' " . $project_id . " ' AND criteria_id =' " . $rcr -> criteria_id . " ' " );
if ( $qset ){
while ( $rset = mysql_fetch_object ( $qset )){ // should only be one record for this criteria
if ( $rset -> level_id == $rlv -> level_id ){
$rbsel = " checked " ;
$count_crits += 1 ;
}
else {
$rbsel = " " ;
}
}
}
$nam = $rlv -> level_name ;
echo " <input type='radio' name='CR_ " . $rcr -> criteria_id . " ' id='CR_ " . $rcr -> criteria_id . " _ " . $rlv -> level_id . " ' value=' " . $rlv -> level_id . " ' " . $rbsel . " /> " . $nam . " <br /> " ;
}
}
echo " </td> " ;
}
}
}
echo " </tr><tr <td colspan=' " . $total_crits . " ' > " ;
echo " <input type= \" hidden \" name= \" team_num \" value= \" $team_num\ " /> " ;
echo " <input type= \" hidden \" name= \" project_num \" value= \" $project_num\ " /> " ;
echo " <input type= \" hidden \" name= \" project_id \" value= \" $project_id\ " /> " ;
echo " <input type= \" hidden \" name= \" team_name \" value= \" $judges_team_name\ " /> " ;
echo " <input type= \" hidden \" name= \" team_id \" value= \" $judges_teams_id\ " /> " ;
echo " <input type= \" hidden \" name= \" enter \" value= \" evals \" /> " ;
if ( $total_crits == $count_crits ){
echo " Complete! Enter changes or select another project. " ;
}
else {
echo " EVALUATION NOT COMPLETE! " ;
}
echo " <br /><input type= \" submit \" value= \" Enter Evaluations \" /> " ;
echo " </td></tr> " ;
echo " </table> " ;
echo " </form> " ;
echo " <br /> " ;
?>
</ body >
</ html >