Models

This app provides the core functionality for tracking user engagement with content and the Kolibri app.

It stores:

  • details of users’ interactions with content

  • summaries of those interactions

  • interactions with the software in general

Eventually, it may also store user feedback on the content and the software.

class kolibri.core.logger.models.AttemptLog(*args, **kwargs)[source]

This model provides a summary of a user’s interactions with a question in a content node. (Think of it like a ContentNodeAttemptLog to distinguish it from ExamAttemptLog and BaseAttemptLog)

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • item (CharField) – Item

  • start_timestamp (DateTimeTzField) – Start timestamp

  • end_timestamp (DateTimeTzField) – End timestamp

  • completion_timestamp (DateTimeTzField) – Completion timestamp

  • time_spent (FloatField) – (in seconds)

  • complete (BooleanField) – Complete

  • correct (FloatField) – Correct

  • hinted (BooleanField) – Hinted

  • answer (JSONField) – Answer

  • simple_answer (CharField) – Simple answer

  • interaction_history (JSONField) – Interaction history

  • user_id (ForeignKey to ~) – User

  • error (BooleanField) – Error

  • masterylog_id (ForeignKey to ~) – Masterylog

  • sessionlog_id (ForeignKey to ~) – Sessionlog

exception DoesNotExist
exception MultipleObjectsReturned
infer_dataset(*args, **kwargs)[source]

This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of AbstractFacilityDataModel, to define a model-specific inference.

class kolibri.core.logger.models.BaseAttemptLog(*args, **kwargs)[source]

This is an abstract model that provides a summary of a user’s interactions with a particular item/question in an assessment/exercise/exam

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • item (CharField) – Item

  • start_timestamp (DateTimeTzField) – Start timestamp

  • end_timestamp (DateTimeTzField) – End timestamp

  • completion_timestamp (DateTimeTzField) – Completion timestamp

  • time_spent (FloatField) – (in seconds)

  • complete (BooleanField) – Complete

  • correct (FloatField) – Correct

  • hinted (BooleanField) – Hinted

  • answer (JSONField) – Answer

  • simple_answer (CharField) – Simple answer

  • interaction_history (JSONField) – Interaction history

  • user_id (ForeignKey to ~) – User

  • error (BooleanField) – Error

class kolibri.core.logger.models.BaseLogModel(*args, **kwargs)[source]
Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

calculate_partition()[source]

Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.

infer_dataset(*args, **kwargs)[source]

This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of AbstractFacilityDataModel, to define a model-specific inference.

class kolibri.core.logger.models.BaseLogQuerySet(model=None, query=None, using=None, hints=None)[source]
filter_by_content_ids(content_ids, content_id_lookup='content_id')[source]

Filter a set of logs by content_id, using content_ids from the provided list or queryset.

filter_by_topic(topic, content_id_lookup='content_id')[source]

Filter a set of logs by content_id, using content_ids from all descendants of specified topic.

class kolibri.core.logger.models.ContentSessionLog(*args, **kwargs)[source]

This model provides a record of interactions with a content item within a single visit to that content page.

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • user_id (ForeignKey to ~) – User

  • content_id (UUIDField) – Content id

  • visitor_id (UUIDField) – Visitor id

  • channel_id (UUIDField) – Channel id

  • start_timestamp (DateTimeTzField) – Start timestamp

  • end_timestamp (DateTimeTzField) – End timestamp

  • time_spent (FloatField) – (in seconds)

  • progress (FloatField) – Progress

  • kind (CharField) – Kind

  • extra_fields (JSONField) – Extra fields

exception DoesNotExist
exception MultipleObjectsReturned
save(*args, **kwargs)[source]

Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class kolibri.core.logger.models.ContentSummaryLog(*args, **kwargs)[source]

This model provides an aggregate summary of all recorded interactions a user has had with a content item over time.

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • user_id (ForeignKey to ~) – User

  • content_id (UUIDField) – Content id

  • channel_id (UUIDField) – Channel id

  • start_timestamp (DateTimeTzField) – Start timestamp

  • end_timestamp (DateTimeTzField) – End timestamp

  • completion_timestamp (DateTimeTzField) – Completion timestamp

  • time_spent (FloatField) – (in seconds)

  • progress (FloatField) – Progress

  • kind (CharField) – Kind

  • extra_fields (JSONField) – Extra fields

