diff options
author | Prabhu Ramachandran | 2018-01-08 19:14:09 +0530 |
---|---|---|
committer | GitHub | 2018-01-08 19:14:09 +0530 |
commit | 3abbc557c57eaf2f3d08222034f9a720a1e7a1ed (patch) | |
tree | a0ce81036853bb96c722b233153a580f58d22236 /yaksh/models.py | |
parent | d1cc992eb7dc1a23b866ed89baf602579637244a (diff) | |
parent | 08a4c0271535bfb24a82a07d6e881cd2b9bab470 (diff) | |
download | online_test-3abbc557c57eaf2f3d08222034f9a720a1e7a1ed.tar.gz online_test-3abbc557c57eaf2f3d08222034f9a720a1e7a1ed.tar.bz2 online_test-3abbc557c57eaf2f3d08222034f9a720a1e7a1ed.zip |
Merge pull request #416 from adityacp/enhance_yaksh_ui
Enhance yaksh design
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index 6622067..d4a73fa 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -668,6 +668,19 @@ class Course(models.Model): module.learning_unit.all().delete() learning_modules.delete() + def is_last_unit(self, module, unit_id): + last_unit = module.get_learning_units().last() + return unit_id == last_unit.id + + def next_module(self, current_module_id): + modules = self.get_learning_modules() + module_ids = list(modules.values_list("id", flat=True)) + current_unit_index = module_ids.index(current_module_id) + next_index = current_unit_index + 1 + if next_index == len(module_ids): + next_index = 0 + return modules.get(id=module_ids[next_index]) + def __str__(self): return self.name |