- Unclutter the judge query

- Add project info, timeslots, and students to the judge query.
This commit is contained in:
dave 2007-12-22 21:50:25 +00:00
parent edf26caf1e
commit 0b782d467d

View File

@ -134,7 +134,71 @@ $report_judges_fields = array(
'width' => 0.5,
'table' => 'judges.complete',
'value_map' => array ('no' => 'No', 'yes' => 'Yes')),
'project_pn' => array(
'name' => 'Project -- Number',
'header' => 'Number',
'width' => 0.5,
'table' => 'projects.projectnumber',
'components' => array('teams', 'projects')),
'project_title' => array(
'name' => 'Project -- Title',
'header' => 'Project',
'width' => 3,
'table' => 'projects.title',
'components' => array('teams', 'projects')),
'project_summary' => array(
'name' => 'Project -- Summary',
'header' => 'Summary',
'width' => 5,
'table' => 'projects.summary',
'components' => array('teams', 'projects')),
'project_language' => array(
'name' => 'Project -- Language',
'header' => 'Lang',
'width' => 0.4,
'table' => 'projects.language',
'components' => array('teams', 'projects')),
'project_students' => array(
'name' => 'Project -- Student Name(s) (REQUIRES MYSQL 5.0) ',
'header' => 'Student(s)',
'width' => 3.0,
'table' => "GROUP_CONCAT(students.firstname, ' ', students.lastname ORDER BY students.lastname SEPARATOR ', ')",
'group_by' => array('judges.id','judges_teams_timeslots_projects_link.id'),
'components' => array('teams', 'projects', 'students')),
'project_timeslot_start' => array(
'name' => 'Project -- Timeslot Start Time (HH:MM)',
'header' => 'Start',
'width' => 0.75,
'table' => "TIME_FORMAT(judges_timeslots.starttime,'%H:%i')",
'components' => array('teams', 'projects')),
'project_timeslot_end ' => array(
'name' => 'Project -- Timeslot End Time (HH:MM)',
'header' => 'End',
'width' => 0.75,
'table' => "TIME_FORMAT(judges_timeslots.endtime,'%H:%i')",
'components' => array('teams', 'projects')),
'project_timeslot' => array(
'name' => 'Project -- Timeslot Start - End (HH:MM - HH:MM)',
'header' => 'Timeslot',
'width' => 1.5,
'table' => "CONCAT(TIME_FORMAT(judges_timeslots.starttime,'%H:%i'),'-',TIME_FORMAT(judges_timeslots.endtime,'%H:%i'))",
'components' => array('teams', 'projects')),
'project_timeslot_date' => array(
'name' => 'Project -- Timeslot Date - (YYYY-MM-DD)',
'header' => 'Timeslot Date',
'width' => 1,
'table' => "judges_timeslots.date",
'components' => array('teams', 'projects')),
'static_text' => array(
'name' => 'Static Text (useful for labels)',
'header' => '',
@ -150,32 +214,51 @@ $report_judges_fields = array(
$fields = $report_judges_fields;
$year = $report['year'];
/* For now languages is a module, doesn't duplicate rows, but it requries mysql 5 for
* a GROUP_CONCAT */
$languages_from = '';
$languages_where = '';
if(in_array('languages', $components)) {
$languages_from = ', judges_languages';
$languages_where = 'AND judges_languages.judges_id=judges.id';
$languages_from = 'LEFT JOIN judges_languages ON judges_languages.judges_id=judges.id';
}
$teams_from = '';
$teams_where = '';
if(in_array('teams', $components)) {
$teams_from = ",judges_teams_link, judges_teams";
$teams_where = "AND judges_teams_link.judges_id=judges.id
AND judges_teams_link.year='$year'
AND judges_teams.id=judges_teams_link.judges_teams_id
$teams_from = "LEFT JOIN judges_teams_link ON judges_teams_link.judges_id=judges.id
LEFT JOIN judges_teams ON judges_teams.id=judges_teams_link.judges_teams_id";
$teams_where = "AND judges_teams_link.year='$year'
AND judges_teams.year='$year'";
}
$projects_from='';
$projects_where='';
if(in_array('projects', $components)) {
$projects_from = "LEFT JOIN judges_teams_timeslots_projects_link ON
judges_teams_timeslots_projects_link.judges_teams_id=judges_teams.id
LEFT JOIN projects ON projects.id=judges_teams_timeslots_projects_link.projects_id
LEFT JOIN judges_timeslots ON judges_timeslots.id=judges_teams_timeslots_projects_link.judges_timeslots_id";
$projects_where = "AND judges_teams_timeslots_projects_link.year='$year'
AND projects.year='$year'";
}
$students_from='';
$students_where='';
if(in_array('students', $components)) {
$students_from = "LEFT JOIN students ON students.registrations_id=projects.registrations_id";
$students_where = "AND students.year='$year'";
}
$q = " FROM
judges, judges_years
$teams_from
$q = " FROM judges
LEFT JOIN judges_years ON judges_years.judges_id = judges.id
$languages_from
$teams_from
$projects_from
$students_from
WHERE
judges_years.judges_id = judges.id
AND judges_years.year='$year'
judges_years.year='$year'
$teams_where
$languages_where
$projects_where
$students_where
";
return $q;