Repository navigation
Expand file tree
/
Copy pathtest-classroom-performance.js
More file actions
51 lines (42 loc) · 2.37 KB
/
Copy pathtest-classroom-performance.js
File metadata and controls
51 lines (42 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Test script to verify classroom performance endpoint returns real data
const axios = require('axios');
// Configuration - update these values as needed
const API_URL = process.env.API_URL || 'http://localhost:3001';
const CLASSROOM_ID = 1; // Update with a real classroom ID
async function testClassroomPerformance() {
try {
console.log(`\n🔍 Testing classroom performance endpoint for classroom ${CLASSROOM_ID}...`);
const response = await axios.get(`${API_URL}/api/classrooms/${CLASSROOM_ID}/performance`);
const performanceData = response.data;
console.log(`\n✅ Successfully fetched performance data for ${performanceData.length} students\n`);
// Check each student's data
performanceData.forEach((data, index) => {
console.log(`\nStudent ${index + 1}: ${data.student.name}`);
console.log('─'.repeat(40));
console.log(`Math Mastery: ${(data.performance.mathMastery * 100).toFixed(1)}%`);
console.log(`Average Score: ${data.performance.averageScore.toFixed(1)}%`);
console.log(`Questions Answered: ${data.performance.questionsAnswered}`);
console.log(`Time Spent: ${Math.floor(data.performance.timeSpent / 60)} minutes`);
console.log(`Last Active: ${data.performance.lastActive ? new Date(data.performance.lastActive).toLocaleString() : 'Never'}`);
console.log(`Intervention Needed: ${data.intervention.needed ? 'Yes' : 'No'}`);
if (data.intervention.needed) {
console.log(`Intervention Priority: ${data.intervention.priority}`);
console.log(`Reason: ${data.intervention.reason}`);
}
});
// Summary statistics
const avgMastery = performanceData.reduce((sum, d) => sum + d.performance.mathMastery, 0) / performanceData.length;
const needingIntervention = performanceData.filter(d => d.intervention.needed).length;
console.log('\n' + '═'.repeat(50));
console.log('SUMMARY:');
console.log(`Average Class Math Mastery: ${(avgMastery * 100).toFixed(1)}%`);
console.log(`Students Needing Intervention: ${needingIntervention} out of ${performanceData.length}`);
} catch (error) {
console.error('\n❌ Error testing classroom performance:', error.message);
if (error.response) {
console.error('Response data:', error.response.data);
}
}
}
// Run the test
testClassroomPerformance();