-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abd6d8b
commit 2839fbe
Showing
4 changed files
with
217 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { publicRouter } from "./api"; | ||
|
||
export const submitAnswer = async (participantId: string, answer: string) : Promise<SubmitResponse | null> => { | ||
try{ | ||
var res = await publicRouter.post("/api/cq/submit/", {participantId, answer}); | ||
return res.data.data as SubmitResponse; | ||
}catch(err){ | ||
console.log(err); | ||
alert("An Error Occured! [E-03]"); | ||
return null; | ||
} | ||
} | ||
|
||
export const initializeParticipant = async (name: string) : Promise<InitializeResponse | null> => { | ||
try{ | ||
var res = await publicRouter.post("/api/cq/initialize/",{name: name}); | ||
var data = res.data.data as InitializeResponse; | ||
return data; | ||
}catch(err){ | ||
console.log(err); | ||
alert("An Error Occured! [E-01]"); | ||
return null; | ||
} | ||
}; | ||
|
||
export const getQuestion = async (participantId: string) : Promise<QuestionResponse | null> => { | ||
try { | ||
var res = await publicRouter.get("/api/cq/get-question/?participantId="+participantId); | ||
var data = res.data.data as QuestionResponse; | ||
return data; | ||
}catch(err){ | ||
console.log(err); | ||
alert("An Error Occured! [E-02]"); | ||
return null; | ||
} | ||
}; | ||
|
||
|
||
export type QuestionResponse = { | ||
won: boolean; | ||
data: Question; | ||
} | ||
export type Question = { | ||
question: string; | ||
order: number; | ||
difficulty: number; | ||
name: string; | ||
}; | ||
|
||
export type InitializeResponse = { | ||
participantId: string; | ||
current_order: number; | ||
}; | ||
|
||
export type SubmitResponse = { | ||
won: boolean; | ||
correct: boolean; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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