diff --git a/judge/tasks/experiment.py b/judge/tasks/experiment.py new file mode 100644 index 0000000..12ea1ca --- /dev/null +++ b/judge/tasks/experiment.py @@ -0,0 +1,24 @@ +from collections import defaultdict +from judge.models import SubmissionTestCase, Problem + + +def generate_report(problem): + testcases = SubmissionTestCase.objects.filter(submission__problem=problem).all() + + score = defaultdict(int) + total = defaultdict(int) + rate = defaultdict(int) + + for case in testcases.iterator(): + score[case.case] += int(case.status == 'AC') + total[case.case] += 1 + + for i in score: + rate[i] = score[i] / total[i] + + for i, _ in sorted(rate.items(), key=lambda x: x[1], reverse=True): + print(i, score[i], total[i], rate[i]) + +def test(code): + problem = Problem.objects.get(code=code) + generate_report(problem) \ No newline at end of file diff --git a/judge/views/submission.py b/judge/views/submission.py index 4848eb7..9dac6e7 100644 --- a/judge/views/submission.py +++ b/judge/views/submission.py @@ -233,8 +233,12 @@ class SubmissionSourceRaw(SubmissionSource): @require_POST def abort_submission(request, submission): submission = get_object_or_404(Submission, id=int(submission)) - if (not request.user.is_authenticated or (submission.was_rejudged or (request.profile != submission.user)) and - not request.user.has_perm('abort_any_submission')): + # if (not request.user.is_authenticated or (submission.was_rejudged or (request.profile != submission.user)) and + # not request.user.has_perm('abort_any_submission')): + # raise PermissionDenied() + if (not request.user.is_authenticated + or submission.was_rejudged + or not request.user.has_perm('abort_any_submission')): raise PermissionDenied() submission.abort() return HttpResponseRedirect(reverse('submission_status', args=(submission.id,))) diff --git a/templates/submission/status.html b/templates/submission/status.html index 33689a2..41dc7f5 100644 --- a/templates/submission/status.html +++ b/templates/submission/status.html @@ -78,7 +78,7 @@
{% include "submission/status-testcases.html" %}
{% if not submission.is_graded %} - {% if request.user == submission.user.user or perms.judge.abort_any_submission %} + {% if perms.judge.abort_any_submission %}