exception DoesNotExist
exception MultipleObjectsReturned
calculate_source_id()[source]

Should return a string that uniquely defines the model instance or None for a random uuid.

save(*args, **kwargs)[source]

Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class kolibri.core.logger.models.ExamAttemptLog(*args, **kwargs)[source]

This model provides a summary of a user’s interactions with a question in an exam

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • item (CharField) – Item

  • start_timestamp (DateTimeTzField) – Start timestamp

  • end_timestamp (DateTimeTzField) – End timestamp

  • completion_timestamp (DateTimeTzField) – Completion timestamp

  • time_spent (FloatField) – (in seconds)

  • complete (BooleanField) – Complete

  • correct (FloatField) – Correct

  • hinted (BooleanField) – Hinted

  • answer (JSONField) – Answer

  • simple_answer (CharField) – Simple answer

  • interaction_history (JSONField) – Interaction history

  • user_id (ForeignKey to ~) – User

  • error (BooleanField) – Error

  • examlog_id (ForeignKey to ~) – Examlog

  • content_id (UUIDField) – Content id

exception DoesNotExist
exception MultipleObjectsReturned
calculate_partition()[source]

Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.

infer_dataset(*args, **kwargs)[source]

This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of AbstractFacilityDataModel, to define a model-specific inference.

class kolibri.core.logger.models.ExamLog(*args, **kwargs)[source]

This model provides a summary of a user’s interactions with an exam, and serves as an aggregation point for individual attempts on questions in that exam.

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • exam_id (ForeignKey to ~) – Exam

  • user_id (ForeignKey to ~) – User

  • closed (BooleanField) – Closed

  • completion_timestamp (DateTimeTzField) – Completion timestamp

exception DoesNotExist
exception MultipleObjectsReturned
calculate_partition()[source]

Should return a string specifying this model instance’s partition, using self.ID_PLACEHOLDER in place of its own ID, if needed.

calculate_source_id()[source]

Should return a string that uniquely defines the model instance or None for a random uuid.

class kolibri.core.logger.models.MasteryLog(*args, **kwargs)[source]

This model provides a summary of a user’s engagement with an assessment within a mastery level

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • user_id (ForeignKey to ~) – User

  • summarylog_id (ForeignKey to ~) – Summarylog

  • mastery_criterion (JSONField) – Mastery criterion

  • start_timestamp (DateTimeTzField) – Start timestamp

  • end_timestamp (DateTimeTzField) – End timestamp

  • completion_timestamp (DateTimeTzField) – Completion timestamp

  • mastery_level (IntegerField) – Mastery level

  • complete (BooleanField) – Complete

exception DoesNotExist
exception MultipleObjectsReturned
calculate_source_id()[source]

Should return a string that uniquely defines the model instance or None for a random uuid.

infer_dataset(*args, **kwargs)[source]

This method is used by ensure_dataset to “infer” which dataset should be associated with this instance. It should be overridden in any subclass of AbstractFacilityDataModel, to define a model-specific inference.

class kolibri.core.logger.models.UserSessionLog(*args, **kwargs)[source]

This model provides a record of a user session in Kolibri.

Parameters
  • id (UUIDField) – Id

  • _morango_dirty_bit (BooleanField) – morango dirty bit

  • _morango_source_id (CharField) – morango source id

  • _morango_partition (CharField) – morango partition

  • dataset_id (ForeignKey to ~) – Dataset

  • user_id (ForeignKey to ~) – User

  • channels (TextField) – Channels

  • start_timestamp (DateTimeTzField) – Start timestamp

  • last_interaction_timestamp (DateTimeTzField) – Last interaction timestamp

  • pages (TextField) – Pages

  • device_info (CharField) – Device info

exception DoesNotExist
exception MultipleObjectsReturned
classmethod update_log(user, os_info=None, browser_info=None)[source]

Update the current UserSessionLog for a particular user.

ua_parser never defaults the setting of os.family and user_agent.family It uses the value ‘other’ whenever the values are not recognized or the parsing fails. The code depends on this behaviour.