teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

補足依頼欄の返答を受けて追記2

2021/05/29 02:58

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37512

answer CHANGED
@@ -23,4 +23,21 @@
23
23
  ZeroPossibilityResponsies.forEach(responce => {
24
24
  document.getElementById(responce).closest('div').classList.add('ZeroPossibility')
25
25
  });
26
+ ```
27
+
28
+ # 補足依頼欄の返答を受けて追記2
29
+
30
+ 「絞り込み・切り分けを狙っている選択肢が「不正解」状態ならば、設問ごと非表示」というロジックで書いたコードも提示します。
31
+ ただ、結果は3つとも同じだと思います。
32
+
33
+ 信用できないのは仕方ないけど、だまされたと思って試してほしい……
34
+
35
+ ```js
36
+ document.querySelectorAll('#Questions > div').forEach(el => el.classList.remove("ZeroPossibility"))
37
+
38
+ const ZeroPossibilities = Object.entries(Judge).flatMap(e => e[1] === "不正解" ? e[0] : []);
39
+ const ZeroPossibilityResponsies = ResponseAndProcess.flatMap(e => e.omit.every(x => ZeroPossibilities.includes(x)) ? e.Response : [])
40
+ ZeroPossibilityResponsies.forEach(responce => {
41
+ document.getElementById(responce).closest('div').classList.add('ZeroPossibility')
42
+ });
26
43
  ```

1

補足依頼欄の返答を受けて追記

2021/05/29 02:58

投稿

Lhankor_Mhy
Lhankor_Mhy

スコア37512

answer CHANGED
@@ -8,4 +8,19 @@
8
8
  ZeroPossibilityResponsies.forEach(responce => {
9
9
  document.getElementById(responce).closest('div').classList.add('ZeroPossibility')
10
10
  });
11
+ ```
12
+
13
+ # 補足依頼欄の返答を受けて追記
14
+
15
+ 「その質問のいずれかの選択肢を選ぶと正解候補が減らない」というロジックで書いたコードも提示します。
16
+ ただ、結果は変わらないと思います。
17
+
18
+ ```js
19
+ document.querySelectorAll('#Questions > div').forEach(el => el.classList.remove("ZeroPossibility"))
20
+
21
+ const possibilities = Object.entries(Judge).flatMap(e => e[1] === "不正解" ? [] : e[0]);
22
+ const ZeroPossibilityResponsies = ResponseAndProcess.flatMap(e => possibilities.every(x => !e.omit.includes(x)) ? e.Response : [])
23
+ ZeroPossibilityResponsies.forEach(responce => {
24
+ document.getElementById(responce).closest('div').classList.add('ZeroPossibility')
25
+ });
11
26
  ```