summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/models.py3
-rw-r--r--yaksh/test_models.py9
-rw-r--r--yaksh/views.py4
3 files changed, 10 insertions, 6 deletions
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"
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index d6fac96..8205b88 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -140,6 +140,11 @@ class LearningModuleTestCases(unittest.TestCase):
self.course_status = CourseStatus.objects.get(
course=self.course, user=self.student)
+ def tearDown(self):
+ # Remove unit from course status completed units
+ self.course_status.completed_units.remove(self.learning_unit_one)
+ self.course_status.completed_units.remove(self.learning_unit_two)
+
def test_learning_module(self):
self.assertEqual(self.learning_module.description, 'module one')
self.assertEqual(self.learning_module.creator, self.creator)
@@ -199,7 +204,7 @@ class LearningModuleTestCases(unittest.TestCase):
# Then
self.assertEqual(unit, next_unit)
- def test_get_status(self):
+ def test_get_module_status(self):
# Given
module_status = 'not attempted'
# When
@@ -238,6 +243,8 @@ class LearningModuleTestCases(unittest.TestCase):
self.assertEqual(percent, 0)
# for module with learning units
+ self.course_status.completed_units.add(self.learning_unit_one)
+ self.course_status.completed_units.add(self.learning_unit_two)
percent = self.learning_module.get_module_complete_percent(
self.course, self.student
)
diff --git a/yaksh/views.py b/yaksh/views.py
index 27325c6..011b417 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -2354,10 +2354,9 @@ def show_lesson(request, lesson_id, module_id, course_id):
learn_unit = learn_module.learning_unit.get(lesson_id=lesson_id)
learning_units = learn_module.get_learning_units()
- # if learning module is active
if not learn_module.active:
return view_module(request, module_id, course_id)
- # if lesson is active or not
+
if not learn_unit.lesson.active:
msg = "{0} is not active".format(learn_unit.lesson.name)
return view_module(request, module_id, course_id, msg)
@@ -2674,7 +2673,6 @@ def view_module(request, module_id, course_id, msg=None):
return course_modules(request, course_id, msg)
learning_module = course.learning_module.get(id=module_id)
- # Check if module is active or not
if not learning_module.active:
msg = "{0} is not active".format(learning_module.name)
return course_modules(request, course_id, msg)