Update app.py
Browse files
app.py
CHANGED
|
@@ -84,6 +84,53 @@ def initialize_mongodb_connection():
|
|
| 84 |
return False
|
| 85 |
|
| 86 |
##################################################################################################################3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
# Funci贸n para insertar un documento
|
| 88 |
def insert_document(document):
|
| 89 |
try:
|
|
@@ -294,6 +341,30 @@ def main_app():
|
|
| 294 |
|
| 295 |
with col2:
|
| 296 |
st.markdown(f"### {t['title']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
if st.session_state.role == "Estudiante":
|
| 299 |
# Student interface code
|
|
|
|
| 84 |
return False
|
| 85 |
|
| 86 |
##################################################################################################################3
|
| 87 |
+
def get_student_data(username):
|
| 88 |
+
if analysis_collection is None:
|
| 89 |
+
logger.error("La conexi贸n a MongoDB no est谩 inicializada")
|
| 90 |
+
return None
|
| 91 |
+
|
| 92 |
+
try:
|
| 93 |
+
# Buscar los datos del estudiante
|
| 94 |
+
student_data = analysis_collection.find({"username": username}).sort("timestamp", -1)
|
| 95 |
+
|
| 96 |
+
if not student_data:
|
| 97 |
+
return None
|
| 98 |
+
|
| 99 |
+
# Formatear los datos
|
| 100 |
+
formatted_data = {
|
| 101 |
+
"username": username,
|
| 102 |
+
"entries": [],
|
| 103 |
+
"entries_count": 0,
|
| 104 |
+
"word_count": {},
|
| 105 |
+
"arc_diagrams": [],
|
| 106 |
+
"network_diagrams": []
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
for entry in student_data:
|
| 110 |
+
formatted_data["entries"].append({
|
| 111 |
+
"timestamp": entry["timestamp"].isoformat(),
|
| 112 |
+
"text": entry["text"]
|
| 113 |
+
})
|
| 114 |
+
formatted_data["entries_count"] += 1
|
| 115 |
+
|
| 116 |
+
# Agregar conteo de palabras
|
| 117 |
+
for category, count in entry.get("word_count", {}).items():
|
| 118 |
+
if category in formatted_data["word_count"]:
|
| 119 |
+
formatted_data["word_count"][category] += count
|
| 120 |
+
else:
|
| 121 |
+
formatted_data["word_count"][category] = count
|
| 122 |
+
|
| 123 |
+
# Agregar diagramas
|
| 124 |
+
formatted_data["arc_diagrams"].extend(entry.get("arc_diagrams", []))
|
| 125 |
+
formatted_data["network_diagrams"].append(entry.get("network_diagram", ""))
|
| 126 |
+
|
| 127 |
+
return formatted_data
|
| 128 |
+
except Exception as e:
|
| 129 |
+
logger.error(f"Error al obtener datos del estudiante {username}: {str(e)}")
|
| 130 |
+
return None
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
##################################################################################################################
|
| 134 |
# Funci贸n para insertar un documento
|
| 135 |
def insert_document(document):
|
| 136 |
try:
|
|
|
|
| 341 |
|
| 342 |
with col2:
|
| 343 |
st.markdown(f"### {t['title']}")
|
| 344 |
+
|
| 345 |
+
if st.session_state.role == "Estudiante":
|
| 346 |
+
# Agregar un bot贸n para ver el progreso del estudiante
|
| 347 |
+
if st.button("Ver mi progreso"):
|
| 348 |
+
student_data = get_student_data(st.session_state.username)
|
| 349 |
+
if student_data:
|
| 350 |
+
st.success("Datos obtenidos exitosamente")
|
| 351 |
+
|
| 352 |
+
# Mostrar estad铆sticas generales
|
| 353 |
+
st.subheader("Estad铆sticas generales")
|
| 354 |
+
st.write(f"Total de entradas: {student_data['entries_count']}")
|
| 355 |
+
|
| 356 |
+
# Mostrar gr谩fico de conteo de palabras
|
| 357 |
+
st.subheader("Conteo de palabras por categor铆a")
|
| 358 |
+
st.bar_chart(student_data['word_count'])
|
| 359 |
+
|
| 360 |
+
# Mostrar entradas recientes
|
| 361 |
+
st.subheader("Entradas recientes")
|
| 362 |
+
for entry in student_data['entries'][:5]: # Mostrar las 5 entradas m谩s recientes
|
| 363 |
+
st.text_area(f"Entrada del {entry['timestamp']}", entry['text'], height=100)
|
| 364 |
+
|
| 365 |
+
# Aqu铆 puedes agregar m谩s visualizaciones seg煤n necesites
|
| 366 |
+
else:
|
| 367 |
+
st.warning("No se encontraron datos para este estudiante")
|
| 368 |
|
| 369 |
if st.session_state.role == "Estudiante":
|
| 370 |
# Student interface code
|