#!/usr/bin/env python3
"""
Serdarli Primary School — English Weekly Lesson Plan
Format matches the Music lesson example exactly.
All content in English.
"""

from docx import Document
from docx.shared import Pt, Cm, RGBColor, Inches
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.enum.section import WD_ORIENT

# ═══ Week 1 Data (14-18 September) ═══
# (Grade, Learning Area, Learning Outcome, Activities, Key Concepts/Skills)

HAFTA1 = [
    (
        "Grade 2",
        "My Classroom",
        [
            "Introduces self using 'I am ___'",
            "Names classroom objects (door, board, table, chair)",
            "Counts 1-10",
        ],
        [
            "Self-introduction: 'I am ___', 'You are ___'",
            "Classroom objects flashcards",
            "Counting 1-10",
            "Name plate craft (IW)",
        ],
        "Self-expression / Numbers 1-10 / Classroom objects",
    ),
    (
        "Grade 3",
        "My Classroom",
        [
            "Uses pronouns (I, you, it, they) to introduce self and objects",
            "Forms inverted questions and short answers with verb to be",
        ],
        [
            "Self-introduction (I/you/it/they)",
            "Q&A: 'Are you ___?' / 'Is it ___?'",
            "Classroom objects flashcards",
            "Spelling Bee (WCA)",
            "Simon Says (WCA)",
            "Name plate (IW)",
        ],
        "Pronouns / Verb to be / Numbers 1-20",
    ),
    (
        "Grade 4",
        "My School",
        [
            "Expresses ongoing actions using Present Continuous Tense (affirmative/interrogative)",
            "Asks and answers 'What is she doing?'",
        ],
        [
            "Present Continuous intro: 'I am reading', 'She is writing'",
            "Pair work: 'What is she doing?'",
            "Classroom activities song",
            "School places flashcards",
            "Weekdays + timetable",
            "Group work: School Day Activities (GW)",
        ],
        "Present Continuous / Wh-questions / School places / Weekdays",
    ),
    (
        "Grade 5",
        "My Day",
        [
            "Expresses daily routine using Present Simple Tense to be (affirmative, negative, interrogative)",
            "Uses object pronouns (me, you, him, her)",
        ],
        [
            "Daily routines vocabulary: get up, have breakfast, go to school",
            "'I am at school', 'She is happy' (affirmative)",
            "Negative + interrogative: 'Are you ready?'",
            "Object pronouns: 'Tell me', 'Help him'",
            "Time: o'clock, half past",
            "Writing: short text about daily life (IW)",
        ],
        "Present Simple to be / Object pronouns / Daily routines / Time",
    ),
]

def create_plan():
    doc = Document()

    for section in doc.sections:
        # Landscape orientation
        new_width, new_height = section.page_height, section.page_width
        section.orientation = WD_ORIENT.LANDSCAPE
        section.page_width = new_width
        section.page_height = new_height
        section.top_margin = Cm(2.0)
        section.bottom_margin = Cm(2.0)
        section.left_margin = Cm(2.0)
        section.right_margin = Cm(2.0)

    style = doc.styles['Normal']
    style.font.name = 'Arial'
    style.font.size = Pt(11)

    # ─── Title ───
    p1 = doc.add_paragraph()
    run = p1.add_run("\tSERDARLI PRIMARY SCHOOL\t14 - 18 September 2026")
    run.bold = True
    run.font.name = 'Arial'

    p2 = doc.add_paragraph()
    run = p2.add_run("\tENGLISH LESSON WEEKLY PLAN")
    run.bold = True
    run.font.name = 'Arial'

    doc.add_paragraph()

    # ─── Table ───
    headers = [
        "Grade Level",
        "Learning Area",
        "Learning Outcome",
        "Activities and Content",
        "Key Concepts / Skills",
    ]

    table = doc.add_table(rows=0, cols=5)
    table.style = 'Table Grid'
    table.alignment = WD_TABLE_ALIGNMENT.CENTER

    # Header row
    header_row = table.add_row()
    for i, h in enumerate(headers):
        cell = header_row.cells[i]
        cell.text = h
        for p in cell.paragraphs:
            for r in p.runs:
                r.bold = True
                r.font.name = 'Arial'
                r.font.size = Pt(11)
                r.font.color.rgb = RGBColor(0x1F, 0x1F, 0x1F)

    # Data rows
    for row_data in HAFTA1:
        row = table.add_row()
        for i, val in enumerate(row_data):
            cell = row.cells[i]
            # Columns 2 (Learning Outcome) and 3 (Activities) are bullet lists
            if isinstance(val, list):
                # Clear default empty paragraph
                cell.text = ''
                for j, item in enumerate(val):
                    if j == 0:
                        p = cell.paragraphs[0]
                    else:
                        p = cell.add_paragraph()
                    p.style = doc.styles['List Bullet']
                    run = p.add_run(item)
                    run.font.name = 'Arial'
                    run.font.size = Pt(11)
            else:
                cell.text = val
                for p in cell.paragraphs:
                    for r in p.runs:
                        r.font.name = 'Arial'
                        r.font.size = Pt(11)

    # ─── Signatures ───
    doc.add_paragraph()

    p = doc.add_paragraph()
    run = p.add_run("Teacher:\t\tHeadteacher")
    run.font.name = 'Arial'

    p = doc.add_paragraph()
    run = p.add_run("Niyazi Coban  \t\tOzgul Dervisogullari")
    run.font.name = 'Arial'

    output = "/root/Akademik/İngilizce/Ingilizce_Haftalik_Plan_H1_14-18_Eylul.docx"
    doc.save(output)
    print(f"Saved: {output}")
    return output

if __name__ == "__main__":
    create_plan()