]> git.sesse.net Git - ccbs/commitdiff
Add headings to the score display.
authorSteinar H. Gunderson <sesse@samfundet.no>
Mon, 14 Feb 2005 01:27:05 +0000 (01:27 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Mon, 14 Feb 2005 01:27:05 +0000 (01:27 +0000)
html/show-tournament.pl
html/templates/show-tournament.tmpl

index 999ea107bf0d017109e1ddcfc1f7b360342ea3cf..c359511e54b6b332d76ef899b44f1072cff2e987 100755 (executable)
@@ -14,7 +14,7 @@ my $tournament = $dbh->selectrow_hashref('SELECT * FROM tournaments WHERE tourna
 # Swoop all the data in in a big join, then order it over to quasi-sane Perl objects.
 # (round -> parallel -> player -> songs -> title,chosen,score)
 my $scores = ccbs::db_fetch_all($dbh,
-       'SELECT round,parallel,nick,title,chosen,score FROM scores NATURAL JOIN players NATURAL JOIN songs NATURAL JOIN roundparticipation WHERE tournament=? ORDER BY round,parallel,position,songnumber',
+       'SELECT round,parallel,position,nick,title,chosen,score FROM scores NATURAL JOIN players NATURAL JOIN songs NATURAL JOIN roundparticipation WHERE tournament=? ORDER BY round,parallel,position,songnumber',
        $id);
 
 my @rounds = ();
@@ -29,13 +29,26 @@ for my $score (@$scores) {
        my $p = $rounds[$#rounds]->{'parallels'};
        if ($score->{'parallel'} != $parallel) {
                $parallel = $score->{'parallel'};
-               push @$p, { parallel => $parallel, players => [] };
+               push @$p, { parallel => $parallel, players => [], songs => [] };
                $player = '';
+
+               # Information on songs is not selected from roundrandomsongs etc.,
+               # but is filled in the first time the song is seen for this round
+               # (ie. below)
+       }
+       if ($score->{'position'} == 1) {
+               if ($score->{'chosen'}) {
+                       push @{$p->[$#$p]->{'songs'}}, '';
+               } else {
+                       push @{$p->[$#$p]->{'songs'}}, $score->{'title'};
+               }
        }
+       
        my $pl = $p->[$#$p]->{'players'};
        if ($score->{'nick'} ne $player) {
                $player = $score->{'nick'};
                push @$pl, { nick => $player, songs => [] };
+
        }
        
        push @{$pl->[$#$pl]->{'songs'}}, {
index b17b39b99b2d2b804a2330252ac4e71fdf145e8c..df259eff291a6726fbe6da42327cbfd00443e494 100644 (file)
@@ -3,11 +3,18 @@
   <h2>Runde [% r.round %]</h2>
 
 [% FOR p = r.parallels %]
-[% IF p.parallel != 0 %]
-  <h3>Gruppe [% p.parallel %]</h3>
-[% END %]
-
   <table>
+    <tr>
+[% IF p.parallel == 0 %]
+      <th></th>
+[% ELSE %]
+      <th>Gruppe [% p.parallel %]</th>
+[% END %]
+[% FOR s = p.songs %]
+      <th>[% s %]</th>
+[% END %]
+    </tr>
+    
 [% FOR pl = p.players %]
     <tr>
       <th>[% pl.nick %]</th>