ClassQuiz · Study plan API · for the Unity and front-end teams

Study Plan API Flow

What the app calls at each screen, what it sends, and what it gets back. Pick a step to see a real request and response, captured from the API for a grade-5 test student, plus the fields the screen should read.

Base URL https://plan.class-quiz.com/api/v1 {student_id} = numeric ClassQuiz id, e.g. 535045 Responses: JsonUtility-safe · week.days[].subjects in requests needs Newtonsoft Errors: {"error": {code, message, details[]}} Simple version ↗ Swagger: try every call ↗ Demo app ↗
Calls the API Happens in the app only (no call)

Who talks to whom

The app only ever talks to the Study Plan API. The API looks the student up on ClassQuiz (token stays on the server) and keeps saved plans in its own database.

sequenceDiagram
  autonumber
  participant U as Unity app
  participant A as Study Plan API
  participant C as ClassQuiz
  participant D as Database
  U->>A: GET /students/{id}/setup
  A->>C: student profile (cached 10 min)
  A->>D: latest saved plan
  A-->>U: grade, subjects, periods, plans, latest plan
  loop every change of marks / priority / period / plan
    U->>A: POST /simulate  (+ POST /recommend)
    A-->>U: predicted marks, week cards, suggested week
  end
  Note over U: Student drags cards on the week (no call)
  opt Suggest pressed with cards already placed
    U->>A: POST /week/suggest
    A-->>U: the week completed around the student's cards
  end
  U->>A: POST /week/confirm  (marks, period, plan, week)
  A->>D: save plan + time split + week
  A-->>U: saved plan (id, week)
  opt Edit plan
    U->>A: PUT /week/edit
    A->>D: replace the week only
  end
  U->>A: GET /missions
  A->>D: latest plan + week
  A-->>U: one daily mission per slot + weekly missions

Where each piece of the weekly planner comes from

Rules the planner screen must follow

Placing cards

  • All 7 days, Monday first (day_index 0–6). Show them right to left.
  • Exactly week.rest_days rest days. A rest day holds no cards.
  • Never more than 5 cards on a day (week.max_cards_per_day). A study day may stay empty (a free day) once every card is placed.
  • Every card of cards[] is placed once (count of each subject), at most once per day.
  • Each card keeps its minutes from cards[].
  • Enable "أؤكد أسبوعي" only when all of the above hold. The server checks again on save.

When the student's board is invalid

"اقترح علي" never fails because of the board.

  • Valid start: their cards stay where they are and the rest is filled in.
  • Invalid start (e.g. too few days left for the rest days): their cards are dropped and recommended is a whole new week, with started_week_replaced: true.
  • "أؤكد أسبوعي" and "تعديل الخطة" still refuse an invalid week with invalid_week.

Texts to show

User-facing texts come ready in Arabic. Show them as they are; don't rebuild them from numbers.

  • name, label, description of plans and periods
  • name_ar of subjects and days
  • minutes_label, total_label, rest_label in the week
  • Mission description and completed_paragraph

Other endpoints

CallUse it for
GET /students/{id}/plans?limit=20&offset=0The student's plan history, newest first (items[]).
GET /students/{id}/plans/latestThe current plan. 404 not_found if none.
GET /students/{id}/plans/{saved_plan_id}One saved plan.
DELETE /students/{id}/plans/{saved_plan_id}Delete one saved plan → 204.
POST /simulate · /recommend · /week/suggestSame as the student versions, with "grade" in the body. For tests and "what if" screens.
GET /configAll reference data (grades, subjects, periods, plans, thresholds).
GET /healthIs the API up; database and ClassQuiz status.

Errors

Every error has the same shape. Show message to developers only; use code in the app.

codeHTTPWhen
invalid_student_id422student_id is not a number.
student_not_found404ClassQuiz doesn't know this student.
unsupported_level422The student isn't in primary grades 1–6.
invalid_subjects422Missing, duplicate, unknown or not-taught subject. Send exactly the subjects from setup.
invalid_months422months is not 1, 3, 6 or 9.
unknown_plan · invalid_plan422Bad plan_id, or a custom plan without valid days and hours.
invalid_week422Confirm / edit: not every card and rest day placed once, or no week sent.
not_found404No such saved plan for this student.
classquiz_unavailable502ClassQuiz unreachable. Retry later.
database_unavailable · database_error503Saving or loading failed. Simulate still works.