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

Create Grading Service Part 2 (POST /cs3213/feedback_error and a GET endpoint to obtain submission with feedbacks) #30

Merged
merged 9 commits into from
Mar 18, 2024

Conversation

tryyang2001
Copy link
Owner

Pull Request

Description

Part 2 of grading service implementation. Created the API wrapper for the POST /cs3213/feedback_error endpoint. Also created a GET /questions/:questionId/submissions?studentId=xxx endpoint to allow retrieving generated feedbacks for the same submission without calling the ITS API again.

To explain further, the wrapper for POST /cs3213/feedback_error endpoint has the API path of /grading/api/feedback/generate, which also uses POST method. Instead of taking non-human-readable code parser as input request body, it only takes the JSON-friendly actual source code, the language (only support "python" or "c"), the question id and the student id. In short, the request body to POST /grading/api/feedback/generate should have this format, see example:

{
  "language": "python",
  "student_code": "def is_odd(x):\r\n    if x % 2 == 1:\r\n        return False\r\n    else:\r\n        return True",
  "question_id": "some-question-id",
  "student_id": "some-student-id-in-integer-value"
}

The response of this generateFeedback endpoint is shown in the screenshot section.

Related Issue(s)

Closes #20

Screenshots (if applicable)

image
Above is the example request and response of GET /grading/api/questions/:questionId/submissions endpoint.

image
And this is the example request and response of POST /grading/api/feedback/generate endpoint.

Checklist

  • I have checked that the changes included in the PR are intended to merge to master or any destination branch.
  • I have verified that the new changes do not break any existing functionalities, unless the new changes are intended and have approved by the team.
  • I will take care of the merging and delete the side-branch after the PR is merged.

Additional Notes/References

As the next step of action, I will add more proper error checking, create unit tests, and the API docs for grading service. One potential issue is that calling POST /grading/api/feedback/generate is extremely slow, as ITS API takes quite long to generate the output, and the code parser can be very long.

tryyang2001 added 4 commits March 16, 2024 22:49
…backs and submission (for now only one submission allowed, user can submit multiple times, but only the latest submission is stored), and a GET /questions/:questionId/submissions endpoint to retrieve submission.
@tryyang2001 tryyang2001 changed the title Tryyang/create grading service Create Grading Service Part 2 (POST /cs3213/feedback_error and a GET endpoint to obtain submission with feedbacks) Mar 16, 2024
Copy link
Collaborator

@vivienherq vivienherq left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@hhchinh2002 hhchinh2002 left a comment

Choose a reason for hiding this comment

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

LGTM! beside few very minor code quality that I left reviews, all sample requests from Postman json file work for me, however:

  • due to complexity of the techstack you are using, maybe can consider create a README.md file with few simple instruction on how to build/run the service locally
  • add yarn prisma generate to the package.json file scripts under build

@@ -18,6 +66,22 @@ const postParser = async (request: Request, response: Response) => {

response.status(HttpStatusCode.OK).json({ parser });
} catch (error) {
if (error instanceof ITSPostParserError) {
if (error.errorField === "language") {
response.status(HttpStatusCode.BAD_REQUEST).json({
Copy link
Collaborator

Choose a reason for hiding this comment

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

This look like DRY to me cause this piece of code appear in other place, I think you can consider exporting an method that set response status and json body from ITSPostParserError.ts and invoke it

Copy link
Owner Author

Choose a reason for hiding this comment

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

Oh okay, tbh the actual reason was that the ITS response on error is not very clear and consistent, so I was just using a simple way to distinguish what happens... Will polish this in the future.

@tryyang2001 tryyang2001 merged commit 1f818ec into master Mar 18, 2024
4 checks passed
@tryyang2001 tryyang2001 deleted the tryyang/create_grading_service branch March 18, 2024 14:42
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.

Create Grading Service
3 participants