From 8e5354fb2fdab96780bfd147ba5b1724eebd673b Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 21 Nov 2017 17:08:23 +0530 Subject: 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 --- yaksh/static/yaksh/js/add_quiz.js | 14 +------ yaksh/templates/exam.html | 11 ++++-- yaksh/templates/yaksh/add_module.html | 7 +++- yaksh/templates/yaksh/complete.html | 30 ++++++++------- yaksh/templates/yaksh/design_course_session.html | 3 ++ yaksh/templates/yaksh/intro.html | 2 +- yaksh/templates/yaksh/question.html | 48 +++++++++++++++++++++--- yaksh/templates/yaksh/quizzes_user.html | 24 +++++++++--- yaksh/templates/yaksh/show_video.html | 38 +++++++++++++------ yaksh/templatetags/custom_filters.py | 3 ++ 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 @@ Yaksh
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 %} - Cancel + + Back to Courses {% else %} - Cancel + + Back to Learning Modules {% endif %} {% if status == "add" %} {% csrf_token %} +
{{ 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 %}
- + @@ -29,21 +29,25 @@ {% endfor %}
Submission Status

Submission Status

Question
{% endif %} -

Good bye!

-

{{message}}

- {% if not module_id %} -

You may now close the browser.


- {% endif %} -
- Home -
+

{{message}}

+
+
+ {% if not module_id %} +

You may now close the browser.


+ {% endif %} + Home {% if module_id %} -
{% if first_unit %} - Next Unit + Next Unit + + + {% else %} - Next Unit + Next Unit + + + {% endif %} -
{% endif %} +
{% 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 %} + + Back to Courses + {% csrf_token %}
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 @@
{% if not questionpaper.quiz.is_expired %} - + {% csrf_token %}
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 = "
" + hh + ":" + mm + ":" + ss + "
"; } } - 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}}" @@ -97,6 +96,45 @@ module_id = "{{module_id}}" {% block onload %} onload="updateTime();" {% endblock %} +{% block learning_units %} +

Lessons/Quizzes

+
    +{% for unit in module.get_learning_units %} + +
  • + +{% get_unit_status course module unit user as status %} + +{% if unit.quiz.id == paper.question_paper.quiz.id %} + +{% endif %} + +{% if unit.learning_type == "quiz" %} + {% if status == "completed" %} + + {{ unit.quiz.description }} + + + {% else %} + {{ unit.quiz.description }} + {% endif %} +{% else %} + {% if status == "completed" %} + + {{ unit.lesson.name }} + + + {% else %} + {{ unit.lesson.name }} + {% endif %} +{% endif %} +
  • +
    +
    +{% endfor %} +
+{% endblock %} + {% block main %}

{% if notification %} @@ -113,7 +151,7 @@ module_id = "{{module_id}}" {% endif %} -
+ {% csrf_token %}
@@ -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 %} - + {% endif %}
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 %} + + {% endif %} {% if 'Enrolled Courses' not in title%}
- + {% csrf_token %}
@@ -63,6 +69,10 @@ No Courses to display {{module.name}} + + + View Learning Units +
@@ -80,9 +90,9 @@ No Courses to display {% endfor %}
Lesson/quiz status {% get_unit_status course module unit user as status %} {% if status == "completed" %} - {{status}} + {{status|title}} {% else %} - {{status}} + {{status|title}} {% endif %} @@ -100,12 +110,14 @@ No Courses to display
+
- {% if module.status == "completed" %} - {{module.status}} + {% get_module_status user module course as module_status %} + {% if module_status == "completed" %} + {{module_status|title}} {% else %} - {{module.status}} + {{module_status|title}} {% endif %} 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 %}


-

Module List

+

Lessons/Quizzes

    {% for unit in learning_units %}
  • +{% get_unit_status course learning_module unit user as status %} + +{% if unit.id == current_unit.id %} + + +{% endif %} {% if unit.learning_type == "quiz" %} - - {{ unit.quiz.description }} + {% if status == "completed" %} + + {{ unit.quiz.description }} + + + {% else %} + {{ unit.quiz.description }} + {% endif %} {% else %} + {% if status == "completed" %} - {{ unit.lesson.name }} -{% endif %} - -{% get_unit_status course learning_module unit user as status %} -{% if status == "completed" %} - {{status}} -{% else %} - {{status}} + {{ unit.lesson.name }} + + + {% else %} + {{ unit.lesson.name }} + {% endif %} {% endif %}
  • @@ -34,6 +45,11 @@ {% endblock %} {% block main %} +{% if msg %} +
    +
    {{msg}}
    +
    +{% endif %} {% if state == "module" %}
    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 -- cgit