Spaces:
Runtime error
Runtime error
IsaacKerson
commited on
Commit
•
bb2ca5e
1
Parent(s):
cbab7f1
add chk_conn and get_tables functions to utils.py
Browse files- pages/quiz.py +0 -12
- pages/utils.py +13 -1
pages/quiz.py
CHANGED
@@ -17,13 +17,6 @@ def app():
|
|
17 |
c = conn.cursor()
|
18 |
return c, conn
|
19 |
|
20 |
-
def chk_conn(conn):
|
21 |
-
try:
|
22 |
-
conn.cursor()
|
23 |
-
return True
|
24 |
-
except Exception as ex:
|
25 |
-
return False
|
26 |
-
|
27 |
def form_callback(questions):
|
28 |
st.session_state.form_submit = True
|
29 |
num_correct = 0
|
@@ -57,11 +50,6 @@ def app():
|
|
57 |
if "form_submit" not in st.session_state:
|
58 |
c, conn = db_connect(DATABASE)
|
59 |
|
60 |
-
st.write(chk_conn(conn))
|
61 |
-
|
62 |
-
c.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
63 |
-
st.write(c.fetchall())
|
64 |
-
|
65 |
units_list = []
|
66 |
for item in c.execute("SELECT DISTINCT unit FROM vocab"):
|
67 |
units_list.append(item[0])
|
|
|
17 |
c = conn.cursor()
|
18 |
return c, conn
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
def form_callback(questions):
|
21 |
st.session_state.form_submit = True
|
22 |
num_correct = 0
|
|
|
50 |
if "form_submit" not in st.session_state:
|
51 |
c, conn = db_connect(DATABASE)
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
units_list = []
|
54 |
for item in c.execute("SELECT DISTINCT unit FROM vocab"):
|
55 |
units_list.append(item[0])
|
pages/utils.py
CHANGED
@@ -2,6 +2,7 @@ import re
|
|
2 |
import random
|
3 |
import datetime
|
4 |
import string
|
|
|
5 |
|
6 |
def add_blanks(word, sentence, blank = "__"):
|
7 |
return re.sub(word, blank, sentence, flags=re.IGNORECASE)
|
@@ -14,4 +15,15 @@ def random_session_id():
|
|
14 |
return ''.join(random.choices(alphabet, k=12))
|
15 |
|
16 |
def check_answer(item, answer):
|
17 |
-
return item == answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import random
|
3 |
import datetime
|
4 |
import string
|
5 |
+
import sqlite3
|
6 |
|
7 |
def add_blanks(word, sentence, blank = "__"):
|
8 |
return re.sub(word, blank, sentence, flags=re.IGNORECASE)
|
|
|
15 |
return ''.join(random.choices(alphabet, k=12))
|
16 |
|
17 |
def check_answer(item, answer):
|
18 |
+
return item == answer
|
19 |
+
|
20 |
+
def chk_conn(conn):
|
21 |
+
try:
|
22 |
+
conn.cursor()
|
23 |
+
return True
|
24 |
+
except Exception as ex:
|
25 |
+
return False
|
26 |
+
|
27 |
+
def get_tables(cursor):
|
28 |
+
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
29 |
+
return cursor.fetchall()
|