Divers : Interro 27

This commit is contained in:
2026-05-08 15:36:18 +02:00
parent 428692f6c8
commit 26d02b0987
7 changed files with 70 additions and 15 deletions
+10 -4
View File
@@ -55,7 +55,10 @@ def compile_to_pdf(text, output_pdf_path): # 21 cm + 3.8 (dimension de la marge
def fetch_and_save_sub_text(ex_id, indices, label, text_path):
"""Fetches text for a specific sub-question and saves it to Text/{label}.tex"""
qinds = ",".join(map(str, indices))
url = f"http://localhost:8080/exercices/exo_q_text/{ex_id}/{qinds}"
if qinds:
url = f"http://localhost:8080/exercices/exo_q_text/{ex_id}/{qinds}"
else:
url = f"http://localhost:8080/exercices/exo_q_text/{ex_id}"
try:
with urllib.request.urlopen(url) as response:
content = response.read().decode('utf-8')
@@ -71,7 +74,10 @@ def fetch_and_save_sub_text(ex_id, indices, label, text_path):
def fetch_and_save_sub_sol(ex_id, indices, label, sol_path):
"""Fetches text for a specific sub-question and saves it to Text/{label}.tex"""
qinds = ",".join(map(str, indices))
url = f"http://localhost:8080/exercices/exo_q_sol/{ex_id}/{qinds}"
if qinds:
url = f"http://localhost:8080/exercices/exo_q_sol/{ex_id}/{qinds}"
else:
url = f"http://localhost:8080/exercices/exo_q_sol/{ex_id}"
try:
with urllib.request.urlopen(url) as response:
content = response.read().decode('utf-8')
@@ -168,11 +174,11 @@ def process_directory(directory):
if not tex_files:
print(f"No .tex file found in {directory}. Looking in /Staging/Interro/")
int_name = directory[:-1] if directory.endswith("/") else directory
tex_path = os.path.join(os.path.expanduser("~"), "Prépa/Staging/Interro/", int_name, ".tex")
tex_path = os.path.join(os.path.expanduser("~"), "Prépa/Staging/Interro", f"{int_name}.tex")
if os.path.exists(tex_path):
tex_file = tex_path
else:
print("Not found.")
print("Not found in ", tex_path)
return
else:
tex_file = tex_files[0]