diff --git a/api/QuestionsApi/Controllers/ExamSimulationsController.cs b/api/QuestionsApi/Controllers/ExamSimulationsController.cs index 8e93819..6752192 100644 --- a/api/QuestionsApi/Controllers/ExamSimulationsController.cs +++ b/api/QuestionsApi/Controllers/ExamSimulationsController.cs @@ -41,8 +41,15 @@ public class ExamSimulationsController(ExamSimulationStore simulations) : Contro } [HttpGet("completed")] - public async Task Completed([FromQuery] int limit = 20, [FromQuery] DateTime? before = null) => - Ok(await simulations.GetCompletedAsync(UserId(), limit, before)); + public async Task Completed([FromQuery] int limit = 20, [FromQuery] string? before = null) + { + DateTime? cursor = null; + if (!string.IsNullOrWhiteSpace(before) && !DateTime.TryParse(before, null, System.Globalization.DateTimeStyles.RoundtripKind, out var parsed)) + return BadRequest("The completed-simulation cursor is invalid."); + else if (!string.IsNullOrWhiteSpace(before)) + cursor = parsed; + return Ok(await simulations.GetCompletedAsync(UserId(), limit, cursor)); + } [HttpGet("{id}")] public async Task Get(string id) diff --git a/scripts/autoload/exam_simulation_service.gd b/scripts/autoload/exam_simulation_service.gd index 467d1fa..d7c2e1c 100644 --- a/scripts/autoload/exam_simulation_service.gd +++ b/scripts/autoload/exam_simulation_service.gd @@ -173,7 +173,8 @@ func _on_request_completed(result: int, response_code: int, _headers: PackedStri if action == "history" or action == "history_append": var items: Array = parsed.get("items", []) completed_history = completed_history + items if action == "history_append" else items - completed_history_next_before = str(parsed.get("nextBefore", "")) + var next_before: Variant = parsed.get("nextBefore", null) + completed_history_next_before = "" if next_before == null else str(next_before) completed_history_changed.emit() return if action.begins_with("outcome_"):