AIdeaText commited on
Commit
2c67534
verified
1 Parent(s): 0bd5403

Update modules/studentact/current_situation_interface.py

Browse files
modules/studentact/current_situation_interface.py CHANGED
@@ -122,121 +122,121 @@ def display_current_situation_interface(lang_code, nlp_models, t):
122
  st.session_state.iteration_metrics = None
123
 
124
  try:
125
- # Container principal con cuatro columnas
126
- with st.container():
127
- # Crear las cuatro columnas con distribuci贸n equitativa
128
- text_base_col, metrics_base_col, text_iter_col, metrics_iter_col = st.columns([3,2,3,2], gap="small")
129
-
130
- # COLUMNA 1: Texto Base
131
- with text_base_col:
132
- text_base = st.text_area(
133
- t.get('input_prompt_base', "Escribe o pega el texto base aqu铆:"),
134
- height=400,
135
- key="text_area_base",
136
- value=st.session_state.text_base,
137
- help="Este texto servir谩 como l铆nea base para la comparaci贸n"
138
- )
139
-
140
- # Manejar cambios en el texto base
141
- if text_base != st.session_state.text_base:
142
- st.session_state.text_base = text_base
143
- st.session_state.show_base_results = False
144
-
145
- if st.button(
146
- t.get('analyze_base_button', "Establecer L铆nea Base"),
147
- type="primary",
148
- disabled=not text_base.strip(),
149
- use_container_width=True,
150
- ):
151
- try:
152
- with st.spinner(t.get('processing_base', "Analizando l铆nea base...")):
153
- doc = nlp_models[lang_code](text_base)
154
- metrics = analyze_text_dimensions(doc)
155
-
156
- storage_success = store_current_situation_result(
157
- username=st.session_state.username,
158
- text=text_base,
159
- metrics=metrics,
160
- feedback=None,
161
- analysis_type='base'
162
- )
163
-
164
- if not storage_success:
165
- logger.warning("No se pudo guardar el an谩lisis base en la base de datos")
166
-
167
- st.session_state.base_doc = doc
168
- st.session_state.base_metrics = metrics
169
- st.session_state.show_base_results = True
170
- except Exception as e:
171
- logger.error(f"Error en an谩lisis base: {str(e)}")
172
- st.error(t.get('analysis_error', "Error al analizar el texto base"))
173
-
174
- # COLUMNA 2: Resultados Base
175
- with metrics_base_col:
176
- if st.session_state.show_base_results and st.session_state.base_metrics is not None:
177
- st.markdown("### M茅tricas Base")
178
- display_results(
179
- metrics=st.session_state.base_metrics,
180
- text_type=st.session_state.get('current_text_type', 'student_essay')
181
  )
182
-
183
- # COLUMNA 3: Texto Iteraci贸n
184
- with text_iter_col:
185
- text_iter = st.text_area(
186
- t.get('input_prompt_iter', "Escribe la nueva versi贸n del texto:"),
187
- height=400,
188
- key="text_area_iter",
189
- value=st.session_state.text_iteration,
190
- help="Este texto ser谩 comparado con la l铆nea base",
191
- disabled=not st.session_state.show_base_results
192
- )
193
-
194
- # Manejar cambios en el texto de iteraci贸n
195
- if text_iter != st.session_state.text_iteration:
196
- st.session_state.text_iteration = text_iter
197
- st.session_state.show_iteration_results = False
198
-
199
- if st.button(
200
- t.get('analyze_iter_button', "Analizar Iteraci贸n"),
201
- type="primary",
202
- disabled=not text_iter.strip() or not st.session_state.show_base_results,
203
- use_container_width=True,
204
- ):
205
- try:
206
- with st.spinner(t.get('processing_iter', "Analizando iteraci贸n...")):
207
- doc = nlp_models[lang_code](text_iter)
208
- metrics = analyze_text_dimensions(doc)
209
-
210
- storage_success = store_current_situation_result(
211
- username=st.session_state.username,
212
- text=text_iter,
213
- metrics=metrics,
214
- feedback=None,
215
- analysis_type='iteration'
216
- )
217
-
218
- if not storage_success:
219
- logger.warning("No se pudo guardar el an谩lisis de iteraci贸n en la base de datos")
220
-
221
- st.session_state.iteration_doc = doc
222
- st.session_state.iteration_metrics = metrics
223
- st.session_state.show_iteration_results = True
224
- except Exception as e:
225
- logger.error(f"Error en an谩lisis de iteraci贸n: {str(e)}")
226
- st.error(t.get('analysis_error', "Error al analizar la iteraci贸n"))
227
-
228
- # COLUMNA 4: Resultados Iteraci贸n
229
- with metrics_iter_col:
230
- if st.session_state.show_iteration_results and st.session_state.iteration_metrics is not None:
231
- st.markdown("### M茅tricas Iteraci贸n")
232
- display_results(
233
- metrics=st.session_state.iteration_metrics,
234
- text_type=st.session_state.get('current_text_type', 'student_essay')
235
  )
236
-
237
- except Exception as e:
238
- logger.error(f"Error en interfaz principal: {str(e)}")
239
- st.error("Ocurri贸 un error al cargar la interfaz")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
  ###################################
