forked from science-ation/science-ation
94 lines
4.0 KiB
PHP
94 lines
4.0 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 Calculate Scores</title>
|
|
</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";
|
|
echo "<h2>Calculate Scores</h2><br /><br />";
|
|
echo "<br />";
|
|
echo "Click the button to Calculate and enter scores values";
|
|
echo "<form method=\"post\" action=\"eval_calc_scores.php\">";
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"calc\" />";
|
|
echo "<br />";
|
|
echo "<input type=\"submit\" value=\"Calculate Scores\">";
|
|
echo "</form>";
|
|
if(!$_POST['action'] == "calc")
|
|
{
|
|
echo "</body>";
|
|
echo "</html>";
|
|
exit;
|
|
}
|
|
echo "<br />All Scores calculated and saved!<br />";
|
|
echo "<br />Development Note: This updates the score field in 'judges_teams_timeslots_projects_link' for every team/project with a 'complete' evaluation entry<br />";
|
|
echo " and updates the eval_score (current average) and eval_score_status fields in table eval_projects for every project for which an average score can be calculated.<br />";
|
|
echo "For test purposes (to be removed later) it lists just the project number for each project, then lists the scores details for the last project in the list.<br /><br /> ";
|
|
// do all projects that qualify for judging (in the judges_teams_timeslots_projects_link table)
|
|
$q = mysql_query("SELECT DISTINCT projects_id from judges_teams_timeslots_projects_link");
|
|
while($r=mysql_fetch_object($q)) {
|
|
$ret_array = calc_scores($r->projects_id); // cal_scores is in eval_common.inc.php
|
|
if($ret_array == 'error') {
|
|
echo " error";
|
|
}
|
|
else{
|
|
echo " ".$ret_array[project_num];
|
|
// put scores in 'judges_teams_timeslots_projects_link'
|
|
for ($i=0;$i < $ret_array[num_teams]; $i++){
|
|
$team_id = $ret_array[team_scores][$i][team_id];
|
|
$score = $ret_array[team_scores][$i][team_score];
|
|
if (is_null($score)) {$score = "NULL";}
|
|
$up = mysql_query("UPDATE judges_teams_timeslots_projects_link SET score = ".$score.
|
|
" WHERE judges_teams_id = '".$team_id."' AND projects_id = '".$r->projects_id."' ");
|
|
}
|
|
// update eval_judges table
|
|
$up = mysql_query("UPDATE eval_projects SET eval_score = '".$ret_array[eval_score]."', eval_score_status = '".$ret_array[eval_score_status]."' WHERE project_id = '".$r->projects_id."' ");
|
|
}
|
|
}
|
|
echo "<br /><br />";
|
|
// for debug - this just prints out the values in the last project
|
|
if ($ret_array =="error"){
|
|
echo $ret_array;
|
|
}
|
|
else {
|
|
for ($i=0;$i < $ret_array[num_teams]; $i++){
|
|
echo "team_id=".$ret_array[team_scores][$i][team_id]." team_num= ".$ret_array[team_scores][$i][team_num] ."project_num = ".
|
|
$ret_array[team_scores][$i][proj_num] ." score =".$ret_array[team_scores][$i][team_score].
|
|
" status = ".$ret_array[team_scores][$i][team_status] ."<br />";
|
|
|
|
}
|
|
echo "Project number ".$ret_array[project_num].": score= ".$ret_array[eval_score]." status = ".$ret_array[eval_score_status]."<br />";
|
|
}
|
|
echo "</body>";
|
|
echo "</html>";
|
|
exit;
|
|
|
|
?>
|
|
</body>
|
|
</html>
|