Skip to content

Commit

Permalink
fix restricted feedback: show all test cases up to the first lowest-s…
Browse files Browse the repository at this point in the history
…coring case
  • Loading branch information
AngusRitossa committed Feb 14, 2024
1 parent 694fd18 commit 738fca3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions cms/grading/scoretypes/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,25 +392,27 @@ def compute_score(self, submission_result):

testcases = []
public_testcases = []
previous_tc_all_correct = True

restricted_feedback_idx = None
restricted_feedback_outcome = None

for tc_idx in target:
tc_outcome = self.get_public_outcome(
float(evaluations[tc_idx].outcome), parameter)
outcome = float(evaluations[tc_idx].outcome)
tc_outcome = self.get_public_outcome(outcome, parameter)

testcases.append({
"idx": tc_idx,
"outcome": tc_outcome,
"text": evaluations[tc_idx].text,
"time": evaluations[tc_idx].execution_time,
"memory": evaluations[tc_idx].execution_memory,
"show_in_restricted_feedback": previous_tc_all_correct})
"show_in_restricted_feedback": True})
if self.public_testcases[tc_idx]:
public_testcases.append(testcases[-1])
# Only block restricted feedback if this is the first
# *public* non-correct testcase, otherwise we might be
# leaking info on private testcases.
if tc_outcome != "Correct":
previous_tc_all_correct = False

if restricted_feedback_outcome is None or outcome < restricted_feedback_outcome:
restricted_feedback_outcome = outcome
restricted_feedback_idx = tc_idx
else:
public_testcases.append({"idx": tc_idx})

Expand All @@ -419,6 +421,10 @@ def compute_score(self, submission_result):
parameter)
st_score = st_score_fraction * parameter[0]

if st_score_fraction < 1.0 and parameter[0] > 0: # display full feedback for sample cases
for t in testcases:
t["show_in_restricted_feedback"] = (t["idx"] <= restricted_feedback_idx)

score += st_score
subtasks.append({
"idx": st_idx + 1,
Expand Down

0 comments on commit 738fca3

Please sign in to comment.