Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

user_content_consumption ( userid text, collectionid text,
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

...

languagejson

...

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

Code Block
languagejson
{
  userid: "<userid>",
  contentid: "<contentid>"
}

Write DB Query

Code Block
languagesql
INSERT into ucc(userid, collectionid, contextid, contentid, status) 
values('<userid>','<contentid>','<contentid>','<contentid>','<status>')

Read API Request

Code Block
languagejson
{
  userid: "<userid>",
  contentid: "<contentid>"
}

Read DB Query

Code Block
from ucc where userid='<contentid><userid>' and collectionid='<contentid>' 
and contextid='<contentid>' and contentid='<contentid>'
2

User consuming a content with in a collection.

Write API Request

Code Block
languagejson
{
  userid: "<userid>",
  collectionid: "<collectionid>",
  contentid: "<contentid>"
}

Write DB Query

Code Block
languagesql
INSERT into ucc(userid, collectionid, contextid, contentid, status) 
values('<userid>','<collectionid>','<collectionid>','<contentid>','<status>')

Read API Request

Code Block
languagejson
{
  userid: "<userid>",
  collection: "<collectionid>"
}

Read DB Query

Code Block
from ucc where userid='<contentid>' and collectionid='<collectionid>' 
and contextid='<collectionid>'
3

User consuming a content with in a collection with a context (A batch, A program or a program batch)

Write API Request

Code Block
languagejson
{
  userid: "<userid>",
  collectionid: "<collectionid>",
  contextid: "<contextid>", // batchId, programId, programBatchId
  contentid: "<contentid>"
}

Write DB Query

Code Block
languagesql
INSERT into ucc(userid, collectionid, contextid, contentid, status) 
values('<userid>','<collectionid>','<contextid>','<contentid>','<status>')

Read API Request

Code Block
languagejson
{
  userid: "<userid>",
  collectionid: "<collectionid>",
  contextid: "<contextid>" // batchId, programId, programBatchId
}

Read DB Query

Code Block
from ucc where userid='<contentid>' and collectionid='<contentid>' 
and contextid='<contextid>'

...

languagejson
{
  userid: "<userid>",
  collection: "<collectionid>"
}

Read DB Query

Code Block
from ucc where userid='<userid>' and collectionid='<collectionid>' 
and contextid='<collectionid>'
3

User consuming a content with in a collection with a context (A batch, A program or a program batch)

Write API Request

Code Block
languagejson
{
  userid: "<userid>",
  collectionid: "<collectionid>",
  contextid: "<contextid>", // batchId, programId, programBatchId
  contentid: "<contentid>"
}

Write DB Query

Code Block
languagesql
INSERT into ucc(userid, collectionid, contextid, contentid, status) 
values('<userid>','<collectionid>','<contextid>','<contentid>','<status>')

Read API Request

Code Block
languagejson
{
  userid: "<userid>",
  collectionid: "<collectionid>",
  contextid: "<contextid>" // batchId, programId, programBatchId
}

Read DB Query

Code Block
from ucc where userid='<userid>' and collectionid='<collectionid>' 
and contextid='<contextid>'

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:

...