@jswork/react-questkit 1.0.7 → 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.cjs +137 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +37 -7
- package/dist/index.d.ts +37 -7
- package/dist/index.mjs +137 -24
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
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({
|
|
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,
|
|
@@ -1654,11 +1671,13 @@ function followReadActions({
|
|
|
1654
1671
|
readonly,
|
|
1655
1672
|
stage,
|
|
1656
1673
|
grade,
|
|
1674
|
+
attemptsLeft,
|
|
1657
1675
|
labels,
|
|
1658
1676
|
onNext
|
|
1659
1677
|
}) {
|
|
1660
1678
|
if (readonly) return onNext ? [{ key: "next", label: labels.next, onClick: onNext }] : [];
|
|
1661
|
-
|
|
1679
|
+
const finished = stage === "result" && grade && grade !== "noise" || attemptsLeft === 0;
|
|
1680
|
+
if (finished) {
|
|
1662
1681
|
return [{ key: "next", label: labels.next, onClick: onNext }];
|
|
1663
1682
|
}
|
|
1664
1683
|
return [];
|
|
@@ -2096,7 +2115,7 @@ function detailHint({
|
|
|
2096
2115
|
if (readonly) return mode === "lookup" ? labels.submitted : void 0;
|
|
2097
2116
|
if (noise) return labels.noiseHint;
|
|
2098
2117
|
if (grade === "again") return labels.againHint;
|
|
2099
|
-
if (
|
|
2118
|
+
if (attemptsLeft === 0) {
|
|
2100
2119
|
return `${maxAttempts} \u6B21${labels.attemptsUsedUp} \xB7 \u53D6\u6700\u540E\u4E00\u6B21\u6709\u6548\u5206`;
|
|
2101
2120
|
}
|
|
2102
2121
|
if (stage === "result") return labels.submitted;
|
|
@@ -2387,6 +2406,7 @@ function FollowRead({
|
|
|
2387
2406
|
readonly: model.readonly,
|
|
2388
2407
|
stage: model.stage,
|
|
2389
2408
|
grade: model.grade,
|
|
2409
|
+
attemptsLeft: model.attemptsLeft,
|
|
2390
2410
|
labels: model.labels,
|
|
2391
2411
|
onNext
|
|
2392
2412
|
});
|
|
@@ -2855,6 +2875,8 @@ function useLinkPairs({
|
|
|
2855
2875
|
onSubmit,
|
|
2856
2876
|
sound,
|
|
2857
2877
|
demoAttempt,
|
|
2878
|
+
initialPairs,
|
|
2879
|
+
initialCorrect,
|
|
2858
2880
|
speakNode
|
|
2859
2881
|
}) {
|
|
2860
2882
|
var _a;
|
|
@@ -2865,13 +2887,17 @@ function useLinkPairs({
|
|
|
2865
2887
|
() => new Set(data.pairs.map(([left, right]) => pairKey(left, right))),
|
|
2866
2888
|
[data.pairs]
|
|
2867
2889
|
);
|
|
2868
|
-
const
|
|
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);
|
|
2869
2894
|
const [selection, setSelection] = useState14(null);
|
|
2870
2895
|
const judge = useJudge({
|
|
2871
2896
|
evaluate: () => pairs.length === totalPairs && (!hasAnswer || pairs.every(([left, right]) => expected.has(pairKey(left, right)))),
|
|
2872
2897
|
onFirstWrong: () => setPairs((current) => current.filter(([left, right]) => expected.has(pairKey(left, right)))),
|
|
2873
2898
|
sound,
|
|
2874
|
-
demoAttempt
|
|
2899
|
+
demoAttempt,
|
|
2900
|
+
initialPhase: initialCorrect === true ? "correct" : void 0
|
|
2875
2901
|
});
|
|
2876
2902
|
const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
|
|
2877
2903
|
const shownPairs = readonly ? data.pairs : pairs;
|
|
@@ -2949,6 +2975,8 @@ function LinkMatch({
|
|
|
2949
2975
|
onSubmit,
|
|
2950
2976
|
sound,
|
|
2951
2977
|
demoAttempt,
|
|
2978
|
+
initialPairs,
|
|
2979
|
+
initialCorrect,
|
|
2952
2980
|
className
|
|
2953
2981
|
}) {
|
|
2954
2982
|
const labels = useQuestLabels();
|
|
@@ -2962,6 +2990,8 @@ function LinkMatch({
|
|
|
2962
2990
|
onSubmit,
|
|
2963
2991
|
sound,
|
|
2964
2992
|
demoAttempt,
|
|
2993
|
+
initialPairs,
|
|
2994
|
+
initialCorrect,
|
|
2965
2995
|
speakNode: audio.speakNode
|
|
2966
2996
|
});
|
|
2967
2997
|
const geometry = useLinkGeometry({
|
|
@@ -3284,7 +3314,9 @@ function useRearrange({
|
|
|
3284
3314
|
mode,
|
|
3285
3315
|
onSubmit,
|
|
3286
3316
|
sound,
|
|
3287
|
-
demoAttempt
|
|
3317
|
+
demoAttempt,
|
|
3318
|
+
initialChars,
|
|
3319
|
+
initialCorrect
|
|
3288
3320
|
}) {
|
|
3289
3321
|
const labels = useQuestLabels();
|
|
3290
3322
|
const readonly = isReadonly(mode);
|
|
@@ -3292,9 +3324,12 @@ function useRearrange({
|
|
|
3292
3324
|
const bank = bankTiles(data, slots);
|
|
3293
3325
|
const words = targetWords(data);
|
|
3294
3326
|
const expected = expectedText(data);
|
|
3327
|
+
const restoredChars = initialChars != null ? initialChars : [];
|
|
3295
3328
|
const [filled, setFilled] = useState15(
|
|
3296
3329
|
() => slots.map((slot, slotIndex) => {
|
|
3297
3330
|
if (slot.holder) return null;
|
|
3331
|
+
const restored = restoredChars[slotIndex];
|
|
3332
|
+
if (typeof restored === "string" && restored) return restored;
|
|
3298
3333
|
if (demoAttempt === 2) {
|
|
3299
3334
|
const tile = bank[(slotIndex + 1) % Math.max(1, bank.length)];
|
|
3300
3335
|
return tile ? tile.char : null;
|
|
@@ -3331,7 +3366,8 @@ function useRearrange({
|
|
|
3331
3366
|
);
|
|
3332
3367
|
},
|
|
3333
3368
|
sound,
|
|
3334
|
-
demoAttempt
|
|
3369
|
+
demoAttempt,
|
|
3370
|
+
initialPhase: initialCorrect === true ? "correct" : void 0
|
|
3335
3371
|
});
|
|
3336
3372
|
const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
|
|
3337
3373
|
useEffect11(() => {
|
|
@@ -3430,9 +3466,19 @@ function Rearrange({
|
|
|
3430
3466
|
onSubmit,
|
|
3431
3467
|
sound,
|
|
3432
3468
|
demoAttempt,
|
|
3469
|
+
initialChars,
|
|
3470
|
+
initialCorrect,
|
|
3433
3471
|
className
|
|
3434
3472
|
}) {
|
|
3435
|
-
const model = useRearrange({
|
|
3473
|
+
const model = useRearrange({
|
|
3474
|
+
data,
|
|
3475
|
+
mode,
|
|
3476
|
+
onSubmit,
|
|
3477
|
+
sound,
|
|
3478
|
+
demoAttempt,
|
|
3479
|
+
initialChars,
|
|
3480
|
+
initialCorrect
|
|
3481
|
+
});
|
|
3436
3482
|
const actions = rearrangeActions({
|
|
3437
3483
|
readonly: model.readonly,
|
|
3438
3484
|
phase: model.judge.phase,
|
|
@@ -4231,14 +4277,19 @@ function useFillBlank({
|
|
|
4231
4277
|
mode,
|
|
4232
4278
|
onSubmit,
|
|
4233
4279
|
sound,
|
|
4234
|
-
demoAttempt
|
|
4280
|
+
demoAttempt,
|
|
4281
|
+
initialValues,
|
|
4282
|
+
initialCorrect
|
|
4235
4283
|
}) {
|
|
4236
4284
|
const labels = useQuestLabels();
|
|
4237
4285
|
const readonly = isReadonly(mode);
|
|
4286
|
+
const restoredValues = initialValues != null ? initialValues : [];
|
|
4238
4287
|
const [values, setValues] = useState18(
|
|
4239
4288
|
() => data.blanks.map((blank, blankIndex) => {
|
|
4240
4289
|
var _a, _b;
|
|
4241
4290
|
if (readonly) return (_a = blank.answers[0]) != null ? _a : "";
|
|
4291
|
+
const restored = restoredValues[blankIndex];
|
|
4292
|
+
if (typeof restored === "string") return restored;
|
|
4242
4293
|
if (demoAttempt === 2) {
|
|
4243
4294
|
return blankIndex === 0 ? (_b = blank.answers[0]) != null ? _b : "" : "wrong";
|
|
4244
4295
|
}
|
|
@@ -4256,7 +4307,8 @@ function useFillBlank({
|
|
|
4256
4307
|
)
|
|
4257
4308
|
),
|
|
4258
4309
|
sound,
|
|
4259
|
-
demoAttempt
|
|
4310
|
+
demoAttempt,
|
|
4311
|
+
initialPhase: initialCorrect === true ? "correct" : void 0
|
|
4260
4312
|
});
|
|
4261
4313
|
const graded = judge.phase === "correct" || judge.phase === "locked";
|
|
4262
4314
|
const filled = data.blanks.every((_, blankIndex) => {
|
|
@@ -4311,9 +4363,19 @@ function FillBlank({
|
|
|
4311
4363
|
onSubmit,
|
|
4312
4364
|
sound,
|
|
4313
4365
|
demoAttempt,
|
|
4366
|
+
initialValues,
|
|
4367
|
+
initialCorrect,
|
|
4314
4368
|
className
|
|
4315
4369
|
}) {
|
|
4316
|
-
const model = useFillBlank({
|
|
4370
|
+
const model = useFillBlank({
|
|
4371
|
+
data,
|
|
4372
|
+
mode,
|
|
4373
|
+
onSubmit,
|
|
4374
|
+
sound,
|
|
4375
|
+
demoAttempt,
|
|
4376
|
+
initialValues,
|
|
4377
|
+
initialCorrect
|
|
4378
|
+
});
|
|
4317
4379
|
const actions = fillBlankActions({
|
|
4318
4380
|
readonly: model.readonly,
|
|
4319
4381
|
phase: model.judge.phase,
|
|
@@ -4527,15 +4589,20 @@ function useWordSelect({
|
|
|
4527
4589
|
mode,
|
|
4528
4590
|
onSubmit,
|
|
4529
4591
|
sound,
|
|
4530
|
-
demoAttempt
|
|
4592
|
+
demoAttempt,
|
|
4593
|
+
initialFilled,
|
|
4594
|
+
initialCorrect
|
|
4531
4595
|
}) {
|
|
4532
4596
|
var _a;
|
|
4533
4597
|
const labels = useQuestLabels();
|
|
4534
4598
|
const readonly = isReadonly(mode);
|
|
4535
4599
|
const interaction = (_a = data.interaction) != null ? _a : "sequence";
|
|
4600
|
+
const restoredFilled = initialFilled != null ? initialFilled : [];
|
|
4536
4601
|
const [filled, setFilled] = useState19(
|
|
4537
4602
|
() => data.blanks.map((blank, blankIndex) => {
|
|
4538
4603
|
if (readonly) return blank.answer;
|
|
4604
|
+
const restored = restoredFilled[blankIndex];
|
|
4605
|
+
if (typeof restored === "string") return restored;
|
|
4539
4606
|
if (demoAttempt === 2) return blankIndex === 1 ? "banana" : blank.answer;
|
|
4540
4607
|
return null;
|
|
4541
4608
|
})
|
|
@@ -4560,7 +4627,8 @@ function useWordSelect({
|
|
|
4560
4627
|
)
|
|
4561
4628
|
),
|
|
4562
4629
|
sound,
|
|
4563
|
-
demoAttempt
|
|
4630
|
+
demoAttempt,
|
|
4631
|
+
initialPhase: initialCorrect === true ? "correct" : void 0
|
|
4564
4632
|
});
|
|
4565
4633
|
const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
|
|
4566
4634
|
const bank = buildBank(data.bank);
|
|
@@ -4642,9 +4710,19 @@ function WordSelect({
|
|
|
4642
4710
|
onSubmit,
|
|
4643
4711
|
sound,
|
|
4644
4712
|
demoAttempt,
|
|
4713
|
+
initialFilled,
|
|
4714
|
+
initialCorrect,
|
|
4645
4715
|
className
|
|
4646
4716
|
}) {
|
|
4647
|
-
const model = useWordSelect({
|
|
4717
|
+
const model = useWordSelect({
|
|
4718
|
+
data,
|
|
4719
|
+
mode,
|
|
4720
|
+
onSubmit,
|
|
4721
|
+
sound,
|
|
4722
|
+
demoAttempt,
|
|
4723
|
+
initialFilled,
|
|
4724
|
+
initialCorrect
|
|
4725
|
+
});
|
|
4648
4726
|
const actions = wordSelectActions({
|
|
4649
4727
|
readonly: model.readonly,
|
|
4650
4728
|
phase: model.judge.phase,
|
|
@@ -4862,14 +4940,20 @@ function useSortSentences({
|
|
|
4862
4940
|
mode,
|
|
4863
4941
|
onSubmit,
|
|
4864
4942
|
sound,
|
|
4865
|
-
demoAttempt
|
|
4943
|
+
demoAttempt,
|
|
4944
|
+
initialRows,
|
|
4945
|
+
initialCorrect
|
|
4866
4946
|
}) {
|
|
4867
4947
|
const labels = useQuestLabels();
|
|
4868
4948
|
const readonly = isReadonly(mode);
|
|
4949
|
+
const restoredRows = initialRows != null ? initialRows : [];
|
|
4869
4950
|
const [rows, setRows] = useState20(
|
|
4870
4951
|
() => data.order.map((sentence, rowIndex) => {
|
|
4871
4952
|
var _a;
|
|
4872
4953
|
if (readonly) return sentence;
|
|
4954
|
+
const restored = restoredRows[rowIndex];
|
|
4955
|
+
if (typeof restored === "string") return restored;
|
|
4956
|
+
if (!demoAttempt) return null;
|
|
4873
4957
|
if (demoAttempt === 2) return rowIndex === 1 ? (_a = data.bank[0]) != null ? _a : sentence : sentence;
|
|
4874
4958
|
return null;
|
|
4875
4959
|
})
|
|
@@ -4881,7 +4965,8 @@ function useSortSentences({
|
|
|
4881
4965
|
(current) => current.map((sentence, rowIndex) => sentence === data.order[rowIndex] ? sentence : null)
|
|
4882
4966
|
),
|
|
4883
4967
|
sound,
|
|
4884
|
-
demoAttempt
|
|
4968
|
+
demoAttempt,
|
|
4969
|
+
initialPhase: initialCorrect === true ? "correct" : void 0
|
|
4885
4970
|
});
|
|
4886
4971
|
const frozen = readonly || judge.phase === "correct" || judge.phase === "locked";
|
|
4887
4972
|
useEffect14(() => {
|
|
@@ -4952,9 +5037,19 @@ function SortSentences({
|
|
|
4952
5037
|
onSubmit,
|
|
4953
5038
|
sound,
|
|
4954
5039
|
demoAttempt,
|
|
5040
|
+
initialRows,
|
|
5041
|
+
initialCorrect,
|
|
4955
5042
|
className
|
|
4956
5043
|
}) {
|
|
4957
|
-
const model = useSortSentences({
|
|
5044
|
+
const model = useSortSentences({
|
|
5045
|
+
data,
|
|
5046
|
+
mode,
|
|
5047
|
+
onSubmit,
|
|
5048
|
+
sound,
|
|
5049
|
+
demoAttempt,
|
|
5050
|
+
initialRows,
|
|
5051
|
+
initialCorrect
|
|
5052
|
+
});
|
|
4958
5053
|
const actions = sortSentencesActions({
|
|
4959
5054
|
readonly: model.readonly,
|
|
4960
5055
|
phase: model.judge.phase,
|
|
@@ -5647,14 +5742,21 @@ function useReadingComprehension({
|
|
|
5647
5742
|
mode,
|
|
5648
5743
|
onSubmit,
|
|
5649
5744
|
sound,
|
|
5650
|
-
demoAttempt
|
|
5745
|
+
demoAttempt,
|
|
5746
|
+
initialAnswers,
|
|
5747
|
+
initialCorrect
|
|
5651
5748
|
}) {
|
|
5652
5749
|
var _a;
|
|
5653
5750
|
const labels = useQuestLabels();
|
|
5654
5751
|
const readonly = isReadonly(mode);
|
|
5752
|
+
const restoredAnswers = initialAnswers != null ? initialAnswers : [];
|
|
5655
5753
|
const [answers, setAnswers] = useState23(
|
|
5656
5754
|
() => data.questions.map((question, questionIndex) => {
|
|
5657
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
|
+
}
|
|
5658
5760
|
if (demoAttempt === 2) {
|
|
5659
5761
|
return questionIndex === 1 ? (question.answer + 1) % question.options.length : question.answer;
|
|
5660
5762
|
}
|
|
@@ -5687,7 +5789,8 @@ function useReadingComprehension({
|
|
|
5687
5789
|
if (wrong.length) setCurrent(wrong[0]);
|
|
5688
5790
|
},
|
|
5689
5791
|
sound,
|
|
5690
|
-
demoAttempt
|
|
5792
|
+
demoAttempt,
|
|
5793
|
+
initialPhase: initialCorrect === true ? "correct" : void 0
|
|
5691
5794
|
});
|
|
5692
5795
|
const judged = judge.phase === "correct" || judge.phase === "locked" || readonly;
|
|
5693
5796
|
useEffect16(() => {
|
|
@@ -5775,10 +5878,20 @@ function ReadingComprehension({
|
|
|
5775
5878
|
onSubmit,
|
|
5776
5879
|
sound,
|
|
5777
5880
|
demoAttempt,
|
|
5881
|
+
initialAnswers,
|
|
5882
|
+
initialCorrect,
|
|
5778
5883
|
className
|
|
5779
5884
|
}) {
|
|
5780
5885
|
var _a, _b;
|
|
5781
|
-
const model = useReadingComprehension({
|
|
5886
|
+
const model = useReadingComprehension({
|
|
5887
|
+
data,
|
|
5888
|
+
mode,
|
|
5889
|
+
onSubmit,
|
|
5890
|
+
sound,
|
|
5891
|
+
demoAttempt,
|
|
5892
|
+
initialAnswers,
|
|
5893
|
+
initialCorrect
|
|
5894
|
+
});
|
|
5782
5895
|
const collapsible = (_a = data.collapsible) != null ? _a : true;
|
|
5783
5896
|
const fold = usePassageFold({
|
|
5784
5897
|
passage: data.passage,
|
|
@@ -6941,7 +7054,7 @@ function BlankInput2({
|
|
|
6941
7054
|
}
|
|
6942
7055
|
|
|
6943
7056
|
// src/index.tsx
|
|
6944
|
-
var version = "1.0.
|
|
7057
|
+
var version = "1.0.9";
|
|
6945
7058
|
var questkit = {
|
|
6946
7059
|
version,
|
|
6947
7060
|
QuestShell,
|