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

Api improvements #373

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

Conversation

matihope
Copy link
Contributor

@matihope matihope commented Apr 24, 2024

This is a draft PR showcasing current functionality implemented in the API. In terms of problems it allows for:

  • listing contests
  • listing problems in a contest
  • getting details about a problem in a contest
  • submitting a solution to a problem in a contest (This was already implemented)

Currently, yet to be implemented is querying a submission list, a ranking, writing tests and request limitation.


VSCode Extension

This issue is being worked on in parallel with a VSCode extension, that already allows to submit solutions right from the editor. What a time to be alive!

@MasloMaslane
Copy link
Member

I have a concern: if there is an onsite contest with ip authentication enabled is it possible to submit as someone else with their api key?

@MasloMaslane
Copy link
Member

Probably all API endpoints should check (maybe with permission_classes?) whether ip authentication is enabled if so, check if the participant is making requests from correct ip

@matihope
Copy link
Contributor Author

I have a concern: if there is an onsite contest with ip authentication enabled is it possible to submit as someone else with their api key?

This is not something related to this issue, as we have not changed anything about submission endpoint.

@matihope matihope marked this pull request as ready for review June 27, 2024 17:00
@matihope matihope requested a review from twalen as a code owner June 27, 2024 17:00
oioioi/contests/api.py Outdated Show resolved Hide resolved
@@ -637,3 +635,47 @@ def has_view_permission(self, request, obj=None):
return True

return ArchivedInlineWrapper


def get_problem_statements(request, controller, problem_instances):
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be a nightmare to maintain this, what about returning list of dicts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate please?

Copy link
Contributor

Choose a reason for hiding this comment

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

In this function you return tuple with very specific order of tuple-elements. This ordering is repeated in two distinct places and the code would fail if they will be out-of-sync.

I suggest to have a get_problem_statements(..) that returns a list of dictionaries i.e.

[
  {"problem_instance": pi1, "statement_visible": True, "round_end_time": datetime(...), ...},
  {"problem_instance": pi2, "statement_visible": False, "round_end_time": datetime(...), ...},
   ...
]

With this change you still need to maintain sync between different fragments of code, but at least you will get an error in case of mispelled key.

Copy link
Contributor

@twalen twalen Dec 12, 2024

Choose a reason for hiding this comment

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

Other than this change I'm happy to merge the PR.

oioioi/contests/urls.py Outdated Show resolved Hide resolved
Copy link
Contributor

@twalen twalen left a comment

Choose a reason for hiding this comment

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

Please handle the comments.

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.

4 participants