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, 10 insertions, 5 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 1e45851..17ba624 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -155,6 +155,9 @@ class Lesson(models.Model):
# Creator of the lesson
creator = models.ForeignKey(User)
+ # Activate/Deactivate Lesson
+ active = models.BooleanField(default=True)
+
def __str__(self):
return "{0}".format(self.name)
@@ -414,6 +417,7 @@ class LearningModule(models.Model):
creator = models.ForeignKey(User, related_name="module_creator")
check_prerequisite = models.BooleanField(default=True)
html_data = models.TextField(null=True, blank=True)
+ active = models.BooleanField(default=True)
is_trial = models.BooleanField(default=False)
def get_quiz_units(self):
@@ -447,21 +451,22 @@ class LearningModule(models.Model):
return ordered_units.get(id=ordered_units_ids[next_index])
def get_status(self, user, course):
- """ Get module status if it completed, inprogress or not attempted"""
+ """ Get module status if completed, inprogress or not attempted"""
learning_module = course.learning_module.prefetch_related(
"learning_unit").get(id=self.id)
ordered_units = learning_module.learning_unit.order_by("order")
status_list = [unit.get_completion_status(user, course)
- for unit in ordered_units]
+ for unit in ordered_units
+ if unit.has_prerequisite()]
if not status_list:
default_status = "no units"
elif all([status == "completed" for status in status_list]):
default_status = "completed"
- elif "inprogress" in status_list:
- default_status = "inprogress"
- else:
+ elif all([status == "not attempted" for status in status_list]):
default_status = "not attempted"
+ else:
+ default_status = "inprogress"
return default_status
def is_prerequisite_passed(self, user, course):