This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathteam_overview.php
141 lines (109 loc) · 6.82 KB
/
team_overview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php /* begin license *
*
* Tabbie, Debating Tabbing Software
* Copyright Contributors
*
* This file is part of Tabbie
*
* Tabbie 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; either version 2 of the License, or
* (at your option) any later version.
*
* Tabbie 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 Tabbie; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* end license */
require_once("includes/backend.php");
$ntu_controller = "print"; #selected in menu
$moduletype="";
$team_id = @$_REQUEST['team_id'];
if ($team_id) {
$team_name = team_name_long($team_id);
$db_result = qp("SELECT S1.speaker_name AS speaker1, S2.speaker_name AS speaker2 FROM team AS T, speaker AS S1, speaker AS S2 WHERE T.team_id = ? AND S1.team_id=T.team_id AND S2.team_id=T.team_id AND S1.speaker_id<S2.speaker_id", array($team_id));
$row = $db_result->FetchRow();
$speakers = "{$row['speaker1']} and {$row['speaker2']}";
$title = "Team Overview for $team_name ($speakers)";
}
else
$title = "Team Overview - Select Team";
require("view/header.php");
require("view/mainmenu.php");
require_once("includes/backend.php");
require_once("includes/teamstanding.php");
if (!$team_id) {
print "<h2>Team Overview</h2><ul>";
$db_result = q(
"SELECT T.team_id, univ_code, team_code, univ_name, S1.speaker_name " .
"AS speaker1, S2.speaker_name AS speaker2, esl, active, composite " .
"FROM university AS U, team AS T, speaker AS S1, speaker AS S2 " .
"WHERE T.univ_id=U.univ_id AND S1.team_id=T.team_id AND " .
"S2.team_id=T.team_id AND S1.speaker_id<S2.speaker_id " .
"ORDER BY univ_code, team_code ");
while ($row = $db_result->FetchRow()) {
print "<li><a href=\"team_overview.php?team_id={$row['team_id']}\">{$row['univ_code']} {$row['team_code']} ({$row['speaker1']} and {$row['speaker2']})</a></li>";
}
print "</ul>";
} else {
print "<h2>Team Overview for team " . $team_name . "</h2>";
print "Speakers: $speakers";
$completed_rounds = get_num_completed_rounds();
$round_standing = 1; //Before round 1, defines variable
$final_standing = team_standing_array($completed_rounds);
for ($round = 1; $round <= $completed_rounds; $round++) {
$prev_round_standing = @$round_standing;
$round_standing = team_standing_array($round);
$motion = get_motion_for_round($round) ? get_motion_for_round($round) : "(Unknown)";
print "<h2>Round $round</h2>";
print "<h3>Motion: $motion</h3>";
$db_result = qp(
"SELECT debate_id AS debate_id, T1.team_id AS ogid, T2.team_id AS ooid, T3.team_id AS cgid, T4.team_id AS coid, T1.team_code AS ogt, T2.team_code AS oot, T3.team_code AS cgt, T4.team_code AS cot, U1.univ_code AS ogtc, U2.univ_code AS ootc, U3.univ_code AS cgtc, U4.univ_code AS cotc, venue_name, venue_location FROM draws D, team T1, team T2, team T3, team T4, university U1, university U2, university U3, university U4,venue WHERE D.round_no=? AND og = T1.team_id AND oo = T2.team_id AND cg = T3.team_id AND co = T4.team_id AND T1.univ_id = U1.univ_id AND T2.univ_id = U2.univ_id AND T3.univ_id = U3.univ_id AND T4.univ_id = U4.univ_id AND D.venue_id=venue.venue_id AND (og=? OR oo=? OR cg=? OR co=?)", array($round, $team_id, $team_id, $team_id, $team_id));
if ($db_result->RecordCount() == 0) {
print "<h3>Team did not participate in this round</h3>";
} else {
$row = $db_result->FetchRow();
$debate_id = $row['debate_id'];
print "<h3>Venue: {$row['venue_name']} ({$row['venue_location']})</h3>";
print "<h3>Teams:</h3>";
print "<table><tr><th>Role</th><th>Team</th><th>Ranking</th><th>Points</th><th>Before Round $round</th><th>After Round $round</th><th>After Round $completed_rounds</th></tr>";
foreach (array('og' => 'Opening Government', 'oo' => 'Opening Opposition', 'cg' => 'Closing Government', 'co' => 'Closing Opposition') as $short => $long) {
$id = $row["{$short}id"];
$name = $row["{$short}tc"] . " " . $row["{$short}t"];
$ranking = ranking_for_team_in_round($id, $round);
$points = points_for_ranking($ranking);
$ranking = ucwords($ranking);
if ($round == 1)
$before = "1st (0 points, 0 speaks)";
else
$before = team_standing_for_team($prev_round_standing, $id);
$after = team_standing_for_team($round_standing, $id);
$final = team_standing_for_team($final_standing, $id);
print "<tr><td>$long</td><td><a href=\"team_overview.php?team_id=$id\">$name</a></td><td>$ranking</td><td>$points</td><td>$before</td><td>$after</td><td>$final</td></tr>";
}
print "</table>";
print "<h3>Speakers:</h3>";
$db_result = qp("SELECT SR.points, speaker.speaker_name, university.univ_code, team.team_code FROM speaker_results SR, speaker, team, university WHERE SR.round_no=? AND debate_id=? AND SR.speaker_id = speaker.speaker_id AND speaker.team_id = team.team_id AND team.univ_id = university.univ_id ORDER BY speaker_name", array($round, $debate_id));
print "<table><tr><th>Name</th><th>Team</th><th>Points</th></tr>";
while ($row = $db_result->FetchRow()) {
print "<tr><td>{$row['speaker_name']}</td><td>{$row['univ_code']} {$row['team_code']}</td><td>{$row['points']}</td></tr>";
}
print "</table>";
print "<h3>Adjudicators:</h3>";
$db_result = qp("SELECT draw_adjud.status, adjudicator.adjud_name, university.univ_name, university.univ_code FROM draw_adjud, adjudicator, university WHERE draw_adjud.round_no=? AND debate_id=? AND draw_adjud.adjud_id = adjudicator.adjud_id AND adjudicator.univ_id = university.univ_id ORDER BY status", array($round, $debate_id));
print "<table><tr><th>Role</th><th>Name</th><th>University</th></tr>";
while ($row = $db_result->FetchRow()) {
$role = ucwords($row['status']);
print "<tr><td>$role</td><td>{$row['adjud_name']}</td><td>{$row['univ_name']} ({$row['univ_code']})</td></tr>";
}
print "</table>";
}
}
}
require("view/footer.php");
?>