...
Viewer Service - Database Design
The user can consume a content by searching it in our platform (organically) or via a collection when the user enrolled to a course.
With Viewer-Service, we will support tracking individual content consumption also. Below details explain how the data will be stored for a content consumption in different scenarios.
...
The below table has various scenarios considering the current and future use cases. Here we defined the database read/write logic to support these use case and fetch the save or fetch the required data from user_content_consumption
table.
Code Block |
---|
Code Block |
user_content_consumption ( userid text, collectionid text, // currently labelled as courseid contextid text, // currently labelled as courseid contextid text, // currently labelled as batchid contentid text, last_access_time timestamp, last_completed_time timestamp, last_updated_time timestamp, progressdetails json, status int, PRIMARY KEY (userid, collectionid, contextid, contentid) ) assessment_aggregator ( user_id text, collection_id text, // currently labelled as courseid context_id text, // currently labelled as contextid content_id text, attempt_id text, created_on timestamp, grand_total text, last_attempted_on timestamp, questions list<frozen<question>>, total_max_score double, total_score double, updated_on timestamp, PRIMARY KEY ((user_id, collection_id), context_id, content_id, attempt_id) ) user_activity_agg ( activity_type text, activity_id text, user_id text, context_id text, agg map<text, int>, content_status frozen<map<text,int>>, agg_last_updated map<text, timestamp>, PRIMARY KEY ((activity_type, activity_id, user_id), context_id) ) |
...
Scenario
...
API & DB details
...
User consuming individual content.
Write API Request
...
language | json |
---|
...
The user can consume a content by searching it in our platform (organically) or via a collection when the user enrolled to a course.
With Viewer-Service, we will support tracking individual content consumption also. Below details explain how the data will be stored for a content consumption in different scenarios.
...
The below table has various scenarios considering the current and future use cases. Here we defined the database read/write logic to support these use case and fetch the save or fetch the required data from user_content_consumption
table.
Scenario | API & DB details | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | User consuming individual content. | Write API Request
Write DB Query
Read API Request
Read DB Query
| |||||||||||||||||
2 | User consuming a content with in a collection. | Write API Request
Write DB Query
Read API Request
Read DB Query
| |||||||||||||||||
3 | User consuming a content with in a collection with a context (A batch, A program or a program batch) | Write API Request
Write DB Query
Read API Request
Read DB Query
|
...
Read DB Query
| |||||||||||||||||||
3 | User consuming a content with in a collection with a context (A batch, A program or a program batch) | Write API Request
Write DB Query
Read API Request
Read DB Query
|
Config Modes
While the viewer-service as an infra component provides flexibility to configure any tracking use-case, there is a need for preconfigured “modes” enabled at an instance level to be able to make better use of the service and also to make any solution or usecase simpler to implement and understand.
Following are the modes one can configure the viewer service at an instance level
Strict Context Mode
Any content or collection consumption is strictly tracked at the context it was consumed. This is the default mode setup currently in SunbirdEd
Example Use-case
Rahul completes content “single-digit-addition” as part of batch “batch-1“ within the course “class-1-maths”
Entry in DB
user_id | collection_id | context_id | content_id | status |
---|---|---|---|---|
Rahul | class-1-maths | batch-1 | single-digit-addition | 2 |
Action | Progress |
---|---|
Rahul opens the “single-digit-addition” content after going into the course “class-1-maths” when batch-1 is active | Complete |
Rahul opens the “single-digit-addition” content after searching for it | Not Started |
batch-1 has expired and Rahul has rejoined batch-2 and opened the content “single-digit-addition” | Not Started |
Carry Forward Mode
Any content or collection consumption is tracked at its level only and is carry forwarded into any context. This is the expected mode of SunbirdCB.
Example Use-case
Rahul completes content “single-digit-addition” as part of batch “batch-1“ within the course “class-1-maths”
Action | Progress |
---|---|
Rahul opens the “single-digit-addition” content after going into the course “class-1-maths” when batch-1 is active | Complete |
Rahul opens the “single-digit-addition” content after searching for it | Not Started |
batch-1 has expired and Rahul has rejoined batch-2 and opened the content “single-digit-addition” | Not Started |
Copy Mode
In this mode, any content or collection that is tracked, is copied over into context based on the business rules configured.
Example Use-case
Rahul completes content “single-digit-addition” as part of batch “batch-1“ within the course “class-1-maths”
Action | Progress |
---|---|
Rahul opens the “single-digit-addition” content after going into the course “class-1-maths” when batch-1 is active | Complete |
Rahul opens the “single-digit-addition” content after searching for it | Not Started |
batch-1 has expired and Rahul has rejoined batch-2 and opened the content “single-digit-addition” | Not Started |
Move Mode
In this mode, any content or collection that is tracked, is moved over into context based on the business rules configured.
Example Use-case
Rahul completes content “single-digit-addition” as part of batch “batch-1“ within the course “class-1-maths”
Action | Progress |
---|---|
Rahul opens the “single-digit-addition” content after going into the course “class-1-maths” when batch-1 is active | Complete |
Rahul opens the “single-digit-addition” content after searching for it | Not Started |
batch-1 has expired and Rahul has rejoined batch-2 and opened the content “single-digit-addition” | Not Started |
Extended Enrolment Consumption:
...