From 7238470290c419a79a27a9c41ce52e4e7611cbf0 Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 3 Jul 2017 20:57:18 +0800 Subject: [PATCH] Fix different rank with same score in contest ranklist --- views/contest_ranklist.ejs | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/views/contest_ranklist.ejs b/views/contest_ranklist.ejs index b93d3aa..319975f 100644 --- a/views/contest_ranklist.ejs +++ b/views/contest_ranklist.ejs @@ -46,35 +46,44 @@ problem.min = minPos; } - let i = 0; + let i = 0, rank = 0, lastItem; for (let item of ranklist) { - i++ + i++; let latest = contest.start_time, timeSum = 0, unacceptedCount = 0; %> + <% + if (contest.type === 'noi' || contest.type === 'ioi') { + console.log(i); + console.log(lastItem); + if (i === 1 || item.player.score !== lastItem.player.score) rank++; + } else if (contest.type === 'acm') { + for (let problem of problems) { + if (item.player.score_details[problem.id] && item.player.score_details[problem.id].accepted) { + timeSum += (item.player.score_details[problem.id].acceptedTime - contest.start_time) + (item.player.score_details[problem.id].unacceptedCount * 20 * 60); + unacceptedCount += item.player.score_details[problem.id].unacceptedCount; + } + } + item.player.timeSum = timeSum; + + if (i === 1 || item.player.score !== lastItem.player.score || item.player.timeSum !== lastItem.player.timeSum) rank++; + } + %> - <% if (i == 1) { %> + <% if (rank == 1) { %>
- <% } else if (i == 2) { %> + <% } else if (rank == 2) { %>
- <% } else if (i == 3) { %> + <% } else if (rank == 3) { %>
<% } else { %>
<% } %> - <%= i %> + <%= rank %>
<%= item.user.username %><% if (item.user.nameplate) { %><%- item.user.nameplate %><% } %> - <% - if (contest.type === 'acm') { - for (let problem of problems) { - if (item.player.score_details[problem.id] && item.player.score_details[problem.id].accepted) { - timeSum += (item.player.score_details[problem.id].acceptedTime - contest.start_time) + (item.player.score_details[problem.id].unacceptedCount * 20 * 60); - unacceptedCount += item.player.score_details[problem.id].unacceptedCount; - } - } - %> + <% if (contest.type === 'acm') { %> <%= item.player.score %> @@ -137,6 +146,7 @@ <% } %> + <% lastItem = item; %> <% } %>