chandralegend commited on
Commit
2b87fe8
1 Parent(s): 7a6f06b

added tutorial content

Browse files
Files changed (2) hide show
  1. pages/5_Quiz.py +10 -5
  2. utils/login.py +34 -2
pages/5_Quiz.py CHANGED
@@ -24,7 +24,7 @@ if "questions" not in st.session_state:
24
  def step_page():
25
  st.header("Quiz")
26
  st.markdown(
27
- """Now that you've learned about how speech recognition systems work, let's test your knowledge with a quiz!"""
28
  )
29
 
30
  for i in range(len(st.session_state["questions"])):
@@ -33,10 +33,15 @@ def step_page():
33
  st.markdown(question["question"])
34
  answer = st.radio("Select an answer:", question["options"], key=f"radio{i}")
35
 
36
- if answer == question["answer"]:
37
- st.success("Correct!")
38
- else:
39
- st.error("Incorrect!")
 
 
 
 
 
40
 
41
  st.info("Click on the button below to complete the tutorial!")
42
  if st.button("Complete"):
 
24
  def step_page():
25
  st.header("Quiz")
26
  st.markdown(
27
+ """Now that you've learned about how Emotion Detection work, let's test your knowledge with a quiz!"""
28
  )
29
 
30
  for i in range(len(st.session_state["questions"])):
 
33
  st.markdown(question["question"])
34
  answer = st.radio("Select an answer:", question["options"], key=f"radio{i}")
35
 
36
+ if st.session_state.get("EVALUATE", False):
37
+ if answer == question["answer"]:
38
+ st.success("Correct!")
39
+ else:
40
+ st.error("Incorrect! Try Again")
41
+
42
+ if st.button("Evaluate"):
43
+ st.session_state["EVALUATE"] = True
44
+ st.experimental_rerun()
45
 
46
  st.info("Click on the button below to complete the tutorial!")
47
  if st.button("Complete"):
utils/login.py CHANGED
@@ -1,5 +1,10 @@
1
  import streamlit as st
2
  import os
 
 
 
 
 
3
 
4
 
5
  def initialize_login():
@@ -7,9 +12,9 @@ def initialize_login():
7
  st.columns(3)[1].image("assets/logo.png")
8
  username = st.text_input("Username")
9
  password = st.text_input("Password", type="password")
 
10
  if st.button("Login"):
11
- # TODO: replace with actual authorization check
12
- authorized = {"status": True, "Name": "John Doe", "username": "johndoe"}
13
  if authorized["status"]:
14
  st.session_state["login"] = authorized
15
  os.makedirs(
@@ -22,6 +27,33 @@ def initialize_login():
22
  st.error("Invalid username or password")
23
  else:
24
  st.sidebar.success(f'Hello, {st.session_state["login"]["Name"]}!')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
 
27
  def get_login():
 
1
  import streamlit as st
2
  import os
3
+ import requests
4
+ import os
5
+ import json
6
+
7
+ # Fetch the service account key JSON file contents
8
 
9
 
10
  def initialize_login():
 
12
  st.columns(3)[1].image("assets/logo.png")
13
  username = st.text_input("Username")
14
  password = st.text_input("Password", type="password")
15
+
16
  if st.button("Login"):
17
+ authorized = authenticate(username, password)
 
18
  if authorized["status"]:
19
  st.session_state["login"] = authorized
20
  os.makedirs(
 
27
  st.error("Invalid username or password")
28
  else:
29
  st.sidebar.success(f'Hello, {st.session_state["login"]["Name"]}!')
30
+ st.sidebar.image("assets/logo.png", use_column_width=True)
31
+
32
+
33
+ def authenticate(username, password):
34
+ FIREBASE_WEB_API_KEY = os.environ.get("FIREBASE_WEB_API_KEY")
35
+ payload = json.dumps(
36
+ {
37
+ "email": f"{username}@aieye.com",
38
+ "password": password,
39
+ "returnSecureToken": False,
40
+ }
41
+ )
42
+
43
+ rest_api_url = (
44
+ f"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword"
45
+ )
46
+ r = requests.post(rest_api_url, params={"key": FIREBASE_WEB_API_KEY}, data=payload)
47
+ print(r.json())
48
+
49
+ if r.status_code == 200:
50
+ return {
51
+ "status": True,
52
+ "Name": " ".join(username.split("_")),
53
+ "username": username,
54
+ }
55
+ else:
56
+ return {"status": False}
57
 
58
 
59
  def get_login():