Update modules/ui.py
Browse files- modules/ui.py +38 -15
modules/ui.py
CHANGED
|
@@ -20,6 +20,23 @@ from .semantic_analysis import visualize_semantic_relations, perform_semantic_an
|
|
| 20 |
from .discourse_analysis import compare_semantic_analysis, perform_discourse_analysis
|
| 21 |
from .chatbot import initialize_chatbot, get_chatbot_response
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
##################################################################################################
|
| 24 |
def login_register_page():
|
| 25 |
st.title("AIdeaText")
|
|
@@ -78,7 +95,7 @@ def login_register_page():
|
|
| 78 |
|
| 79 |
##################################################################################################
|
| 80 |
def login_form():
|
| 81 |
-
username = st.text_input("
|
| 82 |
password = st.text_input("Contraseña", type='password')
|
| 83 |
captcha_answer = st.text_input("Captcha: ¿Cuánto es 2 + 3?")
|
| 84 |
|
|
@@ -96,22 +113,27 @@ def login_form():
|
|
| 96 |
st.error("Captcha incorrecto")
|
| 97 |
|
| 98 |
##################################################################################################
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
carrera = st.text_input("Carrera")
|
| 103 |
-
captcha_answer = st.text_input("Captcha: ¿Cuánto es 3 + 4?")
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
else:
|
| 113 |
-
st.error("
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
##################################################################################################
|
| 116 |
def display_chat_interface():
|
| 117 |
st.markdown("### Chat con AIdeaText")
|
|
@@ -459,4 +481,5 @@ def display_chatbot_interface(lang_code):
|
|
| 459 |
store_chat_history(st.session_state.username, st.session_state.messages)
|
| 460 |
|
| 461 |
# Scroll al final del chat
|
| 462 |
-
st.markdown('<script>window.scrollTo(0,document.body.scrollHeight);</script>', unsafe_allow_html=True)
|
|
|
|
|
|
| 20 |
from .discourse_analysis import compare_semantic_analysis, perform_discourse_analysis
|
| 21 |
from .chatbot import initialize_chatbot, get_chatbot_response
|
| 22 |
|
| 23 |
+
|
| 24 |
+
##################################################################################################
|
| 25 |
+
def main():
|
| 26 |
+
if 'logged_in' not in st.session_state:
|
| 27 |
+
st.session_state.logged_in = False
|
| 28 |
+
|
| 29 |
+
if not st.session_state.logged_in:
|
| 30 |
+
login_register_page()
|
| 31 |
+
else:
|
| 32 |
+
if st.session_state.role == 'admin':
|
| 33 |
+
admin_page()
|
| 34 |
+
else:
|
| 35 |
+
user_page() # Esta sería la página normal para estudiantes
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
main()
|
| 39 |
+
|
| 40 |
##################################################################################################
|
| 41 |
def login_register_page():
|
| 42 |
st.title("AIdeaText")
|
|
|
|
| 95 |
|
| 96 |
##################################################################################################
|
| 97 |
def login_form():
|
| 98 |
+
username = st.text_input("Correo electrónico")
|
| 99 |
password = st.text_input("Contraseña", type='password')
|
| 100 |
captcha_answer = st.text_input("Captcha: ¿Cuánto es 2 + 3?")
|
| 101 |
|
|
|
|
| 113 |
st.error("Captcha incorrecto")
|
| 114 |
|
| 115 |
##################################################################################################
|
| 116 |
+
# En ui.py
|
| 117 |
+
def admin_page():
|
| 118 |
+
st.title("Panel de Administración")
|
|
|
|
|
|
|
| 119 |
|
| 120 |
+
# Crear nuevo usuario
|
| 121 |
+
st.header("Crear Nuevo Usuario")
|
| 122 |
+
new_username = st.text_input("Correo electrónico del nuevo usuario")
|
| 123 |
+
new_password = st.text_input("Contraseña", type="password")
|
| 124 |
+
if st.button("Crear Usuario"):
|
| 125 |
+
if create_invited_user(new_username, new_password):
|
| 126 |
+
st.success(f"Usuario {new_username} creado exitosamente")
|
| 127 |
else:
|
| 128 |
+
st.error("Error al crear el usuario")
|
| 129 |
|
| 130 |
+
# Aquí puedes añadir más funcionalidades CRUD en el futuro
|
| 131 |
+
|
| 132 |
+
##################################################################################################
|
| 133 |
+
def register_form():
|
| 134 |
+
##
|
| 135 |
+
##
|
| 136 |
+
pass
|
| 137 |
##################################################################################################
|
| 138 |
def display_chat_interface():
|
| 139 |
st.markdown("### Chat con AIdeaText")
|
|
|
|
| 481 |
store_chat_history(st.session_state.username, st.session_state.messages)
|
| 482 |
|
| 483 |
# Scroll al final del chat
|
| 484 |
+
st.markdown('<script>window.scrollTo(0,document.body.scrollHeight);</script>', unsafe_allow_html=True)
|
| 485 |
+
|