VR Session Complete API

VR Session Complete API

Mark a VR session as complete with optional score.

Endpoint

POST /api/vr-sessions/:sessionId/complete

Overview

Marks a VR learning session as complete. Supports self-reported completion with optional score entry. If the session is linked to a learning activity, the activity progress is automatically updated.

Authentication

Requires authentication. User must own the session.

Path Parameters

ParameterTypeDescription
sessionIduuidThe VR session ID

Request Body

All fields are optional:

{
  "score": 85,
  "time_spent_minutes": 30,
  "notes": "Completed all safety scenarios"
}
FieldTypeDescription
scorenumberScore 0-100 (optional)
time_spent_minutesnumberTime spent in minutes (optional)
notesstringCompletion notes, max 1000 chars (optional)

Response (200 OK)

{
  "session": {
    "id": "uuid",
    "package_id": "uuid",
    "activity_id": "uuid",
    "status": "completed",
    "completion_mode": "score_entry",
    "completed_at": "2025-01-15T11:30:00Z",
    "score": {
      "raw": 85,
      "max": 100,
      "scaled": 0.85
    },
    "success_status": "passed",
    "time_spent_seconds": 1800,
    "self_reported": true,
    "package": {
      "id": "uuid",
      "title": "Safety Training VR",
      "version": "1.0.0",
      "target_platforms": ["quest2", "quest3"]
    }
  },
  "message": "VR experience completed successfully"
}

Score Handling

When a score is provided:

  • score.raw: The provided score (0-100)
  • score.max: Always 100
  • score.scaled: Normalized score (raw/max)
  • success_status: "passed" if score >= 70, otherwise "failed"

Activity Progress Sync

If the session is linked to an activity_id, the following is automatically updated:

  • activity_progress.status → "completed"
  • activity_progress.score → provided score
  • activity_progress.completed_at → current timestamp
  • activity_progress.time_spent_seconds → provided time

Error Responses

StatusCodeDescription
400VALIDATION_ERRORInvalid request body
400ALREADY_COMPLETEDSession is already completed
401UNAUTHORIZEDAuthentication required
404PROFILE_NOT_FOUNDUser profile not found
404SESSION_NOT_FOUNDVR session not found or not owned by user
500DB_ERRORDatabase error

Example Requests

Simple Completion (Self-Report)

curl -X POST "https://api.allurelms.com/api/vr-sessions/abc123/complete" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

Completion with Score

curl -X POST "https://api.allurelms.com/api/vr-sessions/abc123/complete" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "score": 92,
    "time_spent_minutes": 45,
    "notes": "Completed all modules with excellent performance"
  }'

xAPI Integration

When a VR session is completed, the following xAPI statements are generated:

  • Verb: http://adlnet.gov/expapi/verbs/completed
  • Activity Type: http://activitystrea.ms/schema/1.0/application
  • Result: Includes score and success if provided

See xAPI Telemetry for more details.


Related