Skip to content

Commit 7be6d64

Browse files
committed
Added result_percentage
1 parent d022bc0 commit 7be6d64

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

oioioi/programs/handlers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ def make_report(env, kind='NORMAL', save_scores=True, **kwargs):
555555
test_report.score = result['score'] if save_scores else None
556556
test_report.status = result['status']
557557
test_report.time_used = result['time_used']
558+
percentage = result.get('result_percentage', 0.)
559+
if percentage != 100. and percentage != 0.:
560+
test_report.result_percentage = percentage
558561

559562
comment = result.get('result_string', '')
560563
if comment.lower() in ['ok', 'time limit exceeded']: # Annoying

oioioi/programs/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ class TestReport(models.Model):
326326
max_score = ScoreField(null=True, blank=True)
327327
time_used = models.IntegerField(blank=True)
328328
output_file = FileField(upload_to=make_output_filename, null=True, blank=True)
329+
result_percentage = models.FloatField(null=True, blank=True)
329330

330331
test = models.ForeignKey(Test, blank=True, null=True, on_delete=models.SET_NULL)
331332
test_name = models.CharField(max_length=30)

oioioi/programs/templates/programs/report-comments.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{% for group in groups %}
66
{% for record in group.tests %}
77
{% with test=record.test %}
8-
{% if test.comment and allow_test_comments or test.get_status_display != 'OK' and allow_download_out and test.test %}
8+
{% if test.comment or test.result_percentage and allow_test_comments or test.get_status_display != 'OK' and allow_download_out and test.test %}
99
<li class="small text-muted">
1010
<span>{{ test.test_name }}</span>
1111
{% if allow_download_out and test.test %}
@@ -24,7 +24,22 @@
2424
{% endif %}
2525
{% endif %}
2626
{% if allow_test_comments %}
27-
<span>{{ test.comment }}</span>
27+
<span>
28+
{% if test.comment %}
29+
{% if test.result_percentage %}
30+
{% blocktranslate with test.result_percentage as percentage %}
31+
Granted {{ percentage }}% points, comment:
32+
{% endblocktranslate %}
33+
{% endif %}
34+
{{ test.comment }}
35+
{% else %}
36+
{% if test.result_percentage %}
37+
{% blocktranslate with test.result_percentage as percentage %}
38+
Granted {{ percentage }}% points.
39+
{% endblocktranslate %}
40+
{% endif %}
41+
{% endif %}
42+
</span>
2843
{% endif %}
2944
</li>
3045
{% endif %}

0 commit comments

Comments
 (0)