- implement the judge_other selection for years of experience and willing_chair and whatnot.

This commit is contained in:
dave 2008-10-17 22:44:33 +00:00
parent ca81fc2273
commit 4b247de611
5 changed files with 58 additions and 80 deletions

View File

@ -64,26 +64,23 @@ function judge_status_expertise($u)
$q=mysql_query("SELECT COUNT(id) AS num FROM projectcategories WHERE year='".$config['FAIRYEAR']."'"); $q=mysql_query("SELECT COUNT(id) AS num FROM projectcategories WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q); $r=mysql_fetch_object($q);
$numcats=$r->num; $numcats=$r->num;
if($numcats != count($u['cat_prefs'])) return 'incomplete';
if($numcats != count($u['catprefs'])) {
return "incomplete";
}
$q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'"); $q=mysql_query("SELECT COUNT(id) AS num FROM projectdivisions WHERE year='".$config['FAIRYEAR']."'");
$r=mysql_fetch_object($q); $r=mysql_fetch_object($q);
$numdivisions=$r->num; $numdivisions=$r->num;
if($numdivisions != count($u['div_prefs'])) return 'incomplete';
if($numdivisions != count($u['divprefs'])) { return 'complete';
return "incomplete";
}
return "complete";
} }
function judge_status_other($u) function judge_status_other($u)
{ {
global $config; global $config;
/* They must select a language to judge in */
if(count($u['languages']) < 1) return 'incomplete';
return 'complete'; return 'complete';
} }

View File

@ -29,7 +29,7 @@
$u = user_load($_SESSION['users_id'], true); $u = user_load($_SESSION['users_id'], true);
//send the header //send the header
$type = $_SESSION['users_type']; // $type = $_SESSION['users_type'];
send_header('Category and Division Preferences', send_header('Category and Division Preferences',
array('Judge Registration' => 'judge_main.php') array('Judge Registration' => 'judge_main.php')
); );

View File

