summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2019-02-18 11:45:07 +0530
committerankitjavalkar2019-03-12 18:41:09 +0530
commit0df9abf2dce51ed0b1f8247f91f0fe4c039bc14b (patch)
treefda80884d1e1658b00a69c2eea15f98ad9f128b7 /yaksh/views.py
parent34a8dcac95c215432a32662310648f69f6dc504a (diff)
downloadonline_test-0df9abf2dce51ed0b1f8247f91f0fe4c039bc14b.tar.gz
online_test-0df9abf2dce51ed0b1f8247f91f0fe4c039bc14b.tar.bz2
online_test-0df9abf2dce51ed0b1f8247f91f0fe4c039bc14b.zip
Add functionality to restrict access to next module based on passing previous module
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 6c7a12e..5009cb6 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -471,11 +471,17 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None,
# unit module prerequiste check
if learning_module.has_prerequisite():
- if not learning_module.is_prerequisite_passed(user, course):
+ if not learning_module.is_prerequisite_complete(user, course):
msg = "You have not completed the module previous to {0}".format(
learning_module.name)
return course_modules(request, course_id, msg)
+ if learning_module.check_prerequisite_passes:
+ if not learning_module.is_prerequisite_passed(user, course):
+ msg = "You have not successfully passed the module previous to {0}".format(
+ learning_module.name)
+ return course_modules(request, course_id, msg)
+
# is user enrolled in the course
if not course.is_enrolled(user):
msg = 'You are not enrolled in {0} course'.format(course.name)
@@ -501,7 +507,7 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None,
# prerequisite check and passing criteria for quiz
if learning_unit.has_prerequisite():
- if not learning_unit.is_prerequisite_passed(
+ if not learning_unit.is_prerequisite_complete(
user, learning_module, course):
msg = "You have not completed the previous Lesson/Quiz/Exercise"
if is_moderator(user):
@@ -2424,17 +2430,22 @@ def show_lesson(request, lesson_id, module_id, course_id):
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):
+ if not learn_module.is_prerequisite_complete(user, course):
msg = "You have not completed the module previous to {0}".format(
learn_module.name)
return view_module(request, module_id, course_id, msg)
+ if learn_module.check_prerequisite_passes:
+ if not learn_module.is_prerequisite_passed(user, course):
+ msg = "You have not successfully passed the module previous to {0}".format(
+ learn_module.name)
+ return view_module(request, module_id, course_id, msg)
# update course status with current unit
_update_unit_status(course_id, user, learn_unit)
all_modules = course.get_learning_modules()
if learn_unit.has_prerequisite():
- if not learn_unit.is_prerequisite_passed(user, learn_module, course):
+ if not learn_unit.is_prerequisite_complete(user, learn_module, course):
msg = "You have not completed previous Lesson/Quiz/Exercise"
return view_module(request, learn_module.id, course_id, msg=msg)
context = {'lesson': learn_unit.lesson, 'user': user,
@@ -2696,13 +2707,20 @@ def design_course(request, course_id):
if remove_values:
course.learning_module.remove(*remove_values)
- if "Change_prerequisite" in request.POST:
+ if "change_prerequisite_completion" in request.POST:
unit_list = request.POST.getlist("check_prereq")
for unit in unit_list:
learning_module = course.learning_module.get(id=unit)
learning_module.toggle_check_prerequisite()
learning_module.save()
+ if "change_prerequisite_passing" in request.POST:
+ unit_list = request.POST.getlist("check_prereq_passes")
+ for unit in unit_list:
+ learning_module = course.learning_module.get(id=unit)
+ learning_module.toggle_check_prerequisite_passes()
+ learning_module.save()
+
added_learning_modules = course.get_learning_modules()
all_learning_modules = LearningModule.objects.filter(
creator=user, is_trial=False)
@@ -2734,11 +2752,17 @@ def view_module(request, module_id, course_id, msg=None):
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):
+ if not learning_module.is_prerequisite_complete(user, course):
msg = "You have not completed the module previous to {0}".format(
learning_module.name)
return course_modules(request, course_id, msg)
+ if learning_module.check_prerequisite_passes:
+ if not learning_module.is_prerequisite_passed(user, course):
+ msg = "You have not successfully passed the module previous to {0}".format(
+ learning_module.name)
+ return course_modules(request, course_id, msg)
+
learning_units = learning_module.get_learning_units()
context['learning_units'] = learning_units
context['learning_module'] = learning_module