if ($Gruntmaster::Data::contest) {
$tries{job_user()}{job_problem()}++;
$scores{job_user()}{job_problem()} = job_result() ? 0 : calc_score (job_user(), job_problem(), job_date(), $tries{job_user()}{job_problem()}, $totaltime) if job_date() > $start;
- } else {
- if (job_result_text =~ m/^(\scores+)/) {
+ } elsif (defined job_user && defined job_problem && defined job_result) {
+ if (defined job_result_text && job_result_text =~ m/^(\scores+)/) {
$scores{job_user()}{job_problem()} = $ct;
} else {
$scores{job_user()}{job_problem()} = job_result() ? 0 : 100;
}
}
- my @st = sort { $b->{score} <=> $a->{score} } map {
+ my @st = sort { $b->{score} <=> $a->{score} or $a->{user} cmp $b->{user}} map {
my $user = $_;
+{
user => $user,
problems => $Gruntmaster::Data::contest,
}
} keys %scores;
+
+ $st[0]->{rank} = 1;
+ $st[$_]->{rank} = $st[$_ - 1]->{rank} + ($st[$_]->{score} < $st[$_ - 1]->{score}) for 1 .. $#st;
$htc->param(problems => [map { problem_name } @problems ]) if $Gruntmaster::Data::contest;
$htc->param(st => \@st);
}
<table border class="table table-border table-striped">
<thead>
-<tmpl_if problems><tr><th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total
-<tmpl_else><tr><th>Username<th>Score
+<tmpl_if problems><tr><th>Rank<th>Username<tmpl_loop problems><th><tmpl_var _></tmpl_loop><th>Total
+<tmpl_else><tr><th>Rank<th>Username<th>Score
</tmpl_if>
<tbody>
-<tmpl_loop st><tr><td><tmpl_var user>
+<tmpl_loop st><tr><td><tmpl_var rank><td><tmpl_var user>
<tmpl_if problems><tmpl_loop scores><td><tmpl_var _>
</tmpl_loop></tmpl_if><td><tmpl_var score>
</tmpl_loop>