Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display % of points granted by the checker when partially scoring #301

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

SZonkil
Copy link
Contributor

@SZonkil SZonkil commented Dec 6, 2023

Addition of translation is required

Closes #288

@SZonkil SZonkil requested a review from twalen as a code owner December 6, 2023 15:29
Copy link
Contributor

@DietPawel DietPawel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you for delivering a PR. Did You tested the translations?

I tried testing it and it seems that when You change user's language the comment is not reflected.

I believe that, this string "Granted...." is saved during judging of the problem and there is no access to user's language preferences there.

I might have clicked something wrong though.

twalen
twalen previously approved these changes Dec 20, 2023
@@ -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.:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can You please convince me it is okay here to check equality of some floating point number? I would prefer to rather see

if percentage > 0 and percentage < 100:

keep in mind that sometimes "different" number are equal due to precision

>>> 100.000000000000001 == 100.
True
>>> 100.00000000000001 == 100.
False

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the domain of these values is not necessarily [0, 100]. I actually have abused this mechanism with values well above 100 to circumvent some architectural shortcomings once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insight. In the wiki it says that the percentage is a whole integer. It says that this option can be used to give partial scoring. It does not mention whether it is allowed to grant more than 100%. It should be more documented in the specs

As for this logic, I am not sure we should tell user that he got 150% for this test, as this i probably not the intended behavior for this feature and was properly called "an abuse".

I suspect there would be disagreements about this, so please express your opinions here!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if the percentage value should be greater than 100, but in the context of this PR I think that the message should not be displayed when the value is 0 (then the result should be WA) or 100 (then there is no comment and you can see assume that you have full points).

But if we decided to allow a percentage greater than 100, we would have to find another way to check whether this value is equal to 100

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, if we could change this to an Integer, the float-related discussion is unnecessary. Is there any reason to use FloatField not IntegerField?

Secondly I think that Verdict and partial scoring are different things and it should be allowed to give 0% points but OK as a verdict. The checker returns both the verdict and partial scoring independently. We should treat is as such independent values.

Thirdly If partial scoring does not affect number of points awarded there should be no comment (what for it would be). If user get less points we definitely should post the comment. If it is allowed to give more, it is debatable if it should be displayed.

oioioi/programs/models.py Outdated Show resolved Hide resolved
{% if test.comment %}
{% if test.result_percentage %}
{% blocktranslate with test.result_percentage as percentage %}
Granted {{ percentage }}% points, comment:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "Granted {{ percentage }}% of points". Also as percentage could be 33.33333333 I think we should pretty print this floating point value

@@ -24,7 +24,22 @@
{% endif %}
{% endif %}
{% if allow_test_comments %}
<span>{{ test.comment }}</span>
<span>
{% if test.comment %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is quite complex. Do we have any performance degradation due to this change?
I also disagree that the percentage should be graphically the same as comment. They should be visually different.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DietPawel do you still request changes?

Copy link
Contributor

@DietPawel DietPawel Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 3 things I am still not sure about:

  • math.isclose instead of == for Floats.
  • pretty-printing of Floats
  • Performance of django templates is not ideal. Is there any visible performance penalty for this template expansion?

Other than that I am totally for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • result_percentage is now a Fraction, so there are no rounding errors
  • added
  • for ~60 tests each with comment and result percentage, the templates render less than 0.01s slower

@DietPawel DietPawel changed the title Display % of points outpu by checker Display % of points granted by the checker when partially scoring. Dec 20, 2023
@DietPawel DietPawel changed the title Display % of points granted by the checker when partially scoring. Display % of points granted by the checker when partially scoring Dec 20, 2023
@DietPawel
Copy link
Contributor

CC: @Kostero @craniac-swistak

twalen
twalen previously approved these changes Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

% of points output by chk to be displayed by SIO
5 participants