- Judge timeslot selection page, default: disabled. The scheduler doesn't use

it yet, but here it is.
This commit is contained in:
dave 2009-02-09 07:09:09 +00:00
parent e508efece9
commit c158b9aad1
7 changed files with 186 additions and 8 deletions

View File

@ -31,32 +31,37 @@ $tabs = array('personal' => array(
'name' => 'Personal', 'name' => 'Personal',
'types' => array('student','judge','committee','volunteer','sponsor'), 'types' => array('student','judge','committee','volunteer','sponsor'),
'file' => '../user_personal.php', 'file' => '../user_personal.php',
), 'enabled' => true),
'roles' => array( 'roles' => array(
'name' => 'Roles/Account', 'name' => 'Roles/Account',
'types' => array('student','judge','committee','volunteer','sponsor'), 'types' => array('student','judge','committee','volunteer','sponsor'),
'file' => '../user_activate.php', 'file' => '../user_activate.php',
), 'enabled' => true),
'judgeother' => array( 'judgeother' => array(
'name' => 'Judge Other', 'name' => 'Judge Other',
'types' => array('judge'), 'types' => array('judge'),
'file' => '../judge_other.php', 'file' => '../judge_other.php',
), 'enabled' => true),
'judgeexpertise' => array( 'judgeexpertise' => array(
'name' => 'Expertise', 'name' => 'Expertise',
'types' => array('judge'), 'types' => array('judge'),
'file' => '../judge_expertise.php', 'file' => '../judge_expertise.php',
), 'enabled' => true),
'judgeavailability' => array(
'name' => 'Time Avail.',
'types' => array('judge'),
'file' => '../judge_availability.php',
'enabled' => $config['judges_availability_enable'] == 'yes' ? true : false),
'judgesa' => array( 'judgesa' => array(
'name' => 'Special Awards', 'name' => 'Special Awards',
'types' => array('judge'), 'types' => array('judge'),
'file' => '../judge_special_awards.php', 'file' => '../judge_special_awards.php',
), 'enabled' => true,),
'volunteerpos' => array( 'volunteerpos' => array(
'name' => 'Volunteer Positions', 'name' => 'Volunteer Positions',
'types' => array('volunteer'), 'types' => array('volunteer'),
'file' => '../volunteer_position.php', 'file' => '../volunteer_position.php',
), 'enabled' => true,),
); );
@ -90,8 +95,12 @@ send_popup_header(i18n("User Editor").": {$u['name']}");
echo '<ul id="htabs">'; echo '<ul id="htabs">';
foreach($tabs as $k=>$t) { foreach($tabs as $k=>$t) {
/* Make sure the tab is enabled */
if($t['enabled'] == false) continue;
/* Make sure the user has the right type to see the tab */
$i = array_intersect($t['types'], $u['types']); $i = array_intersect($t['types'], $u['types']);
if(count($i) == 0) continue; if(count($i) == 0) continue;
/* Show the tab */
$sel = ($selected == $k) ? 'htabsel' : ''; $sel = ($selected == $k) ? 'htabsel' : '';
$href = "$PHP_SELF?id=$id&tab=$k"; $href = "$PHP_SELF?id=$id&tab=$k";
echo "<li class=\"$sel\"><a href=\"$href\">".i18n($t['name'])."</a></li>"; echo "<li class=\"$sel\"><a href=\"$href\">".i18n($t['name'])."</a></li>";

View File

@ -57,7 +57,7 @@ function openeditor(id)
{ {
if(id) currentid=id; if(id) currentid=id;
window.open("user_editor_window.php?id="+currentid,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes"); window.open("user_editor_window.php?id="+currentid,"User Editor","location=no,menubar=no,directories=no,toolbar=no,width=1000,height=640,scrollbars=yes");
return false; return false;
} }

View File

@ -1 +1 @@
123 124

11
db/db.update.124.sql Normal file
View File

@ -0,0 +1,11 @@
CREATE TABLE `judges_availability` (
`id` INT NOT NULL AUTO_INCREMENT ,
`users_id` INT NOT NULL ,
`date` DATE NOT NULL ,
`start` TIME NOT NULL ,
`end` TIME NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM ;
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `year`)
VALUES ( 'judges_availability_enable', 'no', 'Judge Registration', 'yesno', '', '950', 'Allow judges to specify their time availability on the fair day based on the defined judging rounds/timeslots. The scheduler will then use this judge availability data when assigning judges to teams and projects.', '-1');

View File

@ -5,6 +5,7 @@
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org> Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org> Copyright (C) 2005 James Grant <james@lightbox.org>
Copyright (C) 2009 David Grant <dave@lightbox.org>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public modify it under the terms of the GNU General Public
@ -100,6 +101,17 @@ function judge_status_special_awards(&$u)
return 'incomplete'; return 'incomplete';
} }
function judge_status_availability(&$u)
{
global $config;
if($config['judges_availability_enable'] == 'no') return 'complete';
$q = mysql_query("SELECT id FROM judges_availability
WHERE users_id=\"{$u['id']}\"");
if(mysql_num_rows($q) > 0) return 'complete';
return 'incomplete';
}
function judge_status_update(&$u) function judge_status_update(&$u)
{ {
@ -108,6 +120,7 @@ function judge_status_update(&$u)
if( user_personal_info_status($u) == 'complete' if( user_personal_info_status($u) == 'complete'
&& judge_status_expertise($u) == 'complete' && judge_status_expertise($u) == 'complete'
&& judge_status_other($u) == 'complete' && judge_status_other($u) == 'complete'
&& judge_status_availability($u) == 'complete'
&& judge_status_special_awards($u) == 'complete') && judge_status_special_awards($u) == 'complete')
$u['judge_complete'] = 'yes'; $u['judge_complete'] = 'yes';
else else

140
judge_availability.php Normal file
View File

@ -0,0 +1,140 @@
<?
/*
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>
Copyright (C) 2009 David Grant <dave@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');
if($_SESSION['embed'] == true) {
user_auth_required('committee');
$u = user_load($_SESSION['embed_edit_id']);
} else {
user_auth_required('judge');
$u = user_load($_SESSION['users_id']);
}
$times = array();
/* Load the judging rounds */
$q = mysql_query("SELECT date,starttime,endtime,name FROM judges_timeslots WHERE round_id='0' AND year='{$config['FAIRYEAR']}' ORDER BY starttime,type");
$x = 0;
while($r = mysql_fetch_object($q)) {
$found = false;
foreach($times as $xx => $t) {
if($t['date'] == $r->date && $t['starttime'] == $r->starttime && $t['endtime'] == $r->endtime) {
$times[$xx]['name'] .= ", {$r->name}";
$found = true;
break;
}
}
if(!$found) {
$times[$x] = array( 'date' => $r->date,
'starttime' => $r->starttime,
'endtime' => $r->endtime,
'name' => $r->name);
$x++;
}
}
if($_POST['action']=='save') {
mysql_query("DELETE FROM judges_availability WHERE users_id='{$u['id']}'");
if(is_array($_POST['time']) ) {
foreach($_POST['time'] as $x) {
if(trim($times[$x]['starttime']) == '') continue;
mysql_query("INSERT INTO judges_availability (users_id, `date`,`start`,`end`)
VALUES ('{$u['id']}',
'{$times[$x]['date']}',
'{$times[$x]['starttime']}','{$times[$x]['endtime']}')");
}
}
message_push(notice(i18n("Time Availability preferences successfully saved")));
}
if($_SESSION['embed'] == true) {
echo "<br />";
display_messages();
echo "<h3>".i18n('Time Availability')."</h3>";
echo "<br />";
} else {
//send the header
send_header('Time Availability',
array('Judge Registration' => 'judge_main.php')
);
}
judge_status_update($u);
if($_SESSION['embed'] != true) {
//output the current status
$newstatus=judge_status_availability($u);
if($newstatus!='complete')
echo error(i18n("Time Availability Preferences Incomplete"));
else
echo happy(i18n("Time Availability Preferences Complete"));
}
$url = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'judge_availability.php';
echo "<form name=\"availabilityform\" method=\"post\" action=\"$url\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "<br />";
/* Get all their available times */
$q = mysql_query("SELECT * FROM judges_availability WHERE users_id=\"{$u['id']}\" ORDER BY `start`");
$sel = array();
while($r=mysql_fetch_object($q)) {
foreach($times as $x=>$t) {
if($r->start == $t['starttime'] && $r->end == $t['endtime'] && $r->date == $t['date']) {
$sel[$x] = true;
}
}
}
echo "<table>\n";
foreach($times as $x=>$t) {
$ch = $sel[$x] == true ? 'checked="checked"' : '';
echo "<tr><td>";
echo "<input onclick=\"checkboxclicked(this)\" $ch type=\"checkbox\" name=\"time[]\" value=\"$x\" />";
$st = substr($t['starttime'], 0, 5);
$end = substr($t['endtime'], 0, 5);
echo "</td><td><b>{$times[$x]['date']} $st - $end</b></td>";
echo "<td>{$t['name']}</td>";
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo "<br />";
echo "<input type=\"submit\" value=\"".i18n("Save Time Availability Preferences")."\" />\n";
echo "</form>";
if($_SESSION['embed'] != true) send_footer();
?>

View File

@ -65,6 +65,11 @@
user_page_summary_item("Areas of Expertise", user_page_summary_item("Areas of Expertise",
"judge_expertise.php", "judge_status_expertise", array($u)); "judge_expertise.php", "judge_status_expertise", array($u));
if($config['judges_availability_enable'] == 'yes') {
user_page_summary_item("Time Availability",
"judge_availability.php", "judge_status_availability", array($u));
}
if($config['judges_specialaward_enable'] == 'yes' || $u['special_award_only'] == 'yes') { if($config['judges_specialaward_enable'] == 'yes' || $u['special_award_only'] == 'yes') {
user_page_summary_item("Special Award Preferences", user_page_summary_item("Special Award Preferences",
"judge_special_awards.php", "judge_status_special_awards", array($u)); "judge_special_awards.php", "judge_status_special_awards", array($u));