online-judge icon indicating copy to clipboard operation
online-judge copied to clipboard

Add problem points vote functionality

Open lakshy-gupta opened this issue 3 years ago • 31 comments

lakshy-gupta avatar Apr 19 '21 02:04 lakshy-gupta

Codecov Report

Base: 46.44% // Head: 46.64% // Increases project coverage by +0.20% :tada:

Coverage data is based on head (2506f09) compared to base (97f2c45). Patch coverage: 66.27% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1645      +/-   ##
==========================================
+ Coverage   46.44%   46.64%   +0.20%     
==========================================
  Files         236      237       +1     
  Lines       13072    13229     +157     
==========================================
+ Hits         6071     6171     +100     
- Misses       7001     7058      +57     
Impacted Files Coverage Δ
dmoj/urls.py 89.47% <ø> (ø)
judge/admin/profile.py 62.22% <ø> (ø)
judge/models/__init__.py 100.00% <ø> (ø)
judge/models/submission.py 88.81% <ø> (ø)
judge/views/problem.py 24.14% <26.98%> (-0.26%) :arrow_down:
judge/admin/problem.py 56.64% <61.90%> (+0.15%) :arrow_up:
judge/models/problem.py 90.85% <91.17%> (+0.03%) :arrow_up:
dmoj/settings.py 97.72% <100.00%> (+0.03%) :arrow_up:
judge/admin/__init__.py 100.00% <100.00%> (ø)
judge/forms.py 46.03% <100.00%> (+1.46%) :arrow_up:
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov-commenter avatar Apr 19 '21 02:04 codecov-commenter

Can you please read this tutorial on how to rebase and this one on rewriting git history so we can review the relevant changes without having to cross-reference what we already have in master.

kiritofeng avatar Apr 19 '21 02:04 kiritofeng

I've squashed the commits and fixed the rebase issue, this pull request should be ready for review.

lakshy-gupta avatar Apr 19 '21 19:04 lakshy-gupta

Could you upload screenshots for how this looks on both desktop and mobile?

ehhthing avatar Apr 19 '21 20:04 ehhthing

We updated the request, it should be ready for another round of code review.

lakshy-gupta avatar Jul 27 '21 19:07 lakshy-gupta

Commits definitely need to be split up. Maybe one for the migration, another for the unit tests, and maybe find some sane division of the remaining work. Label them appropriately.

Riolku avatar Sep 13 '21 01:09 Riolku

image Please make sure the overlay covers the entire screen for large screens.

Ninjaclasher avatar Oct 02 '21 15:10 Ninjaclasher

Yeah, just cursor: pointer should do.

Riolku avatar Mar 21 '22 03:03 Riolku

image

What is this error?

Riolku avatar Mar 22 '22 03:03 Riolku

image I'm not sold on the wording here, maybe something like Invalid points value! Points must be integers in the range [1, 50]

Riolku avatar Mar 22 '22 03:03 Riolku

image Same with this. I think standard wording is more like "Points must be at most 50" or "Points cannot be greater than 50" or something... "Ensure" is just strange

Riolku avatar Mar 22 '22 03:03 Riolku

Should I be able to vote without justification?

Riolku avatar Mar 22 '22 03:03 Riolku

+1 on general UI, the lightboxes and what not look pretty clean.

Riolku avatar Mar 22 '22 03:03 Riolku

Good, you use min and max on the integer field.

Riolku avatar Mar 22 '22 03:03 Riolku

With reference to the error messages on the voting field, I believe they are automatically generated by Django.

lakshy-gupta avatar Mar 22 '22 13:03 lakshy-gupta

Well unless explicitly overridden by Roger or someone above, I think that error message (especially "this field is required") needs to be fixed. Do other parts of the codebase do it differently? Why is this error message garbage?

Riolku avatar Mar 22 '22 13:03 Riolku

There are other parts of the codebase that do it like this: image I'll try to see what the codebase does for non-admin users though.

lakshy-gupta avatar Mar 22 '22 14:03 lakshy-gupta

Based on my search, the codebase doesn't have this issue yet, for non-admins.

Riolku avatar Mar 22 '22 14:03 Riolku

FWIW, if we want to customize the error messages, we can: https://docs.djangoproject.com/en/4.0/ref/forms/fields/#error-messages

Riolku avatar Mar 22 '22 14:03 Riolku

I'm going to look in Django to figure out what's wrong with IntegerField.

Riolku avatar Mar 22 '22 14:03 Riolku

Worst-case, we can override the "required" error message with something very generic.

Riolku avatar Mar 22 '22 14:03 Riolku

I see the issue: in JS, if the integer is invalid, it sends an empty string, or rather, if I have a entered, the POST request sends an empty string: so not an issue with django. The question is: what do we want to do now? Can we find a non-terrible workaround? Do we validate on the client? Sounds kinda ugly. Do we override required? I'm not super fond of that either.

Riolku avatar Mar 22 '22 14:03 Riolku

I think for now, let's override required, with an explicit comment about why we do so. This avoids issues with translations.

Riolku avatar Mar 22 '22 14:03 Riolku

Should I be able to vote without justification?

Yes

lakshy-gupta avatar Mar 23 '22 13:03 lakshy-gupta

Should I be able to vote without justification?

Yes

Out of band discussion: users will probably just put in garbage if it's required, so let's not bother. Besides, will we read the justifications?

Riolku avatar Mar 23 '22 14:03 Riolku

Sure, whatever, keep it.

Riolku avatar Mar 23 '22 19:03 Riolku

Note: you are failing lint.

Riolku avatar Mar 25 '22 04:03 Riolku

All previous conversations are resolved. Ready for review.

int-y1 avatar Jun 09 '22 06:06 int-y1

Up-to-date screenshots:

vote1

vote2

int-y1 avatar Jun 17 '22 20:06 int-y1

image

Oh no, what happened. (Firefox, reproduced in Chromium)

image

The chart also seems to be messed up...

Riolku avatar Sep 08 '22 14:09 Riolku