Files

118 lines
7.9 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Database\Seeders;
use App\Models\User;
use App\Models\Subject;
use App\Models\Question;
use App\Models\AnswerOption;
use App\Models\Reward;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder {
public function run(): void {
User::create([
'name' => 'Admin',
'email' => 'admin@lernapp.de',
'password' => Hash::make('Admin1234!'),
'role' => 'admin',
'points' => 0,
]);
$subjects = [
['name'=>'Mathe', 'slug'=>'mathe', 'icon'=>'🔢', 'color'=>'green'],
['name'=>'Deutsch', 'slug'=>'deutsch', 'icon'=>'📖', 'color'=>'blue'],
['name'=>'Englisch','slug'=>'englisch', 'icon'=>'🌍', 'color'=>'orange'],
];
foreach ($subjects as $s) {
Subject::create($s);
}
$questions = [
// Mathe
['subject'=>'mathe','text'=>'7 × 8 = ?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['56',true],['48',false],['54',false],['64',false]]],
['subject'=>'mathe','text'=>'144 ÷ 12 = ?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['12',true],['10',false],['11',false],['14',false]]],
['subject'=>'mathe','text'=>'234 + 567 = ?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['801',true],['791',false],['800',false],['811',false]]],
['subject'=>'mathe','text'=>'1000 387 = ?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['613',true],['623',false],['713',false],['587',false]]],
['subject'=>'mathe','text'=>'Eine Schachtel hat 24 Pralinen. Wie viele Schachteln brauchst du für 96 Pralinen?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['4',true],['3',false],['5',false],['6',false]]],
['subject'=>'mathe','text'=>'Was ist die Hälfte von 136?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['68',true],['64',false],['70',false],['72',false]]],
['subject'=>'mathe','text'=>'Ein Rechteck ist 9 cm lang und 6 cm breit. Wie groß ist sein Flächeninhalt?','type'=>'multiple_choice','diff'=>3,'pts'=>20,
'options'=>[['54 cm²',true],['30 cm²',false],['45 cm²',false],['60 cm²',false]]],
['subject'=>'mathe','text'=>'3 × 4 + 2 × 5 = ?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['22',true],['34',false],['26',false],['20',false]]],
// Deutsch
['subject'=>'deutsch','text'=>'Welches Wort ist ein Nomen?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['Hund',true],['laufen',false],['schnell',false],['grün',false]]],
['subject'=>'deutsch','text'=>'Was ist die Einzahl von „Häuser"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['Haus',true],['Häusen',false],['Häuse',false],['Hausung',false]]],
['subject'=>'deutsch','text'=>'Welche Zeitform ist: „Er spielte Fußball."?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['Präteritum',true],['Präsens',false],['Futur',false],['Perfekt',false]]],
['subject'=>'deutsch','text'=>'Welche Satzart ist das: „Wie schön der Tag ist!"?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['Ausrufesatz',true],['Aussagesatz',false],['Fragesatz',false],['Aufforderungssatz',false]]],
['subject'=>'deutsch','text'=>'Was ist das Gegenteil von „fröhlich"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['traurig',true],['lustig',false],['mutig',false],['fleißig',false]]],
['subject'=>'deutsch','text'=>'Welches Wort ist ein Verb?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['rennen',true],['Tisch',false],['blau',false],['schnell',false]]],
['subject'=>'deutsch','text'=>'Wie heißt der Plural von „das Kind"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['die Kinder',true],['die Kinde',false],['die Kinds',false],['die Kindern',false]]],
['subject'=>'deutsch','text'=>'Welches Komma ist richtig? „Ich esse ___ Brot, Butter und Käse."','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['kein Komma nötig',true],['nach „esse"',false],['nach „Brot"',false],['nach „Butter"',false]]],
// Englisch
['subject'=>'englisch','text'=>'What is "der Hund" in English?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['the dog',true],['the cat',false],['the horse',false],['the pig',false]]],
['subject'=>'englisch','text'=>'Which word means "groß"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['big',true],['small',false],['old',false],['fast',false]]],
['subject'=>'englisch','text'=>'"I ___ to school every day." Which word fits?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['go',true],['going',false],['goes',false],['gone',false]]],
['subject'=>'englisch','text'=>'What is the plural of "child"?','type'=>'multiple_choice','diff'=>2,'pts'=>10,
'options'=>[['children',true],['childs',false],['childes',false],['child',false]]],
['subject'=>'englisch','text'=>'What color is "gelb"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['yellow',true],['red',false],['green',false],['blue',false]]],
['subject'=>'englisch','text'=>'How do you say "Guten Morgen"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['Good morning',true],['Good night',false],['Good evening',false],['Good afternoon',false]]],
['subject'=>'englisch','text'=>'"She ___ a book yesterday." Which word fits?','type'=>'multiple_choice','diff'=>3,'pts'=>20,
'options'=>[['read',true],['reads',false],['reading',false],['is reading',false]]],
['subject'=>'englisch','text'=>'What is the opposite of "hot"?','type'=>'multiple_choice','diff'=>1,'pts'=>5,
'options'=>[['cold',true],['warm',false],['cool',false],['fast',false]]],
];
$subjectMap = Subject::pluck('id','slug')->all();
foreach ($questions as $i => $q) {
$question = Question::create([
'subject_id' => $subjectMap[$q['subject']],
'question_text' => $q['text'],
'type' => $q['type'],
'difficulty' => $q['diff'],
'points_value' => $q['pts'],
'active' => true,
]);
foreach ($q['options'] as $j => [$text, $correct]) {
AnswerOption::create([
'question_id' => $question->id,
'text' => $text,
'is_correct' => $correct,
'sort_order' => $j,
]);
}
}
$rewards = [
['name'=>'30 Min. Fernsehen', 'description'=>'30 Minuten Fernsehzeit', 'icon'=>'📺','points_cost'=>50, 'minutes'=>30],
['name'=>'1 Std. Fernsehen', 'description'=>'Eine Stunde Fernsehzeit', 'icon'=>'📺','points_cost'=>90, 'minutes'=>60],
['name'=>'30 Min. Konsole', 'description'=>'30 Minuten Spielkonsole', 'icon'=>'🎮','points_cost'=>75, 'minutes'=>30],
['name'=>'1 Std. Konsole', 'description'=>'Eine Stunde Spielkonsole', 'icon'=>'🎮','points_cost'=>130,'minutes'=>60],
['name'=>'Wunschdessert', 'description'=>'Ein Dessert deiner Wahl', 'icon'=>'🍰','points_cost'=>80, 'minutes'=>null],
['name'=>'1 Std. länger aufbleiben','description'=>'Heute eine Stunde später ins Bett','icon'=>'🌙','points_cost'=>120,'minutes'=>null],
];
foreach ($rewards as $r) {
Reward::create(array_merge($r, ['active' => true]));
}
}
}