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 .
*/
?>
2004-12-19 23:16:46 +00:00
< ?
2009-09-09 00:26:12 +00:00
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' );
}
2004-12-19 23:16:46 +00:00
2009-09-26 20:24:38 +00:00
$u = user_load ( $eid );
2009-09-09 00:26:12 +00:00
2009-09-26 20:24:38 +00:00
switch ( $_GET [ 'action' ]) {
case 'save' :
2004-12-20 19:46:08 +00:00
if ( ! is_array ( $_POST [ 'division' ]))
$_POST [ 'division' ] = array ();
if ( ! is_array ( $_POST [ 'subdivision' ]))
$_POST [ 'subdivision' ] = array ();
2009-09-09 00:26:12 +00:00
$u [ 'div_prefs' ] = array ();
2004-12-19 23:16:46 +00:00
foreach ( $_POST [ 'division' ] AS $key => $val )
2009-09-09 00:26:12 +00:00
$u [ 'div_prefs' ][ $key ] = $val ;
2004-12-20 19:46:08 +00:00
2009-09-09 00:26:12 +00:00
$u [ 'div_prefs_sub' ] = array ();
2004-12-20 19:46:08 +00:00
foreach ( $_POST [ 'subdivision' ] AS $key => $val )
2009-09-09 00:26:12 +00:00
$u [ 'div_prefs_sub' ][ $key ] = $val ;
2004-12-20 19:46:08 +00:00
2005-02-11 18:25:59 +00:00
if ( $_POST [ 'expertise_other' ])
2009-09-09 00:26:12 +00:00
$u [ 'expertise_other' ] = stripslashes ( $_POST [ 'expertise_other' ]);
else
$u [ 'expertise_other' ] = NULL ;
2007-01-30 06:12:11 +00:00
2009-09-09 00:26:12 +00:00
$u [ 'cat_prefs' ] = array ();
if ( is_array ( $_POST [ 'catpref' ])) {
foreach ( $_POST [ 'catpref' ] AS $k => $v ) {
if ( $v == '' ) continue ;
2007-01-30 06:12:11 +00:00
2009-09-09 00:26:12 +00:00
$u [ 'cat_prefs' ][ $k ] = $v ;
2007-01-30 06:12:11 +00:00
}
}
2009-09-09 00:26:12 +00:00
user_save ( $u );
2009-09-26 20:24:38 +00:00
happy_ ( " Preferences successfully saved " );
2009-11-26 19:09:37 +00:00
//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 ;
}
2007-01-30 06:12:11 +00:00
2009-09-09 00:26:12 +00:00
if ( $_SESSION [ 'embed' ] == true ) {
2009-11-26 19:09:37 +00:00
echo " <br /><h3> " . i18n ( " Judging Expertise " ) . " </h3> " ;
2009-09-09 00:26:12 +00:00
display_messages ();
} else {
//send the header
send_header ( 'Category and Division Preferences' ,
array ( 'Judge Registration' => 'judge_main.php' )
);
2004-12-19 23:16:46 +00:00
}
2009-09-09 00:26:12 +00:00
2009-11-26 19:09:37 +00:00
$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 ;
}
2009-11-26 19:09:37 +00:00
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 >
< ?
2009-09-09 00:26:12 +00:00
judge_status_update ( $u );
2009-11-26 19:09:37 +00:00
echo " <div id= \" expertise_info_status \" ></div> \n " ;
2004-12-19 23:16:46 +00:00
2009-09-09 00:26:12 +00:00
if ( $u [ 'special_award_only' ] == 'yes' ) {
2007-01-30 06:12:11 +00:00
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 " );
2009-11-26 19:09:37 +00:00
echo " <br /><h4> " . i18n ( " Age Category Preferences " ) . " </h4><br> " ;
echo " <table class= \" editor \" style= \" width: 300px; \" > " ;
2007-01-30 06:12:11 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
2009-10-01 04:42:55 +00:00
echo " <tr><td class= \" label \" > " ;
2007-01-30 06:12:11 +00:00
echo i18n ( " %1 (Grades %2-%3) " , array ( i18n ( $r -> category ), $r -> mingrade , $r -> maxgrade ));
2009-09-26 20:24:38 +00:00
echo " :</td> " ;
2007-01-30 06:12:11 +00:00
echo " <td> " ;
echo " <select name= \" catpref[ $r->id ] \" > " ;
echo " <option value= \" \" > " . i18n ( " Choose " ) . " </option> \n " ;
foreach ( $preferencechoices AS $val => $str )
{
2009-09-09 00:26:12 +00:00
if ( $u [ 'cat_prefs' ][ $r -> id ] == $val && $u [ 'cat_prefs' ][ $r -> id ] != " " )
$sel = " selected= \" selected \" " ;
else
$sel = " " ;
2007-01-30 06:12:11 +00:00
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> " ;
2007-01-30 06:12:11 +00:00
2004-12-19 23:16:46 +00:00
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 /> " ;
2006-12-15 21:18:27 +00:00
echo i18n ( " Once you save, any division that you specified as 3 or more might offer sub-divisions for you to choose from. " );
2004-12-20 19:46:08 +00:00
echo " <br /> " ;
echo " <br /> " ;
2004-12-19 23:16:46 +00:00
2009-09-26 20:24:38 +00:00
echo " <table> \n " ;
2004-12-19 23:16:46 +00:00
//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 " );
2009-09-09 00:26:12 +00:00
$first = true ;
while ( $r = mysql_fetch_object ( $q )) {
$trclass = ( $trclass == 'odd' ) ? 'even' : 'odd' ;
if ( $first == true ) {
2010-07-09 18:36:30 +00:00
echo " <tr><td></td><td colspan= \" 3 \" > " . i18n ( " Novice " ) . " </td><td colspan= \" 3 \" align= \" right \" > " . i18n ( " Expert " ) . " </td></tr> " ;
2009-09-09 00:26:12 +00:00
echo " <tr><th></th> " ;
for ( $x = 1 ; $x <= 5 ; $x ++ )
echo " <th> $x </th> " ;
2010-07-09 18:36:30 +00:00
echo " <th></th> " ;
2009-09-09 00:26:12 +00:00
echo " </tr> " ;
$first = false ;
}
2004-12-20 19:46:08 +00:00
2009-09-09 00:26:12 +00:00
echo " <tr class= \" $trclass\ " >< td >< b > " .i18n( $r->division ). " </ b ></ td > " ;
2004-12-19 23:16:46 +00:00
2009-09-09 00:26:12 +00:00
for ( $x = 1 ; $x <= 5 ; $x ++ ) {
$sel = ( $u [ 'div_prefs' ][ $r -> id ] == $x ) ? " checked= \" checked \" " : '' ;
2005-02-21 23:07:10 +00:00
echo " <td width= \" 30 \" ><input onclick= \" fieldChanged() \" $sel type= \" radio \" name= \" division[ $r->id ] \" value= \" $x\ " /></ td > " ;
2004-12-19 23:16:46 +00:00
}
2010-07-09 18:36:30 +00:00
echo " <td> " . REQUIREDFIELD . " </td> " ;
2009-09-26 20:24:38 +00:00
// echo "<td width=\"100\"></td>";
2004-12-19 23:16:46 +00:00
echo " </tr> " ;
2004-12-20 19:46:08 +00:00
2004-12-20 19:48:13 +00:00
//only show the sub-divisions if the 'main' division is scored >=3
2009-09-09 00:26:12 +00:00
if ( $u [ 'div_prefs' ][ $r -> id ] >= 3 ) {
2004-12-20 19:46:08 +00:00
2006-02-07 20:54:30 +00:00
$subq = mysql_query ( " SELECT * FROM projectsubdivisions WHERE projectdivisions_id=' $r->id ' AND year=' " . $config [ 'FAIRYEAR' ] . " ' ORDER BY subdivision " );
2009-09-09 00:26:12 +00:00
while ( $subr = mysql_fetch_object ( $subq )) {
2004-12-20 19:46:08 +00:00
echo " <tr> " ;
echo " <td> </td> " ;
2009-09-09 00:26:12 +00:00
$ch = ( $u [ 'div_prefs_sub' ][ $subr -> id ]) ? " checked= \" checked \" " : '' ;
2004-12-20 19:46:08 +00:00
2005-02-21 23:07:10 +00:00
echo " <td><input onclick= \" fieldChanged() \" $ch type= \" checkbox \" name= \" subdivision[ $subr->id ] \" value= \" 1 \" /></td> " ;
2005-02-11 18:25:59 +00:00
echo " <td colspan= \" 5 \" > " ;
2004-12-20 19:46:08 +00:00
echo " $subr->subdivision " ;
echo " </td> " ;
echo " </tr> " ;
}
}
2004-12-19 23:16:46 +00:00
}
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 />
2004-12-19 23:16:46 +00:00
2009-09-26 20:24:38 +00:00
< input type = " submit " onclick = " judgeexpertise_save();return false; " value = " <?=i18n( " Save Judging Preferences " )?> " />
</ form >
2004-12-19 23:16:46 +00:00
2009-09-26 20:24:38 +00:00
< ?
2009-09-09 00:26:12 +00:00
if ( $_SESSION [ 'embed' ] != true ) send_footer ();
2004-12-19 23:16:46 +00:00
?>