]> git.sesse.net Git - ccbs/commitdiff
Don't show the "start next round" form until we can actually do so.
authorSteinar H. Gunderson <sesse@samfundet.no>
Wed, 16 Feb 2005 15:32:17 +0000 (15:32 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Wed, 16 Feb 2005 15:32:17 +0000 (15:32 +0000)
html/show-tournament.pl
html/templates/show-tournament.tmpl

index 66045290975b347a0b33b8f458595be924846429..01c301e4f0f2b833ae9791611950699b54203e59 100755 (executable)
@@ -13,6 +13,16 @@ my $tournament = $dbh->selectrow_hashref('SELECT * FROM tournaments NATURAL JOIN
 my $rankings = ccbs::db_fetch_all($dbh, 'SELECT ranking,nick,COALESCE(points,-1) AS points FROM tournamentrankings NATURAL JOIN players WHERE tournament=? ORDER BY ranking', $id);
 my $songs = ccbs::db_fetch_all($dbh, 'SELECT song,title FROM machinesongs NATURAL JOIN songs WHERE machine=? ORDER BY LOWER(title)', $tournament->{'machine'});
 
 my $rankings = ccbs::db_fetch_all($dbh, 'SELECT ranking,nick,COALESCE(points,-1) AS points FROM tournamentrankings NATURAL JOIN players WHERE tournament=? ORDER BY ranking', $id);
 my $songs = ccbs::db_fetch_all($dbh, 'SELECT song,title FROM machinesongs NATURAL JOIN songs WHERE machine=? ORDER BY LOWER(title)', $tournament->{'machine'});
 
+# Check if the last round is valid for closing (by checking if all scores
+# entered are valid)
+my $ref = $dbh->selectrow_hashref('SELECT COUNT(*) AS num_incomplete FROM scores WHERE tournament=? AND (song IS NULL OR playmode IS NULL OR difficulty IS NULL OR chosen IS NULL or score IS NULL)', undef, $tournament->{'tournament'});
+my $closing_valid;
+if ($ref->{'num_incomplete'} == 0) {
+       $closing_valid = 1;
+} else {
+       $closing_valid = 0;
+}
+
 # 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,
 # 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,
@@ -87,6 +97,7 @@ ccbs::process_template('show-tournament.tmpl', $tournament->{'tournamentname'},
        rounds => \@rounds,
        num_rounds => $num_rounds,
        num_qualified => $num_qualified,
        rounds => \@rounds,
        num_rounds => $num_rounds,
        num_qualified => $num_qualified,
-       songs => $songs
+       songs => $songs,
+       closing_valid => $closing_valid
 });
 $dbh->disconnect;
 });
 $dbh->disconnect;
index 56027a5dbd0e5501925ed7c612fd41dd827c5300..d66aa20079d6041a8a9cbf77098433e9898e3622 100644 (file)
@@ -12,6 +12,7 @@
     </ul>
   </div>
 
     </ul>
   </div>
 
+[% IF closing_valid %]
   <h2>Start ny runde</h2>
 
   <div>
   <h2>Start ny runde</h2>
 
   <div>
@@ -51,6 +52,7 @@
       </table>
     </form>
   </div>
       </table>
     </form>
   </div>
+[% END %]
 
 [% IF num_rankings > 0 %]
   <h2>Rankingliste</h2>
 
 [% IF num_rankings > 0 %]
   <h2>Rankingliste</h2>