generated from CS3219-AY2324S1/course-assessment-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from Eclipse-Dominator/link_execution_w_submis…
…sion Link execution w submission
- Loading branch information
Showing
28 changed files
with
580 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import axios from "axios"; | ||
import { judge0Result, submissionResult } from "./types"; | ||
|
||
type Question = { | ||
id: number; | ||
_id: string; | ||
title: string; | ||
description: string; | ||
topics: string[]; | ||
difficulty: number; | ||
}; | ||
|
||
const fetchQn = async (id: string) => { | ||
const response = await axios.get<Question>( | ||
`http://question-service:8080/api/questions/${id}` | ||
); | ||
return response.data; | ||
}; | ||
|
||
export const submitSubmission = async ( | ||
verdict: string, | ||
language: string, | ||
qid: string, | ||
userId: number, | ||
sourceCode: string, | ||
time: Date | ||
) => { | ||
const question = await fetchQn(qid); | ||
const submission = { | ||
question__id: question._id, | ||
userId: userId, | ||
questionTitle: question.title, | ||
questionId: question.id, | ||
difficulty: question.difficulty, | ||
topics: question.topics, | ||
verdict: verdict, | ||
sourceCode: sourceCode, | ||
language: language, | ||
answeredAt: time.toISOString(), | ||
}; | ||
await axios.post( | ||
`http://user-service:8081/api/users/${userId}/addquestions`, | ||
submission | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.