forked from science-ation/science-ation
- fix the message in the config editor
- add a convenience $user['name'] setting - update the judge SA
This commit is contained in:
parent
1774225526
commit
881d6b9be4
@ -22,12 +22,12 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
require_once("../user.inc.php");
|
||||
require("../questions.inc.php");
|
||||
require("../projects.inc.php");
|
||||
require("judges.inc.php");
|
||||
require("anneal.inc.php");
|
||||
require_once('../common.inc.php');
|
||||
require_once('../user.inc.php');
|
||||
require_once('../questions.inc.php');
|
||||
require_once('../projects.inc.php');
|
||||
require_once('judges.inc.php');
|
||||
require_once('anneal.inc.php');
|
||||
|
||||
if($_SERVER['SERVER_ADDR']) {
|
||||
echo "This script must be run from the command line";
|
||||
@ -431,114 +431,55 @@ TRACE(" Done.\n");
|
||||
|
||||
set_status("Loading Judges");
|
||||
|
||||
$q=mysql_query("SELECT judges.* FROM judges,judges_years WHERE ".
|
||||
"complete='yes' AND deleted='no' ".
|
||||
" AND judges_years.year='{$config['FAIRYEAR']}' ".
|
||||
" AND judges_years.judges_id=judges.id"
|
||||
);
|
||||
|
||||
$judges=array();
|
||||
$judges = judges_load_all();
|
||||
$sa_judges = array();
|
||||
|
||||
while($r=mysql_fetch_object($q))
|
||||
{
|
||||
unset($divprefs);
|
||||
unset($catprefs);
|
||||
unset($langprefs);
|
||||
|
||||
/* Try to fetch a team link ID for this judge, if we can, we don't want to use this judge
|
||||
* in the divisional awards, they are already assigned to soemthing */
|
||||
$q2 = mysql_query("SELECT judges_id FROM judges_teams_link WHERE ".
|
||||
"judges_id='$r->id' ".
|
||||
" AND year='".$config['FAIRYEAR']."'");
|
||||
if(mysql_num_rows($q2) != 0) {
|
||||
TRACE(" {$r->firstname} {$r->lastname} is already on a judging team, skipping.\n");
|
||||
foreach($judges as $j) {
|
||||
$q = mysql_query("SELECT users_id FROM judges_teams_link WHERE
|
||||
users_id='{$j['id']}'
|
||||
AND year='{$config['FAIRYEAR']}'");
|
||||
if(mysql_num_rows($q) != 0) {
|
||||
TRACE(" {$j['name']} is already on a judging team, skipping.\n");
|
||||
unset($judges[$j['id']]);
|
||||
continue;
|
||||
}
|
||||
|
||||
//get category preferences
|
||||
$q2=mysql_query("SELECT * FROM judges_catpref WHERE judges_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY projectcategories_id");
|
||||
$catprefs=array();
|
||||
while($r2=mysql_fetch_object($q2))
|
||||
$catprefs[$r2->projectcategories_id]=$r2->rank;
|
||||
|
||||
//get division preferences
|
||||
$q2=mysql_query("SELECT * FROM judges_expertise WHERE judges_id='$r->id' AND year='".$config['FAIRYEAR']."' AND projectsubdivisions_id IS NULL ORDER BY projectdivisions_id");
|
||||
//the areas of expertise are ranked from 1 to 5, and we need them as -2,-1,0,1,2 so we simply subtract 3
|
||||
$divprefs=array();
|
||||
while($r2=mysql_fetch_object($q2))
|
||||
$divprefs[$r2->projectdivisions_id]=$r2->val-3;
|
||||
|
||||
$langprefs = array();
|
||||
$q3=mysql_query("SELECT * from judges_languages WHERE judges_id='$r->id'");
|
||||
while($r3=mysql_fetch_object($q3))
|
||||
$langprefs[]=$r3->languages_lang;
|
||||
|
||||
$q2 = mysql_query("SELECT answer FROM question_answers WHERE ".
|
||||
" registrations_id='{$r->id}' AND ".
|
||||
" questions_id='$willing_chair_question_id' AND ".
|
||||
" year='{$config['FAIRYEAR']}' ");
|
||||
mysql_error();
|
||||
$willing_chair = 'no';
|
||||
if(mysql_num_rows($q2) == 1) {
|
||||
$r2 = mysql_fetch_object($q2);
|
||||
if($r2->answer == 'yes') $willing_chair = 'yes';
|
||||
}
|
||||
|
||||
$sa_only = 'no';
|
||||
if($r->typepref == 'speconly') $sa_only = 'yes';
|
||||
$sa_sel = array();
|
||||
|
||||
|
||||
if($sa_only == 'yes') {
|
||||
TRACE("Judge [{$r->firstname} {$r->lastname}] is a special awards only.\n");
|
||||
if($j['special_award_only'] == 'yes') {
|
||||
$sa_sel = array();
|
||||
TRACE("Judge {$j['name']} is a special awards only.\n");
|
||||
/* Find their special award id */
|
||||
$qq = mysql_query("SELECT award_awards.id,award_awards.name FROM
|
||||
$q = mysql_query("SELECT award_awards.id,award_awards.name FROM
|
||||
judges_specialaward_sel,award_awards
|
||||
WHERE
|
||||
award_awards.id=judges_specialaward_sel.award_awards_id
|
||||
AND judges_specialaward_sel.judges_id='{$r->id}'
|
||||
AND judges_specialaward_sel.year='{$config['FAIRYEAR']}'
|
||||
AND judges_specialaward_sel.users_id='{$j['id']}'
|
||||
AND award_awards.year='{$config['FAIRYEAR']}'");
|
||||
echo mysql_error();
|
||||
if(mysql_num_rows($qq) == 0) {
|
||||
if(mysql_num_rows($q) == 0) {
|
||||
TRACE(" - NO special award selected! (removing special award only request)\n");
|
||||
$sa_only = 'no';
|
||||
} else if(mysql_num_rows($qq) > 1) {
|
||||
$judges[$j['id']]['special_award_only'] = 'no';
|
||||
} else if(mysql_num_rows($q) > 1) {
|
||||
TRACE(" - More than ONE special award selected (removing special award only request):\n");
|
||||
$sa_only = 'no';
|
||||
}
|
||||
while($rr = mysql_fetch_object($qq)) {
|
||||
TRACE(" ".$rr->name."\n");
|
||||
$sa_sel[] = $rr->id;
|
||||
}
|
||||
$judges[$j['id']]['special_award_only'] = 'no';
|
||||
}
|
||||
}
|
||||
|
||||
$j=array(
|
||||
"judges_id"=>"$r->id",
|
||||
"name"=>"$r->firstname $r->lastname",
|
||||
"years_school"=>$r->years_school,
|
||||
"years_regional"=>$r->years_regional,
|
||||
"years_national"=>$r->years_national,
|
||||
"willing_chair"=>$willing_chair,
|
||||
"divprefs"=>$divprefs,
|
||||
"catprefs"=>$catprefs,
|
||||
"languages"=>$langprefs,
|
||||
"sa_only"=>$sa_only,
|
||||
"sa_sel"=>$sa_sel,
|
||||
);
|
||||
|
||||
/* If it's a special award only judge, keep them
|
||||
* out of the judges list for the divisional annealer */
|
||||
if($sa_only == 'yes') {
|
||||
$sa_judges[$r->id] = $j;
|
||||
} else {
|
||||
$judges[$r->id] = $j;
|
||||
$judges[$j['id']]['special_awards'] = array();
|
||||
while($r = mysql_fetch_object($q)) {
|
||||
TRACE(" {$r->name}\n");
|
||||
/* Add them to the SA judge list (modify the actual list, not
|
||||
* $j, which is a copy */
|
||||
$judges[$j['id']]['special_awards'][] = $r->id;
|
||||
}
|
||||
|
||||
|
||||
if($j['special_award_only'] == 'yes') {
|
||||
/* Add to sa judge list, remove from the eligible judge list */
|
||||
$sa_judges[$j['id']] = $judges[$j['id']];
|
||||
unset($judges[$j['id']]);
|
||||
}
|
||||
}
|
||||
TRACE("Loaded ".count($judges)." judges.\n");
|
||||
|
||||
TRACE("Loaded ".count($judges)." judges, and ".count($sa_judges)." special-award-only judges.\n");
|
||||
$jteam[0]['max_judges'] = count($judges);
|
||||
|
||||
|
||||
@ -560,18 +501,14 @@ function pr_judge(&$jt, $jid)
|
||||
{
|
||||
global $judges;
|
||||
$j =& $judges[$jid];
|
||||
print(" - {$j['name']} (");
|
||||
for($x=0; $x<count($j['languages']); $x++) {
|
||||
print($j['languages'][$x]. " ");
|
||||
}
|
||||
print(")");
|
||||
print(" - {$j['name']} (".join(' ', $j['languages']).')');
|
||||
print("(");
|
||||
for($x=0; $x<count($jt['cats']); $x++) {
|
||||
$pref=$j['catprefs'][$jt['cats'][$x]];
|
||||
$pref=$j['cat_prefs'][$jt['cats'][$x]];
|
||||
print("c{$jt['cats'][$x]}=$pref ");
|
||||
}
|
||||
for($x=0; $x<count($jt['divs']); $x++) {
|
||||
$pref=$j['divprefs'][$jt['divs'][$x]];
|
||||
$pref=$j['div_prefs'][$jt['divs'][$x]];
|
||||
print("d{$jt['divs'][$x]}=$pref ");
|
||||
}
|
||||
print(")");
|
||||
@ -643,7 +580,7 @@ for($x=1;$x<count($jteam); $x++) {
|
||||
|
||||
/* Link Judges to the judging team we just inserted */
|
||||
mysql_query("INSERT INTO judges_teams_link ".
|
||||
" (judges_id,judges_teams_id,captain,year) ".
|
||||
" (users_id,judges_teams_id,captain,year) ".
|
||||
" VALUES ('{$ids[$y]}','$team_id','{$j['willing_chair']}',".
|
||||
"'{$config['FAIRYEAR']}')");
|
||||
}
|
||||
@ -719,7 +656,7 @@ function judges_sa_cost_function($annealer, $bucket_id, $ids)
|
||||
* is in the judges selection list */
|
||||
/* Run through all awards this team is judging */
|
||||
foreach($t['award_ids'] as $aid) {
|
||||
if(in_array($aid, $j['sa_sel'])) {
|
||||
if(in_array($aid, $j['special_awards'])) {
|
||||
/* This judge wants to judge this award */
|
||||
/* No cost */
|
||||
} else {
|
||||
@ -865,7 +802,7 @@ if($config['scheduler_enable_sa_scheduling'] == 'yes') {
|
||||
|
||||
/* Link Judges to the judging team we just inserted */
|
||||
mysql_query("INSERT INTO judges_teams_link
|
||||
(judges_id,judges_teams_id,captain,year)
|
||||
(users_id,judges_teams_id,captain,year)
|
||||
VALUES ('{$ids[$y]}','{$t['id']}',
|
||||
'{$j['willing_chair']}',
|
||||
'{$config['FAIRYEAR']}')");
|
||||
|
@ -162,7 +162,7 @@ function config_editor_handle_actions($category, $year, $array_name)
|
||||
$updated = true;
|
||||
}
|
||||
if($updated == true) {
|
||||
$_SESSION['messages'][] = 'config_editor_updated';
|
||||
message_push(happy(i18n("Configuration Updated")));;
|
||||
}
|
||||
return 'update';
|
||||
}
|
||||
@ -185,17 +185,6 @@ function config_editor($category, $year, $array_name, $self)
|
||||
config_editor_handle_actions($category, $year, $array_name);
|
||||
}
|
||||
|
||||
if(is_array($_SESSION['messages'])) {
|
||||
foreach($_SESSION['messages'] as $m) {
|
||||
switch($m) {
|
||||
case 'config_editor_updated':
|
||||
echo happy(i18n("Configuration Updated"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$_SESSION['messages'] = array();
|
||||
}
|
||||
|
||||
/* Load questions, then handle up and down, because with up and down we
|
||||
* have to modify 2 questions to maintain the order */
|
||||
$var = config_editor_load($category, $year);
|
||||
|
@ -144,6 +144,9 @@ function user_load($user)
|
||||
$ts = explode(',', $ret['types']);
|
||||
$ret['types'] = $ts; /* Now we can use in_array('judge', $ret['types']) ; */
|
||||
|
||||
/* Convenience */
|
||||
$ret['name'] = $ret['firstname'].' '.$ret['lastname'];
|
||||
|
||||
foreach($ret['types'] as $t) {
|
||||
/* These all pass $ret by reference, and can modify
|
||||
* $ret */
|
||||
|
Loading…
x
Reference in New Issue
Block a user