| 335 | } |
| 336 | |
| 337 | export async function getAllMCQs() { |
| 338 | const value = await cache.get("getAllMCQs", []); |
| 339 | if (value) { |
| 340 | return value; |
| 341 | } |
| 342 | try { |
| 343 | const mcqs = await db.problem.findMany({ |
| 344 | where: { |
| 345 | type: "MCQ", |
| 346 | }, |
| 347 | include: { |
| 348 | mcqQuestions: true, |
| 349 | }, |
| 350 | }); |
| 351 | await cache.set("getAllMCQs", [], mcqs); |
| 352 | return mcqs; |
| 353 | } catch (e) { |
| 354 | return []; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | export async function getAllMCQQuestion(problemId: string) { |
| 359 | const value = await cache.get("getAllMCQQuestion", [problemId.toString()]); |