summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorKing2019-04-09 17:26:49 +0530
committerGitHub2019-04-09 17:26:49 +0530
commit82f1fa9f778d85619343bbb79b9faec41696261f (patch)
treeada2ee83c333ab6fa2cab5b09e94588ab6ab2aa3 /yaksh/views.py
parent0c8b272aa25210d71e03715c1209402d2b770a98 (diff)
parent54e674c12704013377b9dd6b6c82df526f4e1cdb (diff)
downloadonline_test-82f1fa9f778d85619343bbb79b9faec41696261f.tar.gz
online_test-82f1fa9f778d85619343bbb79b9faec41696261f.tar.bz2
online_test-82f1fa9f778d85619343bbb79b9faec41696261f.zip
Merge pull request #592 from ankitjavalkar/add-prereq-passing-check
Add functionality to restrict access to next module based on passing previous module
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py42
1 files changed, 36 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 9199a3a..d634e0c 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -484,11 +484,19 @@ 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)
@@ -514,7 +522,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):
@@ -2442,17 +2450,24 @@ 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,
@@ -2714,13 +2729,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)
@@ -2752,11 +2774,19 @@ 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