diff options
author | prathamesh | 2017-12-05 19:33:31 +0530 |
---|---|---|
committer | prathamesh | 2017-12-05 19:33:31 +0530 |
commit | 06cc3dc5d3671ca24fc412b6078906a582b83e98 (patch) | |
tree | 93e94a0517f990423242aa69ad6297d583867311 /yaksh/models.py | |
parent | 4fc8565be63375b48a7a897a1701e264f4ccac66 (diff) | |
download | online_test-06cc3dc5d3671ca24fc412b6078906a582b83e98.tar.gz online_test-06cc3dc5d3671ca24fc412b6078906a582b83e98.tar.bz2 online_test-06cc3dc5d3671ca24fc412b6078906a582b83e98.zip |
Added basic model testcases.
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index d29a286..463434b 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -426,19 +426,15 @@ class LearningModule(models.Model): return added_quiz_lessons def toggle_check_prerequisite(self): - if self.check_prerequisite: - self.check_prerequisite = False - else: - self.check_prerequisite = True + self.check_prerequisite = not self.check_prerequisite def get_next_unit(self, current_unit_id): ordered_units = self.learning_unit.order_by("order") ordered_units_ids = list(ordered_units.values_list("id", flat=True)) current_unit_index = ordered_units_ids.index(current_unit_id) - if current_unit_index + 1 == len(ordered_units_ids): + next_index = current_unit_index + 1 + if next_index == len(ordered_units_ids): next_index = 0 - else: - next_index = current_unit_index + 1 return ordered_units.get(id=ordered_units_ids[next_index]) def get_status(self, user, course): @@ -645,10 +641,10 @@ class Course(models.Model): def get_learning_units(self): learning_modules = self.learning_module.all() - learning_unit_list = [] + learning_units = [] for module in learning_modules: - learning_unit_list.extend(module.get_learning_units()) - return learning_unit_list + learning_units.extend(module.get_learning_units()) + return learning_units def remove_trial_modules(self): learning_modules = self.learning_module.all() |