science-ation/judge_expertise.php

231 lines
7.2 KiB
PHP
Raw Normal View History

2005-01-24 18:00:03 +00:00
<?
/*
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_once('common.inc.php');
require_once('user.inc.php');
require_once('judge.inc.php');
2009-09-26 20:24:38 +00:00
/* Sort out who we're editting */
if($_POST['users_id'])
$eid = intval($_POST['users_id']); /* From a save form */
else if(array_key_exists('embed_edit_id', $_SESSION))
$eid = $_SESSION['embed_edit_id']; /* From the embedded editor */
else
$eid = $_SESSION['users_id']; /* Regular entry */
if($eid != $_SESSION['users_id']) {
/* Not editing ourself, we had better be
* a committee member */
user_auth_required('committee','admin');
}
2009-09-26 20:24:38 +00:00
$u = user_load($eid);
2009-09-26 20:24:38 +00:00
switch($_GET['action']) {
case 'save':
if(!is_array($_POST['division']))
$_POST['division']=array();
if(!is_array($_POST['subdivision']))
$_POST['subdivision']=array();
$u['div_prefs'] = array();
foreach($_POST['division'] AS $key=>$val)
$u['div_prefs'][$key] = $val;
$u['div_prefs_sub'] = array();
foreach($_POST['subdivision'] AS $key=>$val)
$u['div_prefs_sub'][$key] = $val;
if($_POST['expertise_other'])
$u['expertise_other'] = stripslashes($_POST['expertise_other']);
else
$u['expertise_other'] = NULL;
$u['cat_prefs'] = array();
if(is_array($_POST['catpref'])) {
foreach($_POST['catpref'] AS $k=>$v) {
if($v == '') continue;
$u['cat_prefs'][$k] = $v;
}
}
user_save($u);
2009-09-26 20:24:38 +00:00
happy_("Preferences successfully saved");
//reload the user record because we dont know if we saved or didnt save above, we just want
//to know what the user looks like _now_
$u = user_load($eid);
$newstatus=judge_status_expertise($u);
echo "<script type=\"text/javascript\">";
echo "expertise_update_status('$newstatus');\n";
echo "</script>\n";
2009-09-26 20:24:38 +00:00
exit;
}
if($_SESSION['embed'] == true) {
echo "<br /><h3>".i18n("Judging Expertise")."</h3>";
display_messages();
} else {
//send the header
send_header('Category and Division Preferences',
array('Judge Registration' => 'judge_main.php')
);
}
$newstatus=judge_status_expertise($u);
2009-09-26 20:24:38 +00:00
?>
<script type="text/javascript">
function judgeexpertise_save()
{
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/judge_expertise.php?action=save", $("#judgeexpertise_form").serializeArray());
return false;
}
function expertise_update_status(s) {
if(s!='complete') {
$("#expertise_info_status").html('<?=error(i18n("Divisional Judging Information Incomplete"))?>');
}
else
$("#expertise_info_status").html('<?=happy(i18n("Divisional Judging Information Complete"))?>');
}
//when we're ready, output the status
$(document).ready( function() { expertise_update_status('<?=$newstatus?>');});
2009-09-26 20:24:38 +00:00
</script>
<?
judge_status_update($u);
echo "<div id=\"expertise_info_status\"></div>\n";
if($u['special_award_only'] == 'yes') {
echo i18n("You have specified that you are a judge for a specific special award. Divisional Judging preferences have been disabled because they do not apply to you.");
echo "<br />";
send_footer();
exit;
}
2009-09-26 20:24:38 +00:00
echo "<form name=\"expertiseform\" id=\"judgeexpertise_form\">\n";
echo "<input type=\"hidden\" name=\"users_id\" value=\"{$u['id']}\">\n";
$q=mysql_query("SELECT * FROM projectcategories WHERE year='{$config['FAIRYEAR']}' ORDER BY mingrade");
echo "<br /><h4>".i18n("Age Category Preferences")."</h4><br>";
echo "<table class=\"editor\" style=\"width: 300px;\" >";
while($r=mysql_fetch_object($q))
{
echo "<tr><td class=\"label\" >";
echo i18n("%1 (Grades %2-%3)",array(i18n($r->category),$r->mingrade,$r->maxgrade));
2009-09-26 20:24:38 +00:00
echo ":</td>";
echo "<td>";
echo "<select name=\"catpref[$r->id]\">";
echo "<option value=\"\">".i18n("Choose")."</option>\n";
foreach($preferencechoices AS $val=>$str)
{
if($u['cat_prefs'][$r->id]==$val && $u['cat_prefs'][$r->id]!="")
$sel="selected=\"selected\"";
else
$sel="";
echo "<option $sel value=\"$val\">".i18n($str)."</option>\n";
}
echo "</select>".REQUIREDFIELD;
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo "<br />";
2009-09-26 20:24:38 +00:00
echo "<h4>".i18n("Division Expertise")."</h4><br>";
echo i18n("Please rank the following divisions according to the amount of knowledge you have of each subject. A '1' indicates very little knowledge, and a '5' indicates you are very knowledgeable of the subject");
echo "<br />";
echo "<br />";
echo i18n("Once you save, any division that you specified as 3 or more might offer sub-divisions for you to choose from.");
echo "<br />";
echo "<br />";
2009-09-26 20:24:38 +00:00
echo "<table>\n";
//query all of the categories
2009-09-26 20:24:38 +00:00
$q=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
$first = true;
while($r=mysql_fetch_object($q)) {
$trclass = ($trclass == 'odd') ? 'even' : 'odd';
if($first == true) {
echo "<tr><td></td><td colspan=\"3\">".i18n("Novice")."</td><td colspan=\"3\" align=\"right\">".i18n("Expert")."</td></tr>";
echo "<tr><th></th>";
for($x=1;$x<=5;$x++)
echo "<th>$x</th>";
echo "<th></th>";
echo "</tr>";
$first = false;
}
echo "<tr class=\"$trclass\"><td><b>".i18n($r->division)."</b></td>";
for($x=1;$x<=5;$x++) {
$sel = ($u['div_prefs'][$r->id]==$x) ? "checked=\"checked\"" : '';
echo "<td width=\"30\"><input onclick=\"fieldChanged()\" $sel type=\"radio\" name=\"division[$r->id]\" value=\"$x\" /></td>";
}
echo "<td>" . REQUIREDFIELD . "</td>";
2009-09-26 20:24:38 +00:00
// echo "<td width=\"100\"></td>";
echo "</tr>";
2004-12-20 19:48:13 +00:00
//only show the sub-divisions if the 'main' division is scored >=3
if($u['div_prefs'][$r->id]>=3) {
$subq=mysql_query("SELECT * FROM projectsubdivisions WHERE projectdivisions_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY subdivision");
while($subr=mysql_fetch_object($subq)) {
echo "<tr>";
echo "<td>&nbsp;</td>";
$ch = ($u['div_prefs_sub'][$subr->id]) ? "checked=\"checked\"" : '';
echo "<td><input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"subdivision[$subr->id]\" value=\"1\" /></td>";
echo "<td colspan=\"5\">";
echo "$subr->subdivision";
echo "</td>";
echo "</tr>";
}
}
}
2009-09-26 20:24:38 +00:00
?>
</table>
<br />
<h4><?=i18n("Other Areas of Expertise not listed above")?></h4>
<textarea name="expertise_other" rows="4" cols="60"><?=htmlspecialchars($u['expertise_other'])?></textarea>
<br />
<br />
2009-09-26 20:24:38 +00:00
<input type="submit" onclick="judgeexpertise_save();return false;" value="<?=i18n("Save Judging Preferences")?>" />
</form>
2009-09-26 20:24:38 +00:00
<?
if($_SESSION['embed'] != true) send_footer();
?>