@@ -73,6 +73,8 @@ class Challenge {
73
73
// Challenge Type 15 - Odin
74
74
final List <String >? assignments;
75
75
76
+ final List <List <SolutionFile >>? solutions;
77
+
76
78
Challenge ({
77
79
required this .id,
78
80
required this .block,
@@ -94,6 +96,7 @@ class Challenge {
94
96
this .audio,
95
97
this .scene,
96
98
required this .hooks,
99
+ this .solutions,
97
100
});
98
101
99
102
factory Challenge .fromJson (Map <String , dynamic > data) {
@@ -134,6 +137,13 @@ class Challenge {
134
137
hooks: Hooks .fromJson (
135
138
data['hooks' ] ?? {'beforeAll' : '' },
136
139
),
140
+ solutions: data['solutions' ] != null
141
+ ? (data['solutions' ] as List )
142
+ .map <List <SolutionFile >>((solutionList) => (solutionList as List )
143
+ .map <SolutionFile >((file) => SolutionFile .fromJson (file))
144
+ .toList ())
145
+ .toList ()
146
+ : null ,
137
147
);
138
148
}
139
149
@@ -180,6 +190,10 @@ class Challenge {
180
190
'solution' : question.solution,
181
191
})
182
192
.toList (),
193
+ 'solutions' : challenge.solutions
194
+ ? .map ((solutionList) =>
195
+ solutionList.map ((file) => file.toJson ()).toList ())
196
+ .toList (),
183
197
};
184
198
}
185
199
}
@@ -494,3 +508,61 @@ class EnglishAudio {
494
508
);
495
509
}
496
510
}
511
+
512
+ class SolutionFile {
513
+ final String head;
514
+ final String tail;
515
+ final String id;
516
+ final List <String > history;
517
+ final String name;
518
+ final String ext;
519
+ final String path;
520
+ final String fileKey;
521
+ final String contents;
522
+ final String seed;
523
+ final String ? error;
524
+
525
+ SolutionFile ({
526
+ required this .head,
527
+ required this .tail,
528
+ required this .id,
529
+ required this .history,
530
+ required this .name,
531
+ required this .ext,
532
+ required this .path,
533
+ required this .fileKey,
534
+ required this .contents,
535
+ required this .seed,
536
+ this .error,
537
+ });
538
+
539
+ factory SolutionFile .fromJson (Map <String , dynamic > data) {
540
+ return SolutionFile (
541
+ head: data['head' ] ?? '' ,
542
+ tail: data['tail' ] ?? '' ,
543
+ id: data['id' ] ?? '' ,
544
+ history: ((data['history' ] ?? []) as List ).cast <String >(),
545
+ name: data['name' ] ?? '' ,
546
+ ext: data['ext' ] ?? '' ,
547
+ path: data['path' ] ?? '' ,
548
+ fileKey: data['fileKey' ] ?? '' ,
549
+ contents: data['contents' ] ?? '' ,
550
+ seed: data['seed' ] ?? '' ,
551
+ error: data['error' ],
552
+ );
553
+ }
554
+
555
+ Map <String , dynamic > toJson () => {
556
+ 'head' : head,
557
+ 'tail' : tail,
558
+ 'id' : id,
559
+ 'history' : history,
560
+ 'name' : name,
561
+ 'ext' : ext,
562
+ 'path' : path,
563
+ 'fileKey' : fileKey,
564
+ 'contents' : contents,
565
+ 'seed' : seed,
566
+ 'error' : error,
567
+ };
568
+ }
0 commit comments