Beispiel #1
0
class ContentItemCollection(models.Model):
    # data members
    contentItemList = models.OneToMany(ContentItem)

    def addItem(ci):
        contentItemList.append(ci)

    def deleteItem(ci):
        contentItemList.remove(ci)
Beispiel #2
0
class ContentItem(models.Model):
    #data members
    grade = models.FloatField(default=0.0)
    description = models.CharField(max_length=1000)
    associatedCourse = models.OneToMany(ContentItem)

    def setGrade(gradeInput):
        self.grade = gradeInput

    def getGrade():
        return self.grade
class GradesCollection(models.Model):
    #data members
    gradesList = models.OneToMany(Grade)

    def addGrade(g):
        gradesList.append(g)

    def getGrade(g):
        for grade in gradesList:
            if grade == g:
                return grade
Beispiel #4
0
class Question():
    #data members
    questionText = models.CharField(max_length=1000)
    answer = models.CharField(max_length=500)
    answerTextList = models.OneToMany(answer)
    correctAnswerIndex = models.IntegerField(default=0)

    def isCorrect(choice):
        if choice == correctAnswerIndex:
            return True
        else:
            return False
Beispiel #5
0
class Question(models.Model):
    # data members
    questions = models.OneToMany(Question)
    name = models.CharField(max_length=200)