judge main questions

This commit is contained in:
dave 2010-08-19 22:56:35 +00:00
parent 9f3dc6c9dc
commit b4a021411d
5 changed files with 141 additions and 134 deletions

View File

@ -26,22 +26,18 @@
require_once('user.inc.php');
require_once('judge.inc.php');
require_once("questions.inc.php");
require_once('user_edit.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 */
/* Ensure they're logged in as a judge or admin */
user_auth_required(array(), array('judge','admin'));
$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
if($edit_id != $_SESSION['users_id'])
user_auth_required('admin');
else
$eid = $_SESSION['users_id']; /* Regular entry */
user_auth_required();
if($eid != $_SESSION['users_id']) {
/* Not editing ourself, we had better be
* a committee member */
user_auth_required('committee','admin');
}
$u = user_load($eid);
$u = user_load($edit_id);
switch($_GET['action']) {
case 'save':
@ -59,123 +55,123 @@ case 'save':
$u['highest_psd'] = stripslashes($_POST['highest_psd']);
user_save($u);
questions_save_answers("judgereg",$u['id'],$_POST['questions']);
happy_("Preferences successfully saved");
$u=user_load($eid);
$newstatus=judge_status_other($u);
echo "<script type=\"text/javascript\">";
echo "other_update_status('$newstatus');\n";
echo "</script>\n";
exit;
}
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Other Information')."</h3>";
echo "<br />";
} else {
//send the header
send_header('Other Information',
array('Judge Registration' => 'judge_main.php')
);
}
$u = user_load($u['id']);
$newstatus=judge_status_other($u);
?>
<script type="text/javascript">
function judgeother_save()
{
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/judge_other.php?action=save", $("#judgeother_form").serializeArray());
return false;
}
function other_update_status(s) {
if(s!='complete') {
$("#other_info_status").html('<?=error(i18n("Other Information Incomplete"))?>');
}
else
$("#other_info_status").html('<?=happy(i18n("Other Information Complete"))?>');
}
//when we're ready, output the status
$(document).ready( function() { other_update_status('<?=$newstatus?>');});
user_update_tab_status('judge','<?=$newstatus?>');
</script>
<?
judge_status_update($u);
echo "<div id=\"other_info_status\"></div>\n";
?>
<form name="otherform" id="judgeother_form">
<input type="hidden" name="users_id" value="<?=$u['id']?>">
<table class="editor">
<tr>
<td style="width:35%"><?=i18n("I can judge in the following languages")." ".REQUIREDFIELD?>: </td>
<td>
<?
$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
echo mysql_error();
while($r=mysql_fetch_object($q))
{
$ch = (in_array($r->lang,$u['languages'])) ? 'checked="checked"' : '';
echo "<input onclick=\"fieldChanged()\" $ch type=\"checkbox\" name=\"languages[]\" value=\"$r->lang\" /> $r->langname <br />";
exit;
}
?>
$fields = array('languages[]', 'years_school','years_regional','years_national','willing_chair','highest_psd');
$required = array('languages[]');
?>
<h4><?=i18n("Judge Information")?> - <span class="status_judge"></span></h4>
<form class="editor" id="judgeother_form">
<table width="90%">
<tr><td style="text-align: left" colspan="2"><b><?=i18n('Judging Language(s)')?></b><hr /></td></tr>
<tr><?=user_edit_item($u, 'Languages', 'languages[]', 'languages')?></tr>
<tr><td style="text-align: left" colspan="2"><br /><b><?=i18n('Judging Experience')?></b><hr />
<i><?=i18n('Please specify the number of years you\'ve judged at the following levels. This helps balance the experience on judging teams.')?></i>
</td></tr>
<?
if($config['judges_specialaward_only_enable'] == 'yes') {
?>
<tr><td colspan="2"><hr /></td></tr>
<tr><td><?=i18n("I am a judge for a specific special award")?>:</td>
<td><table><tr><td>
<?
$ch = ($u['special_award_only'] == 'yes') ? 'checked="checked"' : '';
echo "<input $ch type=\"checkbox\" name=\"special_award_only\" value=\"yes\" />";
echo "</td><td>";
echo 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.");
?>
</td></tr></table>
</td></tr>
<?
}
?>
<tr><?=user_edit_item($u, 'Judge at a School/District Fair', 'years_school', 'textbox', 5)?></tr>
<tr><?=user_edit_item($u, 'Judge at a Regional Fair', 'years_regional', 'textbox', 5)?></tr>
<tr><?=user_edit_item($u, 'Judge at a National Fair', 'years_national', 'textbox', 5)?></tr>
<tr><td colspan="2"><hr /></td></tr>
<tr><td style="text-align: left" colspan="2"><br /><b><?=i18n('Judging Questions')?></b><hr /></td></tr>
<tr><?=user_edit_item($u, 'I am willing to be the lead for my judging team', 'willing_chair', 'yesno')?></tr>
<tr><?=user_edit_item($u, 'Highest post-secondary degree', 'highest_psd', 'textbox')?></tr>
<tr> <td><?=i18n("Years of judging experience at a School level:")?></td>
<td><input onchange="fieldChanged()" type="text" name="years_school" size="5" value="<?=$u['years_school']?>" /></td>
</tr><tr>
<td><?=i18n("Years of judging experience at a Regional level:")?></td>
<td><input onchange="fieldChanged()" type="text" name="years_regional" size="5" value="<?=$u['years_regional']?>" /></td>
</tr><tr>
<td><?=i18n("Years of judging experience at a National level:")?></td>
<td><input onchange="fieldChanged()" type="text" name="years_national" size="5" value="<?=$u['years_national']?>" /></td>
</tr><tr>
<td><?=i18n("I am willing to be the lead for my judging team")?></td>
<td>
<? $ch = ($u['willing_chair'] == 'yes') ? 'checked="checked"' : ''; ?>
<input <?=$ch?> type="checkbox" name="willing_chair" value="yes" />
</tr><tr>
<td><?=i18n("Highest post-secondary degree")?></td>
<td><input onchange="fieldChanged()" type="text" name="highest_psd" size="35" value="<?=$u['highest_psd']?>" /></td>
</tr><tr>
<td colspan="2"><hr /></td></tr>
</table>
<table class="editor">
<td style="width:35%" colspan="2"></td><td colspan="2"></td>
<?
questions_print_answer_editor('judgereg', $u, 'questions');
?>
</table>
<br /><br />
<input type="submit" onclick="judgeother_save(); return false;" value="<?=i18n("Save Information")?>" />
<br />
<button><?=i18n("Save Information")?></button>
</form>
<script type="text/javascript">
function judgeother_save()
{
$("#debug").load("<?=$config['SFIABDIRECTORY']?>/judge_other.php?action=save&users_id=<?=$u['id']?>", $("#judgeother_form").serializeArray());
return false;
}
$(document).ready(function() {
$("#judgeother_form").validate({
errorPlacement: function(error, element) {
if( element.attr('type') == 'checkbox' ) {
error.insertAfter( element.parent("span") );
} else {
error.insertAfter(element);
}
},
rules: {
"languages[]": { required: true },
years_school: { min: 0, max:100 },
years_regional: { min: 0, max:100 },
years_national: { min: 0, max:100 }
},
messages: {
"languages[]": { required: "<?=i18n('Please select the language(s) you can judge in')?>" },
years_school: {
min: "<?=i18n('Please enter a valid number')?>",
max: "<?=i18n('Please enter a valid number')?>",
},
years_regional: {
min: "<?=i18n('Please enter a valid number')?>",
max: "<?=i18n('Please enter a valid number')?>",
},
years_national: {
min: "<?=i18n('Please enter a valid number')?>",
max: "<?=i18n('Please enter a valid number')?>",
}
},
submitHandler: function() {
judgeother_save();
return false;
},
cancelHandler: function() {
judgeother_save();
return false;
}
});
user_update_tab_status('judge');
});
</script>
<?
if($_SESSION['embed'] != true) send_footer();
/*
if($config['judges_specialaward_only_enable'] == 'yes') {
<tr><td colspan="2"><hr /></td></tr>
<tr><td><?=i18n("I am a judge for a specific special award")?>:</td>
<td><table><tr><td>
$ch = ($u['special_award_only'] == 'yes') ? 'checked="checked"' : '';
echo "<input $ch type=\"checkbox\" name=\"special_award_only\" value=\"yes\" />";
echo "</td><td>";
echo 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.");
</td></tr></table>
</td></tr>
}
*/
?>

