diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/forms.py | 5 | ||||
-rw-r--r-- | yaksh/templates/registration/password_change_done.html | 7 | ||||
-rw-r--r-- | yaksh/templates/registration/password_change_form.html | 11 | ||||
-rw-r--r-- | yaksh/templates/registration/password_reset_complete.html | 1 | ||||
-rw-r--r-- | yaksh/templates/registration/password_reset_done.html | 1 | ||||
-rw-r--r-- | yaksh/templates/registration/password_reset_form.html | 1 | ||||
-rw-r--r-- | yaksh/templates/yaksh/add_course.html | 6 | ||||
-rw-r--r-- | yaksh/templates/yaksh/complete.html | 2 | ||||
-rw-r--r-- | yaksh/templates/yaksh/courses.html | 1 | ||||
-rw-r--r-- | yaksh/templates/yaksh/editprofile.html | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/login.html | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/moderator_dashboard.html | 7 | ||||
-rw-r--r-- | yaksh/templates/yaksh/register.html | 3 | ||||
-rw-r--r-- | yaksh/templates/yaksh/showquestions.html | 80 | ||||
-rw-r--r-- | yaksh/views.py | 13 |
15 files changed, 80 insertions, 64 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index ffb15a6..951fcc1 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -398,8 +398,11 @@ class ProfileForm(forms.ModelForm): widget=forms.Select({'class': 'custom-select'}) ) + class UploadFileForm(forms.Form): - file = forms.FileField(widget=forms.FileInput(attrs={'class': 'upload'})) + file = forms.FileField( + widget=forms.FileInput(attrs={'class': 'custom-file-input'}) + ) class QuestionPaperForm(forms.ModelForm): diff --git a/yaksh/templates/registration/password_change_done.html b/yaksh/templates/registration/password_change_done.html index 9dd04b5..34045d4 100644 --- a/yaksh/templates/registration/password_change_done.html +++ b/yaksh/templates/registration/password_change_done.html @@ -1,5 +1,12 @@ {% extends "base.html" %} {% load static %} +{% block pagetitle %} +<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top"> + <a class="navbar-brand" href="{% url 'yaksh:index' %}"> + <img src="{% static 'yaksh/images/yaksh_banner.png' %}" alt="YAKSH"> + </a> +</nav> +{% endblock %} {% block title %} Change Password {% endblock %} {% block script %} diff --git a/yaksh/templates/registration/password_change_form.html b/yaksh/templates/registration/password_change_form.html index b4880c6..f286741 100644 --- a/yaksh/templates/registration/password_change_form.html +++ b/yaksh/templates/registration/password_change_form.html @@ -1,11 +1,18 @@ {% extends "base.html" %} +{% load static %} <!DOCTYPE html> -{% block pagetitle %} Change Password {% endblock %} +{% block pagetitle %} +<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top"> + <a class="navbar-brand" href="{% url 'yaksh:index' %}"> + <img src="{% static 'yaksh/images/yaksh_banner.png' %}" alt="YAKSH"> + </a> +</nav> +Change Password +{% endblock %} {% block title %} Change Password {% endblock %} {% block content %} -<br><br> <form action="" method="post" > {% csrf_token %} <center> diff --git a/yaksh/templates/registration/password_reset_complete.html b/yaksh/templates/registration/password_reset_complete.html index 20dc697..ddf94a6 100644 --- a/yaksh/templates/registration/password_reset_complete.html +++ b/yaksh/templates/registration/password_reset_complete.html @@ -12,7 +12,6 @@ {% endblock %} {% block content %} -<br><br> <center> <div class="container"> <p>Your password has been reset. </p> diff --git a/yaksh/templates/registration/password_reset_done.html b/yaksh/templates/registration/password_reset_done.html index 036d691..94138dd 100644 --- a/yaksh/templates/registration/password_reset_done.html +++ b/yaksh/templates/registration/password_reset_done.html @@ -11,7 +11,6 @@ {% endblock %} {% block content %} -<br><br> <center> <h2>Password reset successful</h2> <div class="alert alert-success col-md-8"> diff --git a/yaksh/templates/registration/password_reset_form.html b/yaksh/templates/registration/password_reset_form.html index eeca8f2..acee288 100644 --- a/yaksh/templates/registration/password_reset_form.html +++ b/yaksh/templates/registration/password_reset_form.html @@ -12,7 +12,6 @@ {% endblock %} {% block content %} -<br><br> <center> <h4>Enter your registered email address to reset your password</h4> <div class="container"> diff --git a/yaksh/templates/yaksh/add_course.html b/yaksh/templates/yaksh/add_course.html index 2f584c9..6276425 100644 --- a/yaksh/templates/yaksh/add_course.html +++ b/yaksh/templates/yaksh/add_course.html @@ -1,8 +1,6 @@ {% extends "manage.html" %} {% load static %} -{% block title %}Add Course{% endblock %} - {% block css %} <link rel="stylesheet" href="{% static 'yaksh/css/jquery.datetimepicker.css' %}"> {% endblock %} @@ -11,9 +9,9 @@ <script type="text/javascript" src="{% static 'yaksh/js/jquery.datetimepicker.full.min.js' %}"> </script> {% endblock %} - +{% block title %} Add Course {% endblock %} +{% block pagetitle %} Add Course {% endblock %} {% block content %} -<br><br><br> <div class="container"> <div class="row"> <div class="col-md-8"> diff --git a/yaksh/templates/yaksh/complete.html b/yaksh/templates/yaksh/complete.html index 03dc4c1..8c8073e 100644 --- a/yaksh/templates/yaksh/complete.html +++ b/yaksh/templates/yaksh/complete.html @@ -49,7 +49,7 @@ </center> {% endif %} <br><br> - <center class="container-fluid"> + <center class="container"> <h5> <span class="alert alert-success">{{message}}</span> </h5> diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index 4548d33..e5f3936 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -11,7 +11,6 @@ </style> {% endblock %} {% block content %} -<br><br> <div class="container-fluid"> <div class="container"> <div class="row"> diff --git a/yaksh/templates/yaksh/editprofile.html b/yaksh/templates/yaksh/editprofile.html index 2161716..47e74ea 100644 --- a/yaksh/templates/yaksh/editprofile.html +++ b/yaksh/templates/yaksh/editprofile.html @@ -1,9 +1,8 @@ {% extends template %} {% block title %} Edit Profile {% endblock %} +{% block pagetitle %} My Profile {% endblock %} {% block main %} -<br><br><br> <div class="container"> - <center><h2> My Profile </h2></center> <br> <form action="{% url 'yaksh:edit_profile'%}" method="post" > {% csrf_token %} diff --git a/yaksh/templates/yaksh/login.html b/yaksh/templates/yaksh/login.html index 464a8dd..e2adca7 100644 --- a/yaksh/templates/yaksh/login.html +++ b/yaksh/templates/yaksh/login.html @@ -4,7 +4,7 @@ {% block title %} Login {% endblock %} {% block nav %} -<nav class="navbar navbar-expand-lg navbar-dark bg-primary"> +<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top"> <a class="navbar-brand" href="{% url 'yaksh:index' %}"> <img src="{% static 'yaksh/images/yaksh_banner.png' %}" alt="YAKSH"> </a> @@ -12,7 +12,6 @@ {% endblock %} {% block content %} -<center></center> <div class="container"> <div class="row justify-content-center"> <div class="col-md-6 col-md-offset-6"> diff --git a/yaksh/templates/yaksh/moderator_dashboard.html b/yaksh/templates/yaksh/moderator_dashboard.html index b36bc2d..db37983 100644 --- a/yaksh/templates/yaksh/moderator_dashboard.html +++ b/yaksh/templates/yaksh/moderator_dashboard.html @@ -1,13 +1,12 @@ {% extends "manage.html" %} {% load custom_filters %} -{% block title %} Moderartor Dashboard {% endblock %} +{% block title %} My Dashboard {% endblock %} +{% block pagetitle %} <h2>My Dashboard</h2> {% endblock %} {% block content %} -<br><br> <div class="container"> <center> - {% block pagetitle %} <h2>My Dashboard</h2> {% endblock %} <h4> List of quizzes! Click on the given links to have a look at answer papers for a quiz </h4> @@ -44,7 +43,7 @@ <div id="accordion"> {% for course in courses %} <div class="card"> - <div class="card-header" style="height: 100px"> + <div class="card-header"> <div class="row"> <div class="col-md-4"> <h4 data-toggle="tooltip" title="{{course.name}}"> diff --git a/yaksh/templates/yaksh/register.html b/yaksh/templates/yaksh/register.html index 33bc561..454cd5b 100644 --- a/yaksh/templates/yaksh/register.html +++ b/yaksh/templates/yaksh/register.html @@ -2,6 +2,7 @@ {% load static %} {% block title %} Register {% endblock %} +{% block pagetitle %} Registration {% endblock %} {% block nav %} <nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top"> @@ -13,8 +14,6 @@ {% block content %} <div class="container-fluid"> - <br> - {% block pagetitle %}<center><h1> Registration </h1></center>{% endblock %} <div class="row justify-content-center form-group"> <div class="col-md-4 col-md-offset-4"> <form action="" method="post"> diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index d0c33dd..c9a7690 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -46,20 +46,31 @@ </p> </div> <div class="card-body"> - <div><a class="btn btn-lg btn-primary" href="{% url 'yaksh:download_yaml_template' %}">Download Template</a></div> - <br/> - <h4> Or </h4> <form action="" method="post" enctype="multipart/form-data"> {% csrf_token %} - <div class="form-group"> - <div class="input-group mb-3"> - <div class="custom-file"> - {{ upload_form.as_p }} + <div class="form-group col-md-6"> + <a class="btn btn-lg btn-primary" href="{% url 'yaksh:download_yaml_template' %}">Download Template</a> + <br><br> + <h4> Or </h4> + <br> + <div class="input-group mb-3"> + <div class="custom-file"> + {{ upload_form }} + <label class="custom-file-label" for="id_file"> + Choose file + </label> + </div> </div> - </div> + <button class="btn btn-lg btn-success" type="submit" name="upload" value="upload">Upload File</button> </div> - <h4>And</h4> - <button class="btn btn-lg btn-success" type="submit" name="upload" value="upload">Upload File</button> + <script> + $('#id_file').on('change',function(){ + //get the file name + var fileName = $(this).val(); + //replace the "Choose a file" label + $(this).next('.custom-file-label').html(fileName); + }) + </script> </form> </div> </div> @@ -67,36 +78,32 @@ <!-- Show questions --> <div id="show" class="tab-pane fade show active" role="tabpanel" aria-labelledby="showbar"> - <form name=frm action="" method="post"> - {% csrf_token %} - {% if message %} - {%if message == "Questions Uploaded Successfully"%} - <div class="alert alert-success alert-dismissable"> - <a href="#" class="close" data-dismiss="alert" aria-label="close"><span class="fa fa-window-close"></span></a> - {{ message }} - </div> - {%else %} - <div class="alert alert-danger alert-dismissable"> - <a href="#" class="close" data-dismiss="alert" aria-label="close"><span class="fa fa-window-close"></span></a> - {{ message }} - </div> - {% endif %} - {% endif %} - {% if msg %} - <div class="alert alert-danger alert-dismissable animated flash"> - <a href="#" class="close" data-dismiss="alert" aria-label="close"><span class="fa fa-window-close"></span></a> - {{ msg }} - </div> - {% endif %} - </form> - <form name=frm action="" method="post"> + {% if messages %} + {% for message in messages %} + <div class="alert alert-dismissible alert-info"> + <button type="button" class="close" data-dismiss="alert"> + <i class="fa fa-close"></i> + </button> + <strong>{{ message }}</strong> + </div> + {% endfor %} + {% endif %} + <form name=frm action="" method="post"> <div class="card"> <div class="card-body"> <!-- Filtering Questions --> <div id="selectors"> <h4>Filters Questions: </h4> <div class="dropdown"> - {{ form.question_type }} {{ form.language }} {{ form.marks }} + <div class="col-md-4"> + {{ form.question_type }} + </div> + <div class="col-md-4"> + {{ form.language }} + </div> + <div class="col-md-4"> + {{ form.marks }} + </div> </div> </div> <hr> @@ -174,6 +181,7 @@ {% include "yaksh/paginator.html" %} {% endif %} </div> + <br> <center> <a class="btn btn-lg btn-primary" href="{% url 'yaksh:add_question' %}">Add Question</a> @@ -183,10 +191,10 @@ {% endif %} <button class="btn btn-lg btn-danger" type="submit" onClick="return confirm_delete(frm);" name='delete' value='delete'>Delete Selected</button> </center> - </form> + </form> </div> <!-- End of Show questions --> - </div> + </div> </div> {% endblock %} diff --git a/yaksh/views.py b/yaksh/views.py index f5a4b82..b826c81 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1500,6 +1500,7 @@ def show_all_questions(request): user = request.user context = {} + message = None if not is_moderator(user): raise Http404("You are not allowed to view this page !") @@ -1534,6 +1535,7 @@ def show_all_questions(request): for question in questions: question.active = False question.save() + message = "Questions deleted successfully" if request.POST.get('upload') == 'upload': form = UploadFileForm(request.POST, request.FILES) @@ -1543,14 +1545,13 @@ def show_all_questions(request): ques = Question() if file_extension == "zip": files, extract_path = extract_files(questions_file) - context['message'] = ques.read_yaml(extract_path, user, + message = ques.read_yaml(extract_path, user, files) elif file_extension in ["yaml", "yml"]: questions = questions_file.read() - context['message'] = ques.load_questions(questions, user) + message = ques.load_questions(questions, user) else: message = "Please Upload a ZIP file" - context['message'] = message if request.POST.get('download') == 'download': question_ids = request.POST.getlist('question') @@ -1565,7 +1566,7 @@ def show_all_questions(request): response.write(zip_file.read()) return response else: - context['msg'] = ("Please select atleast" + + message = ("Please select atleast " + "one question to download") if request.POST.get('test') == 'test': @@ -1578,13 +1579,13 @@ def show_all_questions(request): return my_redirect("/exam/start/1/{0}/{1}/{2}".format( trial_module.id, trial_paper.id, trial_course.id)) else: - context["msg"] = "Please select atleast one question to test" + message = "Please select atleast one question to test" if request.POST.get('question_tags'): question_tags = request.POST.getlist("question_tags") search_result = _get_questions_from_tags(question_tags, user) context['questions'] = search_result - + messages.info(request, message) return my_render_to_response(request, 'yaksh/showquestions.html', context) |