switch to enum for construct type

pull/1384/head
William Jordan-Cooley 1 year ago
parent 91d7600c5d
commit 5d5b35b4eb

@ -87,7 +87,7 @@ class PracticeGenerationController {
PracticeActivityModel dummyModel(PangeaMessageEvent event) =>
PracticeActivityModel(
tgtConstructs: [
ConstructIdentifier(lemma: "be", type: ConstructType.vocab.string),
ConstructIdentifier(lemma: "be", type: ConstructType.vocab),
],
activityType: ActivityType.multipleChoice,
langCode: event.messageDisplayLangCode,

@ -1,22 +1,25 @@
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
import 'package:fluffychat/pangea/models/practice_activities.dart/multiple_choice_activity_model.dart';
class ConstructIdentifier {
final String lemma;
final String type;
final ConstructType type;
ConstructIdentifier({required this.lemma, required this.type});
factory ConstructIdentifier.fromJson(Map<String, dynamic> json) {
return ConstructIdentifier(
lemma: json['lemma'] as String,
type: json['type'] as String,
type: ConstructType.values.firstWhere(
(e) => e.string == json['type'],
),
);
}
Map<String, dynamic> toJson() {
return {
'lemma': lemma,
'type': type,
'type': type.string,
};
}
}
@ -28,8 +31,11 @@ class CandidateMessage {
final String roomId;
final String text;
CandidateMessage(
{required this.msgId, required this.roomId, required this.text});
CandidateMessage({
required this.msgId,
required this.roomId,
required this.text,
});
factory CandidateMessage.fromJson(Map<String, dynamic> json) {
return CandidateMessage(

Loading…
Cancel
Save