@ -30,39 +30,26 @@
$u = user_load($_SESSION['users_id'], true); $u = user_load($_SESSION['users_id'], true);
//send the header //send the header
$type = $_SESSION['users_type'];
send_header('Other Information', send_header('Other Information',
array('Judge Registration' => 'judge_main.php') array('Judge Registration' => 'judge_main.php')
); );
if($_POST['action']=="save") if($_POST['action']=="save")
{ {
if(!is_array($_POST['division']))
$_POST['division']=array(); if(!is_array($_POST['languages'])) $_POST['languages']=array();
if(!is_array($_POST['subdivision']))
$_POST['subdivision']=array();
$u['divprefs'] = array(); $u['languages'] = array();
foreach($_POST['division'] AS $key=>$val) foreach($_POST['languages'] AS $val)
$u['divprefs'][$key] = $val; $u['languages'][] = $val;
$u['divprefs_sub'] = array(); $u['special_award_only'] = ($_POST['special_award_only'] == 'yes') ? 'yes' : 'no';
foreach($_POST['subdivision'] AS $key=>$val) $u['willing_chair'] = ($_POST['willing_chair'] == 'yes') ? 'yes' : 'no';
$u['divprefs_sub'][$key] = $val; $u['years_school'] = intval($_POST['years_school']);
$u['years_regional'] = intval($_POST['years_regional']);
$u['years_national'] = intval($_POST['years_national']);
$u['highest_psd'] = stripslashes($_POST['highest_psd']);
if($_POST['other_other'])
$u['other_other'] = stripslashes($_POST['other_other']);
else
$u['other_other'] = NULL;
$u['catprefs'] = array();
if(is_array($_POST['catpref'])) {
foreach($_POST['catpref'] AS $k=>$v) {
if($v == '') continue;
$u['catprefs'][$k] = $v;
}
}
user_save($u); user_save($u);
message_push(notice(i18n("Preferences successfully saved"))); message_push(notice(i18n("Preferences successfully saved")));
$u = user_load($_SESSION['users_id'], true); $u = user_load($_SESSION['users_id'], true);
@ -86,18 +73,11 @@ echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("I can judge in the following languages")." ".REQUIREDFIELD."</td>"; echo " <td colspan=\"2\">".i18n("I can judge in the following languages")." ".REQUIREDFIELD."</td>";
echo " <td colspan=\"2\">"; echo " <td colspan=\"2\">";
//grab the current languages that are selected
$currentlanguages=array();
$q=mysql_query("SELECT languages_lang FROM judges_languages WHERE judges_id='".$_SESSION['judges_id']."'");
while($r=mysql_fetch_object($q))
{
$currentlanguages[]=$r->languages_lang;
}
$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname"); $q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
echo mysql_error();
while($r=mysql_fetch_object($q)) while($r=mysql_fetch_object($q))
{ {
if(in_array($r->lang,$currentlanguages)) $ch="checked=\"checked\""; else $ch=""; $ch = (in_array($r->lang,$u['languages'])) ? 'checked="checked"' : '';
echo "<input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"languages[]\" value=\"$r->lang\" /> $r->langname <br />"; echo "<input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"languages[]\" value=\"$r->lang\" /> $r->langname <br />";
} }
@ -110,9 +90,8 @@ if($config['judges_specialaward_only_enable'] == 'yes') {
echo "<tr><td colspan=\"4\"><hr /></td></tr>"; echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo "<tr>\n"; echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("I am a judge for a specific special award")."<br /><font size=-1>(".i18n("Check this box if you are supposed to judge a specific special award, and please select that award on the Special Award Preferences page.").")</font></td>"; echo " <td colspan=\"2\">".i18n("I am a judge for a specific special award")."<br /><font size=-1>(".i18n("Check this box if you are supposed to judge a specific special award, and please select that award on the Special Award Preferences page.").")</font></td>";
if($judgeinfo->typepref == "speconly") $ch = "checked=checked"; $ch = ($u['special_award_only'] == 'yes') ? 'checked="checked"' : '';
else $ch=""; echo " <td colspan=\"2\"><input $ch type=\"checkbox\" name=\"special_award_only\" value=\"yes\" />";
echo " <td colspan=\"2\"><input $ch type=\"checkbox\" name=\"typepref\" value=\"speconly\" />";
echo " </td>"; echo " </td>";
echo "</tr>\n"; echo "</tr>\n";
} }
@ -131,26 +110,20 @@ echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Years of judging experience at a National level:")."</td>"; echo " <td colspan=\"2\">".i18n("Years of judging experience at a National level:")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"years_national\" size=\"5\" value=\"{$u['years_national']}\" /></td>\n"; echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"years_national\" size=\"5\" value=\"{$u['years_national']}\" /></td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Other professional qualifications")."</td>"; echo " <td colspan=\"2\">".i18n("I am willing to be the lead for my judging team")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"professional_quals\" size=\"35\" value=\"$judgeinfo->professional_quals\" /></td>\n"; $ch = ($u['willing_chair'] == 'yes') ? 'checked="checked"' : '';
echo " <td colspan=\"2\"><input $ch type=\"checkbox\" name=\"willing_chair\" value=\"yes\" />";
echo "</tr>\n"; echo "</tr>\n";
questions_print_answer_editor('judgereg',
$_SESSION['judges_id'], $config['FAIRYEAR'], 'questions');
echo "<tr>\n"; echo "<tr>\n";
echo " <td colspan=\"2\">".i18n("Highest post-secondary degree")."</td>"; echo " <td colspan=\"2\">".i18n("Highest post-secondary degree")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"highest_psd\" size=\"35\" value=\"$judgeinfo->highest_psd\" /></td>\n"; echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"highest_psd\" size=\"35\" value=\"{$u['highest_psd']}\" /></td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr><td colspan=\"4\"><hr /></td></tr>";
echo " <td colspan=\"2\">".i18n("Other professional qualifications")."</td>";
echo " <td colspan=\"2\"><input onchange=\"fieldChanged()\" type=\"text\" name=\"professional_quals\" size=\"35\" value=\"$judgeinfo->professional_quals\" /></td>\n"; questions_print_answer_editor('judgereg', $u, 'questions');
echo "</tr>\n";
echo "</table>"; echo "</table>";

View File

