From 39586c5d64ee4c504b24a7b5d6a6eba3cb728f31 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Wed, 28 Dec 2022 19:16:38 -0600 Subject: [PATCH] Fix resolver display --- resources/resolver.js | 17 ++++++++++------- templates/resolver/media-js.html | 16 ++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/resources/resolver.js b/resources/resolver.js index ece3f74..611f246 100644 --- a/resources/resolver.js +++ b/resources/resolver.js @@ -7,7 +7,16 @@ function Resolver(problem_sub, sub_frozen, problems, users) { this.operations = []; this.frozen_op = 0; this.isshow = []; + this.total_points = {}; this.delay = false; + + for (var problem in this.problems) { + this.total_points[problem] = 0; + for (var i in this.problems[problem]) { + this.total_points[problem] += this.problems[problem][i]; + } + this.total_points[problem] = round2(this.total_points[problem]); + } } function round2(num) { @@ -45,13 +54,7 @@ Resolver.prototype.substatus = function (problem, subproblem) { Resolver.prototype.pointstatus = function (point, problem, sub) { if (sub == undefined) { - var total_points = 0 - for (var i in this.problems[problem]) { - total_points += this.problems[problem][i]; - } - total_points = round2(total_points); - - if (point == total_points) return 'AC'; + if (point == this.total_points[problem]) return 'AC'; if (point == 0) return 'WA'; return 'PA'; } diff --git a/templates/resolver/media-js.html b/templates/resolver/media-js.html index 972d341..bd97186 100644 --- a/templates/resolver/media-js.html +++ b/templates/resolver/media-js.html @@ -76,11 +76,11 @@ $('#rank-' + operation.user_id + ' .p-' + operation.problem_index + ' .pro-score').addClass(resolver.status(tmp.problem[operation.problem_index])); $('#rank-' + operation.user_id + ' .score').text(tmp.score); if (operation.new_rank % 2 == 0) { - let per = tmp.problem[operation.problem_index].old_point; + let per = round2(tmp.problem[operation.problem_index].old_point / resolver.total_points[operation.problem_index] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${theme_background_color} ${per}%)`; $('#rank-' + operation.user_id + ' .p-' + operation.problem_index + ' .pro-score.partially').css("background", linear); } else { - let per = tmp.problem[operation.problem_index].old_point; + let per = round2(tmp.problem[operation.problem_index].old_point / resolver.total_points[operation.problem_index] * 100);; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${untouched} ${per}%)`; $('#rank-' + operation.user_id + ' .p-' + operation.problem_index + ' .pro-score.partially').css("background", linear); } @@ -97,7 +97,7 @@ $("#rank-" + i + ' .prob-container').addClass('background-secondary'); $("#rank-" + i + ' .problems').addClass('background-secondary'); for (let problemid in resolver.rank_frozen[i].problem) { - let per = resolver.rank_frozen[i].problem[problemid].old_point; + let per = round2(resolver.rank_frozen[i].problem[problemid].old_point / resolver.total_points[problemid] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${primary_color} ${per}%)`; $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); } @@ -111,7 +111,7 @@ $("#rank-" + i + ' .prob-container').addClass('background-primary'); $("#rank-" + i + ' .problems').addClass('background-primary'); for (let problemid in resolver.rank_frozen[i].problem) { - let per = resolver.rank_frozen[i].problem[problemid].old_point; + let per = round2(resolver.rank_frozen[i].problem[problemid].old_point / resolver.total_points[problemid] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${secondary_color} ${per}%)`; $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); } @@ -203,11 +203,11 @@ if (resolver.status(window.resolver.rank_frozen[i].problem[problem_id]) == 'partially') { if (resolver.rank_frozen[i].rank_show % 2 == 1) { - let per = resolver.rank_frozen[i].problem[problem_id].old_point; + let per = round2(resolver.rank_frozen[i].problem[problem_id].old_point / resolver.total_points[problem_id] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${secondary_color} ${per}%)`; $(pro_score).css("background", linear); } else { - let per = resolver.rank_frozen[i].problem[problem_id].old_point; + let per = round2(resolver.rank_frozen[i].problem[problem_id].old_point / resolver.total_points[problem_id] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${primary_color} ${per}%)`; $(pro_score).css("background", linear); } @@ -409,13 +409,13 @@ for (let i in resolver.rank_frozen) { if (resolver.rank_frozen[i].rank_show % 2 == 0) { for (let problemid in resolver.rank_frozen[i].problem) { - let per = resolver.rank_frozen[i].problem[problemid].old_point; + let per = round2(resolver.rank_frozen[i].problem[problemid].old_point / resolver.total_points[problemid] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${primary_color} ${per}%)`; $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); } } else { for (let problemid in resolver.rank_frozen[i].problem) { - let per = resolver.rank_frozen[i].problem[problemid].old_point; + let per = round2(resolver.rank_frozen[i].problem[problemid].old_point / resolver.total_points[problemid] * 100); let linear = `linear-gradient(90deg, ${partially} ${per}%, ${secondary_color} ${per}%)`; $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); }