|
|
|
@ -1,5 +1,3 @@
|
|
|
|
import 'package:get_storage/get_storage.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/pangea/common/config/environment.dart';
|
|
|
|
import 'package:fluffychat/pangea/common/config/environment.dart';
|
|
|
|
import 'package:fluffychat/pangea/course_plans/course_plan_model.dart';
|
|
|
|
import 'package:fluffychat/pangea/course_plans/course_plan_model.dart';
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/enums/language_level_type_enum.dart';
|
|
|
|
@ -8,10 +6,11 @@ import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_p
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_activity.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_activity.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_activity_media.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_activity_media.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_media.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_media.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_module.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_topic.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_module_location.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/models/course_plan/cms_course_plan_topic_location.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/payload_client.dart';
|
|
|
|
import 'package:fluffychat/pangea/payload_client/payload_client.dart';
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
|
|
|
|
import 'package:get_storage/get_storage.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class CourseFilter {
|
|
|
|
class CourseFilter {
|
|
|
|
final LanguageModel? targetLanguage;
|
|
|
|
final LanguageModel? targetLanguage;
|
|
|
|
@ -170,7 +169,7 @@ class CoursePlansRepo {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
final result = await payload.find(
|
|
|
|
final result = await payload.find(
|
|
|
|
"course-plans",
|
|
|
|
CmsCoursePlan.slug,
|
|
|
|
CmsCoursePlan.fromJson,
|
|
|
|
CmsCoursePlan.fromJson,
|
|
|
|
page: 1,
|
|
|
|
page: 1,
|
|
|
|
limit: 10,
|
|
|
|
limit: 10,
|
|
|
|
@ -197,14 +196,14 @@ class CoursePlansRepo {
|
|
|
|
CmsCoursePlan cmsCoursePlan,
|
|
|
|
CmsCoursePlan cmsCoursePlan,
|
|
|
|
) async {
|
|
|
|
) async {
|
|
|
|
final medias = await _getMedia(cmsCoursePlan);
|
|
|
|
final medias = await _getMedia(cmsCoursePlan);
|
|
|
|
final modules = await _getModules(cmsCoursePlan);
|
|
|
|
final topics = await _getTopics(cmsCoursePlan);
|
|
|
|
final locations = await _getModuleLocations(modules ?? []);
|
|
|
|
final locations = await _getTopicLocations(topics ?? []);
|
|
|
|
final activities = await _getModuleActivities(modules ?? []);
|
|
|
|
final activities = await _getTopicActivities(topics ?? []);
|
|
|
|
final activityMedias = await _getActivityMedia(activities ?? []);
|
|
|
|
final activityMedias = await _getActivityMedia(activities ?? []);
|
|
|
|
return CoursePlanModel.fromCmsDocs(
|
|
|
|
return CoursePlanModel.fromCmsDocs(
|
|
|
|
cmsCoursePlan,
|
|
|
|
cmsCoursePlan,
|
|
|
|
medias,
|
|
|
|
medias,
|
|
|
|
modules,
|
|
|
|
topics,
|
|
|
|
locations,
|
|
|
|
locations,
|
|
|
|
activities,
|
|
|
|
activities,
|
|
|
|
activityMedias,
|
|
|
|
activityMedias,
|
|
|
|
@ -222,7 +221,7 @@ class CoursePlansRepo {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
final limit = docs.length;
|
|
|
|
final limit = docs.length;
|
|
|
|
final cmsCoursePlanMediaResult = await payload.find(
|
|
|
|
final cmsCoursePlanMediaResult = await payload.find(
|
|
|
|
"course-plan-media",
|
|
|
|
CmsCoursePlanMedia.slug,
|
|
|
|
CmsCoursePlanMedia.fromJson,
|
|
|
|
CmsCoursePlanMedia.fromJson,
|
|
|
|
where: where,
|
|
|
|
where: where,
|
|
|
|
limit: limit,
|
|
|
|
limit: limit,
|
|
|
|
@ -232,34 +231,34 @@ class CoursePlansRepo {
|
|
|
|
return cmsCoursePlanMediaResult.docs;
|
|
|
|
return cmsCoursePlanMediaResult.docs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<List<CmsCoursePlanModule>?> _getModules(
|
|
|
|
static Future<List<CmsCoursePlanTopic>?> _getTopics(
|
|
|
|
CmsCoursePlan cmsCoursePlan,
|
|
|
|
CmsCoursePlan cmsCoursePlan,
|
|
|
|
) async {
|
|
|
|
) async {
|
|
|
|
final docs = cmsCoursePlan.coursePlanModules?.docs;
|
|
|
|
final docs = cmsCoursePlan.coursePlanTopics?.docs;
|
|
|
|
if (docs == null || docs.isEmpty) return null;
|
|
|
|
if (docs == null || docs.isEmpty) return null;
|
|
|
|
|
|
|
|
|
|
|
|
final where = {
|
|
|
|
final where = {
|
|
|
|
"id": {"in": docs.join(",")},
|
|
|
|
"id": {"in": docs.join(",")},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
final limit = docs.length;
|
|
|
|
final limit = docs.length;
|
|
|
|
final cmsCourseModulesResult = await payload.find(
|
|
|
|
final cmsCourseTopicsResult = await payload.find(
|
|
|
|
"course-plan-modules",
|
|
|
|
CmsCoursePlanTopic.slug,
|
|
|
|
CmsCoursePlanModule.fromJson,
|
|
|
|
CmsCoursePlanTopic.fromJson,
|
|
|
|
where: where,
|
|
|
|
where: where,
|
|
|
|
limit: limit,
|
|
|
|
limit: limit,
|
|
|
|
page: 1,
|
|
|
|
page: 1,
|
|
|
|
sort: "createdAt",
|
|
|
|
sort: "createdAt",
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return cmsCourseModulesResult.docs;
|
|
|
|
return cmsCourseTopicsResult.docs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<List<CmsCoursePlanModuleLocation>?> _getModuleLocations(
|
|
|
|
static Future<List<CmsCoursePlanTopicLocation>?> _getTopicLocations(
|
|
|
|
List<CmsCoursePlanModule> modules,
|
|
|
|
List<CmsCoursePlanTopic> topics,
|
|
|
|
) async {
|
|
|
|
) async {
|
|
|
|
final List<String> locations = [];
|
|
|
|
final List<String> locations = [];
|
|
|
|
for (final module in modules) {
|
|
|
|
for (final top in topics) {
|
|
|
|
if (module.coursePlanModuleLocations?.docs != null) {
|
|
|
|
if (top.coursePlanTopicLocations?.docs != null) {
|
|
|
|
locations.addAll(module.coursePlanModuleLocations!.docs!);
|
|
|
|
locations.addAll(top.coursePlanTopicLocations!.docs!);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (locations.isEmpty) return null;
|
|
|
|
if (locations.isEmpty) return null;
|
|
|
|
@ -268,24 +267,24 @@ class CoursePlansRepo {
|
|
|
|
"id": {"in": locations.join(",")},
|
|
|
|
"id": {"in": locations.join(",")},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
final limit = locations.length;
|
|
|
|
final limit = locations.length;
|
|
|
|
final cmsCoursePlanModuleLocationsResult = await payload.find(
|
|
|
|
final cmsCoursePlanTopicLocationsResult = await payload.find(
|
|
|
|
"course-plan-module-locations",
|
|
|
|
CmsCoursePlanTopicLocation.slug,
|
|
|
|
CmsCoursePlanModuleLocation.fromJson,
|
|
|
|
CmsCoursePlanTopicLocation.fromJson,
|
|
|
|
where: where,
|
|
|
|
where: where,
|
|
|
|
limit: limit,
|
|
|
|
limit: limit,
|
|
|
|
page: 1,
|
|
|
|
page: 1,
|
|
|
|
sort: "createdAt",
|
|
|
|
sort: "createdAt",
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return cmsCoursePlanModuleLocationsResult.docs;
|
|
|
|
return cmsCoursePlanTopicLocationsResult.docs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Future<List<CmsCoursePlanActivity>?> _getModuleActivities(
|
|
|
|
static Future<List<CmsCoursePlanActivity>?> _getTopicActivities(
|
|
|
|
List<CmsCoursePlanModule> module,
|
|
|
|
List<CmsCoursePlanTopic> topics,
|
|
|
|
) async {
|
|
|
|
) async {
|
|
|
|
final List<String> activities = [];
|
|
|
|
final List<String> activities = [];
|
|
|
|
for (final mod in module) {
|
|
|
|
for (final top in topics) {
|
|
|
|
if (mod.coursePlanActivities?.docs != null) {
|
|
|
|
if (top.coursePlanActivities?.docs != null) {
|
|
|
|
activities.addAll(mod.coursePlanActivities!.docs!);
|
|
|
|
activities.addAll(top.coursePlanActivities!.docs!);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (activities.isEmpty) return null;
|
|
|
|
if (activities.isEmpty) return null;
|
|
|
|
@ -295,7 +294,7 @@ class CoursePlansRepo {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
final limit = activities.length;
|
|
|
|
final limit = activities.length;
|
|
|
|
final cmsCoursePlanActivitiesResult = await payload.find(
|
|
|
|
final cmsCoursePlanActivitiesResult = await payload.find(
|
|
|
|
"course-plan-activities",
|
|
|
|
CmsCoursePlanActivity.slug,
|
|
|
|
CmsCoursePlanActivity.fromJson,
|
|
|
|
CmsCoursePlanActivity.fromJson,
|
|
|
|
where: where,
|
|
|
|
where: where,
|
|
|
|
limit: limit,
|
|
|
|
limit: limit,
|
|
|
|
@ -321,7 +320,7 @@ class CoursePlansRepo {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
final limit = mediaIds.length;
|
|
|
|
final limit = mediaIds.length;
|
|
|
|
final cmsCoursePlanActivityMediasResult = await payload.find(
|
|
|
|
final cmsCoursePlanActivityMediasResult = await payload.find(
|
|
|
|
"course-plan-activity-medias",
|
|
|
|
CmsCoursePlanActivityMedia.slug,
|
|
|
|
CmsCoursePlanActivityMedia.fromJson,
|
|
|
|
CmsCoursePlanActivityMedia.fromJson,
|
|
|
|
where: where,
|
|
|
|
where: where,
|
|
|
|
limit: limit,
|
|
|
|
limit: limit,
|
|
|
|
|