summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2018-02-08 11:43:25 +0530
committeradityacp2018-02-08 11:43:25 +0530
commit440c18f4e0565e0824d432b01bc2be7b8847e122 (patch)
tree04c8ddf34d72cc54803f4f82bc1a1143ef68c9cc /yaksh/models.py
parentb78b5d0b46114caefca35e82c502d1f7598e8e59 (diff)
downloadonline_test-440c18f4e0565e0824d432b01bc2be7b8847e122.tar.gz
online_test-440c18f4e0565e0824d432b01bc2be7b8847e122.tar.bz2
online_test-440c18f4e0565e0824d432b01bc2be7b8847e122.zip
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
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):