const db = require('../db');
const fs = require('fs');

async function seedAdditionalLessons() {
    try {
        console.log('Starting to seed additional lessons...');

        // Task 3: Career Paths
        const task3Content = `# Career Paths in Cybersecurity

The cybersecurity field offers diverse and rewarding career opportunities. As cyber threats continue to evolve, the demand for skilled professionals has never been higher.

## Popular Career Paths

### 1. Security Analyst (SOC Analyst)
SOC analysts are the first line of defense, monitoring security alerts and responding to incidents in real-time.

**Key Responsibilities:**
- Monitor security alerts and logs
- Investigate suspicious activities
- Respond to security incidents
- Create incident reports

**Skills Required:**
- Network traffic analysis
- SIEM tools (Splunk, QRadar)
- Incident response
- Understanding of attack patterns

**Average Salary:** $60,000 - $90,000/year

### 2. Penetration Tester (Ethical Hacker)
Pentesters simulate cyber attacks to find vulnerabilities before malicious actors do.

**Key Responsibilities:**
- Conduct vulnerability assessments
- Perform penetration testing
- Document findings and recommendations
- Work with development teams to fix issues

**Skills Required:**
- Knowledge of exploitation techniques
- Programming (Python, PowerShell, Bash)
- Tools like Metasploit, Burp Suite, Nmap
- Creative thinking

**Average Salary:** $80,000 - $120,000/year

### 3. Security Engineer
Security engineers design and implement security solutions to protect organizations.

**Key Responsibilities:**
- Design security architecture
- Implement security controls
- Configure firewalls and IDS/IPS
- Automate security processes

**Skills Required:**
- Network and system administration
- Cloud security (AWS, Azure, GCP)
- Scripting and automation
- Security frameworks

**Average Salary:** $90,000 - $140,000/year`;

        await db.query(
            'INSERT INTO lesson_content (task_id, content, content_type, reading_time_minutes) VALUES (?, ?, ?, ?)',
            [3, task3Content, 'markdown', 12]
        );
        console.log('✓ Added lesson content for Task 3');

        // Task 3 questions
        const task3Questions = [
            ['What is the primary responsibility of a SOC Analyst?', 'Monitor security alerts and respond to incidents', 1, 'Think about the first line of defense', 0],
            ['Which certification is recommended for entry-level cybersecurity professionals?', 'CompTIA Security+', 2, 'Mentioned in the Essential Certifications section', 0],
            ['What is the average salary range for a Penetration Tester?', '$80,000 - $120,000/year', 3, 'Look at the Penetration Tester section', 0],
            ['What does CISO stand for?', 'Chief Information Security Officer', 4, 'This is a leadership position', 0]
        ];

        for (const q of task3Questions) {
            await db.query(
                'INSERT INTO lesson_questions (task_id, question_text, correct_answer, question_order, hint, case_sensitive) VALUES (3, ?, ?, ?, ?, ?)',
                q
            );
        }
        console.log('✓ Added 4 questions for Task 3');

        // Task 4: Quiz content
        const task4Content = `# Cybersecurity Basics Quiz

Congratulations on making it this far! This quiz will test your understanding of the fundamental cybersecurity concepts you've learned.

## Quiz Instructions

- Answer all questions to the best of your ability
- Each question tests your understanding of key concepts from previous lessons
- You need **70%** to pass this quiz
- Take your time and think carefully about each answer
- Hints are provided to help guide you

## Topics Covered

This quiz covers:
- Basic cybersecurity terminology
- Common threats and vulnerabilities
- Network security concepts
- Career paths in cybersecurity

Good luck! 🎯`;

        await db.query(
            'INSERT INTO lesson_content (task_id, content, content_type, reading_time_minutes) VALUES (?, ?, ?, ?)',
            [4, task4Content, 'markdown', 5]
        );
        console.log('✓ Added lesson content for Task 4');

        // Task 4 questions
        const task4Questions = [
            ['What is the practice of protecting systems, networks, and programs from digital attacks called?', 'Cybersecurity', 1, 'This is the most fundamental term', 0],
            ['What type of attack floods a network with traffic to make it unavailable?', 'DDoS', 2, 'Stands for Distributed Denial of Service', 0],
            ['Which protocol is used for secure web browsing?', 'HTTPS', 3, 'It uses port 443', 0],
            ['What does the "C" in CIA triad stand for?', 'Confidentiality', 4, 'The three pillars of information security', 0],
            ['What is software designed to harm or exploit computer systems called?', 'Malware', 5, 'Malicious software', 0],
            ['What security tool monitors network traffic for suspicious activity?', 'IDS', 6, 'Intrusion Detection System', 0]
        ];

        for (const q of task4Questions) {
            await db.query(
                'INSERT INTO lesson_questions (task_id, question_text, correct_answer, question_order, hint, case_sensitive) VALUES (4, ?, ?, ?, ?, ?)',
                q
            );
        }
        console.log('✓ Added 6 questions for Task 4');

        // Task 5: Lab Environment
        const task5Content = `# Setting Up Your Lab Environment

A hands-on cybersecurity lab is essential for practicing your skills safely. This lesson will guide you through setting up your own virtual security lab.

## Why You Need a Lab

- **Safe Practice:** Test tools and techniques without risks
- **Hands-on Learning:** Apply theoretical knowledge
- **Build Portfolio:** Document your projects
- **Stay Updated:** Test new exploits and defenses

## Lab Components

### 1. Virtualization Platform

Choose one of these free options:

**VirtualBox** (Recommended for beginners)
- Free and open-source
- Cross-platform (Windows, Mac, Linux)
- Easy to use
- Great community support

**VMware Workstation Player**
- Free for personal use
- Excellent performance
- Professional features

### 2. Operating Systems for Your Lab

**Kali Linux** - Essential for security testing
- Pre-loaded with 600+ security tools
- Based on Debian
- Regular updates
- Download from: kali.org

**Metasploitable 2/3** - Intentionally vulnerable systems
- Perfect for practicing exploitation
- Learn common vulnerabilities
- Safe testing environment

## Best Practices

✅ **DO:**
- Always use isolated networks
- Take regular snapshots
- Document your findings
- Keep your attacking machine updated
- Practice legally and ethically

❌ **DON'T:**
- Attack systems without permission
- Expose vulnerable VMs to the internet
- Use production networks for testing

Remember: A well-configured lab is your playground for learning!`;

        await db.query(
            'INSERT INTO lesson_content (task_id, content, content_type, reading_time_minutes) VALUES (?, ?, ?, ?)',
            [5, task5Content, 'markdown', 15]
        );
        console.log('✓ Added lesson content for Task 5');

        // Task 5 questions
        const task5Questions = [
            ['Which virtualization platform is recommended for beginners?', 'VirtualBox', 1, 'Free, cross-platform, and easy to use', 0],
            ['What is the name of the Linux distribution pre-loaded with security tools?', 'Kali Linux', 2, 'Based on Debian with 600+ tools', 0],
            ['What is Metasploitable?', 'Intentionally vulnerable system', 3, 'Used for practicing exploitation safely', 0],
            ['Which network mode should you use to isolate vulnerable VMs?', 'Host-Only', 4, 'Creates an isolated network', 0],
            ['What tool is used for packet capture and analysis?', 'Wireshark', 5, 'Essential for network analysis', 0]
        ];

        for (const q of task5Questions) {
            await db.query(
                'INSERT INTO lesson_questions (task_id, question_text, correct_answer, question_order, hint, case_sensitive) VALUES (5, ?, ?, ?, ?, ?)',
                q
            );
        }
        console.log('✓ Added 5 questions for Task 5');

        console.log('\n✅ All additional lessons seeded successfully!');
        process.exit(0);
    } catch (error) {
        console.error('Error seeding lessons:', error);
        process.exit(1);
    }
}

seedAdditionalLessons();
