summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 9aa3e0b..12c902b 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -601,7 +601,12 @@ class LearningUnit(models.Model):
check_prerequisite = models.BooleanField(default=True)
def get_lesson_or_quiz(self):
- return self.lesson if self.lesson else self.quiz
+ unit = None
+ if self.type == 'lesson':
+ unit = self.lesson
+ else:
+ unit = self.quiz
+ return unit
def toggle_check_prerequisite(self):
if self.check_prerequisite:
@@ -653,6 +658,14 @@ class LearningUnit(models.Model):
order=self.order, type="lesson", lesson=new_lesson)
return new_unit
+ def __str__(self):
+ name = None
+ if self.type == 'lesson':
+ name = self.lesson.name
+ else:
+ name = self.quiz.description
+ return name
+
###############################################################################
class LearningModule(models.Model):