@nakamura-123/pages 1.4.0 → 1.4.1
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/component/Article/ArticleContentView.js +13 -6
- package/dist/component/Result/QuizFlatList.js +2 -1
- package/dist/component/Result/ResultActions.js +1 -1
- package/dist/functions/questionFormatD.d.ts +1 -0
- package/dist/functions/questionFormatD.js +14 -13
- package/dist/functions/retryQuizFnc.d.ts +1 -0
- package/dist/functions/retryQuizFnc.js +13 -0
- package/dist/hooks/resultHook.d.ts +1 -0
- package/dist/hooks/resultHook.js +16 -5
- package/dist/page/ResultPage.js +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -22,6 +22,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
29
|
const react_1 = __importStar(require("react"));
|
|
27
30
|
const react_native_1 = require("react-native");
|
|
@@ -29,6 +32,7 @@ const react_redux_1 = require("react-redux");
|
|
|
29
32
|
const lib_1 = require("@nakamura-123/lib");
|
|
30
33
|
const common_1 = require("@nakamura-123/common");
|
|
31
34
|
const articleContentFnc_1 = require("../../functions/articleContentFnc");
|
|
35
|
+
const MyTextqqyy_1 = __importDefault(require("../../quiz/common/MyTextqqyy"));
|
|
32
36
|
const isJudgmentBlock = (block) => (block === null || block === void 0 ? void 0 : block.type) === "incorrect" || (block === null || block === void 0 ? void 0 : block.type) === "correct";
|
|
33
37
|
const ArticleContentView = ({ content, articleId, }) => {
|
|
34
38
|
let exampleCount = 0;
|
|
@@ -90,9 +94,7 @@ const ArticleBlockView = ({ block, exampleNumber, exampleImg, groupPosition, use
|
|
|
90
94
|
{block.text}
|
|
91
95
|
</common_1.MyText>);
|
|
92
96
|
case "paragraph":
|
|
93
|
-
return (<
|
|
94
|
-
{block.text}
|
|
95
|
-
</common_1.MyText>);
|
|
97
|
+
return (<BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.paragraph}/>);
|
|
96
98
|
case "example": {
|
|
97
99
|
const exampleLabel = (<common_1.MyText fsize="sm" weight={700} color="green">
|
|
98
100
|
{String(exampleNumber).padStart(2, "0")}
|
|
@@ -143,15 +145,20 @@ const ArticleBlockView = ({ block, exampleNumber, exampleImg, groupPosition, use
|
|
|
143
145
|
styles.judgmentRowNoMargin,
|
|
144
146
|
]}>
|
|
145
147
|
<common_1.Icon5 name={isIncorrect ? "times" : "check"} size={14} color={isIncorrect ? "red" : "green"} style={styles.judgmentIcon}/>
|
|
146
|
-
<
|
|
147
|
-
{block.text}
|
|
148
|
-
</common_1.MyText>
|
|
148
|
+
<BodyText text={block.text} fsize={(0, articleContentFnc_1.getScaledFsize)("md", userFsize)} weight={(0, articleContentFnc_1.getScaledWeight)(500, userFWeight)} style={styles.judgmentText}/>
|
|
149
149
|
</react_native_1.View>);
|
|
150
150
|
}
|
|
151
151
|
default:
|
|
152
152
|
return null;
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
|
+
// 数式(qq…qq)がある文だけ、解説と同じ部品で描く。ない文を今までどおりにするのは、
|
|
156
|
+
// 解説の部品がyy(検索語)やudl[]も読み替えるため(記事の文はその記法を前提に書かれていない)
|
|
157
|
+
const BodyText = ({ text, fsize, weight, style }) => text.includes("qq") ? (<MyTextqqyy_1.default fsize={fsize} weight={weight} style={style} isNotSearch>
|
|
158
|
+
{text}
|
|
159
|
+
</MyTextqqyy_1.default>) : (<common_1.MyText fsize={fsize} weight={weight} color="text" style={style}>
|
|
160
|
+
{text}
|
|
161
|
+
</common_1.MyText>);
|
|
155
162
|
const styles = react_native_1.StyleSheet.create({
|
|
156
163
|
container: {
|
|
157
164
|
// marginHorizontal: -20,
|
|
@@ -35,12 +35,13 @@ const MyTextqqyy_1 = __importDefault(require("../../quiz/common/MyTextqqyy"));
|
|
|
35
35
|
const RubyText_1 = __importDefault(require("../../quiz/common/RubyText"));
|
|
36
36
|
const JQuestionBottomText_1 = require("../../quiz/jQuestion/JQuestionBottomText");
|
|
37
37
|
const quizHook_1 = require("../../hooks/quizHook");
|
|
38
|
+
const resultHook_1 = require("../../hooks/resultHook");
|
|
38
39
|
// 見直す一覧。番号・○×・問題文・訳・今の付箋。「すべて/×だけ」で切り替え、行をタップするとその問題を見直す
|
|
39
40
|
const QuizFlatList = ({ navigation }) => {
|
|
40
41
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
41
42
|
const { t } = (0, common_1.useDrillTranslation)();
|
|
42
43
|
const [filter, setFilter] = (0, react_1.useState)("all");
|
|
43
|
-
const quizList = (0, react_redux_1.useSelector)((state) => state.quiz.quizList);
|
|
44
|
+
const quizList = (0, resultHook_1.useFrozenOnRetry)((0, react_redux_1.useSelector)((state) => state.quiz.quizList));
|
|
44
45
|
const lang = (0, quizHook_1.useGrammarLang)();
|
|
45
46
|
const grammarTrans = (0, react_redux_1.useSelector)((state) => state.app.grammarTrans[lang]);
|
|
46
47
|
const items = quizList.map((quiz, index) => {
|
|
@@ -12,7 +12,7 @@ const resultHook_1 = require("../../hooks/resultHook");
|
|
|
12
12
|
// 下の薄い段に「全問やり直す」(×があるとき)と「成績を見る」。戻るは画面左上にあるので置かない
|
|
13
13
|
const ResultActions = ({ navigation }) => {
|
|
14
14
|
const { t } = (0, common_1.useDrillTranslation)();
|
|
15
|
-
const wrongCnt = (0, resultHook_1.useWrongCount)();
|
|
15
|
+
const wrongCnt = (0, resultHook_1.useFrozenOnRetry)((0, resultHook_1.useWrongCount)());
|
|
16
16
|
const retry = (0, resultHook_1.useRetryQuizAction)(navigation);
|
|
17
17
|
const next = (0, resultHook_1.useNextInResult)(navigation);
|
|
18
18
|
return (<react_native_1.View style={styles.container}>
|
|
@@ -4,4 +4,5 @@ import { Store } from "@nakamura-123/types";
|
|
|
4
4
|
type QuestionType = typeof DQuestionSchema.prototype;
|
|
5
5
|
type QR = Results<QuestionType>;
|
|
6
6
|
export declare const formatQuestions: (questions: QR | QuestionType[]) => Store.DQInStore[];
|
|
7
|
+
export declare const shuffleMultiRow: (array: Store.ChoiceType[]) => Store.ChoiceType[];
|
|
7
8
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatQuestions = void 0;
|
|
3
|
+
exports.shuffleMultiRow = exports.formatQuestions = void 0;
|
|
4
4
|
const lib_1 = require("@nakamura-123/lib");
|
|
5
5
|
// OO_メインの出力
|
|
6
6
|
const formatQuestions = (questions) => {
|
|
@@ -71,16 +71,17 @@ const getMultiChoice = (choices) => {
|
|
|
71
71
|
num: index + 1,
|
|
72
72
|
isCorrect: index === 0,
|
|
73
73
|
})));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
return
|
|
74
|
+
return formattedChoices.map(exports.shuffleMultiRow);
|
|
75
|
+
};
|
|
76
|
+
// multiの1行分の選択肢をシャッフルする。渡した配列は書き換えない(やり直しではstoreの凍結された配列が来る)
|
|
77
|
+
const shuffleMultiRow = (array) => {
|
|
78
|
+
// 「○適当」のように記号の後に文字が続く選択肢もあるため、先頭の記号で判定する
|
|
79
|
+
const markOrder = (choice) => MARU_BATSU_ORDER.findIndex((mark) => choice.startsWith(mark));
|
|
80
|
+
const isMaruBatsu = array.length >= 2 && array.every(({ choice }) => markOrder(choice) !== -1);
|
|
81
|
+
// ○△×の問題は記号の順に固定する
|
|
82
|
+
if (isMaruBatsu) {
|
|
83
|
+
return [...array].sort((a, b) => markOrder(a.choice) - markOrder(b.choice));
|
|
84
|
+
}
|
|
85
|
+
return lib_1.utilFnc.shuffleList([...array]);
|
|
86
86
|
};
|
|
87
|
+
exports.shuffleMultiRow = shuffleMultiRow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const toRetryQuizList: (quizList: any[], onlyWrong: boolean) => any[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toRetryQuizList = void 0;
|
|
4
|
+
const lib_1 = require("@nakamura-123/lib");
|
|
5
|
+
const questionFormatD_1 = require("./questionFormatD");
|
|
6
|
+
// 結果画面からのやり直しで出す問題を作る。問題の順は保ち、答えの記録を消す。
|
|
7
|
+
// タグは今の段階から動く(文法は解き始めの段階を今の段階に置き直す)。
|
|
8
|
+
// 選択肢は、位置で答えを覚えないように混ぜ直す。
|
|
9
|
+
// shuffleListは渡した配列を書き換え、storeの配列は凍結されているので写しを渡す
|
|
10
|
+
const toRetryQuizList = (quizList, onlyWrong) => quizList
|
|
11
|
+
.filter((q) => !onlyWrong || q.isCorrected !== true)
|
|
12
|
+
.map((q) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, q), { isCorrected: undefined }), ("selectedIndexes" in q ? { selectedIndexes: [] } : {})), (q.choices ? { choices: lib_1.utilFnc.shuffleList([...q.choices]) } : {})), (q.multiSel ? { multiSel: q.multiSel.map(questionFormatD_1.shuffleMultiRow) } : {})), (q.system === "grammar" ? { startTag: q.tag } : {}))));
|
|
13
|
+
exports.toRetryQuizList = toRetryQuizList;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Nav, QSelected } from "@nakamura-123/types";
|
|
2
|
+
export declare const useFrozenOnRetry: <T>(value: T) => T;
|
|
2
3
|
export declare const useWrongCount: () => number;
|
|
3
4
|
export declare const useRetryQuizAction: (navigation: Nav.NavigationProp<"Result">) => (onlyWrong: boolean) => void;
|
|
4
5
|
export declare const useMakeNext: () => (via: "lesson" | "list", type: "unit" | "year", category: number, key: number) => QSelected.NextItem | undefined;
|
package/dist/hooks/resultHook.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useNextInResult = exports.useMakeNext = exports.useRetryQuizAction = exports.useWrongCount = void 0;
|
|
3
|
+
exports.useNextInResult = exports.useMakeNext = exports.useRetryQuizAction = exports.useWrongCount = exports.useFrozenOnRetry = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
4
5
|
const react_redux_1 = require("react-redux");
|
|
5
6
|
const stores_1 = require("@nakamura-123/stores");
|
|
6
7
|
const nextItemFnc_1 = require("../functions/nextItemFnc");
|
|
8
|
+
const retryQuizFnc_1 = require("../functions/retryQuizFnc");
|
|
9
|
+
// やり直すとstoreは先に次の出題の状態(点数0など)へ変わるが、結果画面は切り替えのアニメーションが
|
|
10
|
+
// 終わるまで見えている。その間は直前の結果を見せ続ける。
|
|
11
|
+
// 結果画面のmodeはcheckかresultで、quizになるのはやり直しで離れるときだけ
|
|
12
|
+
const useFrozenOnRetry = (value) => {
|
|
13
|
+
const isLeaving = (0, react_redux_1.useSelector)((state) => state.quiz.currentInfo.state.mode === "quiz");
|
|
14
|
+
const last = (0, react_1.useRef)(value);
|
|
15
|
+
if (!isLeaving)
|
|
16
|
+
last.current = value;
|
|
17
|
+
return last.current;
|
|
18
|
+
};
|
|
19
|
+
exports.useFrozenOnRetry = useFrozenOnRetry;
|
|
7
20
|
// ○でなかった問題(×と、答えずに進めた問題)の数
|
|
8
21
|
const useWrongCount = () => (0, react_redux_1.useSelector)((state) => state.quiz.quizList.filter((q) => q.isCorrected !== true).length);
|
|
9
22
|
exports.useWrongCount = useWrongCount;
|
|
10
23
|
// 結果画面から、同じ問題(または×だけ)を同じ順で1問目から解き直す。
|
|
11
|
-
// 答えの記録だけを消し、タグは今の段階から動く(文法は解き始めの段階を今の段階に置き直す)。
|
|
12
24
|
// 復習なので、試験の記録・履歴には残さない。その日の問題数には数える(isRetry)
|
|
13
25
|
const useRetryQuizAction = (navigation) => {
|
|
14
26
|
const dispatch = (0, react_redux_1.useDispatch)();
|
|
15
27
|
const quizList = (0, react_redux_1.useSelector)((state) => state.quiz.quizList);
|
|
16
28
|
const subject = (0, react_redux_1.useSelector)((state) => state.quiz.selected.subject);
|
|
17
29
|
return (onlyWrong) => {
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
30
|
+
const reset = (0, retryQuizFnc_1.toRetryQuizList)(quizList, onlyWrong);
|
|
31
|
+
if (reset.length === 0)
|
|
20
32
|
return;
|
|
21
|
-
const reset = targets.map((q) => (Object.assign(Object.assign(Object.assign(Object.assign({}, q), { isCorrected: undefined }), ("selectedIndexes" in q ? { selectedIndexes: [] } : {})), (q.system === "grammar" ? { startTag: q.tag } : {}))));
|
|
22
33
|
dispatch(stores_1.quizAction.resetCurrentInfo());
|
|
23
34
|
dispatch(stores_1.quizAction.markRetry());
|
|
24
35
|
dispatch(stores_1.saveStorage.deleteQuizInStorage(subject));
|
package/dist/page/ResultPage.js
CHANGED
|
@@ -38,6 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
39
|
const react_native_1 = require("react-native");
|
|
40
40
|
const quizHook_1 = require("../hooks/quizHook");
|
|
41
|
+
const resultHook_1 = require("../hooks/resultHook");
|
|
41
42
|
const ResultHero_1 = __importDefault(require("../component/Result/ResultHero"));
|
|
42
43
|
const ResultActions_1 = __importDefault(require("../component/Result/ResultActions"));
|
|
43
44
|
const QuizFlatList_1 = __importDefault(require("../component/Result/QuizFlatList"));
|
|
@@ -82,7 +83,7 @@ const ResultPage = ({ navigation }) => {
|
|
|
82
83
|
};
|
|
83
84
|
// 依存は必要最小限。チェック条件が変わった時だけ再評価されるように。
|
|
84
85
|
}, []);
|
|
85
|
-
const scoreInfo = (0, quizHook_1.useScoreInfo)();
|
|
86
|
+
const scoreInfo = (0, resultHook_1.useFrozenOnRetry)((0, quizHook_1.useScoreInfo)());
|
|
86
87
|
return (<react_native_1.View style={styles.page}>
|
|
87
88
|
{!isJLPT && <AdCard_1.default />}
|
|
88
89
|
{/* 上から、キャラと点数のカード → 大きいボタン・薄い段 → 見直す一覧(設計は result_lesson_overview.md) */}
|