Student Examination Performance Analysis
You are tasked with developing a system to analyze student performance across various examinations. This system will help educators understand which students are excelling, which are struggling, and how different examinations are performing. This is crucial for identifying areas for improvement in teaching strategies and curriculum design.
Problem Description
You need to process a list of student examination records and calculate key performance metrics for each student and each examination.
What needs to be achieved:
- For each student, determine their overall average score and identify the examination they performed best in.
- For each examination, calculate the average score of all students who took it and identify the student who scored the highest in that examination.
Key Requirements:
- Input will be a collection of examination records. Each record will contain student information, examination details, and the score obtained.
- The system must be able to handle multiple students and multiple examinations.
- Output should be a structured summary of student and examination performance.
Expected Behavior:
- If a student has not taken any examinations, their average score should be 0, and their best-performing examination should be indicated as "N/A".
- If an examination has no students, its average score should be 0, and the top-performing student should be indicated as "N/A".
- Scores are numerical and can be fractional.
- If there's a tie for the best-performing student in an examination, any one of the tied students can be reported.
- If there's a tie for a student's best-performing examination, any one of the tied examinations can be reported.
Edge Cases to Consider:
- Empty input list of records.
- Students who took only one examination.
- Examinations taken by only one student.
- Scoring of 0.
Examples
Example 1:
Input:
[
{ "student_id": "S101", "student_name": "Alice", "exam_id": "E001", "exam_name": "Math", "score": 85.5 },
{ "student_id": "S101", "student_name": "Alice", "exam_id": "E002", "exam_name": "Science", "score": 92.0 },
{ "student_id": "S102", "student_name": "Bob", "exam_id": "E001", "exam_name": "Math", "score": 78.0 },
{ "student_id": "S102", "student_name": "Bob", "exam_id": "E002", "exam_name": "Science", "score": 88.5 },
{ "student_id": "S101", "student_name": "Alice", "exam_id": "E003", "exam_name": "History", "score": 95.0 }
]
Output:
{
"student_performance": {
"S101": {
"name": "Alice",
"average_score": 90.83, // (85.5 + 92.0 + 95.0) / 3
"best_exam": "History"
},
"S102": {
"name": "Bob",
"average_score": 83.25, // (78.0 + 88.5) / 2
"best_exam": "Science"
}
},
"exam_performance": {
"E001": {
"name": "Math",
"average_score": 81.75, // (85.5 + 78.0) / 2
"top_student": "S101"
},
"E002": {
"name": "Science",
"average_score": 90.25, // (92.0 + 88.5) / 2
"top_student": "S101"
},
"E003": {
"name": "History",
"average_score": 95.0, // 95.0 / 1
"top_student": "S101"
}
}
}
Explanation:
- Alice (S101) took Math, Science, and History. Her average is (85.5 + 92.0 + 95.0) / 3 = 90.83. Her best score was 95.0 in History.
- Bob (S102) took Math and Science. His average is (78.0 + 88.5) / 2 = 83.25. His best score was 88.5 in Science.
- Math (E001) had scores of 85.5 (Alice) and 78.0 (Bob). The average is (85.5 + 78.0) / 2 = 81.75. The top student is Alice (S101) with 85.5.
- Science (E002) had scores of 92.0 (Alice) and 88.5 (Bob). The average is (92.0 + 88.5) / 2 = 90.25. The top student is Alice (S101) with 92.0.
- History (E003) had a score of 95.0 (Alice). The average is 95.0. The top student is Alice (S101).
Example 2:
Input:
[
{ "student_id": "S103", "student_name": "Charlie", "exam_id": "E001", "exam_name": "Math", "score": 60.0 }
]
Output:
{
"student_performance": {
"S103": {
"name": "Charlie",
"average_score": 60.0,
"best_exam": "Math"
}
},
"exam_performance": {
"E001": {
"name": "Math",
"average_score": 60.0,
"top_student": "S103"
}
}
}
Explanation:
- Charlie (S103) took only Math, so his average is his score (60.0), and Math is his best exam.
- Math (E001) had only one student, Charlie (S103), with a score of 60.0. The average is 60.0, and the top student is Charlie.
Example 3: Empty Input
Input:
[]
Output:
{
"student_performance": {},
"exam_performance": {}
}
Explanation: With no records, there are no students or exams to report on.
Constraints
- The number of examination records will be between 0 and 100,000.
- Student IDs and Examination IDs will be unique strings.
- Student names and examination names will be strings.
- Scores will be floating-point numbers between 0.0 and 100.0 (inclusive).
- The solution should be efficient enough to process up to 100,000 records within a reasonable time limit (e.g., a few seconds).
Notes
- You will likely need to use data structures like dictionaries or hash maps to efficiently store and retrieve student and examination data.
- Consider how you will aggregate scores and counts for calculating averages.
- Pay attention to floating-point precision when calculating averages.
- The structure of the input records is assumed to be consistent.