---
# System prepended metadata

title: Webackend

---

## Preface:

Today the activity sequence is pre-generated when the lesson is activated for standalone resources
Ref: 
`voxy.apps.activities.views_api.ExploreLessonView`. Based on the activites pod discussion the activity sequence should be generated dynamically for better learning experience. The following endpoints design is based on the aforementioned assumption.

The activity service will only be responsible for generating the activity sequence based on the resource and learner parameters.

The webackend service will be responsible for tracking learner progress, reporting and wordbank. 


**Note**: All the endpoints are only accessible by an authenticated user


# Webackend

## ** POST /api/v0/lesson-progress/**

This endpoint gets or creates a lesson-progress object


**Request Payload**
```
resource_id: "61d1e32b52cdf51845dbeeaa"
user_id: ""
unit_progress_id: 
```

**Example Response**
```
id : 152315126
activity_progresses : [{
    id: 523673732
    type: "picture-perfect"
    status: "complete"
},
{
    id: 523673737
    type: "quiz"
    status: "complete"
}]
]
```

**Example Response**
```
id : 523673732
activity_progresses : ""

```


## **PUT /api/v0/lesson-progress/<lesson-progress-id>**
    
This endpoint creates activity-progresses and updates lesson-progress

We track `seconds_elapsed` and `word_performance` in activity progress, not sure if its still relevant to capture this information

**Request Payload**
```
  activity_type: "picture-perfect"
  total_answers: 3 
  correct_answers: 3
  word_performance: ""
```

**Example Response**
```
{
	"activity_progress": 523673732,
	"status": complete
}
```
    
## POST /api/v0/UserEvents**

These events would be sent to stream which would be consumed by `time on task`/`wordbank`/`recommendation` service

**Request Payload**
```
activity_type: "imagetagger"
event_type: "start_activity"
skill : "Vocabulary"
platform: "web"
resource_id: "61d1e32b52cdf51845dbeeaa"
resource_level: "3"
resource_title: "Learning to Surf"
resource_type: "ImageResource"
start_time: "2022-04-13T12:46:32.490Z"
user_id: 5295244
word_performance : [

]
```

**Example Response**
```

```

**Request Payload**
```
activity_type: "imagetagger"
event_type: "end_activity",
skill : "Vocabulary",
platform: "web",
resource_id: "61d1e32b52cdf51845dbeeaa",
resource_level: "3",
resource_title: "Learning to Surf",
resource_type: "ImageResource",
start_time: "2022-04-13T12:46:32.490Z",
user_id: 5295244,
word_performance : [

]
```

**Example Response**
```

```

**Request Payload**
```
activity_type: "imagetagger",
event_type: "quit_activity",
skill : "Vocabulary"
platform: "web"
resource_id: "61d1e32b52cdf51845dbeeaa",
resource_level: "3",
resource_title: "Learning to Surf",
resource_type: "ImageResource",
start_time: "2022-04-13T12:46:32.490Z",
user_id: 5295244,
word_performance : [

]
```


# Activities

## **GET /api/v0/activities/**

This endpoint creates activity_progress object for a given lesson_progress or returns an active 
activity_progress for the given lesson_progress

**Request Payload**
```
 resource: "61d1e32b52cdf51845dbeeaa"
 user_id: ""
```

**Example Response**
```
{
	"type": "ImageTagger",
	"challenges": [{
			"prompt": "surf",
			"choices": [{
				"tts": "https://s3.amazonaws.com/voxy_media/audio/string/surf:vb:5ca776e2607b6b7904ee451d1c77add4_1643876387.289283.mp3",
				"definition": "ride the waves of the sea with a board",
				"hints": [
					"pegar as ondas do mar com uma prancha"
				],
				"hotspot": {
					"ul": {
						"y": 0.470131662860093,
						"x": 0.500223755710115
					},
					"lr": {
						"y": 0.6518109589429568,
						"x": 0.8035678407664023
					}
				}
			}],
			"correctIndex": 0
		},
		{
			"prompt": "beach",
			"choices": [{
				"tts": "https://s3.amazonaws.com/voxy_media/audio/string/beach:nn:a87fcf958bf26db643d68c4711b10103_1642755513.451703.mp3",
				"definition": "area of sand next to the sea or ocean",
				"hints": [
					"área de areia próxima ao mar ou oceano"
				],
				"hotspot": {
					"ul": {
						"y": 0.470131662860093,
						"x": 0.500223755710115
					},
					"lr": {
						"y": 0.6518109589429568,
						"x": 0.8035678407664023
					}
				}
			}],
			"correctIndex": 0
		},
		{
			"prompt": "twin",
			"choices": [{
				"tts": "https://s3.amazonaws.com/voxy_media/audio/string/twin:nns:754e29ceba2b315a5de1d18ef3a05b4c_1643876747.663205.mp3",
				"definition": "brothers or sisters born at the same time",
				"hints": [
					"irmãos ou irmãs nascidos ao mesmo tempo"
				],
				"hotspot": {
					"ul": {
						"y": 0.2887291653951009,
						"x": 0.038666636149088544
					},
					"lr": {
						"y": 0.6803958320617676,
						"x": 0.4153333028157552
					}
				}
			}],
			"correctIndex": 0
		}
	]
}
```


