-
Notifications
You must be signed in to change notification settings - Fork 256
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
Add a warning log when clarifications are claimed #2766
base: main
Are you sure you want to change the base?
Conversation
9bf826b
to
d9bcfbb
Compare
509624c
to
e92ee14
Compare
@@ -346,6 +346,25 @@ public function changeQueueAction(Request $request, int $clarId): Response | |||
return $this->redirectToRoute('jury_clarification', ['id' => $clarId]); | |||
} | |||
|
|||
#[Route('/check-claimed', name: 'check_if_claimed', methods: ['GET'])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding another endpoint here, let's just re-use the existing API endpoint for clarifications.
It currently doesn't have the info on whether a clarification has been claimed, but that can be added easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we do this, we also have the info on whether it has been answered before and can use that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which API should this be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am talking about the default API clarification controller:
$ http http://localhost/domjudge/api/contests/demo/clarifications/1
HTTP/1.1 200 OK
Cache-Control: max-age=0, must-revalidate, private
Connection: Keep-Alive
Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:
Content-Type: application/json
Date: Fri, 01 Nov 2024 17:01:08 GMT
Expires: Fri, 01 Nov 2024 17:01:08 GMT
Keep-Alive: timeout=5, max=100
Referrer-Policy: same-origin
Server: Apache/2.4.62 (Debian)
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Current-Contest:
X-Debug-Token: 55677e
X-Debug-Token-Link: http://localhost/domjudge/_profiler/55677e
X-Frame-Options: DENY
X-Robots-Tag: noindex
X-XSS-Protection: 1; mode=block
{
"answered": false,
"clarid": 1,
"contest_time": "233:54:09.605",
"from_team_id": "domjudge",
"id": "1",
"problem_id": "boolfind",
"reply_to_id": null,
"text": "fsdfsdfdf",
"time": "2024-11-01T10:47:16.605+00:00",
"to_team_id": null
}
As you can see, it doesn't output jury_member
as of now. The implementation of it is really simple: https://github.com/DOMjudge/domjudge/blob/main/webapp/src/Controller/API/ClarificationController.php#L81
That means all the logic is in the entity definition. If we check there, you can see the following: https://github.com/DOMjudge/domjudge/blob/main/webapp/src/Entity/Clarification.php#L67
This means it is excluded from serialization in the API. We can change it to
#[Serializer\Groups([ARC::GROUP_RESTRICTED_NONSTRICT])]
and it should appear.
var $body = $('body'); | ||
|
||
$body.on('submit', 'form[name=jury_clarification]', function () { | ||
var clarid = {{ origclar | json_encode(constant('JSON_HEX_TAG')) | raw }}.clarid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also work, doesn't it?
var clarid = {{ origclar | json_encode(constant('JSON_HEX_TAG')) | raw }}.clarid; | |
var clarid = {{ origclar.clarid }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a try. I remember it didn’t work initially, which is why I wrote it this way.
@@ -346,6 +346,25 @@ public function changeQueueAction(Request $request, int $clarId): Response | |||
return $this->redirectToRoute('jury_clarification', ['id' => $clarId]); | |||
} | |||
|
|||
#[Route('/check-claimed', name: 'check_if_claimed', methods: ['GET'])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[Route('/check-claimed', name: 'check_if_claimed', methods: ['GET'])] | |
#[Route('/check-claimed', name: 'check_if_claimed')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like with the previous PR, this front-end check does not properly cover concurrent users. The check for clarification claim should happen in the same request as the submission of a clarification.
I think the best way to handle it, would be to ask for an additional form submission with confirmation if the clarification has been claimed in while typing the message.
It does happen not happen in the "same request" but on clicking submit: |
That is exactly the problem I point out, concurrent jury members handling clarifications can have interleaved requests and double replies. |
If one of the jury members uses claim, then this should not happen in practice. Also, we likely don't want to forbid double posting but make it intentional. |
I prefer to stay away from "should not happen in practice". My solution does not strictly guarantee it as well, but is as close as you can get with minimal changes. Also removing the need of an additional API endpoint is worth it IMHO.
Hence my suggestion to force a form resubmit, thus keeping form contents and adding an explicit warning of the claim in the meantime and asking additional confirmation for the double posting by resubmission of the form. |
See my comment above which does make the additional API endpoint unnecessary by using the existing one.
I see, that works too, although it's a little bit more complex. |
I accidentally closed the PR. I'll open a new one.
issue
#2481
display