diff options
author | adityacp | 2020-01-02 15:34:18 +0530 |
---|---|---|
committer | adityacp | 2020-01-02 15:34:18 +0530 |
commit | 29f93bce956af26e1b3ffe5ffc04e02c9f32de59 (patch) | |
tree | 9d7f566a2d7e5d333d34efa3e1c3fa115a54fa92 /grades | |
parent | d60050dcfe7e32dc720e48942c7457860da79d6b (diff) | |
download | online_test-29f93bce956af26e1b3ffe5ffc04e02c9f32de59.tar.gz online_test-29f93bce956af26e1b3ffe5ffc04e02c9f32de59.tar.bz2 online_test-29f93bce956af26e1b3ffe5ffc04e02c9f32de59.zip |
Change UI in add grades template
Diffstat (limited to 'grades')
-rw-r--r-- | grades/forms.py | 33 | ||||
-rw-r--r-- | grades/models.py | 3 | ||||
-rw-r--r-- | grades/templates/add_grades.html | 97 | ||||
-rw-r--r-- | grades/templates/grading_systems.html | 46 | ||||
-rw-r--r-- | grades/views.py | 6 |
5 files changed, 159 insertions, 26 deletions
diff --git a/grades/forms.py b/grades/forms.py index 130659d..4f9c9a7 100644 --- a/grades/forms.py +++ b/grades/forms.py @@ -1,8 +1,39 @@ -from grades.models import GradingSystem +from grades.models import GradingSystem, GradeRange from django import forms class GradingSystemForm(forms.ModelForm): + + def __init__(self, *args, **kwargs): + super(GradingSystemForm, self).__init__(*args, **kwargs) + self.fields['name'].widget.attrs.update( + {'class': "form-control", 'placeholder': 'Grading Name'} + ) + self.fields['description'].widget.attrs.update( + {'class': "form-control", + 'placeholder': 'Grading description'} + ) class Meta: model = GradingSystem fields = ['name', 'description'] + + +class GradeRangeForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super(GradeRangeForm, self).__init__(*args, **kwargs) + self.fields['lower_limit'].widget.attrs.update( + {'class': "form-control", 'placeholder': 'Lower limit'} + ) + self.fields['upper_limit'].widget.attrs.update( + {'class': "form-control", 'placeholder': 'Upper limit'} + ) + self.fields['grade'].widget.attrs.update( + {'class': "form-control", 'placeholder': 'Grade'} + ) + self.fields['description'].widget.attrs.update( + {'class': "form-control", + 'placeholder': 'Description'} + ) + class Meta: + model = GradeRange + fields = "__all__" diff --git a/grades/models.py b/grades/models.py index fcea510..b395a24 100644 --- a/grades/models.py +++ b/grades/models.py @@ -44,3 +44,6 @@ class GradeRange(models.Model): upper_limit = models.FloatField() grade = models.CharField(max_length=10) description = models.CharField(max_length=127, null=True, blank=True) + + def __str__(self): + return self.system.name.title() diff --git a/grades/templates/add_grades.html b/grades/templates/add_grades.html index a3f52da..d05a9bb 100644 --- a/grades/templates/add_grades.html +++ b/grades/templates/add_grades.html @@ -1,9 +1,51 @@ {% extends "manage.html" %} +{% load custom_filters %} +{% block title %} Add/Edit Grading {% endblock %} {% block main %} <html> -<a href="{% url 'grades:grading_systems'%}" class="btn btn-danger"> Back to Grading Systems </a> -<br><br> -<p><b>Note: For grade range lower limit is inclusive and upper limit is exclusive</b></p> +<br><br><br> +<div class="row"> + <div class="col-md-8"> + <ul class="nav nav-pills" id="course_tabs"> + <li class="nav-item"> + <a class="nav-link" href="{% url 'yaksh:courses' %}"> + My Courses + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="{% url 'yaksh:allotted_courses' %}"> + Allotted Courses + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="{% url 'yaksh:add_course' %}"> + Add New Course + </a> + </li> + <li class="nav-item dropdown hide"> + <a class="nav-link dropdown-toggle active" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="true">More</a> + <div class="dropdown-menu hide" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 37px, 0px); top: 0px; left: 0px; will-change: transform;"> + <a class="dropdown-item" href="{% url 'yaksh:show_all_quizzes' %}"> + View Quizzes + </a> + <a class="dropdown-item" href="{% url 'yaksh:show_all_lessons' %}"> + View Lessons + </a> + <a class="dropdown-item" href="{% url 'yaksh:show_all_modules' %}"> + View Modules + </a> + <a href="{% url 'grades:grading_systems'%}" class="dropdown-item active" > + View Grading Systems + </a> + </div> + </li> + </ul> + </div> +</div> +<hr> +<div class="alert alert-info"> + Note: For grade range lower limit is inclusive and upper limit is exclusive +</div> <br> {% if not system_id %} <form action="{% url 'grades:add_grade' %}" method="POST"> @@ -12,24 +54,39 @@ {% endif %} {% csrf_token %} <table class="table"> - {{ grade_form }} + {% for field in grade_form %} + {{ field }} + <hr> + {% endfor %} + {{ formset.management_form }} + <br> + <div class="col-md-4"> + {% for form in formset %} + {% for hidden in form.hidden_fields %} + {{ hidden }} + {% endfor %} + <b><u>Grade Range {{forloop.counter}}.</u></b> + <br> + {% for field in form.visible_fields %} + {% if field.field.widget|is_checkbox %} + {{field.label}} + {% endif %} + {{ field }} + <hr> + {% endfor %} + <br> + {% endfor %} + </div> </table> - {{ formset.management_form }} - <br> - <b><u>Grade Ranges</u></b> - <hr> - {% for form in formset %} - <div> - {{ form }} - </div> - <hr> - {% endfor %} - {% if not is_default %} - <input type="submit" id="add" name="add" value="Add" class="btn btn-info"> - <input type="submit" id="save" name="save" value="Save" class="btn btn-success"> - {% else %} - <p><b>Note: This is a default grading system. You cannot change this.</b></p> - {% endif %} + {% if not is_default %} + <input type="submit" id="add" name="add" value="Add/Delete Grade Range" class="btn btn-info btn-lg"> + <input type="submit" id="save" name="save" value="Save" class="btn btn-success btn-lg"> + {% else %} + <div class="alert alert-warning"> + Note: This is a default grading system. You cannot change this. + </div> + {% endif %} + <br><br> </form> </html> {% endblock %} diff --git a/grades/templates/grading_systems.html b/grades/templates/grading_systems.html index 3a71ebf..8129c72 100644 --- a/grades/templates/grading_systems.html +++ b/grades/templates/grading_systems.html @@ -1,8 +1,50 @@ {% extends "manage.html" %} +{% block title %} View Grading Systems {% endblock %} {% block main %} <html> - <a href="{% url 'grades:add_grade' %}" class="btn btn-primary"> Add a Grading System </a> - <a href="{% url 'yaksh:courses' %}" class="btn btn-danger"> Back to Courses </a> + <br><br><br> + <div class="row"> + <div class="col-md-8"> + <ul class="nav nav-pills" id="course_tabs"> + <li class="nav-item"> + <a class="nav-link" href="{% url 'yaksh:courses' %}"> + My Courses + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="{% url 'yaksh:allotted_courses' %}"> + Allotted Courses + </a> + </li> + <li class="nav-item"> + <a class="nav-link" href="{% url 'yaksh:add_course' %}"> + Add New Course + </a> + </li> + <li class="nav-item dropdown hide"> + <a class="nav-link dropdown-toggle active" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="true">More</a> + <div class="dropdown-menu hide" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 37px, 0px); top: 0px; left: 0px; will-change: transform;"> + <a class="dropdown-item" href="{% url 'yaksh:show_all_quizzes' %}"> + View Quizzes + </a> + <a class="dropdown-item" href="{% url 'yaksh:show_all_lessons' %}"> + View Lessons + </a> + <a class="dropdown-item" href="{% url 'yaksh:show_all_modules' %}"> + View Modules + </a> + <a href="{% url 'grades:grading_systems'%}" class="dropdown-item active" > + View Grading Systems + </a> + </div> + </li> + </ul> + </div> + </div> + <hr> + <a href="{% url 'grades:add_grade' %}" class="btn btn-success btn-lg"> + <span class=" fa fa-plus-circle"></span> Add a Grading System + </a> <br><br> <b> Available Grading Systems: </b> <table class="table"> diff --git a/grades/views.py b/grades/views.py index 67844bd..7403e4e 100644 --- a/grades/views.py +++ b/grades/views.py @@ -1,7 +1,7 @@ from django.shortcuts import render from django.contrib.auth.decorators import login_required from django.forms import inlineformset_factory -from grades.forms import GradingSystemForm +from grades.forms import GradingSystemForm, GradeRangeForm from grades.models import GradingSystem, GradeRange @@ -21,7 +21,7 @@ def add_grading_system(request, system_id=None): if system_id is not None: grading_system = GradingSystem.objects.get(id=system_id) GradeRangeFormSet = inlineformset_factory(GradingSystem, GradeRange, - fields='__all__', extra=0) + GradeRangeForm, extra=0) grade_form = GradingSystemForm(instance=grading_system) is_default = (grading_system is not None and grading_system.name == 'default') @@ -38,7 +38,7 @@ def add_grading_system(request, system_id=None): formset.save() if 'add' in request.POST: GradeRangeFormSet = inlineformset_factory( - GradingSystem, GradeRange, fields='__all__', extra=1 + GradingSystem, GradeRange, GradeRangeForm, extra=1 ) formset = GradeRangeFormSet(instance=grading_system) |