20.1.11. Scheduled Auto-Close

Most challenges follow a simple pattern: they run for a fixed period, then an administrator needs to remember to press Close Challenge to award the winners. Auto-close removes the “remember to press the button” step.

images/challenges/lightmode/auto-close-toggle.png


20.1.11.1. Enabling auto-close on a challenge

On the Challenge Detail (Editor) editor, tick the Auto-close on end date checkbox. Save.

A challenge is eligible for auto-close when:

  • autoclose = 1

  • closed = 0 (hasn’t been closed yet)

  • enddate is in the past

20.1.11.2. The scheduled job

The backend exposes a dedicated cron hook:

POST /challenges/autoclose-run

Each time the endpoint is hit, it:

  1. Scans for challenges meeting the three conditions above.

  2. For each, calls ResolveParticipants + ComputeChallengeMetric + WriteChallengeResults to create the final snapshot.

  3. Calls CloseChallenge to award points, grant badges, queue notifications, and flip closed = 1.

  4. Returns a JSON summary: {"success":true,"scanned":N,"closed":M}.

20.1.11.3. Scheduling the job

The endpoint is idempotent and safe to call as often as you like – challenges already closed are skipped by the closed = 0 filter. A reasonable schedule is once an hour:

0 * * * * curl -s -X POST https://your-server/challenges/autoclose-run

Or once a day if end dates always fall on day boundaries:

15 1 * * * curl -s -X POST https://your-server/challenges/autoclose-run

Add the entry to clearPath’s own cron management page, or to the operating system’s crontab. The endpoint accepts no authentication by default – gate it at the HTTP layer if exposing to the public internet.

20.1.11.4. What auto-close does not do

  • Does not extend the enddate. Once past, the challenge closes on next scan.

  • Does not send a summary email to administrators. (Coming in a future release.)

  • Does not re-open a closed challenge or roll back an early close.

  • Does not affect challenges with autoclose = 0 – those still require a manual close.

20.1.11.5. Manual override

An administrator can still press Close Challenge on an auto-close challenge at any time before the end date. The early close is recorded with the same idempotent semantics; the scheduled job will then skip this challenge because closed = 1.

20.1.11.6. Troubleshooting

  • “My challenge ended yesterday but is still active.” – Check that Auto-close on end date is ticked (not just Active). The two flags are independent.

  • “The cron is running but nothing is closing.” – Hit the endpoint manually and read the response. scanned=0 means no challenges match the eligibility window; scanned>0, closed=0 means compute or close failed (check the server log for HandleChallengeAutoCloseRun entries).

  • “I want to close a challenge earlier than its end date.” – Either edit the end date then hit the cron, or just press Close Challenge manually.