TiH0 commited on
Commit
91d9dad
·
verified ·
1 Parent(s): 55d28f2

Update prof.py

Browse files
Files changed (1) hide show
  1. prof.py +22 -31
prof.py CHANGED
@@ -1,12 +1,3 @@
1
- """
2
- PROF.PY - Professional Quiz Document Generator
3
- ===============================================
4
- This is the PROF version based on v4u.py with the following key difference:
5
- - NO ANSWER TABLES at the end
6
- - Answers are shown DIRECTLY next to the source for each question
7
- - All other features from v4u.py are preserved (images, highlighting, circled numbers, etc.)
8
- """
9
-
10
  import re
11
  import os
12
  import html
@@ -798,36 +789,19 @@ def format_question_block(doc, question_num, question_text, choices, correct_ans
798
  left_cell = info_table.rows[0].cells[0]
799
  right_cell = info_table.rows[0].cells[1]
800
 
801
- left_cell.width = Inches(4.5) # Left cell for source
802
- right_cell.width = Inches(1.5) # Right cell for "Réponse: ABC"
803
 
804
  # Set spacing
805
  left_cell._element.get_or_add_tcPr()
806
  right_cell._element.get_or_add_tcPr()
807
 
808
- # LEFT cell - Source
809
  left_para = left_cell.paragraphs[0]
810
  left_para.alignment = WD_ALIGN_PARAGRAPH.LEFT
811
  left_para.paragraph_format.space_before = Pt(2)
812
  left_para.paragraph_format.space_after = Pt(2)
813
 
814
- source_label_run = left_para.add_run("Source:")
815
- source_label_run.font.name = 'Inter ExtraBold'
816
- source_label_run.font.size = Pt(8)
817
- source_label_run.font.bold = True
818
- source_label_run.font.underline = True
819
-
820
- source_value_run = left_para.add_run(f" {source}")
821
- source_value_run.font.name = 'Inter ExtraBold'
822
- source_value_run.font.size = Pt(8)
823
- source_value_run.font.color.rgb = theme_color
824
-
825
- # RIGHT cell - Answer
826
- right_para = right_cell.paragraphs[0]
827
- right_para.alignment = WD_ALIGN_PARAGRAPH.RIGHT
828
- right_para.paragraph_format.space_before = Pt(2)
829
- right_para.paragraph_format.space_after = Pt(2)
830
-
831
  # Prepare answer text - convert list to space-separated string
832
  if isinstance(correct_answers, list):
833
  if len(correct_answers) == 0:
@@ -837,17 +811,34 @@ def format_question_block(doc, question_num, question_text, choices, correct_ans
837
  else:
838
  answer_text = str(correct_answers) if correct_answers else "/"
839
 
840
- answer_label_run = right_para.add_run("Réponse:")
841
  answer_label_run.font.name = 'Inter ExtraBold'
842
  answer_label_run.font.size = Pt(8)
843
  answer_label_run.font.bold = True
844
  answer_label_run.font.underline = True
845
 
846
- answer_value_run = right_para.add_run(f' {answer_text}')
847
  answer_value_run.font.name = 'Inter ExtraBold'
848
  answer_value_run.font.size = Pt(8)
849
  answer_value_run.font.color.rgb = theme_color
850
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
851
  # Keep with comment if exists
852
  if comment and str(comment).strip() and str(comment).lower() != 'nan':
853
  right_para.paragraph_format.keep_with_next = True
 
 
 
 
 
 
 
 
 
 
1
  import re
2
  import os
3
  import html
 
789
  left_cell = info_table.rows[0].cells[0]
790
  right_cell = info_table.rows[0].cells[1]
791
 
792
+ left_cell.width = Inches(1.5) # Left cell for "Réponse: ABC"
793
+ right_cell.width = Inches(4.5) # Right cell for source
794
 
795
  # Set spacing
796
  left_cell._element.get_or_add_tcPr()
797
  right_cell._element.get_or_add_tcPr()
798
 
799
+ # LEFT cell - Answer
800
  left_para = left_cell.paragraphs[0]
801
  left_para.alignment = WD_ALIGN_PARAGRAPH.LEFT
802
  left_para.paragraph_format.space_before = Pt(2)
803
  left_para.paragraph_format.space_after = Pt(2)
804
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
805
  # Prepare answer text - convert list to space-separated string
806
  if isinstance(correct_answers, list):
807
  if len(correct_answers) == 0:
 
811
  else:
812
  answer_text = str(correct_answers) if correct_answers else "/"
813
 
814
+ answer_label_run = left_para.add_run("Réponse:")
815
  answer_label_run.font.name = 'Inter ExtraBold'
816
  answer_label_run.font.size = Pt(8)
817
  answer_label_run.font.bold = True
818
  answer_label_run.font.underline = True
819
 
820
+ answer_value_run = left_para.add_run(f' {answer_text}')
821
  answer_value_run.font.name = 'Inter ExtraBold'
822
  answer_value_run.font.size = Pt(8)
823
  answer_value_run.font.color.rgb = theme_color
824
 
825
+ # RIGHT cell - Source
826
+ right_para = right_cell.paragraphs[0]
827
+ right_para.alignment = WD_ALIGN_PARAGRAPH.RIGHT
828
+ right_para.paragraph_format.space_before = Pt(2)
829
+ right_para.paragraph_format.space_after = Pt(2)
830
+
831
+ source_label_run = right_para.add_run("Source:")
832
+ source_label_run.font.name = 'Inter ExtraBold'
833
+ source_label_run.font.size = Pt(8)
834
+ source_label_run.font.bold = True
835
+ source_label_run.font.underline = True
836
+
837
+ source_value_run = right_para.add_run(f" {source}")
838
+ source_value_run.font.name = 'Inter ExtraBold'
839
+ source_value_run.font.size = Pt(8)
840
+ source_value_run.font.color.rgb = theme_color
841
+
842
  # Keep with comment if exists
843
  if comment and str(comment).strip() and str(comment).lower() != 'nan':
844
  right_para.paragraph_format.keep_with_next = True