Skip to content

Commit

Permalink
Fix the keyerror when there are hide test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
aben20807 committed Sep 1, 2021
1 parent 059eaba commit 1c10549
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
15 changes: 11 additions & 4 deletions judge/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SOFTWARE.
"""

__version__ = "2.2.0"
__version__ = "2.2.1"

import sys

Expand Down Expand Up @@ -371,11 +371,17 @@ def print_report(self):
print(dash)
print(row["diff"])
print(doubledash)
correct_cnt = [row["accept"] for row in self.table].count(True)
# The test which ends with "hide" will not be count to calculate the score.
correct_cnt = [
row["accept"] for row in self.table if not row["test"].endswith("hide")
].count(True)
obtained_score = self.get_score_by_correct_cnt(correct_cnt)
total_score = int(self.score_dict[str(len(tests))])
valid_test_number = len(
[test for test in tests if not test.endswith("hide")]
) # not to count hide test case
total_score = int(self.score_dict[str(valid_test_number)])
print(
f"Correct/Total problems:\t{correct_cnt}/{len(tests)}\n"
f"Correct/Total problems:\t{correct_cnt}/{valid_test_number}\n"
f"Obtained/Total scores:\t{obtained_score}/{total_score}"
)
returncode = 0
Expand Down Expand Up @@ -459,6 +465,7 @@ def copy_output_to_dir(judge: LocalJudge, output_dir, delete_temp_output, ans_ex


if __name__ == "__main__":
print(f"local-judge: v{__version__}")
args = get_args()
config = configparser.RawConfigParser()
config.read(args.config)
Expand Down
5 changes: 3 additions & 2 deletions judge/ta_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from judge import __version__

__version__ = "2.2.0"
__version__ = __version__

import sys

Expand All @@ -50,7 +51,6 @@
import multiprocessing
import signal
import time
import json
from judge import Report

Student = namedtuple("Student", ("id", "zip_type", "zip_path", "extract_path"))
Expand Down Expand Up @@ -280,6 +280,7 @@ def setup():


if __name__ == "__main__":
print(f"local-judge: v{__version__}")
args = get_args()
ta_config = configparser.ConfigParser()
ta_config.read(args.ta_config)
Expand Down

0 comments on commit 1c10549

Please sign in to comment.