Ejemplo n.º 1
0
class ContentSummaryLog(BaseLogModel):
    """
    This model provides an aggregate summary of all recorded interactions a user has had with
    a content item over time.
    """

    # Morango syncing settings
    morango_model_name = "contentsummarylog"

    user = models.ForeignKey(FacilityUser)
    content_id = UUIDField(db_index=True)
    channel_id = UUIDField()
    start_timestamp = DateTimeTzField()
    end_timestamp = DateTimeTzField(blank=True, null=True)
    completion_timestamp = DateTimeTzField(blank=True, null=True)
    time_spent = models.FloatField(
        help_text="(in seconds)", default=0.0, validators=[MinValueValidator(0)]
    )
    progress = models.FloatField(
        default=0, validators=[MinValueValidator(0), MaxValueValidator(1.01)]
    )
    kind = models.CharField(max_length=200)
    extra_fields = JSONField(default={}, blank=True)

    def calculate_source_id(self):
        return self.content_id

    def save(self, *args, **kwargs):
        if self.progress < 0 or self.progress > 1.01:
            raise ValidationError("Content summary progress out of range (0-1)")

        super(ContentSummaryLog, self).save(*args, **kwargs)
Ejemplo n.º 2
0
class ContentSessionLog(BaseLogModel):
    """
    This model provides a record of interactions with a content item within a single visit to that content page.
    """

    # Morango syncing settings
    morango_model_name = "contentsessionlog"

    user = models.ForeignKey(FacilityUser, blank=True, null=True)
    content_id = UUIDField(db_index=True)
    channel_id = UUIDField()
    start_timestamp = DateTimeTzField()
    end_timestamp = DateTimeTzField(blank=True, null=True)
    time_spent = models.FloatField(
        help_text="(in seconds)", default=0.0, validators=[MinValueValidator(0)]
    )
    progress = models.FloatField(default=0, validators=[MinValueValidator(0)])
    kind = models.CharField(max_length=200)
    extra_fields = JSONField(default={}, blank=True)

    def save(self, *args, **kwargs):
        if self.progress < 0:
            raise ValidationError("Progress out of range (<0)")

        super(ContentSessionLog, self).save(*args, **kwargs)
Ejemplo n.º 3
0
class LearnerProgressNotification(models.Model):
    id = (models.AutoField(auto_created=True,
                           primary_key=True,
                           serialize=True,
                           verbose_name="ID"), )
    notification_object = models.CharField(
        max_length=200, choices=NotificationObjectType.choices(), blank=True)
    notification_event = models.CharField(
        max_length=200, choices=NotificationEventType.choices(), blank=True)
    user_id = UUIDField()
    classroom_id = UUIDField(
    )  # This can be either a Classroom or a LearnerGroup id
    contentnode_id = UUIDField(null=True)
    lesson_id = UUIDField(null=True)
    quiz_id = UUIDField(null=True)
    quiz_num_correct = models.IntegerField(null=True)
    reason = models.CharField(max_length=200,
                              choices=HelpReason.choices(),
                              blank=True)
    timestamp = DateTimeTzField(default=local_now)

    def __str__(self):
        return "{object} - {event}".format(object=self.notification_object,
                                           event=self.notification_event)

    class Meta:
        app_label = "notifications"
Ejemplo n.º 4
0
class NotificationsLog(models.Model):
    id = (models.AutoField(auto_created=True,
                           primary_key=True,
                           serialize=True,
                           verbose_name="ID"), )
    coach_id = UUIDField()
    timestamp = DateTimeTzField(default=local_now)

    def __str__(self):
        return self.coach_id

    class Meta:
        app_label = "notifications"
Ejemplo n.º 5
0
class ExamAttemptLog(BaseAttemptLog):
    """
    This model provides a summary of a user's interactions with a question in an exam
    """

    morango_model_name = "examattemptlog"

    examlog = models.ForeignKey(
        ExamLog, related_name="attemptlogs", blank=False, null=False
    )
    # We have no session logs associated with ExamLogs, so we need to record the channel and content
    # ids here
    content_id = UUIDField()

    def infer_dataset(self, *args, **kwargs):
        return self.examlog.dataset_id

    def calculate_partition(self):
        return self.dataset_id