Skip to content

Commit

Permalink
Add get questions from question servives
Browse files Browse the repository at this point in the history
  • Loading branch information
linxiaoxin committed Jul 21, 2024
1 parent 65d6566 commit 2780c15
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ NEXT_PUBLIC_IDP_Tokendpoint = $NEXT_PUBLIC_COGNITO_URL/oauth2/token
NEXT_PUBLIC_QUEMISTRY_DOMAIN =https://dkraju438qs82.cloudfront.net
NEXT_PUBLIC_RedirectUrl = $NEXT_PUBLIC_QUEMISTRY_DOMAIN/auth/google
NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL=https://dummyUrl
NEXT_PUBLIC_QUEMISTRY_AUTH_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/auth
NEXT_PUBLIC_QUEMISTRY_AUTH_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/auth
NEXT_PUBLIC_QUEMISTRY_QUESTIONS_URL = $NEXT_PUBLIC_QUEMISTRY_GATEWAY_URL/questions
17 changes: 14 additions & 3 deletions service/QuestionsService.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { Questions } from '@/types';

const QuesionsSvcUrl = process.env.NEXT_PUBLIC_QUEMISTRY_QUESTIONS_URL || ''

export const QuestionsService = {
getMCQ() {
return fetch('/demo/data/questions.json', { headers: { 'Cache-Control': 'no-cache' } })
.then((res) => res.json())
.then((d) => d.data as Questions.MCQ[]);
return fetch(QuesionsSvcUrl, {
headers: {
'Content-Type': 'application/json'
},
credentials: "include"
})
.then((res) => {
return res.json();
})
.then((data) => {
return data.mcqs as Questions.MCQ[]}
);
},
getTopics() {
return fetch('/demo/data/topics.json', { headers: { 'Cache-Control': 'no-cache' } })
Expand Down
2 changes: 1 addition & 1 deletion types/questions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ declare namespace Questions {
interface MCQ {
id?: number;
stem: string;
option: Answer[];
option: Option[];
isAnswer: number;
topics: Topic[];
skills: Skills[];
Expand Down

0 comments on commit 2780c15

Please sign in to comment.