From 440c18f4e0565e0824d432b01bc2be7b8847e122 Mon Sep 17 00:00:00 2001 From: adityacp Date: Thu, 8 Feb 2018 11:43:25 +0530 Subject: Change in forms.py, views.py and models.py - Add new attribute active in lesson and learningmodule model - Change learningmodule get_status method - Add condition in lesson, quiz and module views to check if module is active or not --- yaksh/models.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'yaksh/models.py') 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): -- cgit From 617d09ca9b05185d9a2310c106360091ed8a1b1a Mon Sep 17 00:00:00 2001 From: adityacp Date: Fri, 9 Feb 2018 14:56:02 +0530 Subject: Change in models, test_models and views - Change learning module test to remove units from course status after successful test run - Remove unnecessary comments from views - Remove unnecessary condition from module get_status method --- yaksh/models.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'yaksh/models.py') diff --git a/yaksh/models.py b/yaksh/models.py index 17ba624..fd4ae3f 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -456,8 +456,7 @@ class LearningModule(models.Model): "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 - if unit.has_prerequisite()] + for unit in ordered_units] if not status_list: default_status = "no units" -- cgit