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

Creating & managing the judge system #31

Open
TheFlightSimsOfficial opened this issue May 27, 2023 · 6 comments
Open

Creating & managing the judge system #31

TheFlightSimsOfficial opened this issue May 27, 2023 · 6 comments

Comments

@TheFlightSimsOfficial
Copy link

Hi, developers of the JupyterLab Judge project,

I'm really impressed with what service this project will provide to my campus.

However, I am still under the struggle because I have no idea about creating a test file and linking it to my students.

How can fix this?

@a3626a
Copy link
Contributor

a3626a commented Aug 23, 2023

@TheFlightSimsOfficial Sorry for my late reply. I have not notified for this issue by Github system.

Unfortunately, this project does not work out of the box.
You must implement your "problem server" and "integration jupyter lab extension"
To do this you need some skills on implementing web servers and jupyter lab extension.

This is an our working example for the integration (it is in private repository)

import { includeAndConvert } from '../api/jsonapi';
import { requestAPI } from '../handler';
import snakecaseKeys from 'snakecase-keys';
import { getProblem, validateProblem } from '../api/problems';
import { listSubmissions } from '../api/submissions';
import IUser from '../models/user';
import { IProblemProvider, ProblemProvider } from 'jupyterlab-judge';

export class JupyterServerProblemProvider implements IProblemProvider {
  constructor(user: IUser) {
    this.user = user;
  }

  async getProblem(id: string): Promise<ProblemProvider.IProblem | null> {
    try {
      return await getProblem({ problemId: id });
    } catch (e) {
      return null;
    }
  }

  async getTestCases(id: string): Promise<string[]> {
    return (
      (
        await getProblem({ problemId: id, include: 'test_cases' })
      )?.testCases?.map(testCase => testCase.input) ?? []
    );
  }

  async validate(
    id: string,
    outputs: string[]
  ): Promise<ProblemProvider.IValidateResult> {
    return await validateProblem({
      problemId: id,
      outputs
    });
  }

  async getSubmissions(id: string): Promise<ProblemProvider.ISubmission[]> {
    return await listSubmissions({ userId: this.user.id, problemId: id });
  }

  async submit(
    request: ProblemProvider.ISubmissionRequest
  ): Promise<ProblemProvider.ISubmission> {
    const fromApi = await requestAPI<any>('submissions', {
      method: 'POST',
      body: JSON.stringify(snakecaseKeys({ data: { attributes: request } }))
    });
    return includeAndConvert(fromApi.data, fromApi.included);
  }

  private user: IUser;
}

@shiroinekotfs
Copy link

All right, @TheFlightSimsOfficial and I will stay until the release appears, or maybe we both see your code and try to change it for the test format to be modified.

Your project is impressive because almost no one wants to create a judging system, especially for Jupyter Notebook/Lab.

@jilljenn
Copy link

Sorry, I don't get it, is there a hello world available?

@a3626a
Copy link
Contributor

a3626a commented Dec 14, 2023

Sorry, I don't get it, is there a hello world available?

It is not currently available.

If you tried to use this extension, you probably have some algorithm problems. This extension does not have a general solution to integrate random problem management system.

Let me just collect some real world examples: How do you expect to integrate your problems with this extension?

@jilljenn
Copy link

jilljenn commented Dec 14, 2023

Thanks for the fast reply. From the README:

  • No Additional System For Code Execution
  • Basically, problems are retrieved from codle.io, and submission history is stored in browsers.

I was misled and thought that there would be a couple of examples of problems stored. I was expecting something similar than competitive programming helper but for Jupyter Lab.

Other food for thought:

  • offline-judge
  • having a nice interface for unit tests in Python notebooks (does not seem to exist, except your project)

@a3626a
Copy link
Contributor

a3626a commented Dec 14, 2023

We have problems in codle.io, but it is written in Korean. So that won't help you a lot.

cph seems like similar to this extension. So one of Codeforces, Codechef, TopCoder would provide problems and their TESTCASES.
it is possible to integrate that system to this extension. But it is not implemented, and planned.

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

No branches or pull requests

4 participants