@sunbird-cb/toc 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1898,7 +1898,9 @@ class AppTocService {
|
|
|
1898
1898
|
this.checkModuleWiseData(content);
|
|
1899
1899
|
// Compute milestone locking AFTER progress data is populated
|
|
1900
1900
|
if (content.courseCategory === 'Learning Pathway') {
|
|
1901
|
-
|
|
1901
|
+
// Check if user is enrolled by checking if enrollment data exists
|
|
1902
|
+
const isUserEnrolled = enrolmentList && enrolmentList.length > 0;
|
|
1903
|
+
this.computeMilestoneLockingStatus(isUserEnrolled);
|
|
1902
1904
|
// Ensure hashmap updates are published for change detection
|
|
1903
1905
|
this.hashmap = { ...this.hashmap };
|
|
1904
1906
|
}
|
|
@@ -2378,39 +2380,70 @@ class AppTocService {
|
|
|
2378
2380
|
*/
|
|
2379
2381
|
checkPreAssessmentCompletion() {
|
|
2380
2382
|
console.log('🔍 [PRE-ASSESSMENT] Starting pre-assessment completion check');
|
|
2381
|
-
// Find the Learning Pathway root
|
|
2383
|
+
// Find the Learning Pathway root - check multiple conditions
|
|
2382
2384
|
let learningPathwayId = null;
|
|
2383
2385
|
for (const key of Object.keys(this.hashmap)) {
|
|
2384
2386
|
const item = this.hashmap[key];
|
|
2385
|
-
if
|
|
2387
|
+
// Check if this is the Learning Pathway root by any of these conditions
|
|
2388
|
+
if (item.courseCategory === 'Learning Pathway' ||
|
|
2389
|
+
item.isLearningPathway === true ||
|
|
2390
|
+
(item.primaryCategory === 'Blended Program' && item.courseCategory === 'Learning Pathway')) {
|
|
2386
2391
|
learningPathwayId = key;
|
|
2392
|
+
console.log('🔍 [PRE-ASSESSMENT] Found Learning Pathway root:', key, item.name);
|
|
2387
2393
|
break;
|
|
2388
2394
|
}
|
|
2389
2395
|
}
|
|
2390
|
-
|
|
2396
|
+
if (!learningPathwayId) {
|
|
2397
|
+
console.log('⚠️ [PRE-ASSESSMENT] Learning Pathway root NOT FOUND - returning false to keep milestones locked');
|
|
2398
|
+
return false;
|
|
2399
|
+
}
|
|
2400
|
+
// 1. Look for items explicitly marked as pre-assessment (isPreAssessment flag)
|
|
2401
|
+
console.log('🔍 [PRE-ASSESSMENT] Step 1: Looking for items with isPreAssessment flag...');
|
|
2391
2402
|
for (const key of Object.keys(this.hashmap)) {
|
|
2392
2403
|
const item = this.hashmap[key];
|
|
2393
2404
|
if (item.isPreAssessment === true) {
|
|
2405
|
+
console.log('🔍 [PRE-ASSESSMENT] Found pre-assessment item:', {
|
|
2406
|
+
id: key,
|
|
2407
|
+
name: item.name,
|
|
2408
|
+
completionStatus: item.completionStatus,
|
|
2409
|
+
status: item.status,
|
|
2410
|
+
completionPercentage: item.completionPercentage,
|
|
2411
|
+
progress: item.progress
|
|
2412
|
+
});
|
|
2394
2413
|
const isCompleted = (item.completionStatus === 2 || item.status === 2 ||
|
|
2395
2414
|
(item.completionPercentage !== undefined && item.completionPercentage >= 100) ||
|
|
2396
2415
|
(item.progress !== undefined && item.progress >= 100));
|
|
2416
|
+
console.log('🔍 [PRE-ASSESSMENT] Pre-assessment completion result:', isCompleted ? '✅ COMPLETED' : '❌ NOT COMPLETED');
|
|
2397
2417
|
return isCompleted;
|
|
2398
2418
|
}
|
|
2399
2419
|
}
|
|
2400
2420
|
// 2. Find pre-assessment in hashmap - direct child of Learning Pathway that is NOT a milestone
|
|
2421
|
+
// This is a fallback for cases where isPreAssessment flag is not set
|
|
2422
|
+
console.log('🔍 [PRE-ASSESSMENT] Step 2: Looking for non-milestone direct children of Learning Pathway...');
|
|
2401
2423
|
for (const key of Object.keys(this.hashmap)) {
|
|
2402
2424
|
const item = this.hashmap[key];
|
|
2425
|
+
// Must be a direct child of the Learning Pathway
|
|
2403
2426
|
if (item.parent !== learningPathwayId)
|
|
2404
2427
|
continue;
|
|
2405
|
-
|
|
2428
|
+
// Skip milestones
|
|
2429
|
+
if (item.isMilestone || item.primaryCategory === 'Milestone' || item.courseCategory === 'Milestone')
|
|
2406
2430
|
continue;
|
|
2431
|
+
console.log('🔍 [PRE-ASSESSMENT] Found non-milestone child:', {
|
|
2432
|
+
id: key,
|
|
2433
|
+
name: item.name,
|
|
2434
|
+
primaryCategory: item.primaryCategory,
|
|
2435
|
+
completionStatus: item.completionStatus,
|
|
2436
|
+
status: item.status,
|
|
2437
|
+
completionPercentage: item.completionPercentage
|
|
2438
|
+
});
|
|
2407
2439
|
const isCompleted = (item.completionStatus === 2 || item.status === 2 ||
|
|
2408
2440
|
(item.completionPercentage !== undefined && item.completionPercentage >= 100) ||
|
|
2409
2441
|
(item.progress !== undefined && item.progress >= 100));
|
|
2442
|
+
console.log('🔍 [PRE-ASSESSMENT] Non-milestone child completion result:', isCompleted ? '✅ COMPLETED' : '❌ NOT COMPLETED');
|
|
2410
2443
|
return isCompleted;
|
|
2411
2444
|
}
|
|
2412
|
-
// 3. If we reach here,
|
|
2413
|
-
|
|
2445
|
+
// 3. If we reach here, no pre-assessment found - enforce M1 locked
|
|
2446
|
+
console.log('⚠️ [PRE-ASSESSMENT] No pre-assessment found - returning false to keep M1 locked');
|
|
2414
2447
|
return false;
|
|
2415
2448
|
}
|
|
2416
2449
|
/**
|
|
@@ -2569,35 +2602,19 @@ class AppTocService {
|
|
|
2569
2602
|
const assessmentCompleted = latestAssessment.completionStatus === 2 ||
|
|
2570
2603
|
latestAssessment.status === 2 ||
|
|
2571
2604
|
latestAssessment.completionPercentage >= 100;
|
|
2572
|
-
if
|
|
2573
|
-
|
|
2574
|
-
this.hashmap[assessmentId].milestoneAssessmentLocked = false;
|
|
2575
|
-
this.hashmap[assessmentId].assessmentLockMessage = '';
|
|
2576
|
-
console.log(`Assessment ${assessmentId} is completed - unlocking`);
|
|
2577
|
-
return;
|
|
2578
|
-
}
|
|
2579
|
-
// Count mandatory courses and check their completion
|
|
2605
|
+
// Always check if all mandatory courses are complete, even if assessment is not completed
|
|
2606
|
+
// This ensures assessment is unlocked as soon as all mandatory courses are done
|
|
2580
2607
|
let mandatoryCount = 0;
|
|
2581
2608
|
let completedMandatoryCount = 0;
|
|
2609
|
+
console.log(`[ASSESSMENT LOCK CHECK] Checking mandatory courses for milestone: ${milestoneId}`);
|
|
2582
2610
|
for (const key of Object.keys(this.hashmap)) {
|
|
2583
2611
|
const item = this.hashmap[key];
|
|
2584
|
-
// Skip the assessment itself
|
|
2585
2612
|
if (key === assessmentId)
|
|
2586
2613
|
continue;
|
|
2587
|
-
//
|
|
2588
|
-
|
|
2589
|
-
if (item.parent === milestoneId) {
|
|
2590
|
-
belongsToMilestone = true;
|
|
2591
|
-
}
|
|
2592
|
-
else if (item.parent && this.hashmap[item.parent]) {
|
|
2593
|
-
const parentItem = this.hashmap[item.parent];
|
|
2594
|
-
if (parentItem.parent === milestoneId && parentItem.primaryCategory === 'Course') {
|
|
2595
|
-
belongsToMilestone = true;
|
|
2596
|
-
}
|
|
2597
|
-
}
|
|
2598
|
-
if (!belongsToMilestone)
|
|
2614
|
+
// Only check DIRECT children of the milestone (courses)
|
|
2615
|
+
if (item.parent !== milestoneId)
|
|
2599
2616
|
continue;
|
|
2600
|
-
//
|
|
2617
|
+
// Skip assessments
|
|
2601
2618
|
const isItemAssessment = item.primaryCategory === 'Course Assessment' ||
|
|
2602
2619
|
item.primaryCategory === 'Final Assessment' ||
|
|
2603
2620
|
item.primaryCategory === 'Standalone Assessment' ||
|
|
@@ -2606,32 +2623,54 @@ class AppTocService {
|
|
|
2606
2623
|
(item.name && item.name.toLowerCase().includes('assessment'));
|
|
2607
2624
|
if (isItemAssessment)
|
|
2608
2625
|
continue;
|
|
2609
|
-
//
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2626
|
+
// Only count courses, not other content types
|
|
2627
|
+
if (item.primaryCategory !== 'Course')
|
|
2628
|
+
continue;
|
|
2629
|
+
// Check if this course is mandatory
|
|
2630
|
+
const isMandatory = item.isMandatory !== false;
|
|
2613
2631
|
if (isMandatory) {
|
|
2614
2632
|
mandatoryCount++;
|
|
2615
2633
|
const isCompleted = item.completionStatus === 2 ||
|
|
2616
2634
|
item.status === 2 ||
|
|
2617
2635
|
item.completionPercentage >= 100 ||
|
|
2618
2636
|
item.progress >= 100;
|
|
2637
|
+
console.log(` Course: ${item.name}`, {
|
|
2638
|
+
isMandatory,
|
|
2639
|
+
completionStatus: item.completionStatus,
|
|
2640
|
+
status: item.status,
|
|
2641
|
+
completionPercentage: item.completionPercentage,
|
|
2642
|
+
progress: item.progress,
|
|
2643
|
+
isCompleted
|
|
2644
|
+
});
|
|
2619
2645
|
if (isCompleted) {
|
|
2620
2646
|
completedMandatoryCount++;
|
|
2621
2647
|
}
|
|
2622
2648
|
}
|
|
2623
2649
|
}
|
|
2624
|
-
// Determine if assessment should be locked
|
|
2625
2650
|
const allMandatoryComplete = mandatoryCount === 0 || completedMandatoryCount >= mandatoryCount;
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2651
|
+
console.log(`[ASSESSMENT LOCK CHECK] Summary:`, {
|
|
2652
|
+
mandatoryCount,
|
|
2653
|
+
completedMandatoryCount,
|
|
2654
|
+
allMandatoryComplete,
|
|
2655
|
+
assessmentCompleted,
|
|
2656
|
+
willUnlock: assessmentCompleted || allMandatoryComplete
|
|
2657
|
+
});
|
|
2658
|
+
if (assessmentCompleted || allMandatoryComplete) {
|
|
2659
|
+
this.hashmap[assessmentId].isAssessmentLocked = false;
|
|
2660
|
+
this.hashmap[assessmentId].milestoneAssessmentLocked = false;
|
|
2661
|
+
this.hashmap[assessmentId].assessmentLockMessage = '';
|
|
2662
|
+
console.log(`✅ Assessment ${assessmentId} is UNLOCKED (completed or all mandatory done)`);
|
|
2663
|
+
return;
|
|
2664
|
+
}
|
|
2665
|
+
// If not unlocked, lock the assessment
|
|
2666
|
+
this.hashmap[assessmentId].isAssessmentLocked = true;
|
|
2667
|
+
this.hashmap[assessmentId].milestoneAssessmentLocked = true;
|
|
2668
|
+
this.hashmap[assessmentId].assessmentLockMessage = 'This content is locked. Complete all mandatory items to unlock the assessment.';
|
|
2669
|
+
console.log(`🔒 Assessment ${assessmentId} is LOCKED:`, {
|
|
2631
2670
|
mandatoryCount,
|
|
2632
2671
|
completedMandatoryCount,
|
|
2633
|
-
isLocked:
|
|
2634
|
-
milestoneAssessmentLocked:
|
|
2672
|
+
isLocked: true,
|
|
2673
|
+
milestoneAssessmentLocked: true
|
|
2635
2674
|
});
|
|
2636
2675
|
}
|
|
2637
2676
|
/**
|