Class SessionJsonWriter

java.lang.Object
com.studentgui.apphelpers.SessionJsonWriter

public final class SessionJsonWriter extends Object
Helper to write per-session JSON exports for app pages.
  • Method Details

    • writeSessionJson

      public static Path writeSessionJson(String student, String pageName, Object payload)
      Write a per-session JSON file into the student's StudentDataFiles folder. The filename will include a unix timestamp to ensure uniqueness per session.
      Parameters:
      student - display name of the student
      pageName - short page identifier (e.g. "Abacus")
      payload - arbitrary payload object to serialize (Map or POJO)
      Returns:
      the path to the written file, or null on failure
    • writeSessionJson

      public static Path writeSessionJson(String student, String pageName, Object payload, String explicitSessionId)
      Write a per-session JSON file and optionally include an explicit sessionId. If the explicit sessionId is null, this method will look for a "sessionId" entry inside the payload Map and use that if present. The envelope written to disk will include the sessionId when available. Filename format: PageName-<epoch>-<readable>[-session-<sessionId>].json
      Parameters:
      student - display name of the student
      pageName - short page identifier (e.g. "Abacus")
      payload - arbitrary payload object to serialize (Map or POJO)
      explicitSessionId - optional session id to use in the envelope and filename
      Returns:
      the path to the written file, or null on failure
    • writeSessionJson

      public static Path writeSessionJson(String student, String pageName, Object payload, int explicitSessionId)
      Convenience overload that accepts an int sessionId to avoid callers converting to String. Delegates to the string-based overload.
      Parameters:
      student - display name of the student
      pageName - short page identifier
      payload - arbitrary payload object
      explicitSessionId - numeric session id
      Returns:
      written file path or null
    • writeSessionJson

      public static Path writeSessionJson(String student, String pageName, String[] codes, int[] scores)
      Backwards-compatible convenience method for callers that still have (codes,scores) arrays. It wraps them in a small Map and delegates to the main payload-based writer.
      Parameters:
      student - the student's display name
      pageName - short page identifier (e.g. "Abacus")
      codes - array of part codes to include in the payload
      scores - array of scores corresponding to the codes
      Returns:
      path to the written JSON file, or null on failure