😋 初始化仓库
This commit is contained in:
54
lib/models/evaluation_history.dart
Normal file
54
lib/models/evaluation_history.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user