module api_modules.classroom_compliance.model;

import ddbc : DataSetReader;
import handy_httpd.components.optional;
import std.json;
import std.datetime;
import std.string : split;

struct ClassroomComplianceClass {
    ulong id;
    ushort number;
    string schoolYear;
    bool archived;
    ulong userId;
    string scoreExpression;
    string scorePeriod;

    static ClassroomComplianceClass parse(DataSetReader r) {
        return ClassroomComplianceClass(
            r.getUlong(1),
            r.getUshort(2),
            r.getString(3),
            r.getBoolean(7),
            r.getUlong(4),
            r.getString(5),
            r.getString(6)
        );
    }
}

struct ClassroomComplianceStudent {
    ulong id;
    string name;
    ulong classId;
    ushort deskNumber;
    bool removed;

    static ClassroomComplianceStudent parse(DataSetReader r) {
        return ClassroomComplianceStudent(
            r.getUlong(1),
            r.getString(2),
            r.getUlong(3),
            r.getUshort(4),
            r.getBoolean(5)
        );
    }
}

struct ClassroomComplianceEntry {
    ulong classId;
    ulong studentId;
    Date date;

    ulong createdAt;
    bool absent;
    string comment;
}

struct ClassroomComplianceEntryChecklistItem {
    string item;
    bool checked;
    string category;
}

struct ClassroomComplianceClassNote {
    ulong id;
    ulong classId;
    ulong createdAt;
    string content;

    static ClassroomComplianceClassNote parse(DataSetReader r) {
        return ClassroomComplianceClassNote(
            r.getUlong(1),
            r.getUlong(2),
            r.getUlong(3),
            r.getString(4)
        );
    }
}