242
 
 
122
  st.session_state.iteration_metrics = None
123
 
124
  try:
125
+ # Container principal con cuatro columnas
126
+ with st.container():
127
+ # Crear las cuatro columnas con distribuci贸n equitativa
128
+ text_base_col, metrics_base_col, text_iter_col, metrics_iter_col = st.columns([3,2,3,2], gap="small")
129
+
130
+ # COLUMNA 1: Texto Base
131
+ with text_base_col:
132
+ text_base = st.text_area(
133
+ t.get('input_prompt_base', "Escribe o pega el texto base aqu铆:"),
134
+ height=400,
135
+ key="text_area_base",
136
+ value=st.session_state.text_base,
137
+ help="Este texto servir谩 como l铆nea base para la comparaci贸n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  )
139
+
140
+ # Manejar cambios en el texto base
141
+ if text_base != st.session_state.text_base:
142
+ st.session_state.text_base = text_base
143
+ st.session_state.show_base_results = False
144
+
145
+ if st.button(
146
+ t.get('analyze_base_button', "Establecer L铆nea Base"),
147
+ type="primary",
148
+ disabled=not text_base.strip(),
149
+ use_container_width=True,
150
+ ):
151
+ try:
152
+ with st.spinner(t.get('processing_base', "Analizando l铆nea base...")):
153
+ doc = nlp_models[lang_code](text_base)
154
+ metrics = analyze_text_dimensions(doc)
155
+
156
+ storage_success = store_current_situation_result(
157
+ username=st.session_state.username,
158
+ text=text_base,
159
+ metrics=metrics,
160
+ feedback=None,
161
+ analysis_type='base'
162
+ )
163
+
164
+ if not storage_success:
165
+ logger.warning("No se pudo guardar el an谩lisis base en la base de datos")
166
+
167
+ st.session_state.base_doc = doc
168
+ st.session_state.base_metrics = metrics
169
+ st.session_state.show_base_results = True
170
+ except Exception as e:
171
+ logger.error(f"Error en an谩lisis base: {str(e)}")
172
+ st.error(t.get('analysis_error', "Error al analizar el texto base"))
173
+
174
+ # COLUMNA 2: Resultados Base
175
+ with metrics_base_col:
176
+ if st.session_state.show_base_results and st.session_state.base_metrics is not None:
177
+ st.markdown("### M茅tricas Base")
178
+ display_results(
179
+ metrics=st.session_state.base_metrics,
180
+ text_type=st.session_state.get('current_text_type', 'student_essay')
181
+ )
182
+
183
+ # COLUMNA 3: Texto Iteraci贸n
184
+ with text_iter_col:
185
+ text_iter = st.text_area(
186
+ t.get('input_prompt_iter', "Escribe la nueva versi贸n del texto:"),
187
+ height=400,
188
+ key="text_area_iter",
189
+ value=st.session_state.text_iteration,
190
+ help="Este texto ser谩 comparado con la l铆nea base",
191
+ disabled=not st.session_state.show_base_results
192
  )
193
+
194
+ # Manejar cambios en el texto de iteraci贸n
195
+ if text_iter != st.session_state.text_iteration:
196
+ st.session_state.text_iteration = text_iter
197
+ st.session_state.show_iteration_results = False
198
+
199
+ if st.button(
200
+ t.get('analyze_iter_button', "Analizar Iteraci贸n"),
201
+ type="primary",
202
+ disabled=not text_iter.strip() or not st.session_state.show_base_results,
203
+ use_container_width=True,
204
+ ):
205
+ try:
206
+ with st.spinner(t.get('processing_iter', "Analizando iteraci贸n...")):
207
+ doc = nlp_models[lang_code](text_iter)
208
+ metrics = analyze_text_dimensions(doc)
209
+
210
+ storage_success = store_current_situation_result(
211
+ username=st.session_state.username,
212
+ text=text_iter,
213
+ metrics=metrics,
214
+ feedback=None,
215
+ analysis_type='iteration'
216
+ )
217
+
218
+ if not storage_success:
219
+ logger.warning("No se pudo guardar el an谩lisis de iteraci贸n en la base de datos")
220
+
221
+ st.session_state.iteration_doc = doc
222
+ st.session_state.iteration_metrics = metrics
223
+ st.session_state.show_iteration_results = True
224
+ except Exception as e:
225
+ logger.error(f"Error en an谩lisis de iteraci贸n: {str(e)}")
226
+ st.error(t.get('analysis_error', "Error al analizar la iteraci贸n"))
227
+
228
+ # COLUMNA 4: Resultados Iteraci贸n
229
+ with metrics_iter_col:
230
+ if st.session_state.show_iteration_results and st.session_state.iteration_metrics is not None:
231
+ st.markdown("### M茅tricas Iteraci贸n")
232
+ display_results(
233
+ metrics=st.session_state.iteration_metrics,
234
+ text_type=st.session_state.get('current_text_type', 'student_essay')
235
+ )
236
+
237
+ except Exception as e:
238
+ logger.error(f"Error en interfaz principal: {str(e)}")
239
+ st.error("Ocurri贸 un error al cargar la interfaz")
240
 
241
  ###################################
242