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
| Parameter | Type | Description |
|---|---|---|
| sessionId | uuid | The VR session ID |
Request Body
All fields are optional:
{
"score": 85,
"time_spent_minutes": 30,
"notes": "Completed all safety scenarios"
}
| Field | Type | Description |
|---|---|---|
| score | number | Score 0-100 (optional) |
| time_spent_minutes | number | Time spent in minutes (optional) |
| notes | string | Completion 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 scoreactivity_progress.completed_at→ current timestampactivity_progress.time_spent_seconds→ provided time
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid request body |
| 400 | ALREADY_COMPLETED | Session is already completed |
| 401 | UNAUTHORIZED | Authentication required |
| 404 | PROFILE_NOT_FOUND | User profile not found |
| 404 | SESSION_NOT_FOUND | VR session not found or not owned by user |
| 500 | DB_ERROR | Database 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
- VR Sessions - Create and list sessions
- VR Packages - Manage VR packages
- Progress Tracking - Activity progress