summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2018-01-08 19:14:09 +0530
committerGitHub2018-01-08 19:14:09 +0530
commit3abbc557c57eaf2f3d08222034f9a720a1e7a1ed (patch)
treea0ce81036853bb96c722b233153a580f58d22236 /yaksh/views.py
parentd1cc992eb7dc1a23b866ed89baf602579637244a (diff)
parent08a4c0271535bfb24a82a07d6e881cd2b9bab470 (diff)
downloadonline_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/views.py')
-rw-r--r--yaksh/views.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 8fe4523..49249ca 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -504,7 +504,7 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None,
if learning_unit.has_prerequisite():
if not learning_unit.is_prerequisite_passed(
user, learning_module, course):
- msg = "You have not completed the prerequisite"
+ msg = "You have not completed the previous Lesson/Quiz/Exercise"
if is_moderator(user):
return prof_manage(request, msg=msg)
return view_module(request, module_id=module_id,
@@ -608,6 +608,7 @@ def show_question(request, question, paper, error_message=None, notification=Non
files = FileUpload.objects.filter(question_id=question.id, hide=False)
course = Course.objects.get(id=course_id)
module = course.learning_module.get(id=module_id)
+ all_modules = course.get_learning_modules()
context = {
'question': question,
'paper': paper,
@@ -621,7 +622,8 @@ def show_question(request, question, paper, error_message=None, notification=Non
'module': module,
'can_skip': can_skip,
'delay_time': delay_time,
- 'quiz_type': quiz_type
+ 'quiz_type': quiz_type,
+ 'all_modules': all_modules
}
answers = paper.get_previous_answers(question)
if answers:
@@ -2330,12 +2332,13 @@ 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()
+ all_modules = course.get_learning_modules()
if learn_unit.has_prerequisite():
if not learn_unit.is_prerequisite_passed(user, learn_module, course):
- msg = "You have not completed the prerequisite"
+ 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,
- 'course': course, 'state': "lesson",
+ 'course': course, 'state': "lesson", "all_modules": all_modules,
'learning_units': learning_units, "current_unit": learn_unit,
'learning_module': learn_module}
return my_render_to_response('yaksh/show_video.html', context)
@@ -2517,13 +2520,14 @@ def get_next_unit(request, course_id, module_id, current_unit_id,
current_learning_unit = learning_module.learning_unit.get(
id=current_unit_id)
- course_status = CourseStatus.objects.filter(
- user=user, course_id=course_id,
- )
if first_unit:
next_unit = current_learning_unit
else:
next_unit = learning_module.get_next_unit(current_learning_unit.id)
+
+ course_status = CourseStatus.objects.filter(
+ user=user, course_id=course_id,
+ )
if not course_status.exists():
course_status = CourseStatus.objects.create(
user=user, course_id=course_id
@@ -2535,6 +2539,14 @@ def get_next_unit(request, course_id, module_id, current_unit_id,
if not first_unit:
course_status.completed_units.add(current_learning_unit.id)
+ # if last unit of current module go to next module
+ is_last_unit = course.is_last_unit(learning_module,
+ current_learning_unit.id)
+ if is_last_unit:
+ next_module = course.next_module(learning_module.id)
+ return my_redirect("/exam/quizzes/view_module/{0}/{1}/".format(
+ next_module.id, course.id))
+
# make next available unit as current unit
course_status.current_unit = next_unit
course_status.save()
@@ -2620,14 +2632,17 @@ 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)
+ all_modules = course.get_learning_modules()
if learning_module.has_prerequisite():
if not learning_module.is_prerequisite_passed(user, course):
msg = "You have not completed the previous learning module"
return course_modules(request, course_id, msg)
+
learning_units = learning_module.get_learning_units()
context['learning_units'] = learning_units
context['learning_module'] = learning_module
context['first_unit'] = learning_units[0]
+ context['all_modules'] = all_modules
context['user'] = user
context['course'] = course
context['state'] = "module"