55 lines
1.3 KiB
Dart
55 lines
1.3 KiB
Dart
import 'course.dart';
|
|
|
|
/// Evaluation history record
|
|
class EvaluationHistory {
|
|
final String id;
|
|
final Course course;
|
|
final DateTime timestamp;
|
|
final bool success;
|
|
final String? errorMessage;
|
|
|
|
EvaluationHistory({
|
|
required this.id,
|
|
required this.course,
|
|
required this.timestamp,
|
|
required this.success,
|
|
this.errorMessage,
|
|
});
|
|
|
|
factory EvaluationHistory.fromJson(Map<String, dynamic> json) {
|
|
return EvaluationHistory(
|
|
id: json['id'] as String? ?? '',
|
|
course: Course.fromJson(json['course'] as Map<String, dynamic>),
|
|
timestamp: json['timestamp'] != null
|
|
? DateTime.parse(json['timestamp'] as String)
|
|
: DateTime.now(),
|
|
success: json['success'] as bool? ?? false,
|
|
errorMessage: json['errorMessage'] as String?,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'course': course.toJson(),
|
|
'timestamp': timestamp.toIso8601String(),
|
|
'success': success,
|
|
'errorMessage': errorMessage,
|
|
};
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'EvaluationHistory(id: $id, course: ${course.name}, success: $success, timestamp: $timestamp)';
|
|
}
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if (identical(this, other)) return true;
|
|
return other is EvaluationHistory && other.id == id;
|
|
}
|
|
|
|
@override
|
|
int get hashCode => id.hashCode;
|
|
}
|