View File

@ -100,17 +100,18 @@ function questions_print_answer_editor($section, &$u, $array_name)
$qs = questions_load_questions($section, $u['year']);
$keys = array_keys($qs);
foreach($keys as $qid) {
print("<tr>\n");
print(" <td colspan=\"2\">".i18n($qs[$qid]['question'])."</td>\n");
print(" <td colspan=\"2\">");
$iname = "{$array_name}[{$qid}]";
print("<tr>\n");
print(" <td><label for=\"$iname\">".i18n($qs[$qid]['question'])."</label></td>\n");
print(" <td >");
switch($qs[$qid]['type']) {
case 'yesno':
if($ans[$qid]=="yes") $ch="checked=\"checked\""; else $ch="";
print("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"yes\" />".i18n("Yes"));
print("&nbsp; &nbsp; ");
if($ans[$qid]=="no") $ch="checked=\"checked\""; else $ch="";
print("<input onclick=\"fieldChanged()\" $ch type=\"radio\" name=\"$iname\" value=\"no\" />".i18n("No"));
echo "<select name=\"$iname\">";
$sel = ($ans[$qid]=='yes') ? 'selected="selected"' : '';
echo "<option value=\"yes\" $sel>".i18n("Yes")."</option>\n";
$sel = ($ans[$qid]=='no') ? 'selected="selected"' : '';
echo "<option value=\"no\" $sel>".i18n("No")."</option>\n";
echo "</select>";
break;
case 'int':
print("<input onclick=\"fieldChanged()\" type=\"text\" ".

View File

@ -24,7 +24,7 @@
require_once('account.inc.php');
function user_edit_item(&$u, $label, $fname, $type='textbox')
function user_edit_item(&$u, $label, $fname, $type='textbox', $data1=NULL)
{
global $required, $fields, $config;
@ -41,7 +41,8 @@ function user_edit_item(&$u, $label, $fname, $type='textbox')
echo '<td>';
switch($type) {
case 'textbox':
echo "<input id=\"$fname\" name=\"$fname\" type=\"text\" value=\"{$u[$fname]}\">";
if($data1 != NULL) $size = "size=\"$data1\"";
echo "<input id=\"$fname\" name=\"$fname\" $size type=\"text\" value=\"{$u[$fname]}\">";
break;
case 'province':
@ -74,6 +75,18 @@ function user_edit_item(&$u, $label, $fname, $type='textbox')
}
echo "</select>";
break;
case 'languages':
echo "<span>";
$x = 0;
foreach($config['languages'] AS $l=>$ln) {
$ch = (in_array($l,$u['languages'])) ? 'checked="checked"' : '';
if($x) echo '<br />';
echo "<input $ch type=\"checkbox\" name=\"$fname\" value=\"$l\" />$ln";
$x=1;
}
echo "</span>";
break;
}
echo '</td>';
}

View File

@ -25,6 +25,7 @@
require_once('common.inc.php');
require_once('user.inc.php');
require_once('user_edit.inc.php');
require_once('judge.inc.php');
$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
if($edit_id != $_SESSION['users_id'])
@ -56,11 +57,11 @@ $tabs = array( 'fairinfo' => array(
'file' => 'user_organization.php',
'status_func' => 'user_organization_status',
),
'judgeother' => array(
'label' => 'Judge Other',
'judge' => array(
'label' => 'Judge',
'types' => array('judge'),
'file' => 'judge_other.php',
'disabled' => true,
'status_func' => 'judge_status_other',
),
'judgeexpertise' => array(
'label' => 'Expertise',

View File

@ -70,7 +70,7 @@ case 'save':
//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($u['id']);
// $u = user_load($u['id']);
$newstatus=user_organization_status($u);
?>
<script type="text/javascript">
@ -80,18 +80,14 @@ case 'save':
exit;
}
//send the header
?>
<h4><?=i18n("Organization")?> - <span class="status_organization"></span></h4>
<br/>
<form class="editor" id="orgform">
<table width="90%">
<tr><td style="text-align: left" colspan="2"><b>Organization</b><hr /></td></tr>
<tr><td style="text-align: left" colspan="2"><b><?=i18n('Organization')?></b><hr /></td></tr>
<tr><?=user_edit_item($u, 'Organization Name', 'organization')?></tr>
<tr><?=user_edit_item($u, 'Phone', 'phonework')?></tr>
<tr><?=user_edit_item($u, 'Fax', 'fax')?></tr>