diff --git a/mobile-app/integration_test/learn/learn_landing.dart b/mobile-app/integration_test/learn/learn_landing.dart index 5cc802017..f30638c83 100644 --- a/mobile-app/integration_test/learn/learn_landing.dart +++ b/mobile-app/integration_test/learn/learn_landing.dart @@ -22,7 +22,18 @@ void main() { String baseUrl = LearnService.baseUrl; final Response res = await dio.get('$baseUrl/available-superblocks.json'); - List superBlocks = res.data['superblocks']; + Map superBlockStages = res.data['superblocks']; + + List> superBlocks = []; + for (var stage in superBlockStages.keys) { + List stageBlocks = superBlockStages[stage]; + for (var superBlock in stageBlocks) { + if (!superBlock['dashedName'].toString().contains('full-stack')) { + superBlocks.add(superBlock); + } + } + } + int publicSuperBlocks = 0; for (int i = 0; i < superBlocks.length; i++) { @@ -39,7 +50,7 @@ void main() { ); expect( superBlockButtons, - findsNWidgets(superBlocks.length - 1), // Exclude 'full-stack' superblock + findsNWidgets(superBlocks.length), ); expect(publicSuperBlockButtons, findsNWidgets(publicSuperBlocks)); diff --git a/mobile-app/lib/models/learn/curriculum_model.dart b/mobile-app/lib/models/learn/curriculum_model.dart index e5989d92f..5f1e16400 100644 --- a/mobile-app/lib/models/learn/curriculum_model.dart +++ b/mobile-app/lib/models/learn/curriculum_model.dart @@ -1,6 +1,12 @@ const chapterBasedSuperBlocks = ['full-stack-developer']; enum SuperBlocks { + respWebDesignV9('responsive-web-design-v9'), + javascriptV9('javascript-v9'), + frontEndDevLibsV9('front-end-development-libraries-v9'), + pythonV9('python-v9'), + relationalDbV9('relational-databases-v9'), + backEndDevApisV9('back-end-development-and-apis-v9'), respWebDesignNew('2022/responsive-web-design'), respWebDesign('responsive-web-design'), jsAlgoDataStruct('javascript-algorithms-and-data-structures'), diff --git a/mobile-app/lib/service/learn/learn_service.dart b/mobile-app/lib/service/learn/learn_service.dart index 9f8651b4d..eed7d1122 100644 --- a/mobile-app/lib/service/learn/learn_service.dart +++ b/mobile-app/lib/service/learn/learn_service.dart @@ -26,10 +26,7 @@ class LearnService { final Dio _dio = DioService.dio; - // TODO: change this to v2 and remove baseUrlV2 once the migration is complete - static final baseUrl = '${AuthenticationService.baseURL}/curriculum-data/v1'; - static final baseUrlV2 = - '${AuthenticationService.baseURL}/curriculum-data/v2'; + static final baseUrl = '${AuthenticationService.baseURL}/curriculum-data/v2'; final LearnOfflineService learnOfflineService = locator(); @@ -62,7 +59,7 @@ class LearnService { String challengeId = challenge.id; int challengeType = challenge.challengeType; - Response submitTypesRes = await _dio.get('$baseUrlV2/submit-types.json'); + Response submitTypesRes = await _dio.get('$baseUrl/submit-types.json'); Map submitTypes = submitTypesRes.data; switch (submitTypes[challengeType.toString()]) { diff --git a/mobile-app/lib/ui/views/learn/challenge/challenge_viewmodel.dart b/mobile-app/lib/ui/views/learn/challenge/challenge_viewmodel.dart index d3e339d18..aa9f1b285 100644 --- a/mobile-app/lib/ui/views/learn/challenge/challenge_viewmodel.dart +++ b/mobile-app/lib/ui/views/learn/challenge/challenge_viewmodel.dart @@ -661,7 +661,7 @@ class ChallengeViewModel extends BaseViewModel { ); String slug = block!.challengeTiles[challengeIndex].id; - String url = LearnService.baseUrlV2; + String url = LearnService.baseUrl; String challengeUrl = '$url/challenges/${block!.superBlock.dashedName}/${block!.dashedName}/$slug.json'; diff --git a/mobile-app/lib/ui/views/learn/challenge/templates/template_viewmodel.dart b/mobile-app/lib/ui/views/learn/challenge/templates/template_viewmodel.dart index 9872fabba..08831561d 100644 --- a/mobile-app/lib/ui/views/learn/challenge/templates/template_viewmodel.dart +++ b/mobile-app/lib/ui/views/learn/challenge/templates/template_viewmodel.dart @@ -24,7 +24,7 @@ class ChallengeTemplateViewModel extends BaseViewModel { void initiate(Block block, String challengeId, DateTime? challengeDate) { if (challengeDate == null) { - final String base = LearnService.baseUrlV2; + final String base = LearnService.baseUrl; String url = '$base/challenges/${block.superBlock.dashedName}/${block.dashedName}/$challengeId.json'; diff --git a/mobile-app/lib/ui/views/learn/chapter/chapter_viewmodel.dart b/mobile-app/lib/ui/views/learn/chapter/chapter_viewmodel.dart index 61ee7050e..88fc39423 100644 --- a/mobile-app/lib/ui/views/learn/chapter/chapter_viewmodel.dart +++ b/mobile-app/lib/ui/views/learn/chapter/chapter_viewmodel.dart @@ -64,7 +64,7 @@ class ChapterViewModel extends BaseViewModel { } Future requestChapters() async { - String baseUrl = LearnService.baseUrlV2; + String baseUrl = LearnService.baseUrl; final Response res = await _dio.get('$baseUrl/full-stack-developer.json'); if (res.statusCode == 200) { diff --git a/mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart b/mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart index fb28b52ab..1ad0bcb8f 100644 --- a/mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart +++ b/mobile-app/lib/ui/views/learn/landing/landing_viewmodel.dart @@ -220,44 +220,49 @@ class LearnLandingViewModel extends BaseViewModel { bool showAllSB = dotenv.get('SHOWALLSB', fallback: 'false').toLowerCase() == 'true'; - // Map superBlockStages = res.data['superblocks']; - // for (var superBlockStage in superBlockStages.keys) { - // layout.add(Padding( - // padding: const EdgeInsets.all(8.0), - // child: handleStageTitle(superBlockStage), - // )); - - // for (var superBlock in superBlockStages[superBlockStage]) { - // layout.add( - // SuperBlockButton( - // button: SuperBlockButtonData( - // path: superBlock['dashedName'], - // name: superBlock['title'], - // public: !showAllSB ? superBlock['public'] : true, - // ), - // model: this, - // ), - // ); - // } - // } - - List superBlocks = res.data['superblocks']; - for (int i = 0; i < superBlocks.length; i++) { - if (superBlocks[i]['dashedName'].toString().contains('full-stack')) { - continue; + Map superBlockStages = res.data['superblocks']; + + List stageOrder = [ + 'legacy', + 'professional', + 'extra', + 'core', + 'english' + ]; + + List publicButtons = []; + List nonPublicButtons = []; + + for (var stage in stageOrder) { + if (superBlockStages.containsKey(stage)) { + List stageBlocks = superBlockStages[stage]; + + for (var superBlock in stageBlocks) { + if (superBlock['dashedName'].toString().contains('full-stack')) { + continue; + } + + bool isPublic = superBlock['public'] ?? false; + Widget button = SuperBlockButton( + button: SuperBlockButtonData( + path: superBlock['dashedName'], + name: superBlock['title'], + public: !showAllSB ? superBlock['public'] : true, + ), + model: this, + ); + + if (isPublic) { + publicButtons.add(button); + } else { + nonPublicButtons.add(button); + } + } } - layout.add( - SuperBlockButton( - button: SuperBlockButtonData( - path: superBlocks[i]['dashedName'], - name: superBlocks[i]['title'], - public: !showAllSB ? superBlocks[i]['public'] : true, - ), - model: this, - ), - ); } + layout = [...publicButtons, ...nonPublicButtons]; + return layout; } return []; diff --git a/mobile-app/lib/ui/views/learn/superblock/superblock_viewmodel.dart b/mobile-app/lib/ui/views/learn/superblock/superblock_viewmodel.dart index 2c615e07f..2f515e3e9 100644 --- a/mobile-app/lib/ui/views/learn/superblock/superblock_viewmodel.dart +++ b/mobile-app/lib/ui/views/learn/superblock/superblock_viewmodel.dart @@ -62,7 +62,7 @@ class SuperBlockViewModel extends BaseViewModel { String name, bool hasInternet, ) async { - String baseUrl = LearnService.baseUrlV2; + String baseUrl = LearnService.baseUrl; if (!hasInternet) { return SuperBlock(