Package com.studentgui.apphelpers
Class SessionJsonWriter
java.lang.Object
com.studentgui.apphelpers.SessionJsonWriter
Helper to write per-session JSON exports for app pages.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathwriteSessionJson(String student, String pageName, Object payload) Write a per-session JSON file into the student's StudentDataFiles folder.static PathwriteSessionJson(String student, String pageName, Object payload, int explicitSessionId) Convenience overload that accepts an int sessionId to avoid callers converting to String.static PathwriteSessionJson(String student, String pageName, Object payload, String explicitSessionId) Write a per-session JSON file and optionally include an explicit sessionId.static PathwriteSessionJson(String student, String pageName, String[] codes, int[] scores) Backwards-compatible convenience method for callers that still have (codes,scores) arrays.
-
Method Details
-
writeSessionJson
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 studentpageName- 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 studentpageName- 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 studentpageName- short page identifierpayload- arbitrary payload objectexplicitSessionId- numeric session id- Returns:
- written file path or null
-
writeSessionJson
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 namepageName- short page identifier (e.g. "Abacus")codes- array of part codes to include in the payloadscores- array of scores corresponding to the codes- Returns:
- path to the written JSON file, or null on failure
-