Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions oioioi/programs/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ def make_report(env, kind='NORMAL', save_scores=True, **kwargs):
test_report.score = result['score'] if save_scores else None
test_report.status = result['status']
test_report.time_used = result['time_used']
percentage = result.get('result_percentage', 0.)
if percentage != 100. and percentage != 0.:
test_report.result_percentage = percentage

comment = result.get('result_string', '')
if comment.lower() in ['ok', 'time limit exceeded']: # Annoying
Expand Down
18 changes: 18 additions & 0 deletions oioioi/programs/migrations/0020_testreport_result_percentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-13 16:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('programs', '0019_add_limits_override'),
]

operations = [
migrations.AddField(
model_name='testreport',
name='result_percentage',
field=models.FloatField(blank=True, null=True),
),
]
1 change: 1 addition & 0 deletions oioioi/programs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ class TestReport(models.Model):
max_score = ScoreField(null=True, blank=True)
time_used = models.IntegerField(blank=True)
output_file = FileField(upload_to=make_output_filename, null=True, blank=True)
result_percentage = models.FloatField(null=True, blank=True)

test = models.ForeignKey(Test, blank=True, null=True, on_delete=models.SET_NULL)
test_name = models.CharField(max_length=30)
Expand Down
19 changes: 17 additions & 2 deletions oioioi/programs/templates/programs/report-comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% for group in groups %}
{% for record in group.tests %}
{% with test=record.test %}
{% if test.comment and allow_test_comments or test.get_status_display != 'OK' and allow_download_out and test.test %}
{% if test.comment or test.result_percentage and allow_test_comments or test.get_status_display != 'OK' and allow_download_out and test.test %}
<li class="small text-muted">
<span>{{ test.test_name }}</span>
{% if allow_download_out and test.test %}
Expand All @@ -24,7 +24,22 @@
{% endif %}
{% endif %}
{% if allow_test_comments %}
<span>{{ test.comment }}</span>
<span>
{% if test.comment %}
{% if test.result_percentage %}
{% blocktranslate with test.result_percentage as percentage %}
Granted {{ percentage }}% points, comment:
{% endblocktranslate %}
{% endif %}
{{ test.comment }}
{% else %}
{% if test.result_percentage %}
{% blocktranslate with test.result_percentage as percentage %}
Granted {{ percentage }}% points.
{% endblocktranslate %}
{% endif %}
{% endif %}
</span>
{% endif %}
</li>
{% endif %}
Expand Down