or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

Student Grade Tracker

Build a student grade tracking system that persists and restores grade data with automatic list initialization for new students.

Requirements

The system should track student grades across multiple subjects. When a new student is added or when loading data from storage, the system should automatically initialize an empty list of grades if the student doesn't have any yet.

Core Functionality

Implement a GradeTracker class with the following behavior:

  1. Data Structure: Store student grades using a structure that automatically initializes an empty list for new students
  2. Add Grade: Add a numerical grade for a specific student
  3. Get Grades: Retrieve all grades for a specific student (returns empty list if student has no grades)
  4. Serialization: Convert the grade tracker to a JSON-compatible format
  5. Deserialization: Restore the grade tracker from a JSON-compatible format, preserving the automatic initialization behavior

Test Cases

  • Adding a grade for a new student automatically initializes their grade list @test
  • Retrieving grades for a student with no grades returns an empty list @test
  • Serializing and deserializing the grade tracker preserves all student grades @test
  • After deserialization, adding a grade for a new student still works correctly @test

Implementation

@generates

API

from typing import List

class GradeTracker:
    """Tracks student grades with automatic list initialization."""

    def __init__(self):
        """Initialize the grade tracker."""
        pass

    def add_grade(self, student_name: str, grade: float) -> None:
        """
        Add a grade for a student.

        Args:
            student_name: The name of the student
            grade: The numerical grade to add
        """
        pass

    def get_grades(self, student_name: str) -> List[float]:
        """
        Get all grades for a student.

        Args:
            student_name: The name of the student

        Returns:
            List of grades for the student (empty list if no grades)
        """
        pass

    def to_json(self) -> dict:
        """
        Serialize the grade tracker to a JSON-compatible dictionary.

        Returns:
            Dictionary representation of the grade tracker
        """
        pass

    @staticmethod
    def from_json(data: dict) -> 'GradeTracker':
        """
        Deserialize a grade tracker from a JSON-compatible dictionary.

        Args:
            data: Dictionary representation of the grade tracker

        Returns:
            A new GradeTracker instance with the deserialized data
        """
        pass

Dependencies { .dependencies }

jsons { .dependency }

Provides JSON serialization and deserialization support for Python objects.