105 lines
4.0 KiB
Dart
105 lines
4.0 KiB
Dart
/// Real Lesson Model from /api/student/lessons
|
|
class LessonModel {
|
|
final int id;
|
|
final int courseId;
|
|
final String title;
|
|
final int sequenceOrder;
|
|
final String storageType;
|
|
final String? videoUuid;
|
|
final String? hlsUrl;
|
|
final String? thumbnailUrl;
|
|
final String? aiVideoUrl;
|
|
final int durationSeconds;
|
|
final bool isFreePreview;
|
|
final String courseTitle;
|
|
final bool isAiVersion;
|
|
final int? checkpointCount;
|
|
|
|
LessonModel({
|
|
required this.id,
|
|
required this.courseId,
|
|
required this.title,
|
|
required this.sequenceOrder,
|
|
required this.storageType,
|
|
this.videoUuid,
|
|
this.hlsUrl,
|
|
this.thumbnailUrl,
|
|
this.aiVideoUrl,
|
|
required this.durationSeconds,
|
|
required this.isFreePreview,
|
|
required this.courseTitle,
|
|
required this.isAiVersion,
|
|
this.checkpointCount,
|
|
});
|
|
|
|
factory LessonModel.fromJson(Map<String, dynamic> json) {
|
|
return LessonModel(
|
|
id: json['id'] is int ? json['id'] : int.tryParse(json['id']?.toString() ?? '0') ?? 0,
|
|
courseId: json['course_id'] is int ? json['course_id'] : int.tryParse(json['course_id']?.toString() ?? '0') ?? 0,
|
|
title: json['title']?.toString() ?? 'درس تفاعلي',
|
|
sequenceOrder: json['sequence_order'] is int ? json['sequence_order'] : int.tryParse(json['sequence_order']?.toString() ?? '1') ?? 1,
|
|
storageType: json['storage_type']?.toString() ?? 'local',
|
|
videoUuid: json['video_uuid']?.toString(),
|
|
hlsUrl: json['hls_url']?.toString(),
|
|
thumbnailUrl: json['thumbnail_url']?.toString(),
|
|
aiVideoUrl: json['ai_video_url']?.toString(),
|
|
durationSeconds: json['duration_seconds'] is int ? json['duration_seconds'] : int.tryParse(json['duration_seconds']?.toString() ?? '0') ?? 0,
|
|
isFreePreview: json['is_free_preview'] == 1 || json['is_free_preview'] == true,
|
|
courseTitle: json['course_title']?.toString() ?? 'المنهاج المعتمد',
|
|
isAiVersion: json['is_ai_version'] == 1 || json['is_ai_version'] == true,
|
|
checkpointCount: json['checkpoint_count'] is int ? json['checkpoint_count'] : int.tryParse(json['checkpoint_count']?.toString() ?? '0'),
|
|
);
|
|
}
|
|
|
|
String get formattedDuration {
|
|
if (durationSeconds <= 0) return 'درس تفاعلي';
|
|
final minutes = durationSeconds ~/ 60;
|
|
final seconds = durationSeconds % 60;
|
|
return '$minutes دقيقة ${seconds > 0 ? '$seconds ثانية' : ''}';
|
|
}
|
|
}
|
|
|
|
/// Real Child Profile & Academic Progress Model for Guardian
|
|
class GuardianChildModel {
|
|
final int id;
|
|
final String uuid;
|
|
final String name;
|
|
final String? nationalId;
|
|
final String? gradeLevel;
|
|
final String? stream;
|
|
final String? schoolName;
|
|
final double readinessScore;
|
|
final int examsPassed;
|
|
final int examsTotal;
|
|
|
|
GuardianChildModel({
|
|
required this.id,
|
|
required this.uuid,
|
|
required this.name,
|
|
this.nationalId,
|
|
this.gradeLevel,
|
|
this.stream,
|
|
this.schoolName,
|
|
this.readinessScore = 0.0,
|
|
this.examsPassed = 0,
|
|
this.examsTotal = 0,
|
|
});
|
|
|
|
factory GuardianChildModel.fromJson(Map<String, dynamic> json) {
|
|
return GuardianChildModel(
|
|
id: json['id'] is int ? json['id'] : int.tryParse(json['id']?.toString() ?? '0') ?? 0,
|
|
uuid: json['uuid']?.toString() ?? '',
|
|
name: json['full_name']?.toString() ?? json['name']?.toString() ?? 'الطالب',
|
|
nationalId: json['national_id']?.toString(),
|
|
gradeLevel: json['grade_level']?.toString(),
|
|
stream: json['stream']?.toString(),
|
|
schoolName: json['school_name']?.toString() ?? 'مدرسة معتمدة',
|
|
readinessScore: json['tawjihi_readiness_score'] != null
|
|
? double.tryParse(json['tawjihi_readiness_score'].toString()) ?? 0.0
|
|
: (json['readiness_score'] != null ? double.tryParse(json['readiness_score'].toString()) ?? 0.0 : 0.0),
|
|
examsPassed: json['exams_passed_count'] is int ? json['exams_passed_count'] : int.tryParse(json['exams_passed_count']?.toString() ?? '0') ?? 0,
|
|
examsTotal: json['exams_total_count'] is int ? json['exams_total_count'] : int.tryParse(json['exams_total_count']?.toString() ?? '0') ?? 0,
|
|
);
|
|
}
|
|
}
|