@jswork/react-questkit 1.0.8 → 1.0.9

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/dist/index.d.mts CHANGED
@@ -329,6 +329,8 @@ interface UseJudgeOptions {
329
329
  sound?: boolean;
330
330
  /** 演示直达:0 未答 / 1 首错 / 2 二错 */
331
331
  demoAttempt?: 0 | 1 | 2;
332
+ /** 断点续做回填:直接进入指定判分相位(优先于 demoAttempt) */
333
+ initialPhase?: JudgePhase;
332
334
  }
333
335
  interface UseJudgeResult {
334
336
  state: JudgeState;
@@ -473,9 +475,13 @@ declare function SegmentedControl({ options, value, onChange, ariaLabel, disable
473
475
 
474
476
  interface SingleChoiceProps extends QuestCommonProps {
475
477
  data: SingleChoiceData;
478
+ /** 断点续做回填:学生上次选中的选项序号;null 表示未选。 */
479
+ initialSelected?: number | null;
480
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
481
+ initialCorrect?: boolean | null;
476
482
  }
477
483
 
478
- declare function SingleChoice({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: SingleChoiceProps): react.JSX.Element;
484
+ declare function SingleChoice({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialSelected, initialCorrect, className, }: SingleChoiceProps): react.JSX.Element;
479
485
 
480
486
  interface FollowReadProps extends QuestCommonProps, FollowReadExtraProps {
481
487
  data: FollowReadData;
@@ -487,15 +493,23 @@ declare function FollowRead({ data, mode, index, total, title, instruction, onBa
487
493
 
488
494
  interface LinkMatchProps extends QuestCommonProps {
489
495
  data: LinkMatchData;
496
+ /** 断点续做回填:学生上次已选配对 [[left, right]]。 */
497
+ initialPairs?: Array<[number, number]>;
498
+ /** 上次判分结果(1/0/null);true 时以 correct 相位冻结展示。 */
499
+ initialCorrect?: boolean | null;
490
500
  }
491
501
 
492
- declare function LinkMatch({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: LinkMatchProps): react.JSX.Element;
502
+ declare function LinkMatch({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialPairs, initialCorrect, className, }: LinkMatchProps): react.JSX.Element;
493
503
 
494
504
  interface RearrangeProps extends QuestCommonProps {
495
505
  data: RearrangeData;
506
+ /** 断点续做回填:学生上次每个槽位填入的字母(空槽为 null)。 */
507
+ initialChars?: Array<string | null>;
508
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
509
+ initialCorrect?: boolean | null;
496
510
  }
497
511
 
498
- declare function Rearrange({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: RearrangeProps): react.JSX.Element;
512
+ declare function Rearrange({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialChars, initialCorrect, className, }: RearrangeProps): react.JSX.Element;
499
513
 
500
514
  interface ClassifyProps extends QuestCommonProps {
501
515
  data: ClassifyData;
@@ -511,21 +525,33 @@ declare function Rewrite({ data, mode, index, total, title, instruction, onBack,
511
525
 
512
526
  interface FillBlankProps extends QuestCommonProps {
513
527
  data: FillBlankData;
528
+ /** 断点续做回填:学生上次每个空填入的文本(按空槽顺序)。 */
529
+ initialValues?: string[];
530
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
531
+ initialCorrect?: boolean | null;
514
532
  }
515
533
 
516
- declare function FillBlank({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: FillBlankProps): react.JSX.Element;
534
+ declare function FillBlank({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialValues, initialCorrect, className, }: FillBlankProps): react.JSX.Element;
517
535
 
518
536
  interface WordSelectProps extends QuestCommonProps {
519
537
  data: WordSelectData;
538
+ /** 断点续做回填:学生上次每个空选中的词(按空槽顺序,空为 null)。 */
539
+ initialFilled?: Array<string | null>;
540
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
541
+ initialCorrect?: boolean | null;
520
542
  }
521
543
 
522
- declare function WordSelect({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: WordSelectProps): react.JSX.Element;
544
+ declare function WordSelect({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialFilled, initialCorrect, className, }: WordSelectProps): react.JSX.Element;
523
545
 
524
546
  interface SortSentencesProps extends QuestCommonProps {
525
547
  data: SortSentencesData;
548
+ /** 断点续做回填:学生上次每行填入的句子(空行为 null)。 */
549
+ initialRows?: Array<string | null>;
550
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
551
+ initialCorrect?: boolean | null;
526
552
  }
527
553
 
528
- declare function SortSentences({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: SortSentencesProps): react.JSX.Element;
554
+ declare function SortSentences({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialRows, initialCorrect, className, }: SortSentencesProps): react.JSX.Element;
529
555
 
530
556
  interface ClozeProps extends QuestCommonProps {
531
557
  data: ClozeData;
@@ -535,9 +561,13 @@ declare function Cloze({ data, mode, index, total, title, instruction, onBack, o
535
561
 
536
562
  interface ReadingComprehensionProps extends QuestCommonProps {
537
563
  data: ReadingData;
564
+ /** 断点续做回填:每个子题上次选中的选项序号(未选为 null)。 */
565
+ initialAnswers?: Array<number | null>;
566
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
567
+ initialCorrect?: boolean | null;
538
568
  }
539
569
 
540
- declare function ReadingComprehension({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: ReadingComprehensionProps): react.JSX.Element;
570
+ declare function ReadingComprehension({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialAnswers, initialCorrect, className, }: ReadingComprehensionProps): react.JSX.Element;
541
571
 
542
572
  interface ListenTaskProps extends QuestCommonProps {
543
573
  data: ListenTaskData;
package/dist/index.d.ts CHANGED
@@ -329,6 +329,8 @@ interface UseJudgeOptions {
329
329
  sound?: boolean;
330
330
  /** 演示直达:0 未答 / 1 首错 / 2 二错 */
331
331
  demoAttempt?: 0 | 1 | 2;
332
+ /** 断点续做回填:直接进入指定判分相位(优先于 demoAttempt) */
333
+ initialPhase?: JudgePhase;
332
334
  }
333
335
  interface UseJudgeResult {
334
336
  state: JudgeState;
@@ -473,9 +475,13 @@ declare function SegmentedControl({ options, value, onChange, ariaLabel, disable
473
475
 
474
476
  interface SingleChoiceProps extends QuestCommonProps {
475
477
  data: SingleChoiceData;
478
+ /** 断点续做回填:学生上次选中的选项序号;null 表示未选。 */
479
+ initialSelected?: number | null;
480
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
481
+ initialCorrect?: boolean | null;
476
482
  }
477
483
 
478
- declare function SingleChoice({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: SingleChoiceProps): react.JSX.Element;
484
+ declare function SingleChoice({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialSelected, initialCorrect, className, }: SingleChoiceProps): react.JSX.Element;
479
485
 
480
486
  interface FollowReadProps extends QuestCommonProps, FollowReadExtraProps {
481
487
  data: FollowReadData;
@@ -487,15 +493,23 @@ declare function FollowRead({ data, mode, index, total, title, instruction, onBa
487
493
 
488
494
  interface LinkMatchProps extends QuestCommonProps {
489
495
  data: LinkMatchData;
496
+ /** 断点续做回填:学生上次已选配对 [[left, right]]。 */
497
+ initialPairs?: Array<[number, number]>;
498
+ /** 上次判分结果(1/0/null);true 时以 correct 相位冻结展示。 */
499
+ initialCorrect?: boolean | null;
490
500
  }
491
501
 
492
- declare function LinkMatch({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: LinkMatchProps): react.JSX.Element;
502
+ declare function LinkMatch({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialPairs, initialCorrect, className, }: LinkMatchProps): react.JSX.Element;
493
503
 
494
504
  interface RearrangeProps extends QuestCommonProps {
495
505
  data: RearrangeData;
506
+ /** 断点续做回填:学生上次每个槽位填入的字母(空槽为 null)。 */
507
+ initialChars?: Array<string | null>;
508
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
509
+ initialCorrect?: boolean | null;
496
510
  }
497
511
 
498
- declare function Rearrange({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: RearrangeProps): react.JSX.Element;
512
+ declare function Rearrange({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialChars, initialCorrect, className, }: RearrangeProps): react.JSX.Element;
499
513
 
500
514
  interface ClassifyProps extends QuestCommonProps {
501
515
  data: ClassifyData;
@@ -511,21 +525,33 @@ declare function Rewrite({ data, mode, index, total, title, instruction, onBack,
511
525
 
512
526
  interface FillBlankProps extends QuestCommonProps {
513
527
  data: FillBlankData;
528
+ /** 断点续做回填:学生上次每个空填入的文本(按空槽顺序)。 */
529
+ initialValues?: string[];
530
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
531
+ initialCorrect?: boolean | null;
514
532
  }
515
533
 
516
- declare function FillBlank({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: FillBlankProps): react.JSX.Element;
534
+ declare function FillBlank({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialValues, initialCorrect, className, }: FillBlankProps): react.JSX.Element;
517
535
 
518
536
  interface WordSelectProps extends QuestCommonProps {
519
537
  data: WordSelectData;
538
+ /** 断点续做回填:学生上次每个空选中的词(按空槽顺序,空为 null)。 */
539
+ initialFilled?: Array<string | null>;
540
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
541
+ initialCorrect?: boolean | null;
520
542
  }
521
543
 
522
- declare function WordSelect({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: WordSelectProps): react.JSX.Element;
544
+ declare function WordSelect({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialFilled, initialCorrect, className, }: WordSelectProps): react.JSX.Element;
523
545
 
524
546
  interface SortSentencesProps extends QuestCommonProps {
525
547
  data: SortSentencesData;
548
+ /** 断点续做回填:学生上次每行填入的句子(空行为 null)。 */
549
+ initialRows?: Array<string | null>;
550
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
551
+ initialCorrect?: boolean | null;
526
552
  }
527
553
 
528
- declare function SortSentences({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: SortSentencesProps): react.JSX.Element;
554
+ declare function SortSentences({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialRows, initialCorrect, className, }: SortSentencesProps): react.JSX.Element;
529
555
 
530
556
  interface ClozeProps extends QuestCommonProps {
531
557
  data: ClozeData;
@@ -535,9 +561,13 @@ declare function Cloze({ data, mode, index, total, title, instruction, onBack, o
535
561
 
536
562
  interface ReadingComprehensionProps extends QuestCommonProps {
537
563
  data: ReadingData;
564
+ /** 断点续做回填:每个子题上次选中的选项序号(未选为 null)。 */
565
+ initialAnswers?: Array<number | null>;
566
+ /** 上次判分结果(true/false/null);true 时以 correct 相位冻结展示。 */
567
+ initialCorrect?: boolean | null;
538
568
  }
539
569
 
540
- declare function ReadingComprehension({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: ReadingComprehensionProps): react.JSX.Element;
570
+ declare function ReadingComprehension({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, initialAnswers, initialCorrect, className, }: ReadingComprehensionProps): react.JSX.Element;
541
571
 
542
572
  interface ListenTaskProps extends QuestCommonProps {
543
573
  data: ListenTaskData;
package/dist/index.mjs CHANGED
@@ -140,7 +140,8 @@ var questSfx = {
140
140
 
141
141
  // src/core/use-judge.ts
142
142
  import { useCallback, useRef, useState } from "react";
143
- function resolveInitial(demoAttempt) {
143
+ function resolveInitial(demoAttempt, initialPhase) {
144
+ if (initialPhase) return { phase: initialPhase, attempts: 0 };
144
145
  if (demoAttempt === 2) return { phase: "locked", attempts: 2 };
145
146
  if (demoAttempt === 1) return { phase: "retry", attempts: 1 };
146
147
  return { phase: "idle", attempts: 0 };
@@ -149,7 +150,7 @@ function useJudge(options) {
149
150
  const latest = useRef(options);
150
151
  latest.current = options;
151
152
  const [state, setState] = useState(
152
- () => resolveInitial(options.demoAttempt)
153
+ () => resolveInitial(options.demoAttempt, options.initialPhase)
153
154
  );
154
155
  const stateRef = useRef(state);
155
156
  const commit = useCallback((next) => {
@@ -1504,10 +1505,15 @@ function useSingleChoice({
1504
1505
  mode,
1505
1506
  sound,
1506
1507
  demoAttempt,
1508
+ initialSelected,
1509
+ initialCorrect,
1507
1510
  onSubmit
1508
1511
  }) {
1509
1512
  var _a, _b;
1510
1513
  const [selected, setSelected] = useState7(() => {
1514
+ if (initialSelected != null && initialSelected >= 0 && initialSelected < data.options.length) {
1515
+ return initialSelected;
1516
+ }
1511
1517
  if (!demoAttempt) return null;
1512
1518
  const wrong = data.options.findIndex((_, index) => index !== data.answer);
1513
1519
  return wrong >= 0 ? wrong : null;
@@ -1518,7 +1524,8 @@ function useSingleChoice({
1518
1524
  const judge = useJudge({
1519
1525
  evaluate: () => selected === data.answer,
1520
1526
  sound,
1521
- demoAttempt
1527
+ demoAttempt,
1528
+ initialPhase: initialCorrect === true ? "correct" : void 0
1522
1529
  });
1523
1530
  const canPick = !readonly && judge.phase === "idle";
1524
1531
  const handlePick = (next) => {
@@ -1599,9 +1606,19 @@ function SingleChoice({
1599
1606
  onSubmit,
1600
1607
  sound,
1601
1608
  demoAttempt,
1609
+ initialSelected,
1610
+ initialCorrect,
1602
1611
  className
1603
1612
  }) {
1604
- const model = useSingleChoice({ data, mode, sound, demoAttempt, onSubmit });
1613
+ const model = useSingleChoice({
1614
+ data,
1615
+ mode,
1616
+ sound,
1617
+ demoAttempt,
1618
+ initialSelected,
1619
+ initialCorrect,
1620
+ onSubmit
1621
+ });
1605
1622
  const actions = singleChoiceActions({
1606
1623
  readonly: model.readonly,
1607
1624
  phase: model.judge.phase,
@@ -2858,6 +2875,8 @@ function useLinkPairs({
2858
2875
  onSubmit,
2859
2876
  sound,
2860
2877
  demoAttempt,
2878
+ initialPairs,
2879
+ initialCorrect,
2861
2880
  speakNode
2862
2881
  }) {
2863
2882
  var _a;
@@ -2868,13 +2887,17 @@ function useLinkPairs({
2868
2887
  () => new Set(data.pairs.map(([left, right]) => pairKey(left, right))),
2869
2888
  [data.pairs]
2870
2889
  );
2871
- const [pairs, setPairs] = useState14([]);
2890
+ const restoredPairs = (initialPairs != null ? initialPairs : []).filter(
2891
+ (pair) => Array.isArray(pair) && typeof pair[0] === "number" && typeof pair[1] === "number"
2892
+ );
2893
+ const [pairs, setPairs] = useState14(restoredPairs);
2872
2894
  const [selection, setSelection] = useState14(null);
2873
2895
  const judge = useJudge({
2874
2896
  evaluate: () => pairs.length === totalPairs && (!hasAnswer || pairs.every(([left, right]) => expected.has(pairKey(left, right)))),
2875
2897
  onFirstWrong: () => setPairs((current) => current.filter(([left, right]) => expected.has(pairKey(left, right)))),
2876
2898
  sound,
2877
- demoAttempt
2899
+ demoAttempt,
2900
+ initialPhase: initialCorrect === true ? "correct" : void 0
2878
2901
  });
2879
2902
  const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
2880
2903
  const shownPairs = readonly ? data.pairs : pairs;
@@ -2952,6 +2975,8 @@ function LinkMatch({
2952
2975
  onSubmit,
2953
2976
  sound,
2954
2977
  demoAttempt,
2978
+ initialPairs,
2979
+ initialCorrect,
2955
2980
  className
2956
2981
  }) {
2957
2982
  const labels = useQuestLabels();
@@ -2965,6 +2990,8 @@ function LinkMatch({
2965
2990
  onSubmit,
2966
2991
  sound,
2967
2992
  demoAttempt,
2993
+ initialPairs,
2994
+ initialCorrect,
2968
2995
  speakNode: audio.speakNode
2969
2996
  });
2970
2997
  const geometry = useLinkGeometry({
@@ -3287,7 +3314,9 @@ function useRearrange({
3287
3314
  mode,
3288
3315
  onSubmit,
3289
3316
  sound,
3290
- demoAttempt
3317
+ demoAttempt,
3318
+ initialChars,
3319
+ initialCorrect
3291
3320
  }) {
3292
3321
  const labels = useQuestLabels();
3293
3322
  const readonly = isReadonly(mode);
@@ -3295,9 +3324,12 @@ function useRearrange({
3295
3324
  const bank = bankTiles(data, slots);
3296
3325
  const words = targetWords(data);
3297
3326
  const expected = expectedText(data);
3327
+ const restoredChars = initialChars != null ? initialChars : [];
3298
3328
  const [filled, setFilled] = useState15(
3299
3329
  () => slots.map((slot, slotIndex) => {
3300
3330
  if (slot.holder) return null;
3331
+ const restored = restoredChars[slotIndex];
3332
+ if (typeof restored === "string" && restored) return restored;
3301
3333
  if (demoAttempt === 2) {
3302
3334
  const tile = bank[(slotIndex + 1) % Math.max(1, bank.length)];
3303
3335
  return tile ? tile.char : null;
@@ -3334,7 +3366,8 @@ function useRearrange({
3334
3366
  );
3335
3367
  },
3336
3368
  sound,
3337
- demoAttempt
3369
+ demoAttempt,
3370
+ initialPhase: initialCorrect === true ? "correct" : void 0
3338
3371
  });
3339
3372
  const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
3340
3373
  useEffect11(() => {
@@ -3433,9 +3466,19 @@ function Rearrange({
3433
3466
  onSubmit,
3434
3467
  sound,
3435
3468
  demoAttempt,
3469
+ initialChars,
3470
+ initialCorrect,
3436
3471
  className
3437
3472
  }) {
3438
- const model = useRearrange({ data, mode, onSubmit, sound, demoAttempt });
3473
+ const model = useRearrange({
3474
+ data,
3475
+ mode,
3476
+ onSubmit,
3477
+ sound,
3478
+ demoAttempt,
3479
+ initialChars,
3480
+ initialCorrect
3481
+ });
3439
3482
  const actions = rearrangeActions({
3440
3483
  readonly: model.readonly,
3441
3484
  phase: model.judge.phase,
@@ -4234,14 +4277,19 @@ function useFillBlank({
4234
4277
  mode,
4235
4278
  onSubmit,
4236
4279
  sound,
4237
- demoAttempt
4280
+ demoAttempt,
4281
+ initialValues,
4282
+ initialCorrect
4238
4283
  }) {
4239
4284
  const labels = useQuestLabels();
4240
4285
  const readonly = isReadonly(mode);
4286
+ const restoredValues = initialValues != null ? initialValues : [];
4241
4287
  const [values, setValues] = useState18(
4242
4288
  () => data.blanks.map((blank, blankIndex) => {
4243
4289
  var _a, _b;
4244
4290
  if (readonly) return (_a = blank.answers[0]) != null ? _a : "";
4291
+ const restored = restoredValues[blankIndex];
4292
+ if (typeof restored === "string") return restored;
4245
4293
  if (demoAttempt === 2) {
4246
4294
  return blankIndex === 0 ? (_b = blank.answers[0]) != null ? _b : "" : "wrong";
4247
4295
  }
@@ -4259,7 +4307,8 @@ function useFillBlank({
4259
4307
  )
4260
4308
  ),
4261
4309
  sound,
4262
- demoAttempt
4310
+ demoAttempt,
4311
+ initialPhase: initialCorrect === true ? "correct" : void 0
4263
4312
  });
4264
4313
  const graded = judge.phase === "correct" || judge.phase === "locked";
4265
4314
  const filled = data.blanks.every((_, blankIndex) => {
@@ -4314,9 +4363,19 @@ function FillBlank({
4314
4363
  onSubmit,
4315
4364
  sound,
4316
4365
  demoAttempt,
4366
+ initialValues,
4367
+ initialCorrect,
4317
4368
  className
4318
4369
  }) {
4319
- const model = useFillBlank({ data, mode, onSubmit, sound, demoAttempt });
4370
+ const model = useFillBlank({
4371
+ data,
4372
+ mode,
4373
+ onSubmit,
4374
+ sound,
4375
+ demoAttempt,
4376
+ initialValues,
4377
+ initialCorrect
4378
+ });
4320
4379
  const actions = fillBlankActions({
4321
4380
  readonly: model.readonly,
4322
4381
  phase: model.judge.phase,
@@ -4530,15 +4589,20 @@ function useWordSelect({
4530
4589
  mode,
4531
4590
  onSubmit,
4532
4591
  sound,
4533
- demoAttempt
4592
+ demoAttempt,
4593
+ initialFilled,
4594
+ initialCorrect
4534
4595
  }) {
4535
4596
  var _a;
4536
4597
  const labels = useQuestLabels();
4537
4598
  const readonly = isReadonly(mode);
4538
4599
  const interaction = (_a = data.interaction) != null ? _a : "sequence";
4600
+ const restoredFilled = initialFilled != null ? initialFilled : [];
4539
4601
  const [filled, setFilled] = useState19(
4540
4602
  () => data.blanks.map((blank, blankIndex) => {
4541
4603
  if (readonly) return blank.answer;
4604
+ const restored = restoredFilled[blankIndex];
4605
+ if (typeof restored === "string") return restored;
4542
4606
  if (demoAttempt === 2) return blankIndex === 1 ? "banana" : blank.answer;
4543
4607
  return null;
4544
4608
  })
@@ -4563,7 +4627,8 @@ function useWordSelect({
4563
4627
  )
4564
4628
  ),
4565
4629
  sound,
4566
- demoAttempt
4630
+ demoAttempt,
4631
+ initialPhase: initialCorrect === true ? "correct" : void 0
4567
4632
  });
4568
4633
  const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
4569
4634
  const bank = buildBank(data.bank);
@@ -4645,9 +4710,19 @@ function WordSelect({
4645
4710
  onSubmit,
4646
4711
  sound,
4647
4712
  demoAttempt,
4713
+ initialFilled,
4714
+ initialCorrect,
4648
4715
  className
4649
4716
  }) {
4650
- const model = useWordSelect({ data, mode, onSubmit, sound, demoAttempt });
4717
+ const model = useWordSelect({
4718
+ data,
4719
+ mode,
4720
+ onSubmit,
4721
+ sound,
4722
+ demoAttempt,
4723
+ initialFilled,
4724
+ initialCorrect
4725
+ });
4651
4726
  const actions = wordSelectActions({
4652
4727
  readonly: model.readonly,
4653
4728
  phase: model.judge.phase,
@@ -4865,14 +4940,20 @@ function useSortSentences({
4865
4940
  mode,
4866
4941
  onSubmit,
4867
4942
  sound,
4868
- demoAttempt
4943
+ demoAttempt,
4944
+ initialRows,
4945
+ initialCorrect
4869
4946
  }) {
4870
4947
  const labels = useQuestLabels();
4871
4948
  const readonly = isReadonly(mode);
4949
+ const restoredRows = initialRows != null ? initialRows : [];
4872
4950
  const [rows, setRows] = useState20(
4873
4951
  () => data.order.map((sentence, rowIndex) => {
4874
4952
  var _a;
4875
4953
  if (readonly) return sentence;
4954
+ const restored = restoredRows[rowIndex];
4955
+ if (typeof restored === "string") return restored;
4956
+ if (!demoAttempt) return null;
4876
4957
  if (demoAttempt === 2) return rowIndex === 1 ? (_a = data.bank[0]) != null ? _a : sentence : sentence;
4877
4958
  return null;
4878
4959
  })
@@ -4884,7 +4965,8 @@ function useSortSentences({
4884
4965
  (current) => current.map((sentence, rowIndex) => sentence === data.order[rowIndex] ? sentence : null)
4885
4966
  ),
4886
4967
  sound,
4887
- demoAttempt
4968
+ demoAttempt,
4969
+ initialPhase: initialCorrect === true ? "correct" : void 0
4888
4970
  });
4889
4971
  const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
4890
4972
  useEffect14(() => {
@@ -4955,9 +5037,19 @@ function SortSentences({
4955
5037
  onSubmit,
4956
5038
  sound,
4957
5039
  demoAttempt,
5040
+ initialRows,
5041
+ initialCorrect,
4958
5042
  className
4959
5043
  }) {
4960
- const model = useSortSentences({ data, mode, onSubmit, sound, demoAttempt });
5044
+ const model = useSortSentences({
5045
+ data,
5046
+ mode,
5047
+ onSubmit,
5048
+ sound,
5049
+ demoAttempt,
5050
+ initialRows,
5051
+ initialCorrect
5052
+ });
4961
5053
  const actions = sortSentencesActions({
4962
5054
  readonly: model.readonly,
4963
5055
  phase: model.judge.phase,
@@ -5650,14 +5742,21 @@ function useReadingComprehension({
5650
5742
  mode,
5651
5743
  onSubmit,
5652
5744
  sound,
5653
- demoAttempt
5745
+ demoAttempt,
5746
+ initialAnswers,
5747
+ initialCorrect
5654
5748
  }) {
5655
5749
  var _a;
5656
5750
  const labels = useQuestLabels();
5657
5751
  const readonly = isReadonly(mode);
5752
+ const restoredAnswers = initialAnswers != null ? initialAnswers : [];
5658
5753
  const [answers, setAnswers] = useState23(
5659
5754
  () => data.questions.map((question, questionIndex) => {
5660
5755
  if (readonly) return question.answer;
5756
+ const restored = restoredAnswers[questionIndex];
5757
+ if (typeof restored === "number" && restored >= 0 && restored < question.options.length) {
5758
+ return restored;
5759
+ }
5661
5760
  if (demoAttempt === 2) {
5662
5761
  return questionIndex === 1 ? (question.answer + 1) % question.options.length : question.answer;
5663
5762
  }
@@ -5690,7 +5789,8 @@ function useReadingComprehension({
5690
5789
  if (wrong.length) setCurrent(wrong[0]);
5691
5790
  },
5692
5791
  sound,
5693
- demoAttempt
5792
+ demoAttempt,
5793
+ initialPhase: initialCorrect === true ? "correct" : void 0
5694
5794
  });
5695
5795
  const judged = judge.phase === "correct" || judge.phase === "locked" || readonly;
5696
5796
  useEffect16(() => {
@@ -5778,10 +5878,20 @@ function ReadingComprehension({
5778
5878
  onSubmit,
5779
5879
  sound,
5780
5880
  demoAttempt,
5881
+ initialAnswers,
5882
+ initialCorrect,
5781
5883
  className
5782
5884
  }) {
5783
5885
  var _a, _b;
5784
- const model = useReadingComprehension({ data, mode, onSubmit, sound, demoAttempt });
5886
+ const model = useReadingComprehension({
5887
+ data,
5888
+ mode,
5889
+ onSubmit,
5890
+ sound,
5891
+ demoAttempt,
5892
+ initialAnswers,
5893
+ initialCorrect
5894
+ });
5785
5895
  const collapsible = (_a = data.collapsible) != null ? _a : true;
5786
5896
  const fold = usePassageFold({
5787
5897
  passage: data.passage,
@@ -6944,7 +7054,7 @@ function BlankInput2({
6944
7054
  }
6945
7055
 
6946
7056
  // src/index.tsx
6947
- var version = "1.0.8";
7057
+ var version = "1.0.9";
6948
7058
  var questkit = {
6949
7059
  version,
6950
7060
  QuestShell,