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

Get gym solution for parser #363

Open
unaimillan opened this issue Sep 9, 2022 · 4 comments
Open

Get gym solution for parser #363

unaimillan opened this issue Sep 9, 2022 · 4 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@unaimillan
Copy link

unaimillan commented Sep 9, 2022

Would be cool to add a parser function similar to get_solution, but for mashup contests created in gym.
Implementation should be similar, except for /gym/ in the url path

def get_gym_solution(self, contest_id, submit_id):
    solutionPage = self.session.get(
        "https://codeforces.com/gym/"
        + str(contest_id)
        + "/submission/"
        + str(submit_id)
    )
    if int(solutionPage.status_code) != 200:
        raise Exception("Returned not OK code " + str(solutionPage))
    tree2 = html.fromstring(solutionPage.text)
    code = tree2.xpath("//pre[@id='program-source-text']/text()")
    if len(code) == 0:
        raise ValueError("Incorrect contest_id or submit_id " + str(code))
    return code[0].replace("\r", "")

or just add one more parameter to get_solution with default value gym=False

@unaimillan unaimillan added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 9, 2022
@VadVergasov
Copy link
Owner

Ok, I'll look through it.

@VadVergasov
Copy link
Owner

VadVergasov commented Sep 9, 2022

I can see gym submissions aren't public, so you need to authenticate to grab the solution. So it's nearly impossible to create such feature. Correct me if I'm mistaken.

@unaimillan
Copy link
Author

Yes, this feature requires authorized access to api, so should be available only when api key and secret specified.
Nevertheless, I am as a tutor could have plenty of different private contests for training and anyway will need to download student's solutions for plagiarism and code style checks.

@unaimillan
Copy link
Author

Ahh, understood the problem, as parser requests are made directly bypassing API, this feature requires access to contest manager account(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants