-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjudge_expertise.php
229 lines (190 loc) · 7.15 KB
/
judge_expertise.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?
/*
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');
/* 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');
}
$u = user_load($eid);
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);
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";
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);
?>
<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?>');});
</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;
}
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));
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 />";
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 />";
echo "<table>\n";
//query all of the categories
$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=\"2\">".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 "</tr>";
$first = false;
}
echo "<tr class=\"$trclass\"><td><b>".i18n($r->division)."</b></td>";
for($x=1;$x<=5;$x++) {
if(!$u['div_prefs'][$r->id]) $u['div_prefs'][$r->id]=1;
$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 width=\"100\"></td>";
echo "</tr>";
//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> </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>";
}
}
}
?>
</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 />
<input type="submit" onclick="judgeexpertise_save();return false;" value="<?=i18n("Save Judging Preferences")?>" />
</form>
<?
if($_SESSION['embed'] != true) send_footer();
?>