@ -24,13 +24,12 @@
<? <?
function questions_load_answers($section, $id, $year) function questions_load_answers($section, $users_id)
{ {
$q = mysql_query('SELECT question_answers.*, questions.* '. $q = mysql_query('SELECT question_answers.*, questions.* '.
'FROM question_answers '. 'FROM question_answers '.
'LEFT JOIN questions ON questions.id=question_answers.questions_id '. 'LEFT JOIN questions ON questions.id=question_answers.questions_id '.
"WHERE question_answers.year='$year' ". "WHERE users_id='$users_id' ".
" AND registrations_id='$id' ".
" AND questions.section='$section' ". " AND questions.section='$section' ".
'ORDER BY questions.ord ASC'); 'ORDER BY questions.ord ASC');
@ -62,13 +61,13 @@ function questions_load_questions($section, $year)
return $qs; return $qs;
} }
function questions_save_answers($section, $id, $year, $answers) function questions_save_answers($section, $id, $answers)
{ {
$qs = questions_load_questions($section, $year); $qs = questions_load_questions($section);
$keys = array_keys($answers); $keys = array_keys($answers);
$query = "DELETE FROM question_answers ". $query = "DELETE FROM question_answers ".
"WHERE registrations_id='$id' ". "WHERE users_id='$id' ".
" AND year='$year' AND ("; " AND (";
$n = 0; $n = 0;
foreach($keys as $qid) { foreach($keys as $qid) {
if($n == 1) $query .= " OR "; if($n == 1) $query .= " OR ";
@ -82,18 +81,17 @@ function questions_save_answers($section, $id, $year, $answers)
foreach($keys as $qid) { foreach($keys as $qid) {
/* Poll key */ /* Poll key */
mysql_query("INSERT INTO question_answers ". mysql_query("INSERT INTO question_answers ".
"(year,registrations_id,questions_id,answer) VALUES(". "(users_id,questions_id,answer) VALUES(".
"'$year','$id','$qid',". "'$id','$qid',".
"'".mysql_escape_string($answers[$qid])."'". "'".mysql_escape_string($answers[$qid])."'".
")" ); ")" );
} }
} }
function questions_find_question_id($section, $year, $dbheading) function questions_find_question_id($section, $dbheading)
{ {
$q = mysql_query("SELECT id FROM questions WHERE ". $q = mysql_query("SELECT id FROM questions WHERE ".
" section='$section' ". " section='$section' ".
" AND year='$year' ".
" AND db_heading='$dbheading' "); " AND db_heading='$dbheading' ");
if(mysql_num_rows($q) == 1) { if(mysql_num_rows($q) == 1) {
$r = mysql_fetch_object($q); $r = mysql_fetch_object($q);
@ -103,10 +101,10 @@ function questions_find_question_id($section, $year, $dbheading)
} }
function questions_print_answer_editor($section, $id, $year, $array_name) function questions_print_answer_editor($section, &$u, $array_name)
{ {
$ans = questions_load_answers($section, $id, $year); $ans = questions_load_answers($section, $u['id']);
$qs = questions_load_questions($section, $year); $qs = questions_load_questions($section, $u['year']);
$keys = array_keys($qs); $keys = array_keys($qs);
foreach($keys as $qid) { foreach($keys as $qid) {
@ -133,10 +131,10 @@ function questions_print_answer_editor($section, $id, $year, $array_name)
} }
} }
function questions_print_answers($section, $id, $year) function questions_print_answers($section, $id)
{ {
$ans = questions_load_answers($section, $id, $year); $ans = questions_load_answers($section, $id);
$qs = questions_load_questions($section, $year); $qs = questions_load_questions($section);
$keys = array_keys($qs); $keys = array_keys($qs);
foreach($keys as $qid) { foreach($keys as $qid) {
echo "<tr>\n"; echo "<tr>\n";
@ -158,7 +156,7 @@ function questions_parse_from_http_headers($array_name)
return $ans; return $ans;
} }
function questions_update_question($qs, $year) function questions_update_question($qs)
{ {
mysql_query("UPDATE questions SET mysql_query("UPDATE questions SET
`question`='".mysql_escape_string($qs['question'])."', `question`='".mysql_escape_string($qs['question'])."',
@ -166,7 +164,7 @@ function questions_update_question($qs, $year)
`db_heading`='".mysql_escape_string($qs['db_heading'])."', `db_heading`='".mysql_escape_string($qs['db_heading'])."',
`required`='".mysql_escape_string($qs['required'])."', `required`='".mysql_escape_string($qs['required'])."',
`ord`=".intval($qs['ord'])." `ord`=".intval($qs['ord'])."
WHERE id='{$qs['id']}' AND year='$year'"); WHERE id='{$qs['id']}' ");
echo mysql_error(); echo mysql_error();
} }

View File

@ -98,7 +98,16 @@ function user_load_judge($u)
$ret['div_prefs'] = unserialize($r->div_prefs); $ret['div_prefs'] = unserialize($r->div_prefs);
$ret['divsub_prefs'] = unserialize($r->divsub_prefs); $ret['divsub_prefs'] = unserialize($r->divsub_prefs);
$ret['expertise_other'] = $r->expertise_other; $ret['expertise_other'] = $r->expertise_other;
$ret['languages'] = unserialize($r->languages);
$ret['highest_psd'] = $r->highest_psd;
/* Sanity check the arrays, make sure they are arrays */
$should_be_arrays = array('cat_prefs','div_prefs',
'divsub_prefs','languages');
foreach($should_be_arrays as $k) {
if(!is_array($ret[$k])) $ret[$k] = array();
}
return $ret; return $ret;
} }
@ -315,7 +324,8 @@ function user_save_judge($u)
{ {
$fields = array('judge_active','years_school','years_regional','years_national', $fields = array('judge_active','years_school','years_regional','years_national',
'willing_chair','special_award_only', 'willing_chair','special_award_only',
'cat_prefs','div_prefs','divsub_prefs','expertise_other'); 'cat_prefs','div_prefs','divsub_prefs',
'expertise_other','languages', 'highest_psd');
user_save_type_list($u, 'users_judge', $fields); user_save_type_list($u, 'users_judge', $fields);
} }