models.py 1.98 KB
Newer Older
ichuang committed
1 2 3 4 5 6 7 8 9
#
# db model for psychometrics data
#
# this data is collected in real time
#

from django.db import models
from courseware.models import StudentModule

Calen Pennington committed
10

ichuang committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
class PsychometricData(models.Model):
    """
    This data is a table linking student, module, and module performance,
    including number of attempts, grade, max grade, and time of checks.

    Links to instances of StudentModule, but only those for capa problems.

    Note that StudentModule.module_state_key is nominally a Location instance (url string).
    That means it is of the form {tag}://{org}/{course}/{category}/{name}[@{revision}]
    and for capa problems, category = "problem".

    checktimes is extracted from tracking logs, or added by capa module via psychometrics callback.
    """

    studentmodule = models.ForeignKey(StudentModule, db_index=True, unique=True)   # contains student, module_state_key, course_id

    done = models.BooleanField(default=False)
    attempts = models.IntegerField(default=0)			# extracted from studentmodule.state
Calen Pennington committed
29
    checktimes = models.TextField(null=True, blank=True)  	# internally stored as list of datetime objects
ichuang committed
30 31 32 33 34 35 36

    # keep in mind
    # grade = studentmodule.grade
    # max_grade = studentmodule.max_grade
    # student = studentmodule.student
    # course_id = studentmodule.course_id
    # location = studentmodule.module_state_key
Calen Pennington committed
37

ichuang committed
38 39 40 41 42 43 44 45
    def __unicode__(self):
        sm = self.studentmodule
        return "[PsychometricData] %s url=%s, grade=%s, max=%s, attempts=%s, ct=%s" % (sm.student,
                                                                                       sm.module_state_key,
                                                                                       sm.grade,
                                                                                       sm.max_grade,
                                                                                       self.attempts,
                                                                                       self.checktimes)