/// Course data model representing a course that needs evaluation
class Course {
  final String id;
  final String name;
  final String teacher;
  final String evaluatedPeople;
  final String evaluatedPeopleNumber;
  final String coureSequenceNumber;
  final String evaluationContentNumber;
  final String questionnaireCode;
  final String questionnaireName;
  final bool isEvaluated;

  Course({
    required this.id,
    required this.name,
    required this.teacher,
    required this.evaluatedPeople,
    required this.evaluatedPeopleNumber,
    required this.coureSequenceNumber,
    required this.evaluationContentNumber,
    required this.questionnaireCode,
    required this.questionnaireName,
    this.isEvaluated = false,
  });

  /// Create Course from JSON
  factory Course.fromJson(Map<String, dynamic> json) {
    return Course(
      id: json['id'] as String? ?? '',
      name: json['name'] as String? ?? '',
      teacher: json['teacher'] as String? ?? '',
      evaluatedPeople: json['evaluatedPeople'] as String? ?? '',
      evaluatedPeopleNumber: json['evaluatedPeopleNumber'] as String? ?? '',
      coureSequenceNumber: json['coureSequenceNumber'] as String? ?? '',
      evaluationContentNumber: json['evaluationContentNumber'] as String? ?? '',
      questionnaireCode: json['questionnaireCode'] as String? ?? '',
      questionnaireName: json['questionnaireName'] as String? ?? '',
      isEvaluated: json['isEvaluated'] as bool? ?? false,
    );
  }

  /// Convert Course to JSON
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'teacher': teacher,
      'evaluatedPeople': evaluatedPeople,
      'evaluatedPeopleNumber': evaluatedPeopleNumber,
      'coureSequenceNumber': coureSequenceNumber,
      'evaluationContentNumber': evaluationContentNumber,
      'questionnaireCode': questionnaireCode,
      'questionnaireName': questionnaireName,
      'isEvaluated': isEvaluated,
    };
  }

  /// Create a copy of Course with updated fields
  Course copyWith({
    String? id,
    String? name,
    String? teacher,
    String? evaluatedPeople,
    String? evaluatedPeopleNumber,
    String? coureSequenceNumber,
    String? evaluationContentNumber,
    String? questionnaireCode,
    String? questionnaireName,
    bool? isEvaluated,
  }) {
    return Course(
      id: id ?? this.id,
      name: name ?? this.name,
      teacher: teacher ?? this.teacher,
      evaluatedPeople: evaluatedPeople ?? this.evaluatedPeople,
      evaluatedPeopleNumber:
          evaluatedPeopleNumber ?? this.evaluatedPeopleNumber,
      coureSequenceNumber: coureSequenceNumber ?? this.coureSequenceNumber,
      evaluationContentNumber:
          evaluationContentNumber ?? this.evaluationContentNumber,
      questionnaireCode: questionnaireCode ?? this.questionnaireCode,
      questionnaireName: questionnaireName ?? this.questionnaireName,
      isEvaluated: isEvaluated ?? this.isEvaluated,
    );
  }

  @override
  String toString() {
    return 'Course(id: $id, name: $name, teacher: $teacher, isEvaluated: $isEvaluated)';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;
    return other is Course && other.id == id;
  }

  @override
  int get hashCode => id.hashCode;
}
