Oviya commited on
Commit ·
ee234ff
1
Parent(s): d0f7937
changes on service
Browse filesFiles changed (2)
9 unmodified lines101112131415162 unmodified lines19202122232425262728293031323334353637383940414243449 unmodified lines}@Injectable({ providedIn: 'root' })export class QuestionAnswerService {private baseUrl = 'http://127.0.0.1:5000/api/questions';constructor(private http: HttpClient) { }2 unmodified linesreturn this.http.post<any>(`${this.baseUrl}/select-role`, payload);}// Fetch questions by role//getQuestions(role: string): Observable<any> {// return this.http.get<any>(`${this.baseUrl}/${role}`);//}// Submit answers//submitAnswers(role: string, userId: number, answers: any[]): Observable<any> {// const payload = {// user_id: userId,// ...answers.reduce((acc, ans, i) => {// acc[`q${i + 1}`] = ans; // map answers to fields (adjust backend expected fields if needed)// return acc;// }, {}),// created_at: new Date().toISOString()// };// return this.http.post(`${this.baseUrl}/submit-answers/${role}`, payload);//}getQuestions(role: string): Observable<QAItem[]> {return this.http.get<QAItem[]>(`${this.baseUrl}/${role}`);}9 unmodified lines1011121314151617181920212 unmodified lines242526272829309 unmodified lines}@Injectable({ providedIn: 'root' })export class QuestionAnswerService {// hf.space => HF backend; else => local Flaskprivate baseUrl = location.hostname.endsWith('hf.space')? 'https://pykara-py-match-backend.hf.space/api/questions': 'http://localhost:5000/api/questions';//private baseUrl = 'http://127.0.0.1:5000/api/questions';constructor(private http: HttpClient) { }2 unmodified linesreturn this.http.post<any>(`${this.baseUrl}/select-role`, payload);}getQuestions(role: string): Observable<QAItem[]> {return this.http.get<QAItem[]>(`${this.baseUrl}/${role}`);}
5 unmodified lines67891011121314151617183 unmodified lines222324252627285 unmodified linesprovidedIn: 'root'})export class QuizService {private apiUrl = 'http://localhost:5000'; // Your Flask backend URLconstructor(private http: HttpClient) { }// Start the quiz by sending the profile and rolestartQuiz(nQuestions: number, batchSize: number, role: string, profile: any): Observable<any> {return this.http.post<any>(`${this.apiUrl}/q/start`, {n_questions: nQuestions,batch_size: batchSize,role: role,3 unmodified lines// Fetch next questionnextQuestion(sessionId: string, selectedColor: string): Observable<any> {return this.http.post<any>(`${this.apiUrl}/q/next`, {session_id: sessionId,selected_color: selectedColor});5 unmodified lines67891011121314151617181920212223243 unmodified lines282930313233345 unmodified linesprovidedIn: 'root'})export class QuizService {// hf.space => HF backend; else => local Flaskprivate baseUrl = location.hostname.endsWith('hf.space')? 'https://pykara-py-match-backend.hf.space': 'http://localhost:5000';//private apiUrl = 'http://localhost:5000'; // Your Flask backend URLconstructor(private http: HttpClient) { }// Start the quiz by sending the profile and rolestartQuiz(nQuestions: number, batchSize: number, role: string, profile: any): Observable<any> {return this.http.post<any>(`${this.baseUrl}/q/start`, {n_questions: nQuestions,batch_size: batchSize,role: role,3 unmodified lines// Fetch next questionnextQuestion(sessionId: string, selectedColor: string): Observable<any> {return this.http.post<any>(`${this.baseUrl}/q/next`, {session_id: sessionId,selected_color: selectedColor});
src/app/question-answer/question-answer-service.service.ts+7-21
src/app/quiz/quiz.service.ts+9-3