#!/usr/bin/env python3
"""
Serdarli Primary School — Grade 4 / Unit 1 "My School"
Week 1 of 3 (14 - 18 September 2026) — Detailed Learning Outcome Table
Content strictly from MEB Year 4 curriculum (4 Temel.pdf), Unit 1.
All content in English.
"""

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

OUT = "/root/Akademik/İngilizce/4_Sinif_Hafta1_Kazanim_Tablosu_14-18_Eylul.docx"

# ── Main detail table: (Component, [bullet lines]) ──
DETAILS = [
    ("Learning Outcomes", [
        "Develops understanding and ability to use familiar phrases and expressions in English in order to satisfy concrete needs",
        "Develops ability to make introductions on self and others",
        "Develops basic competence in terms of supervised completion of simple tasks and problem-solving in English",
        "Acquires basic CMC related skills for English language learning and use",
    ]),
    ("Weekly Focus (Week 1 of 3)", [
        "Introduces the unit topic 'My School' and the classroom/school context",
        "First grammar structure: Present Continuous Tense (affirmative / interrogative)",
        "First question type: Wh-question 'What is she doing?'",
        "First vocabulary group: classroom objects and school places",
        "Weekdays and the weekly timetable",
    ]),
    ("Grammar — Unit 1 Sequence (as given in the curriculum)", [
        "1. Present Continuous Tense (affirmative / interrogative)  ← Week 1 focus",
        "2. Wh-questions (e.g. What is she doing?)  ← Week 1 focus",
        "3. Can I ...., please? / May I ...? (asking for permission)",
        "4. Singular / Plural nouns",
        "5. There is / are (affirmative, interrogative)",
        "6. Preposition of time: on",
        "7. Personal pronouns: I, you, we, they, he, she, it",
        "8. Possessive adjectives: My, your, his, her, our, their, its",
        "9. Possessive 's",
        "10. Wh-questions: What, Whose, How many",
    ]),
    ("Lexis — Unit 1", [
        "Week 1 focus: Classroom objects (book, pencil, pen, bag, chair, desk, board), School places (classroom, library, canteen, playground), Week days, Classroom activities",
        "To be introduced later in the unit: School subjects, Maths words, Numbers 11-100",
    ]),
    ("Receptive Skills — Listening", [
        "Understanding and responding to routine classroom instructions",
        "Listening and singing a song about classroom activities",
    ]),
    ("Receptive Skills — Reading", [
        "Identifying numbers",
        "Identifying the letters of the alphabet and learning the spelling of numbers",
    ]),
    ("Productive Skills — Speaking", [
        "SP: Articulating sounds of English",
        "SI: Interacting in pairs in a simple way by asking each other what they are doing",
        "SP: Spelling and pronouncing words related to the classroom and school",
        "SP: Saying what objects there are in the classroom by using short sentences",
        "SI: Asking for permission as relevant to classroom and school life",
        "SP: Talking in simple sentences about school subjects on the timetable",
    ]),
    ("Productive Skills — Writing", [
        "Writing about classroom objects in short phrases and sentences",
        "Writing simple phrases and sentences about own regular school subjects (on each week day on the timetable)",
    ]),
    ("Activities and Content", [
        "Present Continuous introduction: 'I am reading', 'She is writing'",
        "Pair work: 'What is she doing?'",
        "Listening and singing a song about classroom activities",
        "School places flashcards",
        "Weekdays + timetable",
        "GW: Learners present in groups what others are doing in the class (School Day Activities)",
        "WCA: Learners discuss what equipment they need",
    ]),
    ("Inter-disciplinary Skills", [
        "Cooperative learning",
        "Personal and social capability (Inter-personal communication, Social interaction)",
        "Problem solving",
        "ICT literacy",
        "Critical thinking",
    ]),
    ("Cross-curricular Themes", [
        "Good citizen — Collaboration, Social awareness",
    ]),
    ("Assessment", [
        "Classroom observation and participation in pair / group work",
        "Unit quizzes are scheduled at the end of the unit groups (Quiz 1 covers Units 1-2)",
    ]),
]


def set_cell_text(cell, value, bullets=True):
    cell.text = ''
    lines = value if isinstance(value, list) else [value]
    for j, item in enumerate(lines):
        p = cell.paragraphs[0] if j == 0 else cell.add_paragraph()
        if bullets and isinstance(value, list):
            p.style = cell.part.document.styles['List Bullet']
        run = p.add_run(item)
        run.font.name = 'Arial'
        run.font.size = Pt(10)


def build():
    doc = Document()

    for section in doc.sections:
        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(1.5)
        section.bottom_margin = Cm(1.5)
        section.left_margin = Cm(1.5)
        section.right_margin = Cm(1.5)

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

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

    p = doc.add_paragraph()
    r = p.add_run("\tGrade 4 — English Learning Outcome Table (Week 1)")
    r.bold = True
    r.font.name = 'Arial'

    doc.add_paragraph()

    # ── Info header table ──
    info = doc.add_table(rows=2, cols=4)
    info.style = 'Table Grid'
    info.alignment = WD_TABLE_ALIGNMENT.CENTER
    info_data = [
        ["Grade Level", "Learning Area", "Unit / Week", "Teaching Days"],
        ["Grade 4", "My School", "Unit 1 — Week 1 of 3", "5 (14 - 18 September 2026)"],
    ]
    for i, row_vals in enumerate(info_data):
        for j, val in enumerate(row_vals):
            cell = info.rows[i].cells[j]
            cell.text = val
            for pp in cell.paragraphs:
                for rr in pp.runs:
                    rr.font.name = 'Arial'
                    rr.font.size = Pt(11)
                    rr.bold = (i == 0)

    doc.add_paragraph()

    # ── Detail table ──
    table = doc.add_table(rows=1, cols=2)
    table.style = 'Table Grid'
    table.alignment = WD_TABLE_ALIGNMENT.CENTER

    hdr = table.rows[0].cells
    for i, h in enumerate(["Component", "Details"]):
        hdr[i].text = h
        for pp in hdr[i].paragraphs:
            for rr in pp.runs:
                rr.bold = True
                rr.font.name = 'Arial'
                rr.font.size = Pt(11)
                rr.font.color.rgb = RGBColor(0x1F, 0x1F, 0x1F)

    for comp, lines in DETAILS:
        row = table.add_row()
        set_cell_text(row.cells[0], comp, bullets=False)
        set_cell_text(row.cells[1], lines, bullets=True)
        for pp in row.cells[0].paragraphs:
            for rr in pp.runs:
                rr.bold = True

    # column widths
    for row in table.rows:
        row.cells[0].width = Cm(7.0)
        row.cells[1].width = Cm(20.0)

    # ── Signatures ──
    doc.add_paragraph()
    p = doc.add_paragraph()
    r = p.add_run("Teacher:\t\tHeadteacher")
    r.font.name = 'Arial'
    p = doc.add_paragraph()
    r = p.add_run("Niyazi Coban  \t\tOzgul Dervisogullari")
    r.font.name = 'Arial'

    doc.save(OUT)
    print("Saved:", OUT)
    return OUT


if __name__ == "__main__":
    build()
