Merge pull request #11 from magical/grade

Add grade report to the bulk tester
This commit is contained in:
Eevee 2020-12-15 23:00:56 -07:00 committed by GitHub
commit 341296dc3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View File

@ -2226,11 +2226,41 @@ class PackTestDialog extends DialogOverlay {
}
}
let grades = [
[100, "A+", "grade-A"],
[93, "A", "grade-A"],
[90, "A-", "grade-A"],
[87, "B+", "grade-B"],
[83, "B", "grade-B"],
[80, "B-", "grade-B"],
[77, "C+", "grade-C"],
[73, "C", "grade-C"],
[70, "C-", "grade-C"],
[60, "D", "grade-D"],
[50, "D-", "grade-D"],
[0, "F", "grade-F"],
];
let gradeText = "NaN";
let gradeClass = "";
let pass_percentage = Math.floor(num_passed / num_levels * 100.0);
for (let i = 0; i < grades.length; i++) {
if (pass_percentage >= grades[i][0]) {
let _pct;
[_pct, gradeText, gradeClass] = grades[i];
break;
}
}
let final_status = `Finished! Simulated ${util.format_duration(total_tics / TICS_PER_SECOND)} of play time in ${util.format_duration((performance.now() - t0) / 1000)}; ${num_passed}/${num_levels} levels passed`;
if (num_passed === num_levels) {
final_status += "! Congratulations! 🎆";
} else {
final_status += '.';
}
final_status += " Grade: ";
this.current_status.textContent = final_status;
this.current_status.appendChild(mk("span", {"class": gradeClass}, gradeText));
}
}

View File

@ -614,6 +614,26 @@ ol.packtest-colorcoded > li[data-status=short] {
ol.packtest-colorcoded > li[data-status=error] {
background: black;
}
.packtest-dialog .grade-A {
color: hsl(120, 60%, 45%);
font-weight: bold;
}
.packtest-dialog .grade-B {
color: hsl(210, 60%, 45%);
font-weight: bold;
}
.packtest-dialog .grade-C {
color: hsl(270, 60%, 45%);
font-weight: bold;
}
.packtest-dialog .grade-D {
color: hsl(36, 60%, 60%);
font-weight: bold;
}
.packtest-dialog .grade-F {
color: hsl(0, 60%, 60%);
font-weight: bold;
}
/**************************************************************************************************/