From eaf4873ff71eb3655a82f24d05e00881040a4326 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 28 Jan 2020 18:18:07 +0530 Subject: Change in views, forms, templates, static - Revamp UI in student dashboard - Fix course form to get bootstrap form class - Add custom css for sidebar in course module page for student - Use django url pattern --- yaksh/forms.py | 27 +- yaksh/static/yaksh/css/custom.css | 72 +++- yaksh/templates/exam.html | 169 ++++---- yaksh/templates/user.html | 95 ++--- yaksh/templates/yaksh/complete.html | 24 +- yaksh/templates/yaksh/course_modules.html | 321 ++++++++-------- yaksh/templates/yaksh/error_template.html | 14 +- yaksh/templates/yaksh/intro.html | 91 ++--- yaksh/templates/yaksh/question.html | 496 ++++++++++++------------ yaksh/templates/yaksh/quit.html | 20 +- yaksh/templates/yaksh/quizzes_user.html | 292 +++++++------- yaksh/templates/yaksh/show_video.html | 282 +++++++------- yaksh/templates/yaksh/view_answerpaper.html | 574 ++++++++++++++++------------ yaksh/urls.py | 17 +- yaksh/views.py | 13 +- 15 files changed, 1323 insertions(+), 1184 deletions(-) diff --git a/yaksh/forms.py b/yaksh/forms.py index d82cd55..79342da 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -354,7 +354,18 @@ class CourseForm(forms.ModelForm): 'view_grade' ] - def __init__(self, *args, **kwargs): + def save(self, commit=True, *args, **kwargs): + instance = super(CourseForm, self).save(commit=False) + if instance.code: + instance.hidden = True + else: + instance.hidden = False + + if commit: + instance.save() + return instance + + def __init__(self, user, *args, **kwargs): super(CourseForm, self).__init__(*args, **kwargs) self.fields['name'].widget.attrs.update( {'class': form_input_class, 'placeholder': 'Course Name'} @@ -377,20 +388,6 @@ class CourseForm(forms.ModelForm): self.fields['grading_system'].widget.attrs.update( {'class': 'custom-select'} ) - - def save(self, commit=True, *args, **kwargs): - instance = super(CourseForm, self).save(commit=False) - if instance.code: - instance.hidden = True - else: - instance.hidden = False - - if commit: - instance.save() - return instance - - def __init__(self, user, *args, **kwargs): - super(CourseForm, self).__init__(*args, **kwargs) if self.instance.id and self.instance.teachers.filter(id=user.id).exists(): self.fields['grading_system'].widget.attrs['disabled'] = True else: diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css index 8623bfb..63ee455 100644 --- a/yaksh/static/yaksh/css/custom.css +++ b/yaksh/static/yaksh/css/custom.css @@ -26,4 +26,74 @@ body, .dropdown-menu { #rendered_text{ width: 550px; -} \ No newline at end of file +} + +.navbar { + padding: 15px 10px; + background: #fff; + border: none; + border-radius: 0; + margin-bottom: 40px; + box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); +} + +.navbar-btn { + box-shadow: none; + outline: none !important; + border: none; +} + +.line { + width: 100%; + height: 1px; + border-bottom: 1px dashed #ddd; + margin: 40px 0; +} + +/* --------------------------------------------------- + SIDEBAR STYLE +----------------------------------------------------- */ + +.wrapper { + display: flex; + width: 100%; + align-items: stretch; +} + +#sidebar { + min-width: 350px; + max-width: 350px; + background: #fff; + transition: all 0.3s; +} + +#sidebar.active { + margin-left: -350px; +} + +#sidebar .sidebar-header { + padding: 20px; + background: #158CBA; +} + +#sidebar ul.components { + padding: 20px 0; + border-bottom: 1px solid #fff; +} + +#sidebar ul li a { + padding: 10px; + font-size: 1.1em; + display: block; +} + +/* --------------------------------------------------- + CONTENT STYLE +----------------------------------------------------- */ + +#content { + width: 100%; + padding: 20px; + min-height: 100vh; + transition: all 0.3s; +} diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html index d439c64..6480cce 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -1,83 +1,89 @@ {% extends "base.html" %} {% load custom_filters %} +{% load static %} + +{% block title %}{{ paper.question_paper.quiz.description }}{% endblock %} + {% block nav %} -
- +
+
{% endblock %} {% block content %}
- - - - -
-
- - {% block main %} - {% endblock %} -
-
+
+
+
+ +
+
+ {% block main %} + {% endblock %} +
diff --git a/yaksh/templates/user.html b/yaksh/templates/user.html index 4ded0a3..4e3974b 100644 --- a/yaksh/templates/user.html +++ b/yaksh/templates/user.html @@ -1,39 +1,46 @@ {% extends "base.html" %} - +{% load static %} {% block nav %} -
- + +
+ {% endblock %} @@ -44,25 +51,3 @@ {% endblock %} {% endblock %} {% endblock %} - -{% block footer %} - - - -{% endblock %} \ No newline at end of file diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 8c8073e..f5bf444 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -1,10 +1,10 @@ {% extends "base.html" %} - +{% load static %} {% block nav %} {% endblock %} @@ -12,7 +12,7 @@
{% if module_id and not paper.question_paper.quiz.is_trial %}
-
+
Note:- Please Click on the Next button to submit the quiz. Please do not close the browser without clicking Next.
@@ -20,11 +20,11 @@ {% csrf_token %} {% if paper.questions_answered.all or paper.questions_unanswered.all %}
-
+

Submission Status

- + @@ -37,7 +37,7 @@ {% else %} - + {% endif %} @@ -56,20 +56,20 @@

- {% if module_id and not paper.question_paper.quiz.is_trial %} + {% if module_id and not paper.course.is_trial %} {% if first_unit %} - {% else %} - {% endif %} {% else %} - Home + Home {% endif %}
{% endblock content %} diff --git a/yaksh/templates/yaksh/course_modules.html b/yaksh/templates/yaksh/course_modules.html index 8440d51..214f8c7 100644 --- a/yaksh/templates/yaksh/course_modules.html +++ b/yaksh/templates/yaksh/course_modules.html @@ -1,186 +1,175 @@ {% extends "user.html" %} {% load custom_filters %} {% block title %} Course Modules {% endblock %} -{% block script %} - -{% endblock %} {% block main %} -
-
-
-
-
{{ course.name }}
-
- {% if course.has_lessons %} - - Download Course - - {% endif %} -
-
-
-
- -
- {% if course.view_grade %} -
- Grade: {% if grade %} {{ grade }} {% else %} Will be available once the course is complete {% endif %} +
+
+ {{ course.name }}
- {% endif %} - - {% if msg %} - - {% endif %} -
- -
-{% if modules %} -
- - Overall Course Progress -
- {% if course_percentage <= 50 %} -
- {% elif course_percentage <= 75 %} -
- {% else %} -
- {% endif %} - {{course_percentage}}% Completed -
-
- - {% for module, percent in modules %} -
-
-
- {{module.name|title}} +
+ {% if course.view_grade %} +
+ Grade: {% if grade %} {{ grade }} {% else %} Will be available once the course is complete {% endif %} +
+ {% endif %} + {% if msg %} +
+ + {{ msg }}
- -
- -
- - - + {% endif %} + {% if modules %} + Overall Course Progress: +
+ {% if course_percentage %} + {% if course_percentage <= 50 %} +
+ {% elif course_percentage <= 75 %} +
+ {% else %} +
+ {% endif %} + {{course_percentage}}% Completed
-
- + {% else %} + 0% Completed + {% endif %} +
+ {% else %} +
+ No lectures found
-
-
-
- - {% get_module_status user module course as module_status %} - {% if module_status == "completed" %} -
- View -
- {% elif module_status == "inprogress" %} -
- Continue -
- {% else %} -
- Start + {% endif %} +
+ {% for module, percent in modules %} +
+
+
+
+
+ {{ module.name|title }} +
+
+ +
+
+ {% if percent %} + {% get_module_status user module course as module_status %} + {% if module_status == "completed" %} +
+ {% elif module_status == "inprogress" %} +
+ {% endif %} + {{percent}}% Completed +
+ {% else %} + 0% Completed + {% endif %} +
+
- {% endif %} -
-
- {% get_module_status user module course as module_status %} - {% if module_status == "completed" %} -
-
{{ percent }} % completed
-
- {% elif module_status == "inprogress" %} -
-
{{ percent }} % completed
+
+
+
Question Status
{{ question.summary }} Attempted
{{ question }} Not completed
+ {% for unit in module.get_learning_units %} + + + + + + + + {% endfor %} +
+ {% if unit.type == "quiz" %} + {% if unit.quiz.is_exercise %} + + {% else %} + + {% endif %} + {% else %} + + {% endif %} + + {% if unit.type == "quiz" %} + {{unit.quiz.description}} + {% else %} + {{unit.lesson.name}} + {% endif %} + + {% if unit.type == "lesson" %} + + View + + {% else %} + + View + + {% endif %} + + {% get_unit_status course module unit user as status %} + {% if status == "completed" %} + {{status|title}} + + {% elif status == "inprogress" %} + {{status|title}} + + {% else %} + {{status|title}} + + {% endif %} + + {% if unit.type == "quiz" %} + {% if unit.quiz.view_answerpaper %} + +  Answer paper + {% else %} + + Answer paper + {% endif %} + {% else %} + ------ + {% endif %} +
- {% else %} -
-
{{ percent }} % completed
-
- {% endif %} -
-
- - - {% for unit in module.get_learning_units %} - - - - - - - - {% endfor %} -
- {% if unit.type == "quiz" %} - {% if unit.quiz.is_exercise %} - - {% else %} - - {% endif %} - {% else %} - - {% endif %} - - {% if unit.type == "quiz" %} - {{unit.quiz.description}} - {% else %} - {{unit.lesson.name}} - {% endif %} - - {% get_unit_status course module unit user as status %} - {% if status == "completed" %} - {{status|title}} - - {% elif status == "inprogress" %} - {{status|title}} - - {% else %} - {{status|title}} - - {% endif %} - - {% if unit.type == "quiz" %} - {% if unit.quiz.view_answerpaper %} - - Answer paper - {% else %} - - Answer paper - {% endif %} - {% else %} - ------ - {% endif %} -
-
+
+ {% endfor %} - {% endfor %} -{% else %} -

No lectures found

-{% endif %} - {% endblock %} diff --git a/yaksh/templates/yaksh/error_template.html b/yaksh/templates/yaksh/error_template.html index 00fa306..9cfeac1 100644 --- a/yaksh/templates/yaksh/error_template.html +++ b/yaksh/templates/yaksh/error_template.html @@ -1,19 +1,17 @@ - +{% load static %} {% block css%} - + {% endblock %} {% block script %} - + {% endblock %} {% load custom_filters %} {% if error_message %} -
{% for error in error_message %} -
Error No. {{ forloop.counter }}
-
+
{% if not error.type %}
 {{error|safe}} 
@@ -92,7 +90,7 @@
+
- {% endfor %} -
+ {% endfor %} {% endif %} \ No newline at end of file diff --git a/yaksh/templates/yaksh/intro.html b/yaksh/templates/yaksh/intro.html index 567282a..7657a65 100644 --- a/yaksh/templates/yaksh/intro.html +++ b/yaksh/templates/yaksh/intro.html @@ -1,61 +1,54 @@ {% extends "base.html" %} -{% block pagetitle %} OnlineTest Instructions and Rules {% endblock pagetitle %} +{% block title %} {{questionpaper.quiz.description}} {% endblock %} +{% block pagetitle %} Quiz Instructions and Rules {% endblock pagetitle %} {% block content %} -
-
- {% if questionpaper.quiz.is_expired %} -
+
+
+
+ {{questionpaper.quiz.description}} +
+
+ {% if questionpaper.quiz.is_expired %} +
This Quiz has expired. You can no longer attempt this Quiz. -
- {% else %} -
- {% load tz %} - {% get_current_timezone as TIME_ZONE %} - You can attempt this Quiz at any time between {{ questionpaper.quiz.start_date_time }} {{ TIME_ZONE }} and {{ questionpaper.quiz.end_date_time }} {{ TIME_ZONE }} -
- You are not allowed to attempt the Quiz before or after this duration -
+ {% else %} +
+ You can attempt this Quiz at any time between {{ questionpaper.quiz.start_date_time }} and {{ questionpaper.quiz.end_date_time }}
- {% endif %} -
-
+ {% endif %}

Welcome {{user.get_full_name|title}}, to the programming quiz!

{{ questionpaper.quiz.instructions|safe }} -
-
-
- {% if status != "moderator" %} - - - - Go Back - {% else %} - - - - Go Back - {% endif %} -
-
-
- {% if not questionpaper.quiz.is_expired %} -
- {% csrf_token %} -
-
- {% endif %} -
+
+
+
+ {% if status != "moderator" %} + + + Go Back + + {% else %} + + + Go Back + + {% endif %} +
+
+
+ {% if not questionpaper.quiz.is_expired %} +
+ {% csrf_token %} + +
+ {% endif %} +
-
+
+
{% endblock content %} - -{% if user %} - {% block info %} -
{{user.get_full_name|title}}({{user.profile.roll_number}}) Logged in as {{user.username}}
- {% endblock %} -{% endif %} - diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index f13de1a..3ad82ca 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -1,11 +1,12 @@ {% extends "exam.html" %} {% load custom_filters %} - +{% load static %} {% block css %} - - - + + + + +
{{user_answer.0|safe}}
+ {% elif question.type == "mcc" or question.type == "mcq" %} + {% for testcases in question.get_test_cases %} + {% if testcases.id|stringformat:"i" in ans.answer.answer.strip %} +
  • {{ testcases.options.strip|safe }}
  • + {% endif %} + {% endfor %} + {% elif question.type == "arrange"%} + {% get_answer_for_arrange_options ans.answer.answer question as tc_list %} + {% for testcases in tc_list %} +
  • {{ testcases.options.strip }}
  • + {% endfor %} + {% else %} + {{ ans.answer.answer.strip }} + {% endif %} + + + + +
    + {% endfor %} - {% else %} -
    Student answer:
    -
    -
    - {{ answers.0.answer }} -
    -
    - {% endif %} - - - {% else %} -
    Student answer:
    - {% for answer in answers %} - {% if not answer.skipped %} - {% if answer.answer.correct %} -
    -
    - Correct Answer -
    - {% else %} -
    -
    - Incorrect Answer -
    - {% endif %} - - {% with answer.error_list as err %} - {% for error in err %} - - {% if error.type == 'stdio' %} -
    -
    - {% if error.given_input %} - - - - - - -
    For given Input value(s):{{error.given_input}}
    - {% endif %} - - - - - - - - - - - - {% for expected,user in error.expected_output|zip:error.user_output %} - - - - {% if forloop.counter0 in error.error_line_numbers or not expected or not user %} - - {% else %} - - {% endif %} - - {% endfor %} -
    Line No.
    Expected Output
    User output
    Status
    {{forloop.counter}} {{expected|default:""}} {{user|default:""}}
    - - - - - - -
    Error:{{error.error_msg}}
    +
    + {% endif %} +
    +
    +
    + + {% with answers|last as answer %} +

    + {% endwith %} +
    +
    +
    + {% endfor %} {# for question, answers ... #} +
    +

    Teacher comments:

    + +
    +
    -
    - {% elif error.type == 'assertion' %} - {% if error.test_case %} - We tried you code with the following test case:

    -
    {{error.test_case}}
    - {% endif %} -

    The following error took place:

    -
    - - - - - - - - - - - {% if error.traceback %} - - - {% endif %} - -
    Exception Name: {{error.exception}}
    Exception Message: {{error.message}}
    Full Traceback:
    {{error.traceback}}
    -
    - {% else %} -
     {{error}} 
    - {% endif %} - {% endfor %} - {% endwith %} -
    - {% pygmentise_user_answer question.language answer.answer.answer.strip as user_answer %} - -
    {{user_answer.0|safe}}
    -
    - - {% endif %} - {% endfor %} - {% endif %} - {% with answers|last as answer %} -

    Obtained Marks: {{answer.answer.marks}}

    - {% endwith %} -
    - {% endfor %} {# for question, answers ... #} -

    Teacher comments:

    - {{ paper.comments|default:"None" }} -

    - {% endif %} {# if paper.answers.count #} - + {% endif %} {# if paper.answers.count #} {% endfor %} {# for paper in data.papers #} - -{% endif %} {# if not data.papers #} + {% else %} +
    +
    +
    + {% if quiz.is_exercise %} + You have not attempted the Exercise {{ quiz.description }} + {% else %} + You have not attempted the quiz {{ quiz.description }} + {% endif %} +
    +
    + {% endif %} {# if data.papers #} {% endblock %} diff --git a/yaksh/urls.py b/yaksh/urls.py index 78e7221..e9f3539 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -15,14 +15,17 @@ urlpatterns = [ name='quizlist_user'), url(r'^results/$', views.results_user), url(r'^start/(?P\d+)/(?P\d+)/' - '(?P\d+)/$', views.start), + '(?P\d+)/$', views.start, name="start_quiz"), url(r'^start/(?P\d+)/(?P\d+)/' - '(?P\d+)/(?P\d+)/$', views.start), + '(?P\d+)/(?P\d+)/$', views.start, + name="start_quiz"), url(r'^quit/(?P\d+)/(?P\d+)/' - '(?P\d+)/(?P\d+)/$', views.quit), - url(r'^complete/$', views.complete), + '(?P\d+)/(?P\d+)/$', views.quit, + name="quit_quiz"), + url(r'^complete/$', views.complete, name="complete"), url(r'^complete/(?P\d+)/(?P\d+)/' - '(?P\d+)/(?P\d+)/$', views.complete), + '(?P\d+)/(?P\d+)/$', views.complete, + name="complete"), url(r'^register/$', views.user_register, name="register"), url(r'^(?P\d+)/check/$', views.check, name="check"), url(r'^get_result/(?P\d+)/(?P\d+)/(?P\d+)/$', @@ -32,10 +35,10 @@ urlpatterns = [ views.check, name="check"), url(r'^(?P\d+)/skip/(?P\d+)/(?P\d+)/' '(?P\d+)/(?P\d+)/$', - views.skip), + views.skip, name="skip_question"), url(r'^(?P\d+)/skip/(?P\d+)/(?P\d+)/' '(?P\d+)/(?P\d+)/(?P\d+)/$', - views.skip), + views.skip, name="skip_question"), url(r'^enroll_request/(?P\d+)/$', views.enroll_request, name='enroll_request'), url(r'^self_enroll/(?P\d+)/$', views.self_enroll, diff --git a/yaksh/views.py b/yaksh/views.py index 6cebe3a..1f714e3 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -175,7 +175,6 @@ def quizlist_user(request, enrolled=None, msg=None): hidden_courses = Course.objects.get_hidden_courses(code=course_code) courses = hidden_courses title = 'Search' - elif enrolled is not None: courses = user.students.filter(is_trial=False).order_by('-id') title = 'Enrolled Courses' @@ -188,7 +187,7 @@ def quizlist_user(request, enrolled=None, msg=None): title = 'All Courses' for course in courses: - if user in course.students.all(): + if course.students.filter(id=user.id).exists(): _percent = course.get_completion_percent(user) else: _percent = None @@ -500,14 +499,14 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, # is user enrolled in the course if not course.is_enrolled(user): msg = 'You are not enrolled in {0} course'.format(course.name) - if is_moderator(user): + if is_moderator(user) and course.is_trial: return prof_manage(request, msg=msg) return quizlist_user(request, msg=msg) # if course is active and is not expired if not course.active or not course.is_active_enrollment(): msg = "{0} is either expired or not active".format(course.name) - if is_moderator(user): + if is_moderator(user) and course.is_trial: return prof_manage(request, msg=msg) return quizlist_user(request, msg=msg) @@ -515,7 +514,7 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, if quest_paper.quiz.is_expired() or not quest_paper.quiz.active: msg = "{0} is either expired or not active".format( quest_paper.quiz.description) - if is_moderator(user): + if is_moderator(user) and course.is_trial: return prof_manage(request, msg=msg) return view_module(request, module_id=module_id, course_id=course_id, msg=msg) @@ -525,7 +524,7 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, 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): + if is_moderator(user) and course.is_trial: return prof_manage(request, msg=msg) return view_module(request, module_id=module_id, course_id=course_id, msg=msg) @@ -2784,7 +2783,7 @@ def get_next_unit(request, course_id, module_id, current_unit_id=None, user = request.user course = Course.objects.prefetch_related("learning_module").get( id=course_id) - if user not in course.students.all(): + if not course.students.filter(id=user.id).exists(): raise Http404('You are not enrolled for this course!') learning_module = course.learning_module.prefetch_related( "learning_unit").get(id=module_id) -- cgit