diff options
author | adityacp | 2018-02-08 11:43:25 +0530 |
---|---|---|
committer | adityacp | 2018-02-08 11:43:25 +0530 |
commit | 440c18f4e0565e0824d432b01bc2be7b8847e122 (patch) | |
tree | 04c8ddf34d72cc54803f4f82bc1a1143ef68c9cc /yaksh/views.py | |
parent | b78b5d0b46114caefca35e82c502d1f7598e8e59 (diff) | |
download | online_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/views.py')
-rw-r--r-- | yaksh/views.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 2bc5dfe..27325c6 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -475,6 +475,10 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, learning_module = course.learning_module.get(id=module_id) learning_unit = learning_module.learning_unit.get(quiz=quest_paper.quiz.id) + # unit module active status + if not learning_module.active: + return view_module(request, module_id, course_id) + # unit module prerequiste check if learning_module.has_prerequisite(): if not learning_module.is_prerequisite_passed(user, course): @@ -1392,7 +1396,8 @@ def design_questionpaper(request, quiz_id, questionpaper_id=None, 'questions': questions, 'fixed_questions': fixed_questions, 'state': state, - 'random_sets': random_sets + 'random_sets': random_sets, + 'course_id': course_id } return my_render_to_response( 'yaksh/design_questionpaper.html', @@ -2348,6 +2353,14 @@ def show_lesson(request, lesson_id, module_id, course_id): learn_module = course.learning_module.get(id=module_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) if learn_module.has_prerequisite(): if not learn_module.is_prerequisite_passed(user, course): msg = "You have not completed the module previous to {0}".format( @@ -2660,6 +2673,11 @@ def view_module(request, module_id, course_id, msg=None): msg = "{0} is either expired or not active".format(course.name) 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) all_modules = course.get_learning_modules() if learning_module.has_prerequisite(): if not learning_module.is_prerequisite_passed(user, course): |