mirror of
https://github.com/marcogll/molding_assesment.git
synced 2026-03-15 14:25:02 +00:00
Refactor assessment system: rename v2 JSON files, update CLI script, add TUI interface, modify Markdown to hide correct answers in collapsible sections, adjust employee number inputs to text type
This commit is contained in:
61
questions/modify_md.py
Normal file
61
questions/modify_md.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import re
|
||||
|
||||
|
||||
def modify_md(file_path):
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
|
||||
# Split by questions, assuming ### \d+\.
|
||||
questions = re.split(r"(?=### \d+\.)", content)
|
||||
|
||||
modified_questions = []
|
||||
for q in questions:
|
||||
if not q.strip():
|
||||
continue
|
||||
# Find the options
|
||||
lines = q.split("\n")
|
||||
options_start = None
|
||||
rational_start = None
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith("- "):
|
||||
if options_start is None:
|
||||
options_start = i
|
||||
if line.startswith("**Racional:**"):
|
||||
rational_start = i
|
||||
break
|
||||
if options_start is not None and rational_start is not None:
|
||||
options = lines[options_start:rational_start]
|
||||
rational = lines[rational_start:]
|
||||
# Find the correct option
|
||||
correct_option = None
|
||||
for opt in options:
|
||||
if "✅" in opt:
|
||||
correct_option = opt.replace(" ✅", "").strip()
|
||||
break
|
||||
if correct_option:
|
||||
# Remove ✅ from options
|
||||
options = [opt.replace(" ✅", "") for opt in options]
|
||||
# Create details
|
||||
details = (
|
||||
[
|
||||
"<details>",
|
||||
"<summary>Respuesta Correcta</summary>",
|
||||
"",
|
||||
correct_option + " ✅",
|
||||
"",
|
||||
]
|
||||
+ rational
|
||||
+ ["</details>"]
|
||||
)
|
||||
# Replace the part
|
||||
lines = lines[:options_start] + options + [""] + details
|
||||
q = "\n".join(lines)
|
||||
modified_questions.append(q)
|
||||
|
||||
modified_content = "".join(modified_questions)
|
||||
with open(file_path, "w", encoding="utf-8") as f:
|
||||
f.write(modified_content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
modify_md("markdown/Basic_assesment.md")
|
||||
Reference in New Issue
Block a user