my $ref = $dbh->selectrow_hashref('SELECT * FROM songs ORDER BY random() LIMIT 1');
$dbh->do('INSERT INTO roundrandomsongs (tournament, round, parallel, song) VALUES (?,?,?,?)',
undef, $tournament, $round, $g, $ref->{'song'});
+
+ $dbh->do('INSERT INTO scores SELECT tournament,round,parallel,player,?,?,NULL,NULL,\'f\',NULL FROM roundparticipation WHERE tournament=? AND round=? AND parallel=?', undef,
+ $s, $ref->{'song'}, $tournament, $round, $g);
+ }
+}
+
+# Add empty "score" records for the chosen songs.
+for my $g (1..$num_groups) {
+ for my $s (1..$num_chosen) {
+ $dbh->do('INSERT INTO scores SELECT tournament,round,parallel,player,?,NULL,NULL,NULL,\'t\',NULL FROM roundparticipation WHERE tournament=? AND round=? AND parallel=?', undef,
+ $s + $num_random, $tournament, $round, $g);
}
}