team-monolith-product / jupyterlab-judge

A simple online judge for Jupyter Lab.
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Creating & managing the judge system #31

Open TheFlightSimsOfficial opened 1 year ago

TheFlightSimsOfficial commented 1 year ago

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 commented 11 months ago

@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 commented 10 months ago

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 commented 7 months ago

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

a3626a commented 7 months ago

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 commented 7 months ago

Thanks for the fast reply. From the README:

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:

a3626a commented 7 months ago

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.