File size: 7,248 Bytes
da819ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');
const User = require('./models/User');
const SourceText = require('./models/SourceText');

// MongoDB connection
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/transcreation-sandbox';

async function seedDatabase() {
  try {
    console.log('Connecting to MongoDB...');
    await mongoose.connect(MONGODB_URI);
    console.log('Connected to MongoDB');

    // Create admin user
    console.log('Creating admin user...');
    const adminPassword = await bcrypt.hash('admin123', 10);
    const adminUser = await User.findOneAndUpdate(
      { email: 'admin@example.com' },
      {
        email: 'admin@example.com',
        password: adminPassword,
        username: 'admin',
        role: 'admin',
        isActive: true
      },
      { upsert: true, new: true }
    );
    console.log('Admin user created:', adminUser.email);

    // Create student user
    console.log('Creating student user...');
    const studentPassword = await bcrypt.hash('student123', 10);
    const studentUser = await User.findOneAndUpdate(
      { email: 'student@example.com' },
      {
        email: 'student@example.com',
        password: studentPassword,
        username: 'student',
        role: 'student',
        isActive: true
      },
      { upsert: true, new: true }
    );
    console.log('Student user created:', studentUser.email);

    // Tutorial Tasks for Week 1
    console.log('Creating tutorial tasks...');
    const tutorialTasks = [
      {
        title: 'Cultural Adaptation Exercise',
        content: 'Translate the following marketing slogan for a Western audience: "Our product brings harmony to your life." Consider cultural differences in how harmony is perceived.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'tutorial',
        weekNumber: 1,
        translationBrief: 'Adapt this slogan for a Western audience, focusing on individualism and personal achievement rather than collective harmony.',
        isActive: true
      },
      {
        title: 'Localization Challenge',
        content: 'Adapt this restaurant menu item: "Spicy Dragon Noodles" for a conservative American audience.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'tutorial',
        weekNumber: 1,
        translationBrief: 'Make this dish more appealing to conservative American diners who might be unfamiliar with Asian cuisine.',
        isActive: true
      },
      {
        title: 'Brand Voice Translation',
        content: 'Translate this luxury brand tagline: "Excellence in every detail" for a younger, more casual audience.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'tutorial',
        weekNumber: 1,
        translationBrief: 'Maintain the premium feel while making it more accessible and relatable to younger consumers.',
        isActive: true
      }
    ];

    for (const task of tutorialTasks) {
      await SourceText.findOneAndUpdate(
        { title: task.title, category: 'tutorial', weekNumber: task.weekNumber },
        task,
        { upsert: true, new: true }
      );
    }
    console.log('Tutorial tasks created for Week 1');

    // Weekly Practice Tasks for all weeks
    console.log('Creating weekly practice tasks...');
    const weeklyPracticeTasks = [
      {
        title: 'Week 1 Practice: Cultural Nuances',
        content: 'Translate this greeting: "How are you?" for different cultural contexts. Consider formality levels and cultural expectations.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'weekly-practice',
        weekNumber: 1,
        translationBrief: 'Adapt this greeting for formal business settings, casual social situations, and family contexts.',
        isActive: true
      },
      {
        title: 'Week 2 Practice: Marketing Adaptation',
        content: 'Adapt this product description: "Revolutionary technology that changes everything" for a skeptical audience.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'weekly-practice',
        weekNumber: 2,
        translationBrief: 'Make this claim more credible and less hyperbolic for a skeptical, evidence-based audience.',
        isActive: true
      },
      {
        title: 'Week 3 Practice: Emotional Translation',
        content: 'Translate this emotional expression: "I am so happy" for different cultural contexts where emotional expression varies.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'weekly-practice',
        weekNumber: 3,
        translationBrief: 'Adapt this expression for cultures that value emotional restraint and those that encourage emotional expression.',
        isActive: true
      },
      {
        title: 'Week 4 Practice: Humor Translation',
        content: 'Adapt this joke: "Why did the chicken cross the road? To get to the other side!" for a culture that doesn\'t have this idiom.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'weekly-practice',
        weekNumber: 4,
        translationBrief: 'Create a culturally appropriate version that maintains the humor while being accessible to the target culture.',
        isActive: true
      },
      {
        title: 'Week 5 Practice: Formal vs Informal',
        content: 'Translate this business communication: "We would appreciate your prompt response" for different formality levels.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'weekly-practice',
        weekNumber: 5,
        translationBrief: 'Create versions for very formal, moderately formal, and casual business contexts.',
        isActive: true
      },
      {
        title: 'Week 6 Practice: Cultural Values',
        content: 'Adapt this value statement: "Success comes from hard work" for cultures with different views on success and work.',
        sourceLanguage: 'English',
        targetLanguage: 'English',
        category: 'weekly-practice',
        weekNumber: 6,
        translationBrief: 'Consider cultures that value collaboration over individual achievement, and those that emphasize luck or fate.',
        isActive: true
      }
    ];

    for (const task of weeklyPracticeTasks) {
      await SourceText.findOneAndUpdate(
        { title: task.title, category: 'weekly-practice', weekNumber: task.weekNumber },
        task,
        { upsert: true, new: true }
      );
    }
    console.log('Weekly practice tasks created for all weeks');

    console.log('Database seeding completed successfully!');
    console.log('');
    console.log('Test Accounts:');
    console.log('Admin: admin@example.com / admin123');
    console.log('Student: student@example.com / student123');
    console.log('');
    console.log('You can now log in and see the tutorial tasks and weekly practice content.');

  } catch (error) {
    console.error('Error seeding database:', error);
  } finally {
    await mongoose.disconnect();
    console.log('Disconnected from MongoDB');
  }
}

// Run the seeding function
seedDatabase();