SongZihuan 3 лет назад
Родитель
Сommit
7d991442f1
2 измененных файлов с 13 добавлено и 2 удалено
  1. 7 2
      core/db.py
  2. 6 0
      templates/test.html

+ 7 - 2
core/db.py

@@ -298,11 +298,16 @@ class WordDatabase(DataBase):
         # box 的概率比分别为:5:4:3:2:1
 
         count = 0
+        double_check = (box == 6)  # 如果 box 已经是 6 了, 就不需要二次检查了
         while count == 0:
             if box == 1:
-                return None
+                if double_check:
+                    return None
+                else:
+                    double_check = True
+                    box = 6
             box -= 1
             count = self.search(columns=["COUNT(ID)"], table="Word", where=f"box={box}")[0][0]
-        get = self.search(columns=["word"], table="Word", limit=1, offset=random.randint(0, count))[0][0]
+        get = self.search(columns=["word"], table="Word", where=f"box={box}", limit=1, offset=random.randint(0, count))[0][0]
         self.__logger.debug(f"Rand word {self.dict_name} from box: {box} count: {count} get: {get}")
         return self.find_word(get)

+ 6 - 0
templates/test.html

@@ -53,6 +53,12 @@
                                 {% endfor %}
                             </ul>
                         {% endfor %}
+                        <div class="row justify-content-center">
+                            <a class="btn btn-info mr-2"> Right </a>
+                            <a class="btn btn-dark mr-2" href="{{ url_for("test.question") }}"> Next word </a>
+                            <a class="btn btn-danger mr-2"> Delete word </a>
+                            <a class="btn btn-info"> Wrong </a>
+                        </div>
                     </div>
                 </div>
             </div>