science-ation/plugins/evaluations/eval_calc_scores.php

75 lines
3.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 "<br />Note: For now, this just calculates scores for every project in table 'judges_teams_timeslots_projects_link'<br />";
echo " and lists just the project number for each and then lists the details for the last project in the list.<br /><br /> ";
echo " and storese the results into table eval_projects and 'judges_teams_timeslots_projects_link' score field<br /><br >";
// do all projects
$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);
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."' ");
}
}
}
echo "<br /><br />";
// 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 />";
}
exit;
?>
</body>
</html>