Fix resolver display

This commit is contained in:
cuom1999 2022-12-28 19:16:38 -06:00
parent 46260b6592
commit 39586c5d64
2 changed files with 18 additions and 15 deletions

View file

@ -7,7 +7,16 @@ function Resolver(problem_sub, sub_frozen, problems, users) {
this.operations = []; this.operations = [];
this.frozen_op = 0; this.frozen_op = 0;
this.isshow = []; this.isshow = [];
this.total_points = {};
this.delay = false; 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) { function round2(num) {
@ -45,13 +54,7 @@ Resolver.prototype.substatus = function (problem, subproblem) {
Resolver.prototype.pointstatus = function (point, problem, sub) { Resolver.prototype.pointstatus = function (point, problem, sub) {
if (sub == undefined) { if (sub == undefined) {
var total_points = 0 if (point == this.total_points[problem]) return 'AC';
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 == 0) return 'WA'; if (point == 0) return 'WA';
return 'PA'; return 'PA';
} }

View file

@ -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 + ' .p-' + operation.problem_index + ' .pro-score').addClass(resolver.status(tmp.problem[operation.problem_index]));
$('#rank-' + operation.user_id + ' .score').text(tmp.score); $('#rank-' + operation.user_id + ' .score').text(tmp.score);
if (operation.new_rank % 2 == 0) { 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}%)`; 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); $('#rank-' + operation.user_id + ' .p-' + operation.problem_index + ' .pro-score.partially').css("background", linear);
} else { } 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${untouched} ${per}%)`;
$('#rank-' + operation.user_id + ' .p-' + operation.problem_index + ' .pro-score.partially').css("background", linear); $('#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 + ' .prob-container').addClass('background-secondary');
$("#rank-" + i + ' .problems').addClass('background-secondary'); $("#rank-" + i + ' .problems').addClass('background-secondary');
for (let problemid in resolver.rank_frozen[i].problem) { 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${primary_color} ${per}%)`;
$('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear);
} }
@ -111,7 +111,7 @@
$("#rank-" + i + ' .prob-container').addClass('background-primary'); $("#rank-" + i + ' .prob-container').addClass('background-primary');
$("#rank-" + i + ' .problems').addClass('background-primary'); $("#rank-" + i + ' .problems').addClass('background-primary');
for (let problemid in resolver.rank_frozen[i].problem) { 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${secondary_color} ${per}%)`;
$('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); $('#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.status(window.resolver.rank_frozen[i].problem[problem_id]) == 'partially') {
if (resolver.rank_frozen[i].rank_show % 2 == 1) { 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${secondary_color} ${per}%)`;
$(pro_score).css("background", linear); $(pro_score).css("background", linear);
} else { } 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${primary_color} ${per}%)`;
$(pro_score).css("background", linear); $(pro_score).css("background", linear);
} }
@ -409,13 +409,13 @@
for (let i in resolver.rank_frozen) { for (let i in resolver.rank_frozen) {
if (resolver.rank_frozen[i].rank_show % 2 == 0) { if (resolver.rank_frozen[i].rank_show % 2 == 0) {
for (let problemid in resolver.rank_frozen[i].problem) { 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${primary_color} ${per}%)`;
$('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear);
} }
} else { } else {
for (let problemid in resolver.rank_frozen[i].problem) { 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}%)`; let linear = `linear-gradient(90deg, ${partially} ${per}%, ${secondary_color} ${per}%)`;
$('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear); $('#rank-' + i + ' .p-' + problemid + ' .pro-score.partially').css("background", linear);
} }