Sina Media Lab
commited on
Commit
·
660fa89
1
Parent(s):
d015779
Updates
Browse files
app.py
CHANGED
@@ -19,6 +19,18 @@ module_names = {
|
|
19 |
"Subtraction": "subtraction_bases",
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Initialize unique session state
|
23 |
if 'session_id' not in st.session_state:
|
24 |
st.session_state.session_id = str(uuid.uuid4())
|
@@ -132,25 +144,17 @@ if module_name != st.session_state.current_module:
|
|
132 |
# Load the current module's question
|
133 |
current_question = st.session_state.questions[st.session_state.current_index]
|
134 |
|
135 |
-
# Navigation buttons (placed on top)
|
136 |
-
col1, col2 = st.columns([1, 1])
|
137 |
-
with col1:
|
138 |
-
if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
|
139 |
-
navigate_question("prev")
|
140 |
-
|
141 |
-
with col2:
|
142 |
-
if st.button("➡️ Next"):
|
143 |
-
navigate_question("next")
|
144 |
-
|
145 |
# Display module title and description
|
146 |
st.title(module_name)
|
|
|
147 |
st.write(current_question["question"])
|
148 |
|
149 |
-
# Render options without
|
150 |
if not current_question.get('answered', False):
|
151 |
selected_answer = st.radio(
|
152 |
"Choose an answer:",
|
153 |
options=current_question['options'],
|
|
|
154 |
key=f"question_{st.session_state.current_index}"
|
155 |
)
|
156 |
|
@@ -164,7 +168,7 @@ if not current_question.get('answered', False):
|
|
164 |
st.session_state.module_correct_count[module_name] += 1
|
165 |
|
166 |
# Trigger a UI update
|
167 |
-
st.
|
168 |
|
169 |
# Show correct/incorrect feedback after submission
|
170 |
if current_question.get('answered', False):
|
@@ -180,6 +184,16 @@ if current_question.get('answered', False):
|
|
180 |
for step in current_question['step_by_step_solution']:
|
181 |
st.write(step)
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
# PDF Download Button (at the bottom)
|
184 |
if len(st.session_state.questions) > 0:
|
185 |
pdf = generate_pdf_report()
|
|
|
19 |
"Subtraction": "subtraction_bases",
|
20 |
}
|
21 |
|
22 |
+
# Module descriptions
|
23 |
+
module_descriptions = {
|
24 |
+
"Bases": "This module covers the presentation of numbers in various bases, including binary, octal, decimal, and hexadecimal.",
|
25 |
+
"Validity": "This module helps determine the validity of numbers in different bases.",
|
26 |
+
"Conversion": "This module covers conversion techniques between different bases, including with and without fractions.",
|
27 |
+
"Grouping": "This module focuses on grouping techniques for conversion between bases such as binary and hexadecimal.",
|
28 |
+
"Addition": "This module covers addition operations in bases like binary, octal, and hexadecimal.",
|
29 |
+
"2's Complement": "This module explains the 2's complement method for representing negative numbers.",
|
30 |
+
"Negative Numbers": "This module covers negative binary numbers and their representation.",
|
31 |
+
"Subtraction": "This module focuses on subtraction operations in binary using the 2's complement method.",
|
32 |
+
}
|
33 |
+
|
34 |
# Initialize unique session state
|
35 |
if 'session_id' not in st.session_state:
|
36 |
st.session_state.session_id = str(uuid.uuid4())
|
|
|
144 |
# Load the current module's question
|
145 |
current_question = st.session_state.questions[st.session_state.current_index]
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
# Display module title and description
|
148 |
st.title(module_name)
|
149 |
+
st.write(module_descriptions.get(module_name, "No description available for this module."))
|
150 |
st.write(current_question["question"])
|
151 |
|
152 |
+
# Render options without pre-selection
|
153 |
if not current_question.get('answered', False):
|
154 |
selected_answer = st.radio(
|
155 |
"Choose an answer:",
|
156 |
options=current_question['options'],
|
157 |
+
index=-1, # Ensures no option is pre-selected
|
158 |
key=f"question_{st.session_state.current_index}"
|
159 |
)
|
160 |
|
|
|
168 |
st.session_state.module_correct_count[module_name] += 1
|
169 |
|
170 |
# Trigger a UI update
|
171 |
+
st.set_query_params(dummy=not st.session_state.get('dummy', False))
|
172 |
|
173 |
# Show correct/incorrect feedback after submission
|
174 |
if current_question.get('answered', False):
|
|
|
184 |
for step in current_question['step_by_step_solution']:
|
185 |
st.write(step)
|
186 |
|
187 |
+
# Navigation buttons (placed after question and options)
|
188 |
+
col1, col2 = st.columns([1, 1])
|
189 |
+
with col1:
|
190 |
+
if st.button("⬅️ Prev", disabled=st.session_state.current_index == 0):
|
191 |
+
navigate_question("prev")
|
192 |
+
|
193 |
+
with col2:
|
194 |
+
if st.button("➡️ Next"):
|
195 |
+
navigate_question("next")
|
196 |
+
|
197 |
# PDF Download Button (at the bottom)
|
198 |
if len(st.session_state.questions) > 0:
|
199 |
pdf = generate_pdf_report()
|