--- /dev/null
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+my $cgi = new CGI;
+my $machine = $cgi->param('machine');
+
+my $dbh = ccbs::db_connect();
+
+my $songs_raw = ccbs::db_fetch_all($dbh, 'SELECT song,title,playmode,difficulty,feetrating FROM songratings NATURAL JOIN songs WHERE machine=? ORDER BY machine,song', $machine);
+
+my @songs = ();
+
+my $last_song = -1;
+my $show_challenge = 0;
+for my $song (@$songs_raw) {
+ if ($song->{'song'} != $last_song) {
+ push @songs, { song => $song->{'song'}, title => $song->{'title'} };
+ }
+
+ my $key = $song->{'playmode'} . '_' . $song->{'difficulty'};
+ $songs[$#songs]->{$key} = $song->{'feetrating'};
+ $last_song = $song->{'song'};
+
+ $show_challenge = 1 if ($song->{'difficulty'} eq 'challenge');
+}
+
+ccbs::print_header();
+ccbs::process_template('songratings.tmpl', 'Sanger', {
+ songs => \@songs,
+});
+$dbh->disconnect;
--- /dev/null
+[%# vim:set filetype=html: %]
+
+ <div>
+ <table class="scores">
+ <tr>
+ <th></th>
+[% IF show_challenge %]
+ <th colspan="5">Single</th>
+ <th colspan="4">Double</th>
+[% ELSE %]
+ <th colspan="4">Single</th>
+ <th colspan="3">Double</th>
+[% END %]
+ </tr>
+ <tr>
+ <th>Sang</th>
+ <th>B</th>
+ <th>S</th>
+ <th>D</th>
+ <th>E</th>
+[% IF show_challenge %]
+ <th>C</th>
+[% END %]
+ <th>S</th>
+ <th>D</th>
+ <th>E</th>
+[% IF show_challenge %]
+ <th>C</th>
+[% END %]
+ </tr>
+[% FOR s = songs %]
+ <tr>
+ <td><a href="song.pl?id=[% s.song %]">[% s.title %]</a></td>
+ <td>[% s.single_beginner %]</td>
+ <td>[% s.single_standard %]</td>
+ <td>[% s.single_difficult %]</td>
+ <td>[% s.single_expert %]</td>
+[% IF show_challenge %]
+ <td>[% s.single_challenge %]</td>
+[% END %]
+ <td>[% s.double_standard %]</td>
+ <td>[% s.double_difficult %]</td>
+ <td>[% s.double_expert %]</td>
+[% IF show_challenge %]
+ <td>[% s.double_challenge %]</td>
+[% END %]
+ </tr>
+[% END %]
+ </table>
+ </div>