@tinyweb_dev/oe-exam-sdk 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/api/exam-taking.js +1 -1
- package/dist/api/exam-taking.types.d.ts +1 -0
- package/dist/components/exams/take/ExamTakingPageContainer.js +1 -1
- package/dist/components/themes/index.d.ts +1 -0
- package/dist/components/themes/index.js +1 -1
- package/dist/components/themes/summer-sky/SummerSkyExitModal.d.ts +8 -0
- package/dist/components/themes/summer-sky/SummerSkyExitModal.js +1 -0
- package/dist/components/themes/summer-sky/assets/images/cancel_exam.jpg +0 -0
- package/dist/components/themes/summer-sky/assets/images/continue_exam.png +0 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/shared/constants/ApiConstant.d.ts +1 -0
- package/dist/shared/constants/ApiConstant.js +1 -1
- package/package.json +155 -163
- package/dist/mcp/config.d.ts +0 -12
- package/dist/mcp/config.js +0 -1
- package/dist/mcp/http-client.d.ts +0 -6
- package/dist/mcp/http-client.js +0 -1
- package/dist/mcp/index.d.ts +0 -6
- package/dist/mcp/index.js +0 -2
- package/dist/mcp/tools/_helpers.d.ts +0 -4
- package/dist/mcp/tools/_helpers.js +0 -1
- package/dist/mcp/tools/exams.d.ts +0 -2
- package/dist/mcp/tools/exams.js +0 -1
- package/dist/mcp/tools/index.d.ts +0 -2
- package/dist/mcp/tools/index.js +0 -1
- package/dist/mcp/tools/results.d.ts +0 -2
- package/dist/mcp/tools/results.js +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @tinyweb_dev/oe-exam-sdk
|
|
2
2
|
|
|
3
|
-
SDK tái sử dụng cho hệ thống OE Exam: màn tạo đề, quản lý câu hỏi, làm bài, xem kết
|
|
3
|
+
SDK tái sử dụng cho hệ thống OE Exam: màn tạo đề, quản lý câu hỏi, làm bài, xem kết quả và theme giao diện.
|
|
4
4
|
|
|
5
5
|
## Cài đặt
|
|
6
6
|
|
|
@@ -91,7 +91,6 @@ export function ResultReviewPage({ attemptId, token, router }) {
|
|
|
91
91
|
@tinyweb_dev/oe-exam-sdk # export tổng hợp thường dùng
|
|
92
92
|
@tinyweb_dev/oe-exam-sdk/api # API adapters, constants, types
|
|
93
93
|
@tinyweb_dev/oe-exam-sdk/shared # shared constants/types/helpers
|
|
94
|
-
@tinyweb_dev/oe-exam-sdk/mcp # MCP server entry và tools
|
|
95
94
|
@tinyweb_dev/oe-exam-sdk/components # shared UI components
|
|
96
95
|
@tinyweb_dev/oe-exam-sdk/components/exams # màn tạo đề / câu hỏi / làm bài / vào phòng
|
|
97
96
|
@tinyweb_dev/oe-exam-sdk/components/exams/entry # màn vào phòng (entry) + state machine
|
|
@@ -238,16 +237,16 @@ Các report shell, renderer, transform helper, polling/status helper và result-
|
|
|
238
237
|
|
|
239
238
|
## MCP server
|
|
240
239
|
|
|
241
|
-
|
|
240
|
+
MCP đã tách sang package riêng:
|
|
242
241
|
|
|
243
242
|
```bash
|
|
244
|
-
oe-exam-mcp
|
|
243
|
+
npm install @tinyweb_dev/oe-exam-mcp-server
|
|
245
244
|
```
|
|
246
245
|
|
|
247
246
|
Chạy bằng PAT/API token. Nếu token có dạng `oeexam_...`, MCP tự gửi qua `X-API-Key`; token khác sẽ gửi qua `Authorization: Bearer`.
|
|
248
247
|
|
|
249
248
|
```bash
|
|
250
|
-
OE_API_URL=http://localhost:3000 OE_API_TOKEN=... npx oe-exam-mcp
|
|
249
|
+
OE_API_URL=http://localhost:3000 OE_API_TOKEN=... npx @tinyweb_dev/oe-exam-mcp-server
|
|
251
250
|
```
|
|
252
251
|
|
|
253
252
|
Tools hiện có:
|
package/dist/api/exam-taking.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{API_BASE_URL as t,API_ENDPOINTS as e}from"../shared/constants/ApiConstant";export function createExamTakingApi(
|
|
1
|
+
import{API_BASE_URL as t,API_ENDPOINTS as e}from"../shared/constants/ApiConstant";export function createExamTakingApi(T={}){const n=function({baseUrl:e=t??"",fetcher:T=fetch,headers:n}){return async function(t,a){const o="undefined"!=typeof FormData&&a?.body instanceof FormData,s=await T(`${e}${t}`,{credentials:"include",...a,headers:{...!o&&{"Content-Type":"application/json"},...n,...a?.headers}});if(!s.ok)throw new Error(await async function(t){const e=await t.json().catch(()=>{});return"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message?e.message:t.statusText}(s));if(204!==s.status)return s.json()}}(T);return{getActiveAttempt:t=>n(e.STUDENT.ATTEMPTS_ACTIVE_BY_ROOM(t)),getActive:()=>n(e.STUDENT.ATTEMPTS_ACTIVE),getAttempt:(t,T)=>n(`${e.STUDENT.ATTEMPT_DETAIL(t)}${T?`?token=${encodeURIComponent(T)}`:""}`),deleteAttempt:t=>n(e.STUDENT.ATTEMPT_DELETE(t),{method:"DELETE"}),getRoom:t=>n(e.STUDENT.ROOM_DETAIL(t)),startAttempt:t=>n(e.STUDENT.ATTEMPTS_START,{method:"POST",body:JSON.stringify({examRoomId:t})}),getQuestions:t=>n(e.STUDENT.ATTEMPT_QUESTIONS(t)),saveAnswers:async({attemptId:t,answers:T,keepalive:a})=>{await n(e.STUDENT.ATTEMPT_ANSWERS(t),{method:"POST",keepalive:a,body:JSON.stringify({answers:T})})},submitAttempt:t=>n(e.STUDENT.ATTEMPT_SUBMIT(t),{method:"POST"}),cancelAttempt:t=>n(e.STUDENT.ATTEMPT_CANCEL(t),{method:"POST"}),uploadAudioAnswer:({attemptId:t,questionId:T,audioBlob:a,durationMs:o})=>{const s=new FormData,i="audio/webm"===a.type?"webm":"audio/ogg"===a.type?"ogg":"mp3";return s.append("file",a,`recording.${i}`),s.append("questionId",T),void 0!==o&&s.append("durationMs",String(o)),n(e.STUDENT.ATTEMPT_AUDIO_ANSWER(t),{method:"POST",body:s})},uploadProctoringSnapshot:({attemptId:t,imageBlob:T})=>{const a=new FormData;return a.append("file",T,"snapshot.jpg"),n(e.STUDENT.ATTEMPT_PROCTORING_SNAPSHOT(t),{method:"POST",body:a})},realtimeGradeSingle:({attemptId:t,questionId:T,audioKey:a})=>n(e.SHARED.SPEAKING_REALTIME_GRADE,{method:"POST",body:JSON.stringify({attemptId:t,questionId:T,audioKey:a})}),getGradingSummary:t=>n(e.STUDENT.ATTEMPT_GRADING_SUMMARY(t)),getAnswerDetail:(t,T)=>n(e.STUDENT.ATTEMPT_ANSWER_DETAIL(t,T)),getAnswersGradingStatus:(t,T)=>n(e.STUDENT.ATTEMPT_ANSWERS_GRADING_STATUS(t),{method:"POST",body:JSON.stringify({answerIds:T})})}}export function createMockExamTakingApi(t){const e=new Map;return{getActiveAttempt:async()=>t.attempt,startAttempt:async()=>t.attempt,getQuestions:async()=>t.questions,saveAnswers:async({answers:t})=>{t.forEach(t=>e.set(t.questionId,t.answer))},submitAttempt:async()=>({answers:Object.fromEntries(e)})}}
|
|
@@ -116,6 +116,7 @@ export interface ExamTakingSdkApi {
|
|
|
116
116
|
getQuestions: (attemptId: string) => Promise<ApiData<ExamTakingQuestionsResult> | ExamTakingQuestionsResult>;
|
|
117
117
|
saveAnswers?: (input: SaveExamTakingAnswersInput) => Promise<void>;
|
|
118
118
|
submitAttempt: (attemptId: string) => Promise<ApiData<SubmitExamTakingAttemptResult> | SubmitExamTakingAttemptResult | unknown>;
|
|
119
|
+
cancelAttempt?: (attemptId: string) => Promise<unknown>;
|
|
119
120
|
uploadAudioAnswer?: (input: {
|
|
120
121
|
attemptId: string;
|
|
121
122
|
questionId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useEffect as i,useRef as s,useState as r,useMemo as a,useCallback as o}from"react";import d from"next/image";import l from"../../../components/themes/summer-sky/assets/images/clock.png";import m from"../../../components/themes/summer-sky/assets/images/submit.png";import c from"../../../components/themes/summer-sky/assets/images/has_answered.png";import{toast as p}from"sonner";import{Loader2 as u}from"lucide-react";import{t as g}from"../../../shared/lib/i18n";import{transformAnswersForSubmission as h}from"./utils/answer-transformers";import{getThemeForLevel as x,normalizeExamTheme as b}from"../../../shared/lib/themes";import{useExamTakingStore as I}from"../../../shared/lib/stores/examTakingStore";import{useGradingTransientStore as f}from"../../../shared/lib/stores/gradingTransientStore";import{AlertDialog as w,AlertDialogAction as E,AlertDialogCancel as S,AlertDialogContent as _,AlertDialogDescription as y,AlertDialogFooter as v,AlertDialogHeader as N,AlertDialogTitle as A}from"../../../components/ui/alert-dialog";import{useExamTimer as T}from"./hooks/useExamTimer";import{useAutoSave as C}from"./hooks/useAutoSave";import{useProctoringCamera as k}from"./hooks/useProctoringCamera";import{getStandardExamTheme as P}from"../../../components/themes";import{QuestionRenderer as q}from"./components/QuestionRenderer";import{FullscreenLoading as M}from"../entry/fullscreen-loading";import{SummerSkySubmitModal as R}from"../../../components/themes/summer-sky/SummerSkySubmitModal";import{EnglishCertificationExamLayout as D,EnglishCertificationQuestionRenderer as L,scrollToEnglishCertQuestion as G}from"../../../components/themes/english-certification";import{groupQuestionsByPart as Q}from"./utils/question-transformers";import{unwrap as B,unwrapAttempt as O}from"./exam-taking.utils";import{ExamTakingApiProvider as Y}from"./ExamTakingApiContext";function F({roomId:Y,api:F,onNavigate:K,resultPath:U=e=>`/student/results/${e}`,fallbackPath:$="/student/contests/discover",proctoringEnabled:V=!1,achieversExamTitle:j,onSubmitted:H}){const z=I(),W=s(!1),J=o((e,t=!1)=>{K?K(e,{replace:t}):"undefined"!=typeof window&&(t?window.location.replace(e):window.location.href=e)},[K]),{isCameraActive:X}=k({api:F,attemptId:z.attemptId,intervalMs:1e4,enabled:V}),[Z,ee]=r(!0),te=z.currentPartIndex,ne=z.currentQuestionGlobalIndex,ie=o(e=>{const t=I.getState().currentPartIndex,n="function"==typeof e?e(t):e;I.getState().setCurrentPartIndex(n)},[]),se=o(e=>{const t=I.getState().currentQuestionGlobalIndex,n="function"==typeof e?e(t):e;I.getState().setCurrentQuestionGlobalIndex(n)},[]),[re,ae]=r([]),[oe,de]=r("SUMMER_SKY"),[le,me]=r(""),[ce,pe]=r(!1),[ue,ge]=r(null),[he,xe]=r(""),be=o(e=>{I.getState().markIntroPlayed(e)},[]),Ie="TOEIC"===z.examType||"ENGLISH_CERTIFICATION"===le,fe=a(()=>{if(!Ie||0===z.parts.length)return te;const e=z.currentIndex;for(let t=0;t<z.parts.length;t++){const n=z.parts[t],i=n.startIndex??0,s=n.endIndex??i;if(e>=i&&e<=s)return t}return 0},[Ie,z.currentIndex,z.parts,te]);i(()=>{(async()=>{try{ee(!0);let e=B(await F.getActiveAttempt(Y));e||(e=O(B(await F.startAttempt(Y))));let t=null;try{t=F.getRoom?B(await F.getRoom(Y)):null,t&&ge(t)}catch{}const{examTemplate:n,questions:i}=B(await F.getQuestions(e.id));n?.title&&xe(n.title);const s=n?.parts??e.exam?.template?.parts,r=Q(i,s),a=n?.subTitle??null,o=(r.every(e=>e.questions.every(e=>"SPEAKING"===e.question_skill_type)),r.some(e=>"SPEAKING"===e.category||e.questions.every(e=>"SPEAKING"===e.question_skill_type)));ae(r);const d=n?.theme||e?.exam?.template?.theme||e?.exam?.theme||t?.exam?.template?.theme||t?.exam?.theme||"",l=b(d);if(o){const e=["SUMMER_SKY"].includes(d);de(e?d:"SUMMER_SKY")}const m=new Date(e.startedAt),c=60*e.durationMinutes*1e3,u=m.getTime()+c,h=Date.now();if(0===Math.max(0,u-h)){p.info(g("student.exam.take.timeExpired"));try{await F.submitAttempt(e.id)}catch{}return I.persist.clearStorage(),void J(U(e.id))}z.hydrateFromServer({attemptId:e.id,examRoomId:Y,questions:i.map(e=>({id:e.id,question_type:e.question_type,content:e.content,is_example:e.is_example,total_points:e.total_points,part_id:e.part_id,part_no:e.part_no,question_number:e.question_number})),durationMinutes:e.durationMinutes,startedAt:e.startedAt,examType:a??void 0,examTitle:n?.title??void 0,parts:s}),a&&z.setExamType(a),me(l),s&&z.setParts(s),ee(!1)}catch(e){const t=e?.response?.data?.errorCode;if("ATTEMPT_ALREADY_SUBMITTED"===t)return p.info(g("student.exam.take.submitted")),void J($,!0);console.error("Failed to load exam data:",e),p.error(g("student.exam.take.loadError")),J($,!0)}})()},[Y]);const we=a(()=>re.length>0&&re.every(e=>e.questions.every(e=>"SPEAKING"===e.question_skill_type)),[re]),Ee=a(()=>{const e=re[te];return!!e&&(("SPEAKING_DESCRIBE_IMAGE"!==e.questionType&&"SPONTANEOUS_QA"!==e.questionType&&"SPEAKING_CUE_CARD"!==e.questionType&&"READ_DISPLAYED_CONTENT"!==e.questionType||"CAMBRIDGE_YLE"!==le)&&("SPEAKING"===e.category||e.questions.every(e=>"SPEAKING"===e.question_skill_type)))},[re,te,le]),{remainingSeconds:Se,warningLevel:_e}=T({onTimeExpired:async()=>{p.info(g("student.exam.take.autoSubmit")),await Ae()},onWarningThreshold:we||Ie?void 0:()=>{p.warning(g("student.exam.take.timeWarning"))},warningThresholdSeconds:we||Ie?void 0:300,warningThresholds:Ie?[{seconds:900,level:"warning",callback:()=>p.warning("Còn 15 phút!",{duration:3e3})},{seconds:300,level:"critical",callback:()=>p.warning("Còn 5 phút! Hãy nộp bài ngay!",{duration:5e3})}]:we?[{seconds:300,level:"warning",callback:()=>p.warning("Còn 5 phút! Hãy hoàn thành bài thi.",{duration:5e3})},{seconds:120,level:"critical",callback:()=>p.warning("Còn 2 phút! Bài thi sẽ được tự động nộp.",{duration:5e3})}]:void 0}),ye=C({api:F,attemptId:z.attemptId||"",parts:re,intervalMs:Ie?15e3:3e4,onSaveError:e=>{console.error("Save error:",e)}}),ve=s(ye.saveNow),Ne=s(re);i(()=>{ve.current=ye.saveNow,Ne.current=re}),i(()=>{const e=()=>{const e=I.getState();if(!e.attemptId||!e.isDirty||e.isSubmitting)return;const t=h(e.answers,Ne.current);if(0!==t.length)try{F.saveAnswers?.({attemptId:e.attemptId,answers:t,keepalive:!0})}catch{}},t=()=>{"hidden"===document.visibilityState&&e()},n=()=>{const e=I.getState();e.isDirty&&!e.isSubmitting&&ve.current()};return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",e),window.addEventListener("online",n),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",e),window.removeEventListener("online",n)}},[]),i(()=>{we||ve.current()},[z.currentIndex,te,ne,we]);const Ae=async()=>{if(!W.current){W.current=!0,z.setIsSubmitting(!0),pe(!1);try{z.isDirty&&await ye.saveNow();const e=B(await F.submitAttempt(z.attemptId)),t=e?.pendingAnswerIds??[];z.attemptId&&(f.getState().setPending(z.attemptId,t),H?.({attemptId:z.attemptId,pendingAnswerIds:t})),0===t.length?p.success(g("student.exam.take.submitSuccess")):p.success(g("student.exam.take.submittedAIGradingInProgress")),I.persist.clearStorage(),J(U(z.attemptId),!0)}catch(e){console.error("Failed to submit exam:",e);const t=e?.response?.data?.errorCode;if("ATTEMPT_ALREADY_SUBMITTED"===t)return I.persist.clearStorage(),void J(U(z.attemptId),!0);p.warning(g("student.exam.take.submitError")),W.current=!1,z.setIsSubmitting(!1)}}},Te=o(()=>{pe(!0)},[]),Ce=s(new Map),ke=s([]),Pe=o((e,t)=>{z.setAnswer(e,t);const n=Ce.current.get(e)||e,i=ke.current.findIndex(e=>e.questionId===n);-1!==i&&se(e=>e!==i?i:e)},[]),qe=s("forward"),Me=e=>{if("CAMBRIDGE_YLE"!==le)return!1;const t=re[e];return"SPEAKING_DESCRIBE_IMAGE"===t?.questionType||"SPONTANEOUS_QA"===t?.questionType||"SPEAKING_CUE_CARD"===t?.questionType||"READ_DISPLAYED_CONTENT"===t?.questionType},Re=()=>{const e=()=>{window.scrollTo({top:0,behavior:"smooth"});const e=document.getElementById("exam-main-scroll-area");if(e){e.scrollTo({top:0,behavior:"smooth"});e.querySelectorAll(".overflow-y-auto").forEach(e=>{e.scrollTo({top:0,behavior:"smooth"})})}};requestAnimationFrame(e),setTimeout(e,100),setTimeout(e,250)},De=()=>{if("ENGLISH_CERTIFICATION"===le){const e=z.parts[fe+1];e&&z.goToQuestion(e.startIndex??0)}else if(Ie)z.goToQuestion(Math.min(z.currentIndex+1,z.questions.length-1));else if("CAMBRIDGE_YLE"===le&&Me(te)){const e=ne+1,t=$e[e];t&&(t.partIndex!==te&&(qe.current="forward",ie(t.partIndex)),se(e))}else qe.current="forward",ie(e=>{const t=Math.min(e+1,re.length-1);if("CAMBRIDGE_YLE"===le){const e=$e.find(e=>e.partIndex===t);e&&se(e.globalIndex)}return t});Re()},Le=()=>{if("ENGLISH_CERTIFICATION"===le){const e=z.parts[fe-1];e&&z.goToQuestion(e.startIndex??0)}else if(Ie)z.goToQuestion(Math.max(z.currentIndex-1,0));else if("CAMBRIDGE_YLE"===le&&Me(te)){const e=ne-1,t=$e[e];t&&(t.partIndex!==te&&(qe.current="backward",ie(t.partIndex)),se(e))}else qe.current="backward",ie(e=>{const t=Math.max(e-1,0);if("CAMBRIDGE_YLE"===le){const e=$e.find(e=>e.partIndex===t);e&&se(e.globalIndex)}return t});Re()},Ge=()=>{J($)},Qe=a(()=>re.reduce((e,t)=>e+("CAMBRIDGE_YLE"===le?t.questions.length:t.questions.filter(e=>!e.is_example).length),0),[re,le]),Be=a(()=>{const e=new Map;return re.forEach(t=>{t.questions.forEach(n=>{if(n.is_example)return;const i=n.content;if("FILL_MISSING_WORDS_IN_GRID"===t.questionType&&i?.grid&&i.grid.forEach((t,i)=>{t.forEach((t,s)=>{e.set(`${i}-${s}`,n.id)})}),"LABEL_THE_PICTURE"===t.questionType&&i?.labels&&i.labels.forEach(t=>{t.id&&e.set(t.id,n.id)}),"READ_AND_COLOR_OBJECTS"===t.questionType){const t=i?.regions||i?.regionNodes;t?.forEach(t=>{t.id&&e.set(t.id,n.id)})}if("IMAGE_OBJECT_MATCHING"===t.questionType){const t=i?.regions||i?.regionNodes;t?.forEach(t=>{t.id&&e.set(t.id,n.id)})}if("LOOK_PICTURE_FILL_WORD_HINT"===t.questionType){const t=i?.word;if(t&&"string"==typeof t){const i=/\{(\d+)\}/g;let s;for(;null!==(s=i.exec(t));){const t=s[1];e.set(`${n.id}-blank-${t}`,n.id)}}}})}),e},[re]);i(()=>{Ce.current=Be},[Be]);const Oe=a(()=>{if(!z.answers)return new Set;const e=new Set(re.flatMap(e=>e.questions.filter(e=>!e.is_example).map(e=>e.id))),t=new Set;return Object.keys(z.answers).forEach(n=>{const i=z.answers[n];if(void 0===i||""===i)return;if(e.has(n))return void t.add(n);const s=Be.get(n);s&&e.has(s)&&t.add(s)}),t},[z.answers,re,Be]),Ye=Oe.size+("CAMBRIDGE_YLE"===le?re.reduce((e,t)=>e+t.questions.filter(e=>e.is_example).length,0):0),Fe=a(()=>ue?.exam?.name||ue?.name||(Ie?"TOEIC Listening and Reading Test":"Bài thi"),[ue,Ie]),Ke=a(()=>x(ue?.exam?.level).displayName,[ue?.exam?.level]),{sidebarParts:Ue,sidebarQuestions:$e}=a(()=>{const e=[],t=[];let n=0;return re.forEach((i,s)=>{const r="CAMBRIDGE_YLE"===le?i.questions:i.questions.filter(e=>!e.is_example);let a=0;r.forEach(e=>{const r=!("CAMBRIDGE_YLE"!==le||!e.is_example)||Oe.has(e.id);r&&a++;const o=i.questions.findIndex(t=>t.id===e.id);t.push({globalIndex:n,partIndex:s,indexInPart:o,questionNumber:e.question_number,isAnswered:r,questionId:e.id,isExample:e.is_example}),n++}),e.push({partIndex:s,partNo:i.partNo,name:i.name,category:i.category,points:i.points,totalQuestions:"CAMBRIDGE_YLE"===le?i.questions.length:i.questions.filter(e=>!e.is_example).length,answeredCount:a})}),{sidebarParts:e,sidebarQuestions:t}},[re,Oe,le]);if(i(()=>{ke.current=$e},[$e]),Z)return e(M,{});const Ve=te,je=re[Ve];if(!je)return e("div",{className:"flex min-h-screen items-center justify-center",children:t("div",{className:"text-center",children:[e("p",{className:"text-lg font-semibold text-red-500",children:"Không tìm thấy câu há»i"}),e("button",{type:"button",onClick:()=>J($),className:"mt-4 rounded-lg bg-blue-500 px-4 py-2 text-white hover:bg-blue-600",children:"Quay lại"})]})});if(Ee)return t(n,{children:[e(q,{part:je,answers:z.answers||{},onAnswerChange:Pe,isReviewMode:!1,onExit:Ge,onPartComplete:Ve<re.length-1?De:Te,onPartBack:Ve>0?Le:void 0,speakingTheme:oe,initialQuestionIndex:"backward"===qe.current?je.questions.length-1:0,skipTeacherVideo:z.playedIntroParts.has(Ve)||he!==j,onTeacherIntroPlayed:()=>be(Ve)},`${je.partId}-${Ve}`),"SUMMER_SKY"===oe?ce&&e(R,{onClose:()=>pe(!1),onSubmit:Ae,isSubmitting:z.isSubmitting}):e(w,{open:ce,onOpenChange:pe,children:t(_,{children:[t(N,{children:[e(A,{children:"Nộp bài thi"}),e(y,{children:"Bạn có chắc chắn muốn nộp bài không? Sau khi nộp, bạn sẽ không thể thay đổi câu trả lời."})]}),t(v,{children:[e(S,{disabled:z.isSubmitting,children:"Quay lại"}),e(E,{onClick:Ae,disabled:z.isSubmitting,children:z.isSubmitting?t(n,{children:[e(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Đang nộp..."]}):"Nộp bài"})]})]})}),t("div",{className:"fixed top-8 right-6 z-[100] flex flex-col items-end gap-4 sm:gap-6 lg:top-10 lg:right-16",children:[t("div",{className:"flex items-center gap-4 sm:gap-6",children:[Se>0&&t("div",{className:"flex items-center w-[130px] sm:w-[170px] h-[40px] sm:h-[50px] rounded-[33.5px] backdrop-blur-[8px] transition-all duration-300 ease-in-out border-none shadow-[0_4px_20px_rgba(0,0,0,0.25)] "+("critical"===_e?"bg-[rgba(220,38,38,0.85)] shadow-[0_0_24px_rgba(220,38,38,0.5)] animate-pulse":"warning"===_e?"bg-[rgba(180,120,0,0.85)]":"bg-[#001590]"),children:[e(d,{src:l,alt:"clock",width:75,height:75,className:"w-[50px] h-[50px] sm:w-[75px] sm:h-[75px] -ml-[5px] sm:-ml-[10px] -mt-[10px] sm:-mt-[15px] shrink-0 drop-shadow-[0_2px_6px_rgba(0,0,0,0.2)] pointer-events-none z-10"}),t("span",{className:"flex-1 text-center font-bold text-[18px] sm:text-[25px] leading-none tracking-[-0.03em] uppercase text-white pr-[10px] sm:pr-[16px]",style:{fontFamily:"'SVN-Volte Rounded', 'Quicksand', sans-serif",textShadow:"0 2px 4px rgba(0, 0, 0, 0.2)"},children:[Math.floor(Se/60).toString().padStart(2,"0"),":",(Se%60).toString().padStart(2,"0")]})]}),t("div",{className:"flex items-center w-[130px] sm:w-[170px] h-[40px] sm:h-[50px] rounded-[33.5px] bg-[#FF9900] shadow-[0_4px_20px_rgba(0,0,0,0.25)] border-none shrink-0",title:"Số câu hỏi đã hoàn thành",children:[e(d,{src:c,alt:"Progress",width:75,height:75,className:"w-[50px] h-[50px] sm:w-[75px] sm:h-[75px] -ml-[5px] sm:-ml-[10px] -mt-[10px] sm:-mt-[15px] shrink-0 drop-shadow-[0_2px_6px_rgba(0,0,0,0.2)] pointer-events-none z-10"}),t("span",{className:"flex-1 text-center font-bold text-[18px] sm:text-[25px] leading-none tracking-[-0.03em] uppercase text-white pr-[10px] sm:pr-[16px]",style:{fontFamily:'"SVN-Volte Rounded", "Quicksand", sans-serif',textShadow:"0 2px 4px rgba(0,0,0,0.2)"},children:[Ye,"/",Qe]})]})]}),t("button",{onClick:Te,disabled:z.isSubmitting,className:"group cursor-pointer flex items-center h-[40px] sm:h-[50px] w-[130px] sm:w-[170px] rounded-[33.5px] shadow-[0_4px_20px_rgba(0,0,0,0.25)] transition-all duration-300 hover:scale-105 active:scale-95 disabled:pointer-events-none disabled:opacity-60 border-none "+(z.isSubmitting?"bg-slate-400":"bg-[#16CA3B] hover:bg-[#15b736]"),children:[e(d,{src:m,alt:"Submit",width:75,height:75,className:"w-[50px] h-[50px] sm:w-[75px] sm:h-[75px] -ml-[5px] sm:-ml-[10px] -mt-[10px] sm:-mt-[15px] shrink-0 drop-shadow-[0_2px_6px_rgba(0,0,0,0.2)] pointer-events-none transition-transform duration-300 group-hover:scale-110 z-10"}),z.isSubmitting?e("div",{className:"flex-1 flex justify-center pr-[10px] sm:pr-[16px]",children:e(u,{className:"h-6 w-6 animate-spin text-white"})}):e("span",{className:"flex-1 text-center font-bold text-[18px] sm:text-[25px] leading-none tracking-[-0.03em] uppercase text-white pr-[10px] sm:pr-[16px]",style:{fontFamily:'"SVN-Volte Rounded", "Quicksand", sans-serif',textShadow:"0 2px 4px rgba(0,0,0,0.2)"},children:"Nộp bài"})]})]}),z.isSubmitting&&e("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:t("div",{className:"rounded-xl bg-white p-8 text-center shadow-2xl",children:[e(u,{className:"mx-auto h-12 w-12 animate-spin text-green-500"}),e("p",{className:"mt-4 text-lg font-semibold text-gray-700",children:"Đang nộp bài..."}),e("p",{className:"mt-2 text-sm text-gray-500",children:"Vui lòng đợi trong giây lát"})]})})]});if(Ie){const i=re[fe],s=z.parts[fe],r=s?Math.max(0,z.currentIndex-(s.startIndex??0)):0,a=(s?.startIndex??0)+1,o=(s?.endIndex??a-1)+1,d={examName:Fe,remainingSeconds:z.remainingSeconds,totalQuestions:Qe,answeredCount:Ye,isSubmitting:z.isSubmitting,onSubmit:Ae,onClose:Ge,lastSavedAt:z.lastSavedAt,isSaving:ye.isSaving,partLabel:(s?.name||i?.name||"").toUpperCase()||void 0,partSubLabel:s?.category||void 0,questionRange:a===o?`${a}`:`${a}–${o}`},l=i?.questions?.[r],m="ENGLISH_CERTIFICATION"===le,c={onPrevious:Le,onClear:m?void 0:()=>{l&&Pe(l.id,{optionId:null})},onToggleMark:m?void 0:()=>{l&&z.toggleFlag(l.id)},onNext:De,isMarked:!!l&&z.flaggedQuestions.has(l.id),showSecondaryActions:!m,isPreviousDisabled:m?fe<=0:z.currentIndex<=0,isNextDisabled:m?fe>=z.parts.length-1:z.currentIndex>=z.questions.length-1},p={parts:z.parts,questions:z.questions,answers:z.answers,flaggedQuestions:z.flaggedQuestions,currentIndex:z.currentIndex,onQuestionClick:e=>{z.goToQuestion(e);const t=z.questions[e];t&&G(t.id,{behavior:"smooth",block:"start"})},onPartClick:e=>{const t=z.parts[e];if(t){const n=t.startIndex??0;z.goToQuestion(n),z.setCurrentPartIndex(e);const i=z.questions[n];i&&G(i.id,{behavior:"smooth",block:"start"})}}};if(i&&s)return t(n,{children:[e(D,{headerProps:d,navigationProps:p,footerProps:c,children:e(L,{part:i,partConfig:s,currentQuestionIndex:r,answers:z.answers,flaggedQuestions:z.flaggedQuestions,onAnswerChange:Pe,onToggleFlag:e=>z.toggleFlag(e),isReviewMode:!1,isAudioPlayed:z.playedListeningAudioParts.has(i.partId),onAudioFirstPlay:()=>z.markListeningAudioPlayed(i.partId)})}),z.isSubmitting&&e("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:t("div",{className:"rounded-xl bg-white p-8 text-center shadow-2xl",children:[e(u,{className:"mx-auto h-12 w-12 animate-spin text-green-500"}),e("p",{className:"mt-4 text-lg font-semibold text-gray-700",children:"Đang nộp bài..."}),e("p",{className:"mt-2 text-sm text-gray-500",children:"Vui lòng đợi trong giây lát"})]})})]})}return t(n,{children:[(()=>{const{Layout:n,QuestionCard:i}=P(le),s={headerProps:{examName:Fe,examType:"EXAM",levelLabel:Ke,totalQuestions:Qe,answeredCount:Ye,remainingSeconds:z.remainingSeconds,isSubmitting:z.isSubmitting,isCameraActive:X,onSubmit:Te},onPrevious:Le,onNext:De,onClose:Ge,isNavDisabled:z.isNavDisabled,partName:je?.name||(je?.partNo?`PART ${je.partNo}`:void 0)};if("CAMBRIDGE_YLE"===le){const e=Me(Ve);s.isFirstQuestion=e?0===ne:0===Ve,s.isLastQuestion=e?ne===$e.length-1:Ve===re.length-1,s.sidebarProps={parts:Ue,questions:$e,currentQuestionGlobalIndex:ne,isNavDisabled:z.isNavDisabled,onPartClick:e=>{if(z.isNavDisabled)return;qe.current=e>Ve?"forward":"backward",ie(e);const t=$e.find(t=>t.partIndex===e);t&&se(t.globalIndex),Re()},onQuestionClick:e=>{if(z.isNavDisabled)return;const t=$e[e];t&&t.partIndex!==Ve&&(qe.current=t.partIndex>Ve?"forward":"backward",ie(t.partIndex)),se(e),t&&setTimeout(()=>{const e=document.getElementById(`question-${t.questionId}`);e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)}}}else s.isFirstQuestion=0===Ve,s.isLastQuestion=Ve===re.length-1;const r="CAMBRIDGE_YLE"===le&&("SPEAKING_DESCRIBE_IMAGE"===je?.questionType||"SPONTANEOUS_QA"===je?.questionType||"SPEAKING_CUE_CARD"===je?.questionType||"READ_DISPLAYED_CONTENT"===je?.questionType),a=$e[ne],o=r&&a?.partIndex===Ve?a.indexInPart:void 0;return t(n,{...s,children:[e(i,{partName:je?.name||(je?.partNo?`PART ${je.partNo}`:void 0),children:e(q,{part:je,answers:z.answers||{},onAnswerChange:Pe,isReviewMode:!1,currentQuestionIndex:o,onExit:Ge,onPartComplete:Ve<re.length-1?De:Te,onPartBack:Ve>0?Le:void 0,speakingTheme:"CAMBRIDGE_YLE"===le?"CAMBRIDGE_YLE":oe,initialQuestionIndex:"backward"===qe.current?je?.questions.length-1:0,skipTeacherVideo:z.playedIntroParts.has(Ve)||he!==j,onTeacherIntroPlayed:()=>be(Ve)})}),z.isSubmitting&&e("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:t("div",{className:"rounded-xl bg-white p-8 text-center shadow-2xl",children:[e(u,{className:"mx-auto h-12 w-12 animate-spin text-green-500"}),e("p",{className:"mt-4 text-lg font-semibold text-gray-700",children:"Đang nộp bài..."}),e("p",{className:"mt-2 text-sm text-gray-500",children:"Vui lòng đợi trong giây lát"})]})})]})})(),"CAMBRIDGE_YLE"===le?ce&&e(R,{onClose:()=>pe(!1),onSubmit:Ae,isSubmitting:z.isSubmitting}):e(w,{open:ce,onOpenChange:pe,children:t(_,{children:[t(N,{children:[e(A,{children:"Nộp bài thi"}),e(y,{children:"Bạn có chắc chắn muốn nộp bài không? Sau khi nộp, bạn sẽ không thể thay đổi câu trả lời."})]}),t(v,{children:[e(S,{disabled:z.isSubmitting,children:"Quay lại"}),e(E,{onClick:Ae,disabled:z.isSubmitting,children:z.isSubmitting?t(n,{children:[e(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Äang ná»™p..."]}):"Nộp bài"})]})]})})]})}export function ExamTakingPageContainer(t){return e(Y,{api:t.api,children:e(F,{...t})})}
|
|
1
|
+
"use client";import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useEffect as i,useRef as s,useState as r,useMemo as a,useCallback as o}from"react";import d from"next/image";import l from"../../../components/themes/summer-sky/assets/images/clock.png";import c from"../../../components/themes/summer-sky/assets/images/submit.png";import m from"../../../components/themes/summer-sky/assets/images/has_answered.png";import{toast as p}from"sonner";import{Loader2 as u}from"lucide-react";import{t as g}from"../../../shared/lib/i18n";import{transformAnswersForSubmission as h}from"./utils/answer-transformers";import{getThemeForLevel as x,normalizeExamTheme as b}from"../../../shared/lib/themes";import{useExamTakingStore as f}from"../../../shared/lib/stores/examTakingStore";import{useGradingTransientStore as I}from"../../../shared/lib/stores/gradingTransientStore";import{AlertDialog as w,AlertDialogAction as E,AlertDialogCancel as S,AlertDialogContent as y,AlertDialogDescription as _,AlertDialogFooter as v,AlertDialogHeader as N,AlertDialogTitle as A}from"../../../components/ui/alert-dialog";import{useExamTimer as T}from"./hooks/useExamTimer";import{useAutoSave as C}from"./hooks/useAutoSave";import{useProctoringCamera as k}from"./hooks/useProctoringCamera";import{getStandardExamTheme as P}from"../../../components/themes";import{QuestionRenderer as q}from"./components/QuestionRenderer";import{FullscreenLoading as M}from"../entry/fullscreen-loading";import{SummerSkySubmitModal as R}from"../../../components/themes/summer-sky/SummerSkySubmitModal";import{SummerSkyExitModal as D}from"../../../components/themes/summer-sky/SummerSkyExitModal";import{EnglishCertificationExamLayout as L,EnglishCertificationQuestionRenderer as G,scrollToEnglishCertQuestion as Q}from"../../../components/themes/english-certification";import{groupQuestionsByPart as B}from"./utils/question-transformers";import{unwrap as O,unwrapAttempt as Y}from"./exam-taking.utils";import{ExamTakingApiProvider as F}from"./ExamTakingApiContext";function K({roomId:F,api:K,onNavigate:U,resultPath:$=e=>`/student/results/${e}`,fallbackPath:V="/student/contests/discover",proctoringEnabled:j=!1,achieversExamTitle:H,onSubmitted:z}){const W=f(),J=s(!1),X=o((e,t=!1)=>{U?U(e,{replace:t}):"undefined"!=typeof window&&(t?window.location.replace(e):window.location.href=e)},[U]),{isCameraActive:Z}=k({api:K,attemptId:W.attemptId,intervalMs:1e4,enabled:j}),[ee,te]=r(!0),ne=W.currentPartIndex,ie=W.currentQuestionGlobalIndex,se=o(e=>{const t=f.getState().currentPartIndex,n="function"==typeof e?e(t):e;f.getState().setCurrentPartIndex(n)},[]),re=o(e=>{const t=f.getState().currentQuestionGlobalIndex,n="function"==typeof e?e(t):e;f.getState().setCurrentQuestionGlobalIndex(n)},[]),[ae,oe]=r([]),[de,le]=r("SUMMER_SKY"),[ce,me]=r(""),[pe,ue]=r(!1),[ge,he]=r(!1),[xe,be]=r(null),[fe,Ie]=r(""),we=o(e=>{f.getState().markIntroPlayed(e)},[]),Ee="TOEIC"===W.examType||"ENGLISH_CERTIFICATION"===ce,Se=a(()=>{if(!Ee||0===W.parts.length)return ne;const e=W.currentIndex;for(let t=0;t<W.parts.length;t++){const n=W.parts[t],i=n.startIndex??0,s=n.endIndex??i;if(e>=i&&e<=s)return t}return 0},[Ee,W.currentIndex,W.parts,ne]);i(()=>{(async()=>{try{te(!0);let e=O(await K.getActiveAttempt(F));e||(e=Y(O(await K.startAttempt(F))));let t=null;try{t=K.getRoom?O(await K.getRoom(F)):null,t&&be(t)}catch{}const{examTemplate:n,questions:i}=O(await K.getQuestions(e.id));n?.title&&Ie(n.title);const s=n?.parts??e.exam?.template?.parts,r=B(i,s),a=n?.subTitle??null,o=(r.every(e=>e.questions.every(e=>"SPEAKING"===e.question_skill_type)),r.some(e=>"SPEAKING"===e.category||e.questions.every(e=>"SPEAKING"===e.question_skill_type)));oe(r);const d=n?.theme||e?.exam?.template?.theme||e?.exam?.theme||t?.exam?.template?.theme||t?.exam?.theme||"",l=b(d);if(o){const e=["SUMMER_SKY"].includes(d);le(e?d:"SUMMER_SKY")}const c=new Date(e.startedAt),m=60*e.durationMinutes*1e3,u=c.getTime()+m,h=Date.now();if(0===Math.max(0,u-h)){p.info(g("student.exam.take.timeExpired"));try{await K.submitAttempt(e.id)}catch{}return f.persist.clearStorage(),void X($(e.id))}W.hydrateFromServer({attemptId:e.id,examRoomId:F,questions:i.map(e=>({id:e.id,question_type:e.question_type,content:e.content,is_example:e.is_example,total_points:e.total_points,part_id:e.part_id,part_no:e.part_no,question_number:e.question_number})),durationMinutes:e.durationMinutes,startedAt:e.startedAt,examType:a??void 0,examTitle:n?.title??void 0,parts:s}),a&&W.setExamType(a),me(l),s&&W.setParts(s),te(!1)}catch(e){const t=e?.response?.data?.errorCode;if("ATTEMPT_ALREADY_SUBMITTED"===t)return p.info(g("student.exam.take.submitted")),void X(V,!0);console.error("Failed to load exam data:",e),p.error(g("student.exam.take.loadError")),X(V,!0)}})()},[F]);const ye=a(()=>ae.length>0&&ae.every(e=>e.questions.every(e=>"SPEAKING"===e.question_skill_type)),[ae]),_e=a(()=>{const e=ae[ne];return!!e&&(("SPEAKING_DESCRIBE_IMAGE"!==e.questionType&&"SPONTANEOUS_QA"!==e.questionType&&"SPEAKING_CUE_CARD"!==e.questionType&&"READ_DISPLAYED_CONTENT"!==e.questionType||"CAMBRIDGE_YLE"!==ce)&&("SPEAKING"===e.category||e.questions.every(e=>"SPEAKING"===e.question_skill_type)))},[ae,ne,ce]),{remainingSeconds:ve,warningLevel:Ne}=T({onTimeExpired:async()=>{p.info(g("student.exam.take.autoSubmit")),await ke()},onWarningThreshold:ye||Ee?void 0:()=>{p.warning(g("student.exam.take.timeWarning"))},warningThresholdSeconds:ye||Ee?void 0:300,warningThresholds:Ee?[{seconds:900,level:"warning",callback:()=>p.warning("Còn 15 phút!",{duration:3e3})},{seconds:300,level:"critical",callback:()=>p.warning("Còn 5 phút! Hãy nộp bài ngay!",{duration:5e3})}]:ye?[{seconds:300,level:"warning",callback:()=>p.warning("Còn 5 phút! Hãy hoàn thành bài thi.",{duration:5e3})},{seconds:120,level:"critical",callback:()=>p.warning("Còn 2 phút! Bài thi sẽ được tự động nộp.",{duration:5e3})}]:void 0}),Ae=C({api:K,attemptId:W.attemptId||"",parts:ae,intervalMs:Ee?15e3:3e4,onSaveError:e=>{console.error("Save error:",e)}}),Te=s(Ae.saveNow),Ce=s(ae);i(()=>{Te.current=Ae.saveNow,Ce.current=ae}),i(()=>{const e=()=>{const e=f.getState();if(!e.attemptId||!e.isDirty||e.isSubmitting)return;const t=h(e.answers,Ce.current);if(0!==t.length)try{K.saveAnswers?.({attemptId:e.attemptId,answers:t,keepalive:!0})}catch{}},t=()=>{"hidden"===document.visibilityState&&e()},n=()=>{const e=f.getState();e.isDirty&&!e.isSubmitting&&Te.current()};return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",e),window.addEventListener("online",n),()=>{document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",e),window.removeEventListener("online",n)}},[]),i(()=>{ye||Te.current()},[W.currentIndex,ne,ie,ye]);const ke=async()=>{if(!J.current){J.current=!0,W.setIsSubmitting(!0),ue(!1);try{W.isDirty&&await Ae.saveNow();const e=O(await K.submitAttempt(W.attemptId)),t=e?.pendingAnswerIds??[];W.attemptId&&(I.getState().setPending(W.attemptId,t),z?.({attemptId:W.attemptId,pendingAnswerIds:t})),0===t.length?p.success(g("student.exam.take.submitSuccess")):p.success(g("student.exam.take.submittedAIGradingInProgress")),f.persist.clearStorage(),X($(W.attemptId),!0)}catch(e){console.error("Failed to submit exam:",e);const t=e?.response?.data?.errorCode;if("ATTEMPT_ALREADY_SUBMITTED"===t)return f.persist.clearStorage(),void X($(W.attemptId),!0);p.warning(g("student.exam.take.submitError")),J.current=!1,W.setIsSubmitting(!1)}}},Pe=o(()=>{ue(!0)},[]),qe=s(new Map),Me=s([]),Re=o((e,t)=>{W.setAnswer(e,t);const n=qe.current.get(e)||e,i=Me.current.findIndex(e=>e.questionId===n);-1!==i&&re(e=>e!==i?i:e)},[]),De=s("forward"),Le=e=>{if("CAMBRIDGE_YLE"!==ce)return!1;const t=ae[e];return"SPEAKING_DESCRIBE_IMAGE"===t?.questionType||"SPONTANEOUS_QA"===t?.questionType||"SPEAKING_CUE_CARD"===t?.questionType||"READ_DISPLAYED_CONTENT"===t?.questionType},Ge=()=>{const e=()=>{window.scrollTo({top:0,behavior:"smooth"});const e=document.getElementById("exam-main-scroll-area");if(e){e.scrollTo({top:0,behavior:"smooth"});e.querySelectorAll(".overflow-y-auto").forEach(e=>{e.scrollTo({top:0,behavior:"smooth"})})}};requestAnimationFrame(e),setTimeout(e,100),setTimeout(e,250)},Qe=()=>{if("ENGLISH_CERTIFICATION"===ce){const e=W.parts[Se+1];e&&W.goToQuestion(e.startIndex??0)}else if(Ee)W.goToQuestion(Math.min(W.currentIndex+1,W.questions.length-1));else if("CAMBRIDGE_YLE"===ce&&Le(ne)){const e=ie+1,t=We[e];t&&(t.partIndex!==ne&&(De.current="forward",se(t.partIndex)),re(e))}else De.current="forward",se(e=>{const t=Math.min(e+1,ae.length-1);if("CAMBRIDGE_YLE"===ce){const e=We.find(e=>e.partIndex===t);e&&re(e.globalIndex)}return t});Ge()},Be=()=>{if("ENGLISH_CERTIFICATION"===ce){const e=W.parts[Se-1];e&&W.goToQuestion(e.startIndex??0)}else if(Ee)W.goToQuestion(Math.max(W.currentIndex-1,0));else if("CAMBRIDGE_YLE"===ce&&Le(ne)){const e=ie-1,t=We[e];t&&(t.partIndex!==ne&&(De.current="backward",se(t.partIndex)),re(e))}else De.current="backward",se(e=>{const t=Math.max(e-1,0);if("CAMBRIDGE_YLE"===ce){const e=We.find(e=>e.partIndex===t);e&&re(e.globalIndex)}return t});Ge()},[Oe,Ye]=r(!1),Fe=()=>{he(!0)},Ke=a(()=>ae.reduce((e,t)=>e+("CAMBRIDGE_YLE"===ce?t.questions.length:t.questions.filter(e=>!e.is_example).length),0),[ae,ce]),Ue=a(()=>{const e=new Map;return ae.forEach(t=>{t.questions.forEach(n=>{if(n.is_example)return;const i=n.content;if("FILL_MISSING_WORDS_IN_GRID"===t.questionType&&i?.grid&&i.grid.forEach((t,i)=>{t.forEach((t,s)=>{e.set(`${i}-${s}`,n.id)})}),"LABEL_THE_PICTURE"===t.questionType&&i?.labels&&i.labels.forEach(t=>{t.id&&e.set(t.id,n.id)}),"READ_AND_COLOR_OBJECTS"===t.questionType){const t=i?.regions||i?.regionNodes;t?.forEach(t=>{t.id&&e.set(t.id,n.id)})}if("IMAGE_OBJECT_MATCHING"===t.questionType){const t=i?.regions||i?.regionNodes;t?.forEach(t=>{t.id&&e.set(t.id,n.id)})}if("LOOK_PICTURE_FILL_WORD_HINT"===t.questionType){const t=i?.word;if(t&&"string"==typeof t){const i=/\{(\d+)\}/g;let s;for(;null!==(s=i.exec(t));){const t=s[1];e.set(`${n.id}-blank-${t}`,n.id)}}}})}),e},[ae]);i(()=>{qe.current=Ue},[Ue]);const $e=a(()=>{if(!W.answers)return new Set;const e=new Set(ae.flatMap(e=>e.questions.filter(e=>!e.is_example).map(e=>e.id))),t=new Set;return Object.keys(W.answers).forEach(n=>{const i=W.answers[n];if(void 0===i||""===i)return;if(e.has(n))return void t.add(n);const s=Ue.get(n);s&&e.has(s)&&t.add(s)}),t},[W.answers,ae,Ue]),Ve=$e.size+("CAMBRIDGE_YLE"===ce?ae.reduce((e,t)=>e+t.questions.filter(e=>e.is_example).length,0):0),je=a(()=>xe?.exam?.name||xe?.name||(Ee?"TOEIC Listening and Reading Test":"Bài thi"),[xe,Ee]),He=a(()=>x(xe?.exam?.level).displayName,[xe?.exam?.level]),{sidebarParts:ze,sidebarQuestions:We}=a(()=>{const e=[],t=[];let n=0;return ae.forEach((i,s)=>{const r="CAMBRIDGE_YLE"===ce?i.questions:i.questions.filter(e=>!e.is_example);let a=0;r.forEach(e=>{const r=!("CAMBRIDGE_YLE"!==ce||!e.is_example)||$e.has(e.id);r&&a++;const o=i.questions.findIndex(t=>t.id===e.id);t.push({globalIndex:n,partIndex:s,indexInPart:o,questionNumber:e.question_number,isAnswered:r,questionId:e.id,isExample:e.is_example}),n++}),e.push({partIndex:s,partNo:i.partNo,name:i.name,category:i.category,points:i.points,totalQuestions:"CAMBRIDGE_YLE"===ce?i.questions.length:i.questions.filter(e=>!e.is_example).length,answeredCount:a})}),{sidebarParts:e,sidebarQuestions:t}},[ae,$e,ce]);if(i(()=>{Me.current=We},[We]),ee)return e(M,{});const Je=ne,Xe=ae[Je];if(!Xe)return e("div",{className:"flex min-h-screen items-center justify-center",children:t("div",{className:"text-center",children:[e("p",{className:"text-lg font-semibold text-red-500",children:"Không tìm thấy câu há»i"}),e("button",{type:"button",onClick:()=>X(V),className:"mt-4 rounded-lg bg-blue-500 px-4 py-2 text-white hover:bg-blue-600",children:"Quay lại"})]})});if(_e)return t(n,{children:[e(q,{part:Xe,answers:W.answers||{},onAnswerChange:Re,isReviewMode:!1,onExit:Fe,onPartComplete:Je<ae.length-1?Qe:Pe,onPartBack:Je>0?Be:void 0,speakingTheme:de,initialQuestionIndex:"backward"===De.current?Xe.questions.length-1:0,skipTeacherVideo:W.playedIntroParts.has(Je)||fe!==H,onTeacherIntroPlayed:()=>we(Je)},`${Xe.partId}-${Je}`),"SUMMER_SKY"===de?pe&&e(R,{onClose:()=>ue(!1),onSubmit:ke,isSubmitting:W.isSubmitting}):e(w,{open:pe,onOpenChange:ue,children:t(y,{children:[t(N,{children:[e(A,{children:"Nộp bài thi"}),e(_,{children:"Bạn có chắc chắn muốn nộp bài không? Sau khi nộp, bạn sẽ không thể thay đổi câu trả lời."})]}),t(v,{children:[e(S,{disabled:W.isSubmitting,children:"Quay lại"}),e(E,{onClick:ke,disabled:W.isSubmitting,children:W.isSubmitting?t(n,{children:[e(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Đang nộp..."]}):"Nộp bài"})]})]})}),t("div",{className:"fixed top-8 right-6 z-[100] flex flex-col items-end gap-4 sm:gap-6 lg:top-10 lg:right-16",children:[t("div",{className:"flex items-center gap-4 sm:gap-6",children:[ve>0&&t("div",{className:"flex items-center w-[130px] sm:w-[170px] h-[40px] sm:h-[50px] rounded-[33.5px] backdrop-blur-[8px] transition-all duration-300 ease-in-out border-none shadow-[0_4px_20px_rgba(0,0,0,0.25)] "+("critical"===Ne?"bg-[rgba(220,38,38,0.85)] shadow-[0_0_24px_rgba(220,38,38,0.5)] animate-pulse":"warning"===Ne?"bg-[rgba(180,120,0,0.85)]":"bg-[#001590]"),children:[e(d,{src:l,alt:"clock",width:75,height:75,className:"w-[50px] h-[50px] sm:w-[75px] sm:h-[75px] -ml-[5px] sm:-ml-[10px] -mt-[10px] sm:-mt-[15px] shrink-0 drop-shadow-[0_2px_6px_rgba(0,0,0,0.2)] pointer-events-none z-10"}),t("span",{className:"flex-1 text-center font-bold text-[18px] sm:text-[25px] leading-none tracking-[-0.03em] uppercase text-white pr-[10px] sm:pr-[16px]",style:{fontFamily:"'SVN-Volte Rounded', 'Quicksand', sans-serif",textShadow:"0 2px 4px rgba(0, 0, 0, 0.2)"},children:[Math.floor(ve/60).toString().padStart(2,"0"),":",(ve%60).toString().padStart(2,"0")]})]}),t("div",{className:"flex items-center w-[130px] sm:w-[170px] h-[40px] sm:h-[50px] rounded-[33.5px] bg-[#FF9900] shadow-[0_4px_20px_rgba(0,0,0,0.25)] border-none shrink-0",title:"Số câu hỏi đã hoàn thành",children:[e(d,{src:m,alt:"Progress",width:75,height:75,className:"w-[50px] h-[50px] sm:w-[75px] sm:h-[75px] -ml-[5px] sm:-ml-[10px] -mt-[10px] sm:-mt-[15px] shrink-0 drop-shadow-[0_2px_6px_rgba(0,0,0,0.2)] pointer-events-none z-10"}),t("span",{className:"flex-1 text-center font-bold text-[18px] sm:text-[25px] leading-none tracking-[-0.03em] uppercase text-white pr-[10px] sm:pr-[16px]",style:{fontFamily:'"SVN-Volte Rounded", "Quicksand", sans-serif',textShadow:"0 2px 4px rgba(0,0,0,0.2)"},children:[Ve,"/",Ke]})]})]}),t("button",{onClick:Pe,disabled:W.isSubmitting,className:"group cursor-pointer flex items-center h-[40px] sm:h-[50px] w-[130px] sm:w-[170px] rounded-[33.5px] shadow-[0_4px_20px_rgba(0,0,0,0.25)] transition-all duration-300 hover:scale-105 active:scale-95 disabled:pointer-events-none disabled:opacity-60 border-none "+(W.isSubmitting?"bg-slate-400":"bg-[#16CA3B] hover:bg-[#15b736]"),children:[e(d,{src:c,alt:"Submit",width:75,height:75,className:"w-[50px] h-[50px] sm:w-[75px] sm:h-[75px] -ml-[5px] sm:-ml-[10px] -mt-[10px] sm:-mt-[15px] shrink-0 drop-shadow-[0_2px_6px_rgba(0,0,0,0.2)] pointer-events-none transition-transform duration-300 group-hover:scale-110 z-10"}),W.isSubmitting?e("div",{className:"flex-1 flex justify-center pr-[10px] sm:pr-[16px]",children:e(u,{className:"h-6 w-6 animate-spin text-white"})}):e("span",{className:"flex-1 text-center font-bold text-[18px] sm:text-[25px] leading-none tracking-[-0.03em] uppercase text-white pr-[10px] sm:pr-[16px]",style:{fontFamily:'"SVN-Volte Rounded", "Quicksand", sans-serif',textShadow:"0 2px 4px rgba(0,0,0,0.2)"},children:"Nộp bài"})]})]}),W.isSubmitting&&e("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:t("div",{className:"rounded-xl bg-white p-8 text-center shadow-2xl",children:[e(u,{className:"mx-auto h-12 w-12 animate-spin text-green-500"}),e("p",{className:"mt-4 text-lg font-semibold text-gray-700",children:"Đang nộp bài..."}),e("p",{className:"mt-2 text-sm text-gray-500",children:"Vui lòng đợi trong giây lát"})]})})]});if(Ee){const i=ae[Se],s=W.parts[Se],r=s?Math.max(0,W.currentIndex-(s.startIndex??0)):0,a=(s?.startIndex??0)+1,o=(s?.endIndex??a-1)+1,d={examName:je,remainingSeconds:W.remainingSeconds,totalQuestions:Ke,answeredCount:Ve,isSubmitting:W.isSubmitting,onSubmit:ke,onClose:Fe,lastSavedAt:W.lastSavedAt,isSaving:Ae.isSaving,partLabel:(s?.name||i?.name||"").toUpperCase()||void 0,partSubLabel:s?.category||void 0,questionRange:a===o?`${a}`:`${a}–${o}`},l=i?.questions?.[r],c="ENGLISH_CERTIFICATION"===ce,m={onPrevious:Be,onClear:c?void 0:()=>{l&&Re(l.id,{optionId:null})},onToggleMark:c?void 0:()=>{l&&W.toggleFlag(l.id)},onNext:Qe,isMarked:!!l&&W.flaggedQuestions.has(l.id),showSecondaryActions:!c,isPreviousDisabled:c?Se<=0:W.currentIndex<=0,isNextDisabled:c?Se>=W.parts.length-1:W.currentIndex>=W.questions.length-1},p={parts:W.parts,questions:W.questions,answers:W.answers,flaggedQuestions:W.flaggedQuestions,currentIndex:W.currentIndex,onQuestionClick:e=>{W.goToQuestion(e);const t=W.questions[e];t&&Q(t.id,{behavior:"smooth",block:"start"})},onPartClick:e=>{const t=W.parts[e];if(t){const n=t.startIndex??0;W.goToQuestion(n),W.setCurrentPartIndex(e);const i=W.questions[n];i&&Q(i.id,{behavior:"smooth",block:"start"})}}};if(i&&s)return t(n,{children:[e(L,{headerProps:d,navigationProps:p,footerProps:m,children:e(G,{part:i,partConfig:s,currentQuestionIndex:r,answers:W.answers,flaggedQuestions:W.flaggedQuestions,onAnswerChange:Re,onToggleFlag:e=>W.toggleFlag(e),isReviewMode:!1,isAudioPlayed:W.playedListeningAudioParts.has(i.partId),onAudioFirstPlay:()=>W.markListeningAudioPlayed(i.partId)})}),W.isSubmitting&&e("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:t("div",{className:"rounded-xl bg-white p-8 text-center shadow-2xl",children:[e(u,{className:"mx-auto h-12 w-12 animate-spin text-green-500"}),e("p",{className:"mt-4 text-lg font-semibold text-gray-700",children:"Đang nộp bài..."}),e("p",{className:"mt-2 text-sm text-gray-500",children:"Vui lòng đợi trong giây lát"})]})})]})}return t(n,{children:[(()=>{const{Layout:n,QuestionCard:i}=P(ce),s={headerProps:{examName:je,examType:"EXAM",levelLabel:He,totalQuestions:Ke,answeredCount:Ve,remainingSeconds:W.remainingSeconds,isSubmitting:W.isSubmitting,isCameraActive:Z,onSubmit:Pe},onPrevious:Be,onNext:Qe,onClose:Fe,isNavDisabled:W.isNavDisabled,partName:Xe?.name||(Xe?.partNo?`PART ${Xe.partNo}`:void 0)};if("CAMBRIDGE_YLE"===ce){const e=Le(Je);s.isFirstQuestion=e?0===ie:0===Je,s.isLastQuestion=e?ie===We.length-1:Je===ae.length-1,s.sidebarProps={parts:ze,questions:We,currentQuestionGlobalIndex:ie,isNavDisabled:W.isNavDisabled,onPartClick:e=>{if(W.isNavDisabled)return;De.current=e>Je?"forward":"backward",se(e);const t=We.find(t=>t.partIndex===e);t&&re(t.globalIndex),Ge()},onQuestionClick:e=>{if(W.isNavDisabled)return;const t=We[e];t&&t.partIndex!==Je&&(De.current=t.partIndex>Je?"forward":"backward",se(t.partIndex)),re(e),t&&setTimeout(()=>{const e=document.getElementById(`question-${t.questionId}`);e&&e.scrollIntoView({behavior:"smooth",block:"center"})},100)}}}else s.isFirstQuestion=0===Je,s.isLastQuestion=Je===ae.length-1;const r="CAMBRIDGE_YLE"===ce&&("SPEAKING_DESCRIBE_IMAGE"===Xe?.questionType||"SPONTANEOUS_QA"===Xe?.questionType||"SPEAKING_CUE_CARD"===Xe?.questionType||"READ_DISPLAYED_CONTENT"===Xe?.questionType),a=We[ie],o=r&&a?.partIndex===Je?a.indexInPart:void 0;return t(n,{...s,children:[e(i,{partName:Xe?.name||(Xe?.partNo?`PART ${Xe.partNo}`:void 0),children:e(q,{part:Xe,answers:W.answers||{},onAnswerChange:Re,isReviewMode:!1,currentQuestionIndex:o,onExit:Fe,onPartComplete:Je<ae.length-1?Qe:Pe,onPartBack:Je>0?Be:void 0,speakingTheme:"CAMBRIDGE_YLE"===ce?"CAMBRIDGE_YLE":de,initialQuestionIndex:"backward"===De.current?Xe?.questions.length-1:0,skipTeacherVideo:W.playedIntroParts.has(Je)||fe!==H,onTeacherIntroPlayed:()=>we(Je)})}),W.isSubmitting&&e("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:t("div",{className:"rounded-xl bg-white p-8 text-center shadow-2xl",children:[e(u,{className:"mx-auto h-12 w-12 animate-spin text-green-500"}),e("p",{className:"mt-4 text-lg font-semibold text-gray-700",children:"Đang nộp bài..."}),e("p",{className:"mt-2 text-sm text-gray-500",children:"Vui lòng đợi trong giây lát"})]})})]})})(),"CAMBRIDGE_YLE"===ce?pe&&e(R,{onClose:()=>ue(!1),onSubmit:ke,isSubmitting:W.isSubmitting}):e(w,{open:pe,onOpenChange:ue,children:t(y,{children:[t(N,{children:[e(A,{children:"Nộp bài thi"}),e(_,{children:"Bạn có chắc chắn muốn nộp bài không? Sau khi nộp, bạn sẽ không thể thay đổi câu trả lời."})]}),t(v,{children:[e(S,{disabled:W.isSubmitting,children:"Quay lại"}),e(E,{onClick:ke,disabled:W.isSubmitting,children:W.isSubmitting?t(n,{children:[e(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Äang ná»™p..."]}):"Nộp bài"})]})]})}),ge&&e(D,{onClose:()=>he(!1),onConfirmExit:async()=>{if(!Oe){Ye(!0);try{const e=W.attemptId;e&&K.cancelAttempt&&await K.cancelAttempt(e)}catch(e){console.error("Failed to cancel attempt:",e)}finally{Ye(!1),he(!1),f.persist.clearStorage(),X(V)}}},isCancelling:Oe})]})}export function ExamTakingPageContainer(t){return e(F,{api:t.api,children:e(K,{...t})})}
|
|
@@ -3,6 +3,7 @@ import type { SpeakingLayoutProps, StandardExamLayoutProps, StandardQuestionCard
|
|
|
3
3
|
export * from './cambridge-yle';
|
|
4
4
|
export * from './english-certification';
|
|
5
5
|
export * from './summer-sky/SummerSkyAudioPlayer';
|
|
6
|
+
export * from './summer-sky/SummerSkyExitModal';
|
|
6
7
|
export * from './summer-sky/SummerSkyLayout';
|
|
7
8
|
export * from './summer-sky/SummerSkySubmitModal';
|
|
8
9
|
export * from './summer-sky/SummerSkyWaitingRoom';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{SummerSkyLayout as r}from"./summer-sky/SummerSkyLayout";import{CambridgeYleExamLayout as m}from"./cambridge-yle/CambridgeYleExamLayout";import e from"./cambridge-yle/CambridgeYleQuestionCard";export*from"./cambridge-yle";export*from"./english-certification";export*from"./summer-sky/SummerSkyAudioPlayer";export*from"./summer-sky/SummerSkyLayout";export*from"./summer-sky/SummerSkySubmitModal";export*from"./summer-sky/SummerSkyWaitingRoom";const o={SUMMER_SKY:r},t="SUMMER_SKY";export function getSpeakingLayout(r){return o[r||t]||o[t]}const u={CAMBRIDGE_YLE:{Layout:m,QuestionCard:e}},a="CAMBRIDGE_YLE";export function getStandardExamTheme(r){return u[r||a]||u[a]}
|
|
1
|
+
import{SummerSkyLayout as r}from"./summer-sky/SummerSkyLayout";import{CambridgeYleExamLayout as m}from"./cambridge-yle/CambridgeYleExamLayout";import e from"./cambridge-yle/CambridgeYleQuestionCard";export*from"./cambridge-yle";export*from"./english-certification";export*from"./summer-sky/SummerSkyAudioPlayer";export*from"./summer-sky/SummerSkyExitModal";export*from"./summer-sky/SummerSkyLayout";export*from"./summer-sky/SummerSkySubmitModal";export*from"./summer-sky/SummerSkyWaitingRoom";const o={SUMMER_SKY:r},t="SUMMER_SKY";export function getSpeakingLayout(r){return o[r||t]||o[t]}const u={CAMBRIDGE_YLE:{Layout:m,QuestionCard:e}},a="CAMBRIDGE_YLE";export function getStandardExamTheme(r){return u[r||a]||u[a]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SummerSkyExitModalProps {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onConfirmExit: () => void;
|
|
5
|
+
/** True while cancel-without-grading request is in flight. */
|
|
6
|
+
isCancelling?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function SummerSkyExitModal({ onClose, onConfirmExit, isCancelling, }: SummerSkyExitModalProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import s from"next/image";import a from"./assets/images/background-noticesubmit.png";import n from"./assets/images/x-noticesubmit.png.png";import i from"./assets/images/ong.png";import l from"./assets/images/title-notisubmit.png";import r from"./assets/images/continue_exam.png";import o from"./assets/images/cancel_exam.jpg";export function SummerSkyExitModal({onClose:c,onConfirmExit:m,isCancelling:d}){return e("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e("div",{className:"relative w-[480px] max-w-[90vw] flex flex-col items-center justify-center mt-6",children:t("div",{className:"relative w-full shadow-[0_15px_40px_rgba(0,0,0,0.4)] rounded-[20px]",children:[e(s,{src:a,alt:"Background",className:"w-full h-auto block rounded-[40px]"}),e("button",{onClick:c,disabled:d,className:"absolute top-[11%] right-[-9%] transition-transform hover:scale-110 active:scale-95 cursor-pointer z-50 border-none bg-transparent p-0 disabled:opacity-50 disabled:pointer-events-none",children:e(s,{src:n,alt:"Close",className:"w-[42px] h-auto object-contain drop-shadow-md"})}),e("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 -translate-y-[40%] z-20 w-[55%] flex justify-center pointer-events-none",children:e(s,{src:l,alt:"Notice Title",className:"w-full h-auto"})}),e("div",{className:"absolute top-[-20%] left-[0%] z-30 pointer-events-none w-[15%]",children:e(s,{src:i,alt:"Bee Mascot",className:"w-full h-auto drop-shadow-xl"})}),t("div",{className:"absolute inset-0 flex flex-col items-center justify-center z-10 pt-[14%] pb-[18%] text-center px-[8%]",children:[e("p",{className:"text-[#D9383A] font-bold text-lg mb-1",style:{fontFamily:'"SVN-Volte Rounded", sans-serif'},children:"Bạn muốn rời khỏi bài thi?"}),t("p",{className:"text-[#646464]",style:{fontFamily:'"SVN-Volte Rounded", sans-serif',fontWeight:600,fontSize:"15px",lineHeight:"22px",letterSpacing:"-0.01em",textAlign:"center"},children:["Nếu rời khỏi lúc này, bài thi sẽ bị",e("br",{}),e("span",{className:"text-[#D9383A] font-bold whitespace-nowrap",children:"HỦY"}),". Hệ thống không chấm điểm và bạn không thể làm lại."]})]}),t("div",{className:"absolute bottom-[-8%] left-1/2 -translate-x-1/2 z-40 flex items-center justify-center gap-3 w-[88%]",children:[e("button",{onClick:c,disabled:d,className:"transition-transform hover:scale-105 active:scale-95 border-none bg-transparent p-0 w-[46%] flex items-center justify-center cursor-pointer disabled:opacity-50",children:e(s,{src:r,alt:"Quay lại làm tiếp",className:"w-full h-auto drop-shadow-xl"})}),t("button",{onClick:m,disabled:d,className:"transition-transform hover:scale-105 active:scale-95 border-none bg-transparent p-0 w-[46%] flex items-center justify-center relative "+(d?"cursor-not-allowed opacity-70":"cursor-pointer"),children:[d?e("div",{className:"absolute inset-0 flex items-center justify-center z-50",children:e("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-white border-t-transparent"})}):null,e(s,{src:o,alt:"Hủy bài thi và thoát",className:"w-full h-auto drop-shadow-xl rounded-full"})]})]})]})})})}
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*as Api from"./api";export*as Components from"./components";export*as
|
|
1
|
+
export*as Api from"./api";export*as Components from"./components";export*as Exams from"./components/exams";export*as Questions from"./components/questions";export*as Results from"./components/results";export*as Themes from"./components/themes";export*as Shared from"./shared";export{buildExamTemplatePayload,createContestRoomsApi,createExamCreateApi,createExamEntryApi,createExamQuestionsApi,createExamQuestionsFetchApi,createExamTakingApi,createMockContestRoomsApi,createMockCreateExamApi,createMockExamEntryApi,createMockExamQuestionsApi,createMockExamTakingApi,createMockResultReviewApi,createResultReviewApi}from"./api";export{CreateExamPageContainer,ExamPreviewDialog,ExamQuestionsPageContainer,ExamTakingPageContainer,ExamViewDialog,StudentContestRoomsPageContainer,StudentExamEntryPageContainer}from"./components/exams";export{ResultReviewPageContainer}from"./components/results";export{QuestionCreator}from"./components/questions/creator/QuestionCreator";export{QuestionGroupCreator}from"./components/questions/creator/QuestionGroupCreator";export{renderDedicatedComponent}from"./components/questions/creator/dedicated-component-router";export{questionTypeRegistry}from"./components/questions/creator/question-type-registry";export{QUESTION_TYPE_CONFIG,QUESTION_TYPES_WITH_DEDICATED_COMPONENTS}from"./components/questions/_shared/config/question-types.config";export{validateQuestion}from"./components/questions/_shared/utils/question-validation";export{buildAnswerPayload}from"./components/questions/_shared/utils/answer-builder";export*from"./components/questions/_shared/types";
|
|
@@ -173,6 +173,7 @@ export declare const API_ENDPOINTS: {
|
|
|
173
173
|
readonly ATTEMPT_QUESTIONS: (id: string) => string;
|
|
174
174
|
readonly ATTEMPT_ANSWERS: (id: string) => string;
|
|
175
175
|
readonly ATTEMPT_SUBMIT: (id: string) => string;
|
|
176
|
+
readonly ATTEMPT_CANCEL: (id: string) => string;
|
|
176
177
|
readonly ATTEMPT_AUDIO_ANSWER: (id: string) => string;
|
|
177
178
|
readonly ATTEMPT_PROCTORING_SNAPSHOT: (id: string) => string;
|
|
178
179
|
readonly ATTEMPT_GRADING_SUMMARY: (id: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const API_VERSION="v1";export const API_BASE_URL="undefined"==typeof process?void 0:process.env.NEXT_PUBLIC_API_URL;export const API_ENDPOINTS={AUTH:{LOGIN:"/api/v1/auth/login",LOGOUT:"/api/v1/auth/logout",REFRESH:"/api/v1/auth/refresh",CHANGE_PASSWORD:"/api/v1/auth/change-password",ME:"/api/v1/auth/me",UPGRADE_ACCOUNT:"/api/v1/auth/upgrade-account",STUDENT_REGISTER:"/api/v1/auth/student/register",REGISTER_SIMPLE:"/api/v1/auth/register-simple",PERMISSIONS:"/api/v1/auth/permissions"},MANAGE:{USERS:"/api/v1/manage/users",USER_DETAIL:a=>`/api/v1/manage/users/${a}`,SYNC_EBM:"/api/v1/manage/users/sync-ebm",BRANCHES:"/api/v1/manage/branches",BRANCH_DETAIL:a=>`/api/v1/manage/branches/${a}`,BRANCHES_STATISTICS:"/api/v1/manage/branches/statistics",BRANCHES_MANAGERS:"/api/v1/manage/branches/managers",BRANCHES_TEACHERS:"/api/v1/manage/branches/teachers",QUESTIONS:"/api/v1/manage/questions",QUESTION_DETAIL:a=>`/api/v1/manage/questions/${a}`,QUESTIONS_BATCH:"/api/v1/manage/questions/batch",QUESTIONS_GENERATE_AUDIO:"/api/v1/manage/questions/generate-audio",QUESTIONS_BY_EXAM:a=>`/api/v1/manage/questions/by-exam/${a}`,EXAMS:"/api/v1/manage/exams",EXAM_DETAIL:a=>`/api/v1/manage/exams/${a}`,EXAM_QUESTIONS:a=>`/api/v1/manage/exams/${a}/questions`,EXAM_SHUFFLE:a=>`/api/v1/manage/exams/${a}/shuffle`,EXAM_COPY:a=>`/api/v1/manage/exams/${a}/copy`,EXAM_CLASSES:"/api/v1/manage/exam-classes",EXAM_CLASS_DETAIL:a=>`/api/v1/manage/exam-classes/${a}`,EXAM_SESSIONS:"/api/v1/manage/exam-sessions",EXAM_SESSION_DETAIL:a=>`/api/v1/manage/exam-sessions/${a}`,EXAM_ROOMS:"/api/v1/manage/rooms",EXAM_ROOM_DETAIL:a=>`/api/v1/manage/rooms/${a}`,ROOM_TEACHERS:"/api/v1/manage/rooms/teachers",ROOM_STUDENTS:"/api/v1/manage/rooms/students",ROOM_EXAMS:"/api/v1/manage/rooms/exams",ROOM_CONTESTS:"/api/v1/manage/rooms/contests",ROOM_STATISTICS:"/api/v1/manage/rooms/statistics",ROOM_CLASSES:"/api/v1/manage/rooms/classes",ROOM_BRANCHES:"/api/v1/manage/rooms/branches",ROOM_TAGS:"/api/v1/manage/rooms/tags",ROOM_REGISTRATIONS:a=>`/api/v1/manage/rooms/${a}/registrations`,ROOM_REGISTRATION_DETAIL:(a,s)=>`/api/v1/manage/rooms/${a}/registrations/${s}`,ROOM_REGISTRATIONS_BULK_REVIEW:a=>`/api/v1/manage/rooms/${a}/registrations/bulk-review`,ROOM_INVITE_LINK:a=>`/api/v1/manage/rooms/${a}/invite-link`,ROOM_MANUAL_GRADING:a=>`/api/v1/manage/rooms/${a}/manual-grading`,ROOM_UPLOAD_ANSWER_SHEETS:a=>`/api/v1/manage/rooms/${a}/upload-answer-sheets`,ROOM_EXTERNAL_ANSWER_SHEETS:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets`,ROOM_EXTERNAL_ANSWER_SHEET_DETAIL:(a,s)=>`/api/v1/manage/rooms/${a}/external-answer-sheets/${s}`,ROOM_EXTERNAL_UPLOAD_TOKEN:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets/upload-token`,ROOM_EXTERNAL_ANSWER_SHEET_REGRADE:(a,s)=>`/api/v1/manage/rooms/${a}/external-answer-sheets/${s}/re-grade`,ROOM_EXTERNAL_ANSWER_SHEETS_REGRADE_ALL:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets/re-grade-all`,ROOM_EXTERNAL_ANSWER_SHEET_REPROCESS:(a,s)=>`/api/v1/manage/rooms/${a}/external-answer-sheets/${s}/re-process`,ROOM_EXTERNAL_ANSWER_SHEETS_REPROCESS_ALL:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets/re-process-all`,CONTESTS:"/api/v1/manage/contests",CONTEST_DETAIL:a=>`/api/v1/manage/contests/${a}`,CONTEST_SUMMARY:"/api/v1/manage/contests/summary",CONTEST_TOP_STUDENTS_LATEST:"/api/v1/manage/contests/top-students-latest",CONTEST_TOP_STUDENTS_ALL_TIME:"/api/v1/manage/contests/top-students-all-time",CONTEST_STATISTICS_LIST:"/api/v1/manage/contests/statistics-list",CONTEST_STUDENT_HISTORY:a=>`/api/v1/manage/contests/student-contest-history/${a}`,CONTEST_STUDENT_STATISTICS:a=>`/api/v1/manage/contests/student-statistics/${a}`,CONTEST_STATISTICS:a=>`/api/v1/manage/contests/${a}/statistics`,CONTEST_STAFF:a=>`/api/v1/manage/contests/${a}/staff`,CONTEST_STAFF_BY_GROUP:a=>`/api/v1/manage/contests/${a}/staff/by-group`,CONTEST_STAFF_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/staff/${s}`,CONTEST_GALLERY:a=>`/api/v1/manage/contests/${a}/gallery`,CONTEST_GALLERY_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/gallery/${s}`,CONTEST_CONVERT_MULTI_ROUND:a=>`/api/v1/manage/contests/${a}/convert-to-multi-round`,CONTEST_ROUNDS:a=>`/api/v1/manage/contests/${a}/rounds`,CONTEST_ROUND_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/rounds/${s}`,CONTEST_REGISTRATIONS:a=>`/api/v1/manage/contests/${a}/registrations`,CONTEST_REGISTRATION_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/registrations/${s}`,CONTEST_REGISTRATIONS_BULK_REVIEW:a=>`/api/v1/manage/contests/${a}/registrations/bulk-review`,CONTEST_RESULTS:a=>`/api/v1/manage/contests/${a}/results`,CONTEST_OVERVIEW_STATS:a=>`/api/v1/manage/contests/${a}/overview-stats`,QUESTION_BANKS:"/api/v1/manage/question-banks",QUESTION_BANK_DETAIL:a=>`/api/v1/manage/question-banks/${a}`,QUESTION_BANKS_STATISTICS:"/api/v1/manage/question-banks/statistics",SCHEDULES_SUMMARY:"/api/v1/manage/schedules/summary",SCHEDULES_CALENDAR:"/api/v1/manage/schedules/calendar",SCHEDULES:"/api/v1/manage/schedules",STUDENT_TEST_PARTICIPANTS:"/api/v1/manage/students/test-participants",REPORTS:"/api/v1/manage/reports",REPORT_OVERVIEW:"/api/v1/manage/reports/overview",REPORT_CLASSES:"/api/v1/manage/reports/classes",REPORT_BRANCHES:"/api/v1/manage/reports/branches",REPORT_SKILLS:"/api/v1/manage/reports/skills",REPORT_TRENDS:"/api/v1/manage/reports/trends",REPORT_CUSTOM:"/api/v1/manage/reports/custom",REPORT_CUSTOM_DETAIL:a=>`/api/v1/manage/reports/custom/${a}`,REPORT_CUSTOM_DOWNLOAD:a=>`/api/v1/manage/reports/custom/${a}/download`,REPORT_ROOMS:"/api/v1/manage/reports/rooms",REPORT_CONTESTS:"/api/v1/manage/reports/contests",REPORT_COMPETENCY:"/api/v1/manage/reports/competency",REPORT_COMPETENCY_EXAM_ROOMS:"/api/v1/manage/reports/competency/exam-rooms",DASHBOARD_SUMMARY:"/api/v1/manage/dashboard/summary",DASHBOARD_USER_GROWTH:"/api/v1/manage/dashboard/user-growth",DASHBOARD_EXAM_STATS:"/api/v1/manage/dashboard/exam-statistics",DASHBOARD_ACTIVITIES:"/api/v1/manage/dashboard/recent-activities",DASHBOARD_ROOMS:"/api/v1/manage/dashboard/rooms",DASHBOARD_CHARTS:"/api/v1/manage/dashboard/charts",DASHBOARD_UPCOMING_ROOMS:"/api/v1/manage/dashboard/upcoming-rooms",DASHBOARD_PENDING_GRADING:"/api/v1/manage/dashboard/pending-grading",ROLES:"/api/v1/manage/roles",ROLE_DETAIL:a=>`/api/v1/manage/roles/${a}`,ROLE_PERMISSIONS:a=>`/api/v1/manage/roles/${a}/permissions`,PERMISSIONS:"/api/v1/manage/permissions",PERMISSIONS_GROUPED:"/api/v1/manage/permissions/grouped",USER_ROLES:a=>`/api/v1/manage/users/${a}/roles`,USER_ROLE_DETAIL:(a,s)=>`/api/v1/manage/users/${a}/roles/${s}`,ROOM_OPEN:a=>`/api/v1/manage/rooms/${a}/open`,ROOM_CLOSE:a=>`/api/v1/manage/rooms/${a}/close`,ROOM_TOGGLE_LOCK:a=>`/api/v1/manage/rooms/${a}/toggle-lock`,GRADING_ATTEMPT:a=>`/api/v1/manage/grading/${a}`,GRADING_ANSWER:(a,s)=>`/api/v1/manage/grading/${a}/answers/${s}`,EXAM_VARIANTS:a=>`/api/v1/manage/exams/${a}/variants`,EXAM_TEMPLATE:a=>`/api/v1/manage/exams/${a}/template`},get ADMIN(){return this.MANAGE},SYSTEM_ADMIN:{BRANCHES:"/api/v1/system-admin/branches",BRANCH_DETAIL:a=>`/api/v1/system-admin/branches/${a}`,BRANCHES_STATISTICS:"/api/v1/system-admin/branches/statistics",USERS:"/api/v1/system-admin/users",USER_DETAIL:a=>`/api/v1/system-admin/users/${a}`,USERS_IMPORT:"/api/v1/system-admin/users/import",USERS_IMPORT_TEMPLATE:"/api/v1/system-admin/users/import/template",USERS_BULK_UPDATE_PASSWORD:"/api/v1/system-admin/users/bulk-update-password",USER_GROUPS:"/api/v1/system-admin/user-groups",USER_GROUP_DETAIL:a=>`/api/v1/system-admin/user-groups/${a}`,USER_GROUP_MEMBERS:a=>`/api/v1/system-admin/user-groups/${a}/members`,USER_GROUP_MEMBERS_BY_EMAIL:a=>`/api/v1/system-admin/user-groups/${a}/members/by-email`,TAGS:"/api/v1/system-admin/tags",TAG_DETAIL:a=>`/api/v1/system-admin/tags/${a}`,TAG_CATEGORIES:"/api/v1/system-admin/tags/categories",BULK_ROOMS_PREVIEW:"/api/v1/system-admin/bulk-rooms/preview",BULK_ROOMS_COMMIT:"/api/v1/system-admin/bulk-rooms/commit",BULK_ROOMS_EBM_BRANCHES:"/api/v1/system-admin/bulk-rooms/ebm-branches",BULK_ASSIGN_EXAMS_MATCH:"/api/v1/system-admin/bulk-assign-exams/match",BULK_ASSIGN_EXAMS_APPLY:"/api/v1/system-admin/bulk-assign-exams/apply",ASSIGN_STUDENTS_TO_ROOMS_IMPORT:"/api/v1/system-admin/rooms/assign-students/import",OEA_RESULTS_IMPORT:"/api/v1/system-admin/oea-results/import",OEA_RESULTS_CLEAR:"/api/v1/system-admin/oea-results/clear",OEA_RESULTS_COUNT:"/api/v1/system-admin/oea-results/count",OEA_RESULTS_LIST:"/api/v1/system-admin/oea-results/list"},STUDENT:{PROFILE:"/api/v1/student/profile",EXAMS:"/api/v1/student/exams",EXAM_START:a=>`/api/v1/student/exams/${a}/start`,EXAM_SUBMIT:a=>`/api/v1/student/exams/${a}/submit`,ROOMS:"/api/v1/student/rooms",ROOMS_JOINED:"/api/v1/student/rooms/joined",ROOM_DETAIL:a=>`/api/v1/student/rooms/${a}`,ROOM_JOIN:"/api/v1/student/rooms/join",ROOM_STATUS:a=>`/api/v1/student/rooms/${a}/status`,ROOM_JOIN_INVITE:(a,s)=>`/api/v1/student/rooms/${a}/invite/${s}`,ATTEMPTS_START:"/api/v1/student/attempts/start",ATTEMPTS_ACTIVE:"/api/v1/student/attempts/active",ATTEMPTS_ACTIVE_BY_ROOM:a=>`/api/v1/student/attempts/active-by-room/${a}`,ATTEMPT_DETAIL:a=>`/api/v1/student/attempts/${a}`,ATTEMPT_DELETE:a=>`/api/v1/student/attempts/${a}`,ATTEMPT_QUESTIONS:a=>`/api/v1/student/attempts/${a}/questions`,ATTEMPT_ANSWERS:a=>`/api/v1/student/attempts/${a}/answers`,ATTEMPT_SUBMIT:a=>`/api/v1/student/attempts/${a}/submit`,ATTEMPT_AUDIO_ANSWER:a=>`/api/v1/student/attempts/${a}/audio-answer`,ATTEMPT_PROCTORING_SNAPSHOT:a=>`/api/v1/student/attempts/${a}/proctoring-snapshot`,ATTEMPT_GRADING_SUMMARY:a=>`/api/v1/student/attempts/${a}/grading-summary`,ATTEMPT_ANSWERS_GRADING_STATUS:a=>`/api/v1/student/attempts/${a}/answers/grading-status`,ATTEMPT_ANSWER_DETAIL:(a,s)=>`/api/v1/student/attempts/${a}/answers/${s}`,SCHEDULES:"/api/v1/student/schedules",SCHEDULES_PAST:"/api/v1/student/schedules/past",RESULTS:"/api/v1/student/results",RESULT_DETAIL:a=>`/api/v1/student/results/${a}`,RESULT_RANKING:a=>`/api/v1/student/results/${a}/ranking`,EXPORT_NATIVE_PDF:"/api/v1/export/exam-report-pdf",STATS:"/api/v1/student/stats",PROGRESS:"/api/v1/student/progress",CONTESTS:"/api/v1/student/contests",CONTESTS_PUBLIC:"/api/v1/student/contests/public",CONTESTS_MY:"/api/v1/student/contests/my",CONTEST_DETAIL:a=>`/api/v1/student/contests/${a}`,CONTEST_REGISTER:a=>`/api/v1/student/contests/${a}/register`,CONTEST_ROOMS:a=>`/api/v1/student/contests/${a}/rooms`,CONTEST_RESULTS:a=>`/api/v1/student/contests/${a}/results`,CONTEST_HISTORY:a=>`/api/v1/student/contests/${a}/history`,CONTEST_LEADERBOARD:a=>`/api/v1/student/contests/${a}/leaderboard`,CONTEST_ROUNDS:a=>`/api/v1/student/contests/${a}/rounds`,CONTEST_GALLERY:a=>`/api/v1/student/contests/${a}/gallery`,CONTEST_ROOM_REGISTER:(a,s)=>`/api/v1/student/contests/${a}/rooms/${s}/register`},SHARED:{EXAM_TEMPLATES:"/api/v1/exam-templates",EXAM_TEMPLATE_DETAIL:a=>`/api/v1/exam-templates/${a}`,EXAM_TEMPLATE_EXPORT:a=>`/api/v1/exam-templates/${a}/export`,EXAM_TEMPLATE_IMPORT:"/api/v1/exam-templates/import",EXAM_TEMPLATE_UPDATE:a=>`/api/v1/exam-templates/${a}`,EXAM_TEMPLATE_DELETE:a=>`/api/v1/exam-templates/${a}`,EXAM_TEMPLATE_EXAMS:a=>`/api/v1/exam-templates/${a}/exams`,EXAM_TEMPLATE_APPLY_CONFIG:a=>`/api/v1/exam-templates/${a}/apply-config`,SUBJECTS:"/api/v1/subjects",CONTESTS:"/api/v1/contests",SPEAKING_REALTIME_GRADE:"/api/v1/speaking-assessment/realtime/grade-single"},STORAGE:{UPLOAD:"/api/v1/storage/upload",UPLOAD_AUDIO:"/api/v1/storage/upload-audio",FILE:a=>`/api/v1/storage/${encodeURIComponent(a)}`},PUBLIC:{EXTERNAL_SHEET_RESULT:a=>`/api/v1/public/external-sheets/result/${a}`,EXTERNAL_SHEET_UPLOAD:a=>`/api/v1/public/external-sheets/upload/${a}`,EXTERNAL_SHEET_TOKEN_INFO:a=>`/api/v1/public/external-sheets/token-info/${a}`,OEA_RESULTS_LOOKUP:"/api/v1/public/oea-results/lookup"},TEST:{COOKIE_SET:"/api/v1/test/cookie/set",COOKIE_SET_AUTH:"/api/v1/test/cookie/set-auth-test",COOKIE_CLEAR:"/api/v1/test/cookie/clear"}};
|
|
1
|
+
export const API_VERSION="v1";export const API_BASE_URL="undefined"==typeof process?void 0:process.env.NEXT_PUBLIC_API_URL;export const API_ENDPOINTS={AUTH:{LOGIN:"/api/v1/auth/login",LOGOUT:"/api/v1/auth/logout",REFRESH:"/api/v1/auth/refresh",CHANGE_PASSWORD:"/api/v1/auth/change-password",ME:"/api/v1/auth/me",UPGRADE_ACCOUNT:"/api/v1/auth/upgrade-account",STUDENT_REGISTER:"/api/v1/auth/student/register",REGISTER_SIMPLE:"/api/v1/auth/register-simple",PERMISSIONS:"/api/v1/auth/permissions"},MANAGE:{USERS:"/api/v1/manage/users",USER_DETAIL:a=>`/api/v1/manage/users/${a}`,SYNC_EBM:"/api/v1/manage/users/sync-ebm",BRANCHES:"/api/v1/manage/branches",BRANCH_DETAIL:a=>`/api/v1/manage/branches/${a}`,BRANCHES_STATISTICS:"/api/v1/manage/branches/statistics",BRANCHES_MANAGERS:"/api/v1/manage/branches/managers",BRANCHES_TEACHERS:"/api/v1/manage/branches/teachers",QUESTIONS:"/api/v1/manage/questions",QUESTION_DETAIL:a=>`/api/v1/manage/questions/${a}`,QUESTIONS_BATCH:"/api/v1/manage/questions/batch",QUESTIONS_GENERATE_AUDIO:"/api/v1/manage/questions/generate-audio",QUESTIONS_BY_EXAM:a=>`/api/v1/manage/questions/by-exam/${a}`,EXAMS:"/api/v1/manage/exams",EXAM_DETAIL:a=>`/api/v1/manage/exams/${a}`,EXAM_QUESTIONS:a=>`/api/v1/manage/exams/${a}/questions`,EXAM_SHUFFLE:a=>`/api/v1/manage/exams/${a}/shuffle`,EXAM_COPY:a=>`/api/v1/manage/exams/${a}/copy`,EXAM_CLASSES:"/api/v1/manage/exam-classes",EXAM_CLASS_DETAIL:a=>`/api/v1/manage/exam-classes/${a}`,EXAM_SESSIONS:"/api/v1/manage/exam-sessions",EXAM_SESSION_DETAIL:a=>`/api/v1/manage/exam-sessions/${a}`,EXAM_ROOMS:"/api/v1/manage/rooms",EXAM_ROOM_DETAIL:a=>`/api/v1/manage/rooms/${a}`,ROOM_TEACHERS:"/api/v1/manage/rooms/teachers",ROOM_STUDENTS:"/api/v1/manage/rooms/students",ROOM_EXAMS:"/api/v1/manage/rooms/exams",ROOM_CONTESTS:"/api/v1/manage/rooms/contests",ROOM_STATISTICS:"/api/v1/manage/rooms/statistics",ROOM_CLASSES:"/api/v1/manage/rooms/classes",ROOM_BRANCHES:"/api/v1/manage/rooms/branches",ROOM_TAGS:"/api/v1/manage/rooms/tags",ROOM_REGISTRATIONS:a=>`/api/v1/manage/rooms/${a}/registrations`,ROOM_REGISTRATION_DETAIL:(a,s)=>`/api/v1/manage/rooms/${a}/registrations/${s}`,ROOM_REGISTRATIONS_BULK_REVIEW:a=>`/api/v1/manage/rooms/${a}/registrations/bulk-review`,ROOM_INVITE_LINK:a=>`/api/v1/manage/rooms/${a}/invite-link`,ROOM_MANUAL_GRADING:a=>`/api/v1/manage/rooms/${a}/manual-grading`,ROOM_UPLOAD_ANSWER_SHEETS:a=>`/api/v1/manage/rooms/${a}/upload-answer-sheets`,ROOM_EXTERNAL_ANSWER_SHEETS:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets`,ROOM_EXTERNAL_ANSWER_SHEET_DETAIL:(a,s)=>`/api/v1/manage/rooms/${a}/external-answer-sheets/${s}`,ROOM_EXTERNAL_UPLOAD_TOKEN:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets/upload-token`,ROOM_EXTERNAL_ANSWER_SHEET_REGRADE:(a,s)=>`/api/v1/manage/rooms/${a}/external-answer-sheets/${s}/re-grade`,ROOM_EXTERNAL_ANSWER_SHEETS_REGRADE_ALL:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets/re-grade-all`,ROOM_EXTERNAL_ANSWER_SHEET_REPROCESS:(a,s)=>`/api/v1/manage/rooms/${a}/external-answer-sheets/${s}/re-process`,ROOM_EXTERNAL_ANSWER_SHEETS_REPROCESS_ALL:a=>`/api/v1/manage/rooms/${a}/external-answer-sheets/re-process-all`,CONTESTS:"/api/v1/manage/contests",CONTEST_DETAIL:a=>`/api/v1/manage/contests/${a}`,CONTEST_SUMMARY:"/api/v1/manage/contests/summary",CONTEST_TOP_STUDENTS_LATEST:"/api/v1/manage/contests/top-students-latest",CONTEST_TOP_STUDENTS_ALL_TIME:"/api/v1/manage/contests/top-students-all-time",CONTEST_STATISTICS_LIST:"/api/v1/manage/contests/statistics-list",CONTEST_STUDENT_HISTORY:a=>`/api/v1/manage/contests/student-contest-history/${a}`,CONTEST_STUDENT_STATISTICS:a=>`/api/v1/manage/contests/student-statistics/${a}`,CONTEST_STATISTICS:a=>`/api/v1/manage/contests/${a}/statistics`,CONTEST_STAFF:a=>`/api/v1/manage/contests/${a}/staff`,CONTEST_STAFF_BY_GROUP:a=>`/api/v1/manage/contests/${a}/staff/by-group`,CONTEST_STAFF_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/staff/${s}`,CONTEST_GALLERY:a=>`/api/v1/manage/contests/${a}/gallery`,CONTEST_GALLERY_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/gallery/${s}`,CONTEST_CONVERT_MULTI_ROUND:a=>`/api/v1/manage/contests/${a}/convert-to-multi-round`,CONTEST_ROUNDS:a=>`/api/v1/manage/contests/${a}/rounds`,CONTEST_ROUND_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/rounds/${s}`,CONTEST_REGISTRATIONS:a=>`/api/v1/manage/contests/${a}/registrations`,CONTEST_REGISTRATION_DETAIL:(a,s)=>`/api/v1/manage/contests/${a}/registrations/${s}`,CONTEST_REGISTRATIONS_BULK_REVIEW:a=>`/api/v1/manage/contests/${a}/registrations/bulk-review`,CONTEST_RESULTS:a=>`/api/v1/manage/contests/${a}/results`,CONTEST_OVERVIEW_STATS:a=>`/api/v1/manage/contests/${a}/overview-stats`,QUESTION_BANKS:"/api/v1/manage/question-banks",QUESTION_BANK_DETAIL:a=>`/api/v1/manage/question-banks/${a}`,QUESTION_BANKS_STATISTICS:"/api/v1/manage/question-banks/statistics",SCHEDULES_SUMMARY:"/api/v1/manage/schedules/summary",SCHEDULES_CALENDAR:"/api/v1/manage/schedules/calendar",SCHEDULES:"/api/v1/manage/schedules",STUDENT_TEST_PARTICIPANTS:"/api/v1/manage/students/test-participants",REPORTS:"/api/v1/manage/reports",REPORT_OVERVIEW:"/api/v1/manage/reports/overview",REPORT_CLASSES:"/api/v1/manage/reports/classes",REPORT_BRANCHES:"/api/v1/manage/reports/branches",REPORT_SKILLS:"/api/v1/manage/reports/skills",REPORT_TRENDS:"/api/v1/manage/reports/trends",REPORT_CUSTOM:"/api/v1/manage/reports/custom",REPORT_CUSTOM_DETAIL:a=>`/api/v1/manage/reports/custom/${a}`,REPORT_CUSTOM_DOWNLOAD:a=>`/api/v1/manage/reports/custom/${a}/download`,REPORT_ROOMS:"/api/v1/manage/reports/rooms",REPORT_CONTESTS:"/api/v1/manage/reports/contests",REPORT_COMPETENCY:"/api/v1/manage/reports/competency",REPORT_COMPETENCY_EXAM_ROOMS:"/api/v1/manage/reports/competency/exam-rooms",DASHBOARD_SUMMARY:"/api/v1/manage/dashboard/summary",DASHBOARD_USER_GROWTH:"/api/v1/manage/dashboard/user-growth",DASHBOARD_EXAM_STATS:"/api/v1/manage/dashboard/exam-statistics",DASHBOARD_ACTIVITIES:"/api/v1/manage/dashboard/recent-activities",DASHBOARD_ROOMS:"/api/v1/manage/dashboard/rooms",DASHBOARD_CHARTS:"/api/v1/manage/dashboard/charts",DASHBOARD_UPCOMING_ROOMS:"/api/v1/manage/dashboard/upcoming-rooms",DASHBOARD_PENDING_GRADING:"/api/v1/manage/dashboard/pending-grading",ROLES:"/api/v1/manage/roles",ROLE_DETAIL:a=>`/api/v1/manage/roles/${a}`,ROLE_PERMISSIONS:a=>`/api/v1/manage/roles/${a}/permissions`,PERMISSIONS:"/api/v1/manage/permissions",PERMISSIONS_GROUPED:"/api/v1/manage/permissions/grouped",USER_ROLES:a=>`/api/v1/manage/users/${a}/roles`,USER_ROLE_DETAIL:(a,s)=>`/api/v1/manage/users/${a}/roles/${s}`,ROOM_OPEN:a=>`/api/v1/manage/rooms/${a}/open`,ROOM_CLOSE:a=>`/api/v1/manage/rooms/${a}/close`,ROOM_TOGGLE_LOCK:a=>`/api/v1/manage/rooms/${a}/toggle-lock`,GRADING_ATTEMPT:a=>`/api/v1/manage/grading/${a}`,GRADING_ANSWER:(a,s)=>`/api/v1/manage/grading/${a}/answers/${s}`,EXAM_VARIANTS:a=>`/api/v1/manage/exams/${a}/variants`,EXAM_TEMPLATE:a=>`/api/v1/manage/exams/${a}/template`},get ADMIN(){return this.MANAGE},SYSTEM_ADMIN:{BRANCHES:"/api/v1/system-admin/branches",BRANCH_DETAIL:a=>`/api/v1/system-admin/branches/${a}`,BRANCHES_STATISTICS:"/api/v1/system-admin/branches/statistics",USERS:"/api/v1/system-admin/users",USER_DETAIL:a=>`/api/v1/system-admin/users/${a}`,USERS_IMPORT:"/api/v1/system-admin/users/import",USERS_IMPORT_TEMPLATE:"/api/v1/system-admin/users/import/template",USERS_BULK_UPDATE_PASSWORD:"/api/v1/system-admin/users/bulk-update-password",USER_GROUPS:"/api/v1/system-admin/user-groups",USER_GROUP_DETAIL:a=>`/api/v1/system-admin/user-groups/${a}`,USER_GROUP_MEMBERS:a=>`/api/v1/system-admin/user-groups/${a}/members`,USER_GROUP_MEMBERS_BY_EMAIL:a=>`/api/v1/system-admin/user-groups/${a}/members/by-email`,TAGS:"/api/v1/system-admin/tags",TAG_DETAIL:a=>`/api/v1/system-admin/tags/${a}`,TAG_CATEGORIES:"/api/v1/system-admin/tags/categories",BULK_ROOMS_PREVIEW:"/api/v1/system-admin/bulk-rooms/preview",BULK_ROOMS_COMMIT:"/api/v1/system-admin/bulk-rooms/commit",BULK_ROOMS_EBM_BRANCHES:"/api/v1/system-admin/bulk-rooms/ebm-branches",BULK_ASSIGN_EXAMS_MATCH:"/api/v1/system-admin/bulk-assign-exams/match",BULK_ASSIGN_EXAMS_APPLY:"/api/v1/system-admin/bulk-assign-exams/apply",ASSIGN_STUDENTS_TO_ROOMS_IMPORT:"/api/v1/system-admin/rooms/assign-students/import",OEA_RESULTS_IMPORT:"/api/v1/system-admin/oea-results/import",OEA_RESULTS_CLEAR:"/api/v1/system-admin/oea-results/clear",OEA_RESULTS_COUNT:"/api/v1/system-admin/oea-results/count",OEA_RESULTS_LIST:"/api/v1/system-admin/oea-results/list"},STUDENT:{PROFILE:"/api/v1/student/profile",EXAMS:"/api/v1/student/exams",EXAM_START:a=>`/api/v1/student/exams/${a}/start`,EXAM_SUBMIT:a=>`/api/v1/student/exams/${a}/submit`,ROOMS:"/api/v1/student/rooms",ROOMS_JOINED:"/api/v1/student/rooms/joined",ROOM_DETAIL:a=>`/api/v1/student/rooms/${a}`,ROOM_JOIN:"/api/v1/student/rooms/join",ROOM_STATUS:a=>`/api/v1/student/rooms/${a}/status`,ROOM_JOIN_INVITE:(a,s)=>`/api/v1/student/rooms/${a}/invite/${s}`,ATTEMPTS_START:"/api/v1/student/attempts/start",ATTEMPTS_ACTIVE:"/api/v1/student/attempts/active",ATTEMPTS_ACTIVE_BY_ROOM:a=>`/api/v1/student/attempts/active-by-room/${a}`,ATTEMPT_DETAIL:a=>`/api/v1/student/attempts/${a}`,ATTEMPT_DELETE:a=>`/api/v1/student/attempts/${a}`,ATTEMPT_QUESTIONS:a=>`/api/v1/student/attempts/${a}/questions`,ATTEMPT_ANSWERS:a=>`/api/v1/student/attempts/${a}/answers`,ATTEMPT_SUBMIT:a=>`/api/v1/student/attempts/${a}/submit`,ATTEMPT_CANCEL:a=>`/api/v1/student/attempts/${a}/cancel`,ATTEMPT_AUDIO_ANSWER:a=>`/api/v1/student/attempts/${a}/audio-answer`,ATTEMPT_PROCTORING_SNAPSHOT:a=>`/api/v1/student/attempts/${a}/proctoring-snapshot`,ATTEMPT_GRADING_SUMMARY:a=>`/api/v1/student/attempts/${a}/grading-summary`,ATTEMPT_ANSWERS_GRADING_STATUS:a=>`/api/v1/student/attempts/${a}/answers/grading-status`,ATTEMPT_ANSWER_DETAIL:(a,s)=>`/api/v1/student/attempts/${a}/answers/${s}`,SCHEDULES:"/api/v1/student/schedules",SCHEDULES_PAST:"/api/v1/student/schedules/past",RESULTS:"/api/v1/student/results",RESULT_DETAIL:a=>`/api/v1/student/results/${a}`,RESULT_RANKING:a=>`/api/v1/student/results/${a}/ranking`,EXPORT_NATIVE_PDF:"/api/v1/export/exam-report-pdf",STATS:"/api/v1/student/stats",PROGRESS:"/api/v1/student/progress",CONTESTS:"/api/v1/student/contests",CONTESTS_PUBLIC:"/api/v1/student/contests/public",CONTESTS_MY:"/api/v1/student/contests/my",CONTEST_DETAIL:a=>`/api/v1/student/contests/${a}`,CONTEST_REGISTER:a=>`/api/v1/student/contests/${a}/register`,CONTEST_ROOMS:a=>`/api/v1/student/contests/${a}/rooms`,CONTEST_RESULTS:a=>`/api/v1/student/contests/${a}/results`,CONTEST_HISTORY:a=>`/api/v1/student/contests/${a}/history`,CONTEST_LEADERBOARD:a=>`/api/v1/student/contests/${a}/leaderboard`,CONTEST_ROUNDS:a=>`/api/v1/student/contests/${a}/rounds`,CONTEST_GALLERY:a=>`/api/v1/student/contests/${a}/gallery`,CONTEST_ROOM_REGISTER:(a,s)=>`/api/v1/student/contests/${a}/rooms/${s}/register`},SHARED:{EXAM_TEMPLATES:"/api/v1/exam-templates",EXAM_TEMPLATE_DETAIL:a=>`/api/v1/exam-templates/${a}`,EXAM_TEMPLATE_EXPORT:a=>`/api/v1/exam-templates/${a}/export`,EXAM_TEMPLATE_IMPORT:"/api/v1/exam-templates/import",EXAM_TEMPLATE_UPDATE:a=>`/api/v1/exam-templates/${a}`,EXAM_TEMPLATE_DELETE:a=>`/api/v1/exam-templates/${a}`,EXAM_TEMPLATE_EXAMS:a=>`/api/v1/exam-templates/${a}/exams`,EXAM_TEMPLATE_APPLY_CONFIG:a=>`/api/v1/exam-templates/${a}/apply-config`,SUBJECTS:"/api/v1/subjects",CONTESTS:"/api/v1/contests",SPEAKING_REALTIME_GRADE:"/api/v1/speaking-assessment/realtime/grade-single"},STORAGE:{UPLOAD:"/api/v1/storage/upload",UPLOAD_AUDIO:"/api/v1/storage/upload-audio",FILE:a=>`/api/v1/storage/${encodeURIComponent(a)}`},PUBLIC:{EXTERNAL_SHEET_RESULT:a=>`/api/v1/public/external-sheets/result/${a}`,EXTERNAL_SHEET_UPLOAD:a=>`/api/v1/public/external-sheets/upload/${a}`,EXTERNAL_SHEET_TOKEN_INFO:a=>`/api/v1/public/external-sheets/token-info/${a}`,OEA_RESULTS_LOOKUP:"/api/v1/public/oea-results/lookup"},TEST:{COOKIE_SET:"/api/v1/test/cookie/set",COOKIE_SET_AUTH:"/api/v1/test/cookie/set-auth-test",COOKIE_CLEAR:"/api/v1/test/cookie/clear"}};
|
package/package.json
CHANGED
|
@@ -1,163 +1,155 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tinyweb_dev/oe-exam-sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Reusable OceanEdu question components.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
],
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"build:
|
|
22
|
-
"
|
|
23
|
-
"build
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"release": "npm run release:
|
|
29
|
-
"release:
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
"@
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"@
|
|
110
|
-
"@
|
|
111
|
-
"@
|
|
112
|
-
"@
|
|
113
|
-
"@
|
|
114
|
-
"@
|
|
115
|
-
"@
|
|
116
|
-
"@radix-ui/react-
|
|
117
|
-
"@radix-ui/react-
|
|
118
|
-
"@radix-ui/react-
|
|
119
|
-
"@radix-ui/react-
|
|
120
|
-
"@radix-ui/react-
|
|
121
|
-
"@radix-ui/react-
|
|
122
|
-
"@radix-ui/react-
|
|
123
|
-
"@radix-ui/react-
|
|
124
|
-
"@radix-ui/react-
|
|
125
|
-
"@radix-ui/react-
|
|
126
|
-
"@
|
|
127
|
-
"@
|
|
128
|
-
"@
|
|
129
|
-
"@
|
|
130
|
-
"@
|
|
131
|
-
"@
|
|
132
|
-
"@
|
|
133
|
-
"@
|
|
134
|
-
"@
|
|
135
|
-
"@
|
|
136
|
-
"@
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"
|
|
142
|
-
"
|
|
143
|
-
"
|
|
144
|
-
"
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"react-hook-form": "^7.65.0",
|
|
157
|
-
"sonner": "^2.0.7",
|
|
158
|
-
"tailwind-merge": "^3.3.1",
|
|
159
|
-
"vaul": "^1.1.2",
|
|
160
|
-
"zod": "^4.1.11",
|
|
161
|
-
"zustand": "^5.0.8"
|
|
162
|
-
}
|
|
163
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tinyweb_dev/oe-exam-sdk",
|
|
3
|
+
"version": "0.1.19",
|
|
4
|
+
"description": "Reusable OceanEdu question components.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"**/*.css"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"build:compile": "tsc -p tsconfig.build.json",
|
|
19
|
+
"build:alias": "tsc-alias -p tsconfig.build.json",
|
|
20
|
+
"build:ts": "npm run build:compile && npm run build:assets && npm run build:alias",
|
|
21
|
+
"build:assets": "for d in cambridge-yle english-certification summer-sky; do [ -d src/components/themes/$d/assets ] && cp -R src/components/themes/$d/assets dist/components/themes/$d/ || true; done; [ -d src/components/shared/audio/assets ] && cp -R src/components/shared/audio/assets dist/components/shared/audio/ || true; [ -d src/components/results/report/assets ] && mkdir -p dist/components/results/report && cp -R src/components/results/report/assets dist/components/results/report/ || true; (cd src && find . -name '*.module.css' -exec cp --parents {} ../dist/ \\;); cp src/global.d.ts dist/global.d.ts",
|
|
22
|
+
"minify:js": "find dist -name '*.js' -type f -exec sh -c 'for f do terser \"$f\" --compress directives=false --mangle --module --comments false --output \"$f\"; done' sh {} +",
|
|
23
|
+
"build": "npm run clean && npm run build:ts && npm run minify:js",
|
|
24
|
+
"pack:local": "npm pack",
|
|
25
|
+
"release": "npm run release:patch",
|
|
26
|
+
"release:patch": "npm version patch --no-git-tag-version && npm run release:push",
|
|
27
|
+
"release:minor": "npm version minor --no-git-tag-version && npm run release:push",
|
|
28
|
+
"release:major": "npm version major --no-git-tag-version && npm run release:push",
|
|
29
|
+
"release:push": "npm run build && npm pack --dry-run && VERSION=$(node -p \"require('./package.json').version\") && git add package.json package-lock.json && git commit -m \"chore(sdk): release v$VERSION\" && git tag \"sdk-v$VERSION\" && git push origin HEAD && git push origin \"sdk-v$VERSION\"",
|
|
30
|
+
"prepack": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./api": {
|
|
38
|
+
"types": "./dist/api/index.d.ts",
|
|
39
|
+
"import": "./dist/api/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./components": {
|
|
42
|
+
"types": "./dist/components/index.d.ts",
|
|
43
|
+
"import": "./dist/components/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./components/exams": {
|
|
46
|
+
"types": "./dist/components/exams/index.d.ts",
|
|
47
|
+
"import": "./dist/components/exams/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./components/exams/take": {
|
|
50
|
+
"types": "./dist/components/exams/take/index.d.ts",
|
|
51
|
+
"import": "./dist/components/exams/take/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./components/exams/entry": {
|
|
54
|
+
"types": "./dist/components/exams/entry/index.d.ts",
|
|
55
|
+
"import": "./dist/components/exams/entry/index.js"
|
|
56
|
+
},
|
|
57
|
+
"./components/exams/rooms": {
|
|
58
|
+
"types": "./dist/components/exams/rooms/index.d.ts",
|
|
59
|
+
"import": "./dist/components/exams/rooms/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./components/questions": {
|
|
62
|
+
"types": "./dist/components/questions/index.d.ts",
|
|
63
|
+
"import": "./dist/components/questions/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./components/themes": {
|
|
66
|
+
"types": "./dist/components/themes/index.d.ts",
|
|
67
|
+
"import": "./dist/components/themes/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./components/results": {
|
|
70
|
+
"types": "./dist/components/results/index.d.ts",
|
|
71
|
+
"import": "./dist/components/results/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./components/questions/*": {
|
|
74
|
+
"types": "./dist/components/questions/*.d.ts",
|
|
75
|
+
"import": "./dist/components/questions/*.js"
|
|
76
|
+
},
|
|
77
|
+
"./shared": {
|
|
78
|
+
"types": "./dist/shared/index.d.ts",
|
|
79
|
+
"import": "./dist/shared/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./*": {
|
|
82
|
+
"types": "./dist/components/questions/*.d.ts",
|
|
83
|
+
"import": "./dist/components/questions/*.js"
|
|
84
|
+
},
|
|
85
|
+
"./package.json": "./package.json"
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"next": ">=15",
|
|
92
|
+
"react": ">=19",
|
|
93
|
+
"react-dom": ">=19"
|
|
94
|
+
},
|
|
95
|
+
"devDependencies": {
|
|
96
|
+
"@types/node": "^25.9.3",
|
|
97
|
+
"terser": "^5.48.0",
|
|
98
|
+
"tsc-alias": "^1.8.17",
|
|
99
|
+
"typescript": "~5.9.2"
|
|
100
|
+
},
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@dnd-kit/core": "^6.3.1",
|
|
103
|
+
"@dnd-kit/sortable": "^10.0.0",
|
|
104
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
105
|
+
"@fortawesome/free-solid-svg-icons": "^7.3.1",
|
|
106
|
+
"@fortawesome/react-fontawesome": "^3.3.1",
|
|
107
|
+
"@hookform/resolvers": "^5.2.2",
|
|
108
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
109
|
+
"@radix-ui/react-avatar": "^1.1.10",
|
|
110
|
+
"@radix-ui/react-checkbox": "^1.3.3",
|
|
111
|
+
"@radix-ui/react-collapsible": "^1.1.12",
|
|
112
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
113
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
114
|
+
"@radix-ui/react-hover-card": "^1.1.15",
|
|
115
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
116
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
117
|
+
"@radix-ui/react-progress": "^1.1.7",
|
|
118
|
+
"@radix-ui/react-radio-group": "^1.3.8",
|
|
119
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
120
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
121
|
+
"@radix-ui/react-separator": "^1.1.7",
|
|
122
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
123
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
124
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
125
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
126
|
+
"@tanstack/react-query": "^5.90.2",
|
|
127
|
+
"@tiptap/extension-table": "^3.22.3",
|
|
128
|
+
"@tiptap/extension-table-cell": "^3.22.3",
|
|
129
|
+
"@tiptap/extension-table-header": "^3.22.3",
|
|
130
|
+
"@tiptap/extension-table-row": "^3.22.3",
|
|
131
|
+
"@tiptap/extension-text-align": "^3.22.3",
|
|
132
|
+
"@tiptap/pm": "^3.22.3",
|
|
133
|
+
"@tiptap/react": "^3.22.3",
|
|
134
|
+
"@tiptap/starter-kit": "^3.22.3",
|
|
135
|
+
"@types/qrcode": "^1.5.6",
|
|
136
|
+
"@xyflow/react": "^12.8.6",
|
|
137
|
+
"axios": "^1.12.2",
|
|
138
|
+
"class-variance-authority": "^0.7.1",
|
|
139
|
+
"clsx": "^2.1.1",
|
|
140
|
+
"cmdk": "^1.1.1",
|
|
141
|
+
"date-fns": "^4.1.0",
|
|
142
|
+
"embla-carousel-react": "^8.6.0",
|
|
143
|
+
"howler": "^2.2.4",
|
|
144
|
+
"lucide-react": "^0.544.0",
|
|
145
|
+
"qrcode": "^1.5.4",
|
|
146
|
+
"radix-ui": "^1.4.3",
|
|
147
|
+
"react-day-picker": "^9.14.0",
|
|
148
|
+
"react-hook-form": "^7.65.0",
|
|
149
|
+
"sonner": "^2.0.7",
|
|
150
|
+
"tailwind-merge": "^3.3.1",
|
|
151
|
+
"vaul": "^1.1.2",
|
|
152
|
+
"zod": "^4.1.11",
|
|
153
|
+
"zustand": "^5.0.8"
|
|
154
|
+
}
|
|
155
|
+
}
|
package/dist/mcp/config.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
declare const schema: z.ZodObject<{
|
|
3
|
-
OE_API_URL: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
4
|
-
OE_API_TOKEN: z.ZodString;
|
|
5
|
-
OE_HTTP_TIMEOUT_MS: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
6
|
-
}, z.core.$strip>;
|
|
7
|
-
export type McpConfig = z.infer<typeof schema> & {
|
|
8
|
-
packageName: string;
|
|
9
|
-
packageVersion: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function loadMcpConfig(): McpConfig;
|
|
12
|
-
export {};
|
package/dist/mcp/config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{readFileSync as e}from"node:fs";import{dirname as r,join as o}from"node:path";import{fileURLToPath as n}from"node:url";import{z as t}from"zod";const s=function(){try{const t=r(n(import.meta.url));return JSON.parse(e(o(t,"..","..","package.json"),"utf8"))}catch{return{name:"@tinyweb_dev/oe-exam-sdk",version:"0.0.0"}}}(),a=t.object({OE_API_URL:t.string().url().transform(e=>e.replace(/\/+$/,"")),OE_API_TOKEN:t.string().min(1),OE_HTTP_TIMEOUT_MS:t.coerce.number().int().positive().default(15e3)});let i=null;export function loadMcpConfig(){if(i)return i;const e=a.safeParse(process.env);if(!e.success){const r=e.error.issues.map(e=>` • ${e.path.join(".")||"<root>"}: ${e.message}`).join("\n");console.error(`\n[oe-exam-mcp] Configuration error:\n${r}\n\nRequired: OE_API_URL and OE_API_TOKEN.\n`),process.exit(1)}return i={...e.data,packageName:s.name,packageVersion:s.version},i}
|
package/dist/mcp/http-client.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ErrorCode as t,McpError as o}from"@modelcontextprotocol/sdk/types.js";import{loadMcpConfig as r}from"./config.js";export async function mcpRequest(n){const s=r(),a=new AbortController,i=setTimeout(()=>a.abort(),s.OE_HTTP_TIMEOUT_MS);try{const r=await fetch(`${s.OE_API_URL}${n.url}`,{method:n.method,signal:a.signal,headers:{Accept:"application/json","Content-Type":"application/json",...e(s.OE_API_TOKEN)},body:void 0===n.body?void 0:JSON.stringify(n.body)}),i=await r.text(),c=i?JSON.parse(i):void 0;if(!r.ok){const e=function(t){if(!t||"object"!=typeof t)return;const o=t.message;return Array.isArray(o)?o.join("; "):"string"==typeof o?o:void 0}(c)??r.statusText,s=400===r.status||404===r.status||422===r.status?t.InvalidParams:t.InternalError;throw new o(s,`[${n.method} ${n.url}] ${r.status}: ${e}`)}return c}catch(r){if(r instanceof o)throw r;throw new o(t.InternalError,r instanceof Error?r.message:"Unknown HTTP error")}finally{clearTimeout(i)}}function e(t){return t?t.startsWith("oeexam_")?{"X-API-Key":t}:{Authorization:`Bearer ${t}`}:{}}
|
package/dist/mcp/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
export declare function startOeExamMcpServer(): Promise<void>;
|
|
3
|
-
export { loadMcpConfig } from './config.js';
|
|
4
|
-
export { registerAllMcpTools } from './tools/index.js';
|
|
5
|
-
export { registerExamTools } from './tools/exams.js';
|
|
6
|
-
export { registerResultTools } from './tools/results.js';
|
package/dist/mcp/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{McpServer as e}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as o}from"@modelcontextprotocol/sdk/server/stdio.js";import{loadMcpConfig as r}from"./config.js";import{registerAllMcpTools as s}from"./tools/index.js";export async function startOeExamMcpServer(){const t=r(),a=new e({name:t.packageName,version:t.packageVersion},{capabilities:{tools:{},logging:{}},instructions:"OE Exam MCP server. Use exam_json_template_generate then exam_create_from_json to create an exam, and exam_result_get to view a result review."});s(a),await a.connect(new o);const c=async()=>{await a.close().catch(e=>console.error("[oe-exam-mcp] server.close failed",e)),process.exit(0)};process.on("SIGINT",()=>{c()}),process.on("SIGTERM",()=>{c()})}import.meta.url===`file://${process.argv[1]}`&&startOeExamMcpServer().catch(e=>{console.error("[oe-exam-mcp] Fatal startup error",e),process.exit(1)});export{loadMcpConfig}from"./config.js";export{registerAllMcpTools}from"./tools/index.js";export{registerExamTools}from"./tools/exams.js";export{registerResultTools}from"./tools/results.js";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
export declare function buildToolResult<T>(value: T): CallToolResult;
|
|
3
|
-
export declare function wrapHandler<TInput extends Record<string, unknown>>(toolName: string, fn: (input: TInput) => Promise<CallToolResult>): (input: TInput) => Promise<CallToolResult>;
|
|
4
|
-
export declare function unwrapData<T>(value: unknown): T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ErrorCode as t,McpError as r}from"@modelcontextprotocol/sdk/types.js";export function buildToolResult(t){return{content:[{type:"text",text:"string"==typeof t?t:JSON.stringify(t,null,2)}],...t&&"object"==typeof t?{structuredContent:t}:{}}}export function wrapHandler(e,o){return async n=>{try{return await o(n)}catch(o){if(o instanceof r)throw o;throw console.error(`[oe-exam-mcp] ${e} failed`,o),new r(t.InternalError,o instanceof Error?o.message:"Unknown error")}}}export function unwrapData(t){return t&&"object"==typeof t&&"data"in t?t.data:t}
|
package/dist/mcp/tools/exams.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{mkdir as e,writeFile as t}from"node:fs/promises";import{dirname as n,resolve as i}from"node:path";import{z as a}from"zod";import{mcpRequest as o}from"../http-client.js";import{buildToolResult as r,unwrapData as s,wrapHandler as l}from"./_helpers.js";const p=a.record(a.string(),a.unknown()).describe("Full API question payload or short form: { question, options, answer, points?, partId?, partNo? }."),u=(a.record(a.string(),a.unknown()).describe("Part payload: { name?, partId?, questions: [...] }."),a.record(a.string(),a.unknown()).describe("Template payload accepted by PATCH /manage/exams/:id/template.")),m=a.enum(["PRE_A1","A1","A2","B1","B2","C1","C2"]);export function registerExamTools(g){g.registerTool("exam_templates_search",{title:"Search exam templates",description:"Search available OE Exam templates. Use this before exam_create_with_questions to choose examTemplateId.",inputSchema:{search:a.string().optional().describe("Template name keyword."),page:a.number().int().positive().default(1).describe("1-based page number."),limit:a.number().int().positive().max(50).default(9).describe("Page size sent as API size.")}},l("exam_templates_search",async e=>{const t=new URLSearchParams({page:String(e.page??1),size:String(e.limit??9)});e.search&&t.set("filter",`name:like:${e.search}`);const n=await o({method:"GET",url:`/api/v1/exam-templates?${t}`});return r({templates:k(n)})})),g.registerTool("exam_template_get",{title:"Get exam template",description:"Get one OE Exam template by id. The returned templatePayload can be passed as template to exam_create_with_questions.",inputSchema:{id:a.string().min(1).describe("Template id from exam_templates_search.")}},l("exam_template_get",async e=>{const t=s(await o({method:"GET",url:`/api/v1/exam-templates/${encodeURIComponent(String(e.id))}`}));return r({template:t,templatePayload:P(t)})})),g.registerTool("exam_question_template_get",{title:"Get question payload template",description:"Return easy-to-fill question JSON templates for exam_create_with_questions. Use this before creating questions if you need the expected shape.",inputSchema:{templateId:a.string().min(1).optional().describe("Template id. If provided, generate question payloads from template.parts."),type:a.string().default("CHOOSE_THE_CORRECT_ANSWER").describe("Fallback question type when templateId is omitted."),count:a.number().int().positive().max(100).default(1).describe("Fallback count when templateId is omitted."),partId:a.union([a.string(),a.number()]).default(1),partNo:a.number().int().positive().default(1),skill:a.string().default("READING")}},l("exam_question_template_get",async e=>{const t="string"==typeof e.templateId?s(await o({method:"GET",url:`/api/v1/exam-templates/${encodeURIComponent(e.templateId)}`})):void 0;return r({usage:"Pass questions directly into exam_create_with_questions.questions. Fill content/correctAnswer for each generated API-format payload.",templateId:t?.id,questions:t?b(t):S(e)})})),g.registerTool("exam_json_template_generate",{title:"Get exam JSON template",description:"Generate a user-friendly examJson skeleton from templateTitle or templateId. Edit this JSON, then pass it to exam_create_from_json.",inputSchema:{templateTitle:a.string().optional().describe("Template title to search, e.g. Achievers 2026 Round 1."),templateId:a.string().optional().describe("Exact template id. Preferred when known."),name:a.string().optional().describe("Exam name to put in the JSON."),examLevel:m.optional().describe("Optional exam level for the generated JSON."),difficulty:a.enum(["EASY","MEDIUM","HARD"]).optional().describe("Optional difficulty for the generated JSON."),durationMinutes:a.number().int().positive().optional().describe("Optional duration for the generated JSON.")}},l("exam_json_template_generate",async a=>{const o=await f({templateId:a.templateId,templateTitle:a.templateTitle}),s=function(e,t){const n=Array.isArray(e.parts)?e.parts.filter(c):[];return{name:v(t.name,`${e.title??e.name??"OE Exam"} Draft`),templateId:e.id,templateTitle:e.title??e.name,totalScore:O(e.totalScore??e.total_questions,y(n)),examLevel:_(t.examLevel)??_(e.examLevel??e.exam_level??e.level)??"A1",difficulty:E(t.difficulty)??"MEDIUM",durationMinutes:O(t.durationMinutes,45),isComplete:!1,isActive:!1,parts:n.map((e,t)=>function(e,t){const n=O(e.startIndex,0),i=O(e.questionCount,O(e.endIndex,n)-n+1);return{id:e.id??t+1,name:e.name??`Part ${t+1}`,questionType:v(e.questionType,"CHOOSE_THE_CORRECT_ANSWER"),skill:v(e.skill,"READING"),questions:Array.from({length:Math.max(i,0)},(t,i)=>function(e,t){const n=v(e.questionType,"CHOOSE_THE_CORRECT_ANSWER"),i=(Array.isArray(e.defaultValue)&&e.defaultValue.length>0?e.defaultValue:Array.from({length:O(e.optionCount,4)},(e,t)=>String.fromCharCode(65+t))).map(String);return n.includes("FILL")||n.includes("WRITE")?{question:`Question ${t}`,answer:""}:n.includes("SPEAK")?{prompt:`Question ${t}`,expectedAnswer:""}:{question:`Question ${t}`,options:i,answer:i[0]??"A"}}(e,n+i+1))}}(e,t))}}(o,a),l=JSON.stringify(s,null,2),p=i(`${u=String(a.name??o.title??o.name??"exam"),u.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,80)||"exam"}.json`);var u;return await e(n(p),{recursive:!0}),await t(p,`${l}\n`,"utf8"),r({usage:"Edit filePath, then call exam_create_from_json with the edited JSON string.",templateId:o.id,templateTitle:o.title??o.name,filePath:p,examJson:s,examJsonString:l})})),g.registerTool("exam_create_from_json",{title:"Create exam from JSON",description:"Create an exam from a user-friendly JSON payload grouped by parts. Searches template by title, patches template, maps questions to template.parts, then creates questions.",inputSchema:{examJson:a.string().optional().describe("JSON string with { name, templateTitle/templateId, parts: [{ questions: [...] }] }. Use this for copy/paste."),exam:a.record(a.string(),a.unknown()).optional().describe("Same payload as object if the client supports object arguments.")}},l("exam_create_from_json",async e=>{const t=function(e,t){if(c(t))return t;if("string"!=typeof e||!e.trim())throw new Error("examJson or exam is required");const n=JSON.parse(e);if(!c(n))throw new Error("examJson must be a JSON object");return n}(e.examJson,e.exam),n=await f(t),i=function(e,t){const n=Array.isArray(t.parts)?t.parts.filter(c):[],i=Array.isArray(e.parts)?e.parts.filter(c):[{questions:e.questions}];return i.flatMap((e,t)=>{const i=function(e,t,n){const i=A(e.partId??e.id),a=A(e.name);return t.find(e=>String(e.id)===i)??t.find(e=>"string"==typeof e.name&&e.name===a)??t[n]??{id:n+1,questionType:"CHOOSE_THE_CORRECT_ANSWER",skill:"READING",optionCount:4}}(e,n,t);return(Array.isArray(e.questions)?e.questions.filter(c):[]).map((e,n)=>function(e,t,n,i){const a=O(t.startIndex,0),o=w({questionType:v(e.questionType??e.type??t.questionType,"CHOOSE_THE_CORRECT_ANSWER"),questionNumber:O(e.questionNumber,a+i+1),partId:String(e.partId??t.id??n+1),partNo:O(e.partNo,n+1),sectionId:R(e.sectionId??t.sectionId),skill:v(e.questionSkillType??e.skill??t.skill,"READING"),optionCount:O(t.optionCount,4),defaultValue:Array.isArray(t.defaultValue)?t.defaultValue:void 0});return q(function(e){const t=c(e.content)?{...e.content}:{};"string"==typeof e.question&&(t.question=e.question);"string"==typeof e.text&&(t.question=e.text);Array.isArray(e.options)&&(t.optionType=t.optionType??"text",t.options=e.options);return d({...e,content:c(t)?t:e.content,correctAnswer:void 0===e.answer&&void 0===e.expectedAnswer?e.correctAnswer:x(e.questionType,e.answer??e.expectedAnswer,t.options)})}({...o,...e}),i)}(e,i,t,n))})}(t,n),a=function(e,t,n){return{exam:d({name:v(e.name,"New OE Exam"),code:A(e.code)??h(v(e.name,"New OE Exam")),totalScore:O(e.totalScore,n.length||100),description:A(e.description)??A(e.templateTitle)??"",isComplete:T(e.isComplete,!1),isActive:T(e.isActive,!1),examTemplateId:t,examLevel:_(e.examLevel),difficulty:E(e.difficulty),durationMinutes:R(e.durationMinutes)})}}(t,n.id,i),l=s(await o({method:"POST",url:"/api/v1/manage/exams",body:a.exam}));await o({method:"PATCH",url:`/api/v1/manage/exams/${encodeURIComponent(l.id)}/template`,body:{template:P(n)}});const p=0===i.length?null:await o({method:"POST",url:"/api/v1/manage/questions/batch",body:{examId:l.id,questions:i}});return r({exam:l,templateId:n.id,questions:p,generatedQuestionCount:i.length})})),g.registerTool("exam_create_with_questions",{title:"Create exam with questions",description:"Create an exam, optionally patch template, then bulk create questions via /api/v1/manage/questions/batch. If you do not know examTemplateId/template, call exam_templates_search then exam_template_get first.",inputSchema:{name:a.string().min(1),code:a.string().min(1).optional(),examLevel:m.optional().describe("Valid exam level only: PRE_A1, A1, A2, B1, B2, C1, C2. Do not use template title/id here."),difficulty:a.enum(["EASY","MEDIUM","HARD"]).optional(),totalScore:a.number().nonnegative().optional(),durationMinutes:a.number().int().positive().optional(),description:a.string().optional(),isComplete:a.boolean().optional(),isActive:a.boolean().optional(),examTemplateId:a.string().min(1).optional(),template:u.optional(),questions:a.array(p).default([])}},l("exam_create_with_questions",async e=>{const{template:t,questions:n,...i}=e,a=s(await o({method:"POST",url:"/api/v1/manage/exams",body:d(i)})),l=c(t)?t:await async function(e){if("string"!=typeof e||!e)return;const t=s(await o({method:"GET",url:`/api/v1/exam-templates/${encodeURIComponent(e)}`}));return P(t)}(i.examTemplateId);c(l)&&await o({method:"PATCH",url:`/api/v1/manage/exams/${encodeURIComponent(a.id)}/template`,body:{template:l}});const p=n.map(q),u=0===p.length?null:await o({method:"POST",url:"/api/v1/manage/questions/batch",body:{examId:a.id,questions:p}});return r({exam:a,questions:u})}))}function d(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}function c(e){return Boolean(e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length>0)}async function f(e){const t=A(e.templateId);if(t)return s(await o({method:"GET",url:`/api/v1/exam-templates/${encodeURIComponent(t)}`}));const n=A(e.templateTitle);if(!n)throw new Error("templateTitle or templateId is required");const i=new URLSearchParams({page:"1",size:"10",filter:`name:like:${n}`}),a=k(await o({method:"GET",url:`/api/v1/exam-templates?${i}`})),r=a.find(e=>(e.title??e.name)===n),l=r??a[0];if(!l?.id)throw new Error(`No exam template found for title: ${n}`);return s(await o({method:"GET",url:`/api/v1/exam-templates/${encodeURIComponent(l.id)}`}))}function y(e){return e.reduce((e,t)=>e+O(t.questionCount,0),0)}function x(e,t,n){if(void 0===t)return;const i=String(e??"");return i.includes("FILL")||i.includes("WRITE")?{answers:[String(t)]}:i.includes("SPEAK")?{expectedAnswer:String(t)}:{answer:g(t,n)}}function g(e,t){if("string"==typeof e&&Array.isArray(t)){const n=t.map(String).findIndex(t=>t===e);if(n>=0)return n}return I(e)}function h(e){return e.toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_|_$/g,"").slice(0,40)||"OE_EXAM"}function A(e){return"string"==typeof e&&e?e:void 0}function T(e,t){return"boolean"==typeof e?e:t}function _(e){return"string"==typeof e&&m.safeParse(e).success?e:void 0}function E(e){return"string"==typeof e&&["EASY","MEDIUM","HARD"].includes(e)?e:void 0}function q(e,t){if(e.questionType)return d({...e,partId:void 0===e.partId?void 0:String(e.partId),partNo:e.partNo??1,questionNumber:e.questionNumber??t+1,points:e.points??1,addToQuestionBank:e.addToQuestionBank??!1,isExample:e.isExample??!1});const n=Array.isArray(e.options)?e.options:["A","B","C","D"];return d({questionType:e.type??"CHOOSE_THE_CORRECT_ANSWER",content:e.content??{question:String(e.question??e.text??`Question ${t+1}`),optionType:"text",options:n},correctAnswer:e.correctAnswer??{answer:I(e.answer??e.correctAnswerIndex??0)},points:e.points??1,explanation:e.explanation??"",questionNumber:e.questionNumber??t+1,partId:String(e.partId??1),partNo:e.partNo??1,sectionId:e.sectionId,questionSkillType:e.questionSkillType??e.skill??"READING",addToQuestionBank:e.addToQuestionBank??!1,isExample:e.isExample??!1})}function I(e){if("number"==typeof e)return e;if("string"==typeof e&&/^[A-E]$/i.test(e))return e.toUpperCase().charCodeAt(0)-65;const t=Number(e);return Number.isFinite(t)?t:0}function S(e){return Array.from({length:Number(e.count??1)},(t,n)=>w({questionType:String(e.type??"CHOOSE_THE_CORRECT_ANSWER"),questionNumber:n+1,partId:String(e.partId??1),partNo:Number(e.partNo??1),skill:String(e.skill??"READING")}))}function b(e){return(Array.isArray(e.parts)?e.parts.filter(c):[]).flatMap((e,t)=>{const n=O(e.startIndex,0),i=O(e.questionCount,O(e.endIndex,n)-n+1);return Array.from({length:Math.max(i,0)},(i,a)=>w({questionType:v(e.questionType,"CHOOSE_THE_CORRECT_ANSWER"),questionNumber:n+a+1,partId:String(e.id??t+1),partNo:t+1,sectionId:R(e.sectionId),skill:v(e.skill,"READING"),optionCount:O(e.optionCount,4),defaultValue:Array.isArray(e.defaultValue)?e.defaultValue:void 0}))})}function w(e){return d({questionType:e.questionType,content:C(e.questionType,e.questionNumber,e.optionCount,e.defaultValue),correctAnswer:N(e.questionType),points:1,explanation:"",questionNumber:e.questionNumber,partId:e.partId,partNo:e.partNo,sectionId:e.sectionId,questionSkillType:e.skill,addToQuestionBank:!1,isExample:!1})}function C(e,t,n=4,i){const a=(i?.length?i:Array.from({length:n},(e,t)=>String.fromCharCode(65+t))).map(String);return e.includes("FILL")||e.includes("WRITE")?{question:`Question ${t}`,text:""}:e.includes("SPEAK")?{prompt:`Question ${t}`}:e.includes("LISTEN")?{question:`Question ${t}`,audioUrl:"",optionType:"text",options:a}:{question:`Question ${t}`,optionType:"text",options:a}}function N(e){return e.includes("FILL")||e.includes("WRITE")?{answers:[""]}:e.includes("SPEAK")?{expectedAnswer:""}:{answer:0}}function v(e,t){return"string"==typeof e&&e?e:t}function O(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function R(e){const t=Number(e);return Number.isFinite(t)?t:void 0}function k(e){const t=s(e);return Array.isArray(t)?t:t&&"object"==typeof t&&"data"in t&&Array.isArray(t.data)?t.data:[]}function P(e){const t=Array.isArray(e.parts)?e.parts:[];return d({id:e.id,title:e.title??e.name,subTitle:e.subTitle??e.sub_title??"",theme:e.theme,totalQuestions:e.totalQuestions??e.total_questions,totalParts:e.totalParts??e.total_parts??t.length,description:e.description??"",examLevel:e.examLevel??e.exam_level??e.level??"",type:e.type??null,parts:t})}
|
package/dist/mcp/tools/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{registerExamTools as o}from"./exams.js";import{registerResultTools as r}from"./results.js";export function registerAllMcpTools(s){o(s),r(s)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as t}from"zod";import{mcpRequest as e}from"../http-client.js";import{buildToolResult as n,wrapHandler as o}from"./_helpers.js";export function registerResultTools(r){r.registerTool("exam_result_get",{title:"Get exam result review",description:"Fetch student exam result review by attemptId. Optional token supports public result review links.",inputSchema:{attemptId:t.string().min(1),token:t.string().min(1).optional(),includeAttempt:t.boolean().default(!0)}},o("exam_result_get",async({attemptId:t,token:o,includeAttempt:r})=>{const i=o?`?token=${encodeURIComponent(String(o))}`:"",s=await e({method:"GET",url:`/api/v1/student/results/${encodeURIComponent(String(t))}${i}`}),l=!1===r?null:await e({method:"GET",url:`/api/v1/student/attempts/${encodeURIComponent(String(t))}${i}`});return n({result:s,attempt:l})}))}
|