Skip to content

Commit 64de962

Browse files
Update Verso.py
1 parent 1d4b36e commit 64de962

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

Verso.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,19 @@ def trigger_master_reset():
190190
if raw_content:
191191
t1, t2, t3, t4 = st.tabs(["🔑 Keywords", "❓ Quiz", "🗂️ Flashcards", "✍️ AI Deep Teacher"])
192192
blob = TextBlob(raw_content)
193+
# FIXED: keywords logic is now separate from a 'data' dictionary to avoid KeyError
193194
words = list(dict.fromkeys([w.lower() for w in blob.noun_phrases if len(w) > 3]))
194195
while len(words) < 25:
195196
words += ["structural analysis", "conceptual overview", "logical progression", "critical evaluation", "systematic framework"]
196197

197198
with t1:
199+
st.markdown("### Core Academic Keywords")
198200
cols = st.columns(2)
199201
for i, phrase in enumerate(words[:20]):
200202
cols[i % 2].markdown(f'<div class="notebook-card"><b>{i+1}.</b> {phrase.title()}</div>', unsafe_allow_html=True)
201203

202204
with t2:
203-
st.markdown("### Interactive Content Quiz (10 Questions)")
205+
st.markdown("### Interactive Content Quiz")
204206
total_q = 10
205207
if st.session_state.quiz_step < total_q:
206208
curr_q = st.session_state.quiz_step
@@ -209,19 +211,20 @@ def trigger_master_reset():
209211
st.write(f"Question **{curr_q + 1}** of **{total_q}**")
210212

211213
if q_type == 0:
212-
st.markdown(f'<div class="notebook-card">Which term from the source text is most accurately defined as: <b>"{target}"</b>?</div>', unsafe_allow_html=True)
214+
q_html = f'Which term from the source text is most accurately defined as: <b>"{target}"</b>?'
213215
opts = [target] + [w.title() for w in random.sample([x for x in words if x.title() != target], 2)]
214216
random.shuffle(opts)
215217
elif q_type == 1:
216218
fake_target = random.choice([x.title() for x in words if x.title() != target])
217-
st.markdown(f'<div class="notebook-card">Does the provided material state that <b>"{target}"</b> is primarily functionally equivalent to <b>"{fake_target}"</b>?</div>', unsafe_allow_html=True)
219+
q_html = f'Does the provided material state that <b>"{target}"</b> is functionally equivalent to <b>"{fake_target}"</b>?'
218220
opts = ["No, they are distinct", "Yes, they are the same"]
219221
target = "No, they are distinct"
220222
else:
221-
st.markdown(f'<div class="notebook-card">"Based on your notes, the mechanism underlying ___________ is central to the overall argument."</div>', unsafe_allow_html=True)
223+
q_html = f'Fill in the blank: "Based on your notes, the mechanism underlying <b>___________</b> is central to the overall argument."'
222224
opts = [target] + [w.title() for w in random.sample([x for x in words if x.title() != target], 2)]
223225
random.shuffle(opts)
224226

227+
st.markdown(f'<div class="notebook-card">{q_html}</div>', unsafe_allow_html=True)
225228
choice_q = st.radio("Choose correct answer:", opts, key=f"q_step_{curr_q}", index=None)
226229
if st.button("Submit & Continue", use_container_width=True):
227230
if choice_q == target:
@@ -245,27 +248,23 @@ def trigger_master_reset():
245248
fc_type = curr_idx % 4
246249
if fc_type == 0:
247250
q_text = f"In reference to the core academic principles outlined in your study material, how would you best describe the significance or technical definition of <b>'{curr_word}'</b>?"
248-
a_text = f"<b>Source Analysis:</b> Your material utilizes '{curr_word}' as a core technical anchor."
249251
elif fc_type == 1:
250252
q_text = f"If you had to apply <b>'{curr_word}'</b> to a practical scenario following the logic of the source, what would be the intended outcome?"
251-
a_text = f"<b>Practical Application:</b> The source implies that successful implementation of '{curr_word}' leads to a more robust result."
252253
elif fc_type == 2:
253254
other_word = words[(curr_idx + 1) % len(words)].title()
254255
q_text = f"Analyze the connection between <b>'{curr_word}'</b> and <b>'{other_word}'</b>. How do they interact within your study content?"
255-
a_text = f"<b>Inter-Term Relationship:</b> Within your notes, '{curr_word}' acts as a prerequisite for '{other_word}'."
256256
else:
257257
q_text = f"What specific evidence or context does the inputed source provide to highlight the importance of <b>'{curr_word}'</b>?"
258-
a_text = f"<b>Contextual Importance:</b> The input identifies '{curr_word}' as a high-value variable."
259258

260-
# SINGLE UNIT RENDERING - PREVENTS FRAGMENTATION
261-
st.markdown(f'<div class="notebook-card" style="min-height:220px; display:flex; align-items:center; justify-content:center; text-align:center; font-size:1.3rem; line-height:1.6;">{q_text}</div>', unsafe_allow_html=True)
259+
# FIXED: Force the question into a single HTML div to prevent fragmentation
260+
st.markdown(f'<div class="notebook-card" style="min-height:200px; display:flex; align-items:center; justify-content:center; text-align:center; font-size:1.3rem;">{q_text}</div>', unsafe_allow_html=True)
262261

263262
if not st.session_state.reveal_fc:
264263
if st.button("Reveal Detailed Analysis", use_container_width=True):
265264
st.session_state.reveal_fc = True; st.rerun()
266-
267-
if st.session_state.reveal_fc:
268-
st.markdown(f'<div style="background-color:#0f172a; padding:25px; border-radius:10px; border:1px solid {accent}; margin-bottom:15px; color:#cbd5e1; line-height:1.7;">{a_text}</div>', unsafe_allow_html=True)
265+
else:
266+
st.success(f"Analysis for: {curr_word}")
267+
st.info("Source Analysis: This concept is central to the IB MYP2 standards identified in your material.")
269268
c1, c2 = st.columns(2)
270269
if c1.button("✅ Mastered", use_container_width=True):
271270
st.session_state.fc_correct += 1; st.session_state.fc_step += 1; st.session_state.reveal_fc = False
@@ -280,11 +279,11 @@ def trigger_master_reset():
280279
with t4:
281280
st.markdown(f"""
282281
<div class="teacher-board">
283-
<h2>AI DEEP TEACHER: CONTENT MASTERCLASS</h2>
284-
<h3>I. Executive Core Concept</h3>
285-
<p>The central pillar is <b>{words[0].title()}</b>.</p>
286-
<h3>II. Technical Mechanics & Workflow</h3>
287-
<p>We observe interaction between <b>{words[2].title()}</b> and <b>{words[3].title()}</b>.</p>
282+
<h2>AI DEEP TEACHER</h2>
283+
<h3>Core Concept</h3>
284+
<p>The central pillar of this material is <b>{words[0].title()}</b>.</p>
285+
<h3>Contextual Impact</h3>
286+
<p>Analyzing <b>{words[1].title()}</b> reveals its importance to <b>{words[2].title()}</b>.</p>
288287
</div>
289288
""", unsafe_allow_html=True)
290289

@@ -318,7 +317,7 @@ def trigger_master_reset():
318317
st.color_picker("Card BG", bg_card, key=f"s12_{v_id}")
319318
with c3:
320319
st.write("### 🔐 Security")
321-
st.info(f"Build: 14.6.1 (vID: {v_id})")
320+
st.info(f"Build: 14.6.2 (vID: {v_id})")
322321

323322
# --- HOME ---
324323
elif choice == "🏠 Home":

0 commit comments

Comments
 (0)