diff options
author | adityacp | 2017-11-21 17:08:23 +0530 |
---|---|---|
committer | adityacp | 2017-11-21 17:18:10 +0530 |
commit | 8e5354fb2fdab96780bfd147ba5b1724eebd673b (patch) | |
tree | 3bcb0ecfc622b600852c5062c0d84fda2e690a12 /yaksh | |
parent | 38f6d5aac0e387fed28003c2655877fa21deac93 (diff) | |
download | online_test-8e5354fb2fdab96780bfd147ba5b1724eebd673b.tar.gz online_test-8e5354fb2fdab96780bfd147ba5b1724eebd673b.tar.bz2 online_test-8e5354fb2fdab96780bfd147ba5b1724eebd673b.zip |
Change in templates, js, template tag
- Add new template tag to fetch course module completion status
- View all lessons/quizzes during quiz
- Change button values
- Change user mode and god mode
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/static/yaksh/js/add_quiz.js | 14 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 11 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_module.html | 7 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 30 | ||||
-rw-r--r-- | yaksh/templates/yaksh/design_course_session.html | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/intro.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 48 | ||||
-rw-r--r-- | yaksh/templates/yaksh/quizzes_user.html | 24 | ||||
-rw-r--r-- | yaksh/templates/yaksh/show_video.html | 38 | ||||
-rw-r--r-- | yaksh/templatetags/custom_filters.py | 3 | ||||
-rw-r--r-- | yaksh/views.py | 10 |
11 files changed, 131 insertions, 59 deletions
diff --git a/yaksh/static/yaksh/js/add_quiz.js b/yaksh/static/yaksh/js/add_quiz.js index f4067ed..57993ef 100644 --- a/yaksh/static/yaksh/js/add_quiz.js +++ b/yaksh/static/yaksh/js/add_quiz.js @@ -21,15 +21,5 @@ String.prototype.beginsWith = function (string) { function usermode(location) { - var select = document.getElementById("id_prerequisite"); - var select_text = select.options[select.selectedIndex].text; - if (select_text.beginsWith("----")){ - window.alert("No prerequisite for this course.\n \ - You can attempt the quiz."); - window.location.replace(location); - } else { - window.alert(select_text + " is a prerequisite for this course.\n \ - You are still allowed to attempt this quiz.") - window.location.replace(location); - } - } + window.location.replace(location); +} diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html index 9b565eb..ce3bf44 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -15,7 +15,7 @@ <a class="navbar-brand" href="#"> Yaksh </a> </div> <div class= "collapse navbar-collapse" id="navbar"> - <form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{module_id}}/{{ paper.question_paper.id }}/{{course_id}}/" method="post" class="pull-right"> + <form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{module.id}}/{{ paper.question_paper.id }}/{{course.id}}/" method="post" class="pull-right"> {% csrf_token %} <ul class="nav navbar-nav navbar"> <li style="padding: 10px"><button class="btn btn-danger btn-sm" type="submit" name="quit"> @@ -52,15 +52,15 @@ {% if qid.id == question.id %} <li class="active"><a style="width:25%" href="#"data-toggle="tooltip" title="{{ qid.description|striptags }}" - onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ module_id }}/{{ paper.question_paper.id }}/{{course_id}}/')">{{ forloop.counter }}</a></li> + onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ module.id }}/{{ paper.question_paper.id }}/{{course.id}}/')">{{ forloop.counter }}</a></li> {% else %} <li><a style="width:25%" href="#" data-toggle="tooltip" title="{{ qid.description|striptags }}" - onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ module_id }}/{{ paper.question_paper.id }}/{{course_id}}/')">{{ forloop.counter }}</a></li> + onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ module.id }}/{{ paper.question_paper.id }}/{{course.id}}/')">{{ forloop.counter }}</a></li> {% endif %} {% endif %} {% if qid in paper.get_questions_answered %} <li><a style="background-color:#B4B8BA; width:25%" href="#" data-toggle="tooltip" - onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ module_id }}/{{ paper.question_paper.id }}/{{course_id}}/')" + onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ qid.id }}/{{ paper.attempt_number }}/{{ module.id }}/{{ paper.question_paper.id }}/{{course.id}}/')" title="{{ qid.description }}">{{ forloop.counter }}</a></li> {% endif %} {% else %} @@ -73,6 +73,9 @@ {% endfor %} </ul> <p>Question(s) left: <b>{{ paper.questions_left }}</b></p> + <br><br><br> + {% block learning_units %} + {% endblock %} </div> <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main"> <div class="row"> diff --git a/yaksh/templates/yaksh/add_module.html b/yaksh/templates/yaksh/add_module.html index f9676e6..499646b 100644 --- a/yaksh/templates/yaksh/add_module.html +++ b/yaksh/templates/yaksh/add_module.html @@ -16,13 +16,16 @@ {% block content %} {% if course_id %} - <a href="{{URL_ROOT}}/exam/manage/courses/" class="btn btn-primary">Cancel</a> + <a href="{{URL_ROOT}}/exam/manage/courses/" class="btn btn-primary"> + Back to Courses</a> {% else %} - <a href="{{URL_ROOT}}/exam/manage/courses/all_learning_module" class="btn btn-primary">Cancel</a> + <a href="{{URL_ROOT}}/exam/manage/courses/all_learning_module" class="btn btn-primary"> + Back to Learning Modules</a> {% endif %} {% if status == "add" %} <form name=frm id=frm action="" method="post"> {% csrf_token %} + <br> <center> <table class="table table-bordered"> {{ module_form.as_table }} diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 5c954da..242b6da 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -5,7 +5,7 @@ {% csrf_token %} {% if paper.questions_answered.all or paper.questions_unanswered.all %} <center><table class="table table-bordered" > - <caption> Submission Status </caption> + <caption> <center><h2>Submission Status</h2> </center></caption> <thead> <tr> <th> Question</th> @@ -29,21 +29,25 @@ {% endfor %} </table></center> {% endif %} - <center><h2> Good bye! </h2></center> - <center><h4> {{message}} </h4></center> - {% if not module_id %} - <br><center><h4>You may now close the browser.</h4></center><br> - {% endif %} - <center> - <a href="{{URL_ROOT}}/exam/" id="home" class="btn btn-success"> Home </a> - </center> + <center><h3>{{message}}</h3></center> + <center> + <br> + {% if not module_id %} + <br><center><h4>You may now close the browser.</h4></center><br> + {% endif %} + <a href="{{URL_ROOT}}/exam/" id="home" class="btn btn-success"> Home </a> {% if module_id %} - <center> {% if first_unit %} - <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}/1" class="btn btn-info"> Next Unit </a> + <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}/1" class="btn btn-info"> Next Unit + <span class="glyphicon glyphicon-chevron-right"> + </span> + </a> {% else %} - <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}" class="btn btn-info"> Next Unit </a> + <a href="{{URL_ROOT}}/exam/next_unit/{{course_id}}/{{module_id}}/{{learning_unit.id}}" class="btn btn-info"> Next Unit + <span class="glyphicon glyphicon-chevron-right"> + </span> + </a> {% endif %} - </center> {% endif %} + </center> {% endblock content %} diff --git a/yaksh/templates/yaksh/design_course_session.html b/yaksh/templates/yaksh/design_course_session.html index 87acc33..35e6949 100644 --- a/yaksh/templates/yaksh/design_course_session.html +++ b/yaksh/templates/yaksh/design_course_session.html @@ -14,6 +14,9 @@ {% endblock %} {% block main %} +<a href="{{URL_ROOT}}/exam/manage/courses/" class="btn btn-primary"> + Back to Courses +</a> <form action="{{URL_ROOT}}/exam/manage/courses/designcourse/{{course_id}}/" method="POST" id="design_course_form"> {% csrf_token %} <div class="tab-pane active" id="available-lesson-quiz"> diff --git a/yaksh/templates/yaksh/intro.html b/yaksh/templates/yaksh/intro.html index bdbdaba..2d213b9 100644 --- a/yaksh/templates/yaksh/intro.html +++ b/yaksh/templates/yaksh/intro.html @@ -30,7 +30,7 @@ </div> <div class="col-md-6"> {% if not questionpaper.quiz.is_expired %} - <form action="{{URL_ROOT}}/exam/start/{{ attempt_num }}/{{module_id}}/{{ questionpaper.id }}/{{course}}/" method="post" align="center"> + <form action="{{URL_ROOT}}/exam/start/{{ attempt_num }}/{{module.id}}/{{ questionpaper.id }}/{{course.id}}/" method="post" align="center"> {% csrf_token %} <center><button class="btn btn-success" type="submit" name="start"> Start Exam <span class="glyphicon glyphicon-chevron-right"></span></button></center> </form> diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 293b02e..eab3289 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -65,7 +65,6 @@ function updateClock(){ clock.innerHTML = "<center><strong>" + hh + ":" + mm + ":" + ss + "</strong></center>"; } } - var clock = document.getElementById("time_left"); updateClock(); var timeinterval = setInterval(updateClock,1000); @@ -88,8 +87,8 @@ function call_skip(url) } init_val = '{{ last_attempt|escape_quotes|safe }}'; lang = "{{ question.language }}" -course_id = "{{course_id}}" -module_id = "{{module_id}}" +course_id = "{{course.id}}" +module_id = "{{module.id}}" </script> @@ -97,6 +96,45 @@ module_id = "{{module_id}}" {% block onload %} onload="updateTime();" {% endblock %} +{% block learning_units %} +<center><h3>Lessons/Quizzes</h3></center> +<ul class="list"> +{% for unit in module.get_learning_units %} +<span> +<li> + +{% get_unit_status course module unit user as status %} + +{% if unit.quiz.id == paper.question_paper.quiz.id %} + <span class="glyphicon glyphicon-pencil" data-toggle="tooltip" title="Current Unit"></span> +{% endif %} + +{% if unit.learning_type == "quiz" %} + {% if status == "completed" %} + <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> + {{ unit.quiz.description }} + </a> + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> + {% else %} + {{ unit.quiz.description }} + {% endif %} +{% else %} + {% if status == "completed" %} + <a href="{{ URL_ROOT }}/exam/show_video/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> + {{ unit.lesson.name }} + </a> + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> + {% else %} + {{ unit.lesson.name }} + {% endif %} +{% endif %} +</li> +</span> +<br> +{% endfor %} +</ul> +{% endblock %} + {% block main %} <p id="status"></p> {% if notification %} @@ -113,7 +151,7 @@ module_id = "{{module_id}}" <div id="notification" role="alert"> </div> {% endif %} - <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/{{ paper.attempt_number }}/{{ module_id }}/{{ paper.question_paper.id }}/{{course_id}}/" method="post" enctype="multipart/form-data"> + <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/{{ paper.attempt_number }}/{{ module.id }}/{{ paper.question_paper.id }}/{{course.id}}/" method="post" enctype="multipart/form-data"> {% csrf_token %} <input type=hidden name="question_id" id="question_id" value={{ question.id }}></input> <div class="panel panel-default"> @@ -227,7 +265,7 @@ module_id = "{{module_id}}" {% if paper.question_paper.quiz.allow_skip and not paper.get_questions_unanswered|length_is:"1" %} {% if question in paper.get_questions_unanswered %} - <button class="btn btn-primary" onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ paper.attempt_number }}/{{ module_id }}/{{ paper.question_paper.id }}/{{course_id}}/')" name="skip" id="skip">Attempt Later <span class="glyphicon glyphicon-arrow-right"></span></button> + <button class="btn btn-primary" onclick="call_skip('{{ URL_ROOT }}/exam/{{ question.id }}/skip/{{ paper.attempt_number }}/{{ module.id }}/{{ paper.question_paper.id }}/{{course.id}}/')" name="skip" id="skip">Attempt Later <span class="glyphicon glyphicon-arrow-right"></span></button> {% endif %} </div> </div> diff --git a/yaksh/templates/yaksh/quizzes_user.html b/yaksh/templates/yaksh/quizzes_user.html index 5699a07..d564a8f 100644 --- a/yaksh/templates/yaksh/quizzes_user.html +++ b/yaksh/templates/yaksh/quizzes_user.html @@ -1,10 +1,16 @@ {% extends "user.html" %} {% load custom_filters %} +{% block title %} Student Dashboard {% endblock %} {% block pagetitle %} {{ title }} {% endblock %} {% block main %} + {% if msg %} + <div class="alert alert-warning" role="alert"> + {{ msg }} + </div> + {% endif %} {% if 'Enrolled Courses' not in title%} <div class="row well"> - <form action="{{ URL_ROOT }}/exam/quizzes/" method="post" id="custom-search-form" class="form-search form-horizontal pull-right"> + <form action="{{ URL_ROOT }}/exam/quizzes/" method="post" id="custom-search-form" class="form-search form-horizontal"> {% csrf_token %} <div class="col-md-12"> <div class="input-group"> @@ -63,6 +69,10 @@ No Courses to display {{module.name}}</a> </td> <td> + <a data-toggle="collapse" data-target="#learning_units{{module.id}}{{course.id}}"> + <span class="glyphicon glyphicon-chevron-down"> + View Learning Units</span></a> + <div id="learning_units{{module.id}}{{course.id}}" class="collapse"> <table class="table table-bordered"> <th>Lesson/quiz</th> <th>status</th> @@ -80,9 +90,9 @@ No Courses to display <td> {% get_unit_status course module unit user as status %} {% if status == "completed" %} - <span class="label label-info">{{status}}</span> + <span class="label label-info">{{status|title}}</span> {% else %} - <span class="label label-warning">{{status}}</span> + <span class="label label-warning">{{status|title}}</span> {% endif %} </td> <td> @@ -100,12 +110,14 @@ No Courses to display </tr> {% endfor %} </table> + </div> </td> <td> - {% if module.status == "completed" %} - <span class="label label-info">{{module.status}}</span> + {% get_module_status user module course as module_status %} + {% if module_status == "completed" %} + <span class="label label-info">{{module_status|title}}</span> {% else %} - <span class="label label-warning">{{module.status}}</span> + <span class="label label-warning">{{module_status|title}}</span> {% endif %} </td> </tr> diff --git a/yaksh/templates/yaksh/show_video.html b/yaksh/templates/yaksh/show_video.html index f0d1c73..fa80ddb 100644 --- a/yaksh/templates/yaksh/show_video.html +++ b/yaksh/templates/yaksh/show_video.html @@ -7,24 +7,35 @@ {% block usersidebar %} <br><br><br> -<center><h3>Module List</h3></center> +<center><h3>Lessons/Quizzes</h3></center> <ul class="list"> {% for unit in learning_units %} <span> <li> +{% get_unit_status course learning_module unit user as status %} + +{% if unit.id == current_unit.id %} + <span class="glyphicon glyphicon-pencil" data-toggle="tooltip" title="Current Unit"> + </span> +{% endif %} {% if unit.learning_type == "quiz" %} - <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> - {{ unit.quiz.description }}</a> + {% if status == "completed" %} + <a href="{{ URL_ROOT }}/exam/start/{{unit.quiz.questionpaper_set.get.id}}/{{learning_module.id}}/{{course.id}}"> + {{ unit.quiz.description }} + </a> + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> + {% else %} + {{ unit.quiz.description }} + {% endif %} {% else %} + {% if status == "completed" %} <a href="{{ URL_ROOT }}/exam/show_video/{{unit.lesson.id}}/{{learning_module.id}}/{{course.id}}"> - {{ unit.lesson.name }}</a> -{% endif %} - -{% get_unit_status course learning_module unit user as status %} -{% if status == "completed" %} - <span class="label label-info">{{status}}</span> -{% else %} - <span class="label label-warning">{{status}}</span> + {{ unit.lesson.name }} + </a> + <span class="glyphicon glyphicon-ok" style="color: #7CFC00;"></span> + {% else %} + {{ unit.lesson.name }} + {% endif %} {% endif %} </li> </span> @@ -34,6 +45,11 @@ {% endblock %} {% block main %} +{% if msg %} +<center> +<div class="alert alert-warning">{{msg}}</div> +</center> +{% endif %} {% if state == "module" %} <div class="panel panel-default"> <div class="panel-body"> diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py index 1195653..1749d71 100644 --- a/yaksh/templatetags/custom_filters.py +++ b/yaksh/templatetags/custom_filters.py @@ -39,3 +39,6 @@ def file_title(name): def get_unit_status(course, module, unit, user): return course.get_unit_completion_status(module, user, unit) +@register.simple_tag +def get_module_status(user, module, course): + return module.get_status(user, course) diff --git a/yaksh/views.py b/yaksh/views.py index f7f5e71..90ef5f9 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1696,14 +1696,14 @@ def test_mode(user, godmode=False, questions_list=None, quiz_id=None, trial_questionpaper = QuestionPaper.objects.create_trial_paper_to_test_questions( trial_quiz, questions_list ) - trial_unit = LearningUnit.objects.get_or_create( + trial_unit, created = LearningUnit.objects.get_or_create( order=1, learning_type="quiz", quiz=trial_quiz, check_prerequisite=False) - module = LearningModule.objects.get_or_create( + module, created = LearningModule.objects.get_or_create( order=1, creator=user, check_prerequisite=False, name="Trial for {0}".format(trial_course.name)) - module[0].learning_unit.add(trial_unit[0]) - trial_course.learning_module.add(module[0].id) + module.learning_unit.add(trial_unit) + trial_course.learning_module.add(module.id) else: trial_quiz, trial_course, module = Quiz.objects.create_trial_from_quiz( quiz_id, user, godmode, course_id @@ -1711,7 +1711,7 @@ def test_mode(user, godmode=False, questions_list=None, quiz_id=None, trial_questionpaper = QuestionPaper.objects.create_trial_paper_to_test_quiz( trial_quiz, quiz_id ) - return trial_questionpaper, trial_course, module[0] + return trial_questionpaper, trial_course, module @login_required |