Skip to content

Commit 2417e74

Browse files
committed
added jquery datatable in quiz list
1 parent a96019c commit 2417e74

File tree

10 files changed

+251
-30
lines changed

10 files changed

+251
-30
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.0.4 on 2020-04-18 15:55
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('classroom', '0003_auto_20191008_0704'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='question',
15+
name='text',
16+
field=models.TextField(verbose_name='Question'),
17+
),
18+
]

django_school/classroom/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __str__(self):
3333

3434
class Question(models.Model):
3535
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE, related_name='questions')
36-
text = models.CharField('Question', max_length=255)
36+
text = models.TextField('Question')
3737

3838
def __str__(self):
3939
return self.text
Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,48 @@
11
{% extends 'base.html' %}
2+
{% load static %}
3+
4+
{% block css %}
5+
<link rel="stylesheet" type="text/css" href="{% static 'datatables/dataTables.bootstrap4.min.css' %}">
6+
{% endblock %}
27

38
{% block content %}
49
{% include 'classroom/students/_header.html' with active='new' %}
5-
<div class="card">
6-
<table class="table mb-0">
7-
<thead>
10+
11+
<table class="table table-striped table-bordered mb-0" id="tb_quizlist" >
12+
<thead>
13+
<tr>
14+
<th>Quiz</th>
15+
<th class="d-none d-sm-table-cell">Subject</th>
16+
<th class="d-none d-sm-table-cell">Length</th>
17+
<th></th>
18+
</tr>
19+
</thead>
20+
<tbody>
21+
{% for quiz in quizzes %}
822
<tr>
9-
<th>Quiz</th>
10-
<th class="d-none d-sm-table-cell">Subject</th>
11-
<th class="d-none d-sm-table-cell">Length</th>
12-
<th></th>
23+
<td class="align-middle">{{ quiz.name }}</td>
24+
<td class="align-middle d-none d-sm-table-cell">{{ quiz.subject.get_html_badge }}</td>
25+
<td class="align-middle d-none d-sm-table-cell">{{ quiz.questions_count }} questions</td>
26+
<td class="text-right">
27+
<a href="{% url 'students:take_quiz' quiz.pk %}" class="btn btn-primary">Start quiz</a>
28+
</td>
1329
</tr>
14-
</thead>
15-
<tbody>
16-
{% for quiz in quizzes %}
17-
<tr>
18-
<td class="align-middle">{{ quiz.name }}</td>
19-
<td class="align-middle d-none d-sm-table-cell">{{ quiz.subject.get_html_badge }}</td>
20-
<td class="align-middle d-none d-sm-table-cell">{{ quiz.questions_count }} questions</td>
21-
<td class="text-right">
22-
<a href="{% url 'students:take_quiz' quiz.pk %}" class="btn btn-primary">Start quiz</a>
23-
</td>
24-
</tr>
25-
{% empty %}
26-
<tr>
27-
<td class="bg-light text-center font-italic" colspan="4">No quiz matching your interests right now.</td>
28-
</tr>
29-
{% endfor %}
30-
</tbody>
31-
</table>
32-
</div>
30+
{% empty %}
31+
<tr>
32+
<td class="bg-light text-center font-italic" colspan="4">No quiz matching your interests right now.</td>
33+
</tr>
34+
{% endfor %}
35+
</tbody>
36+
</table>
3337
{% endblock %}
38+
39+
{% block js %}
40+
<script src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
41+
<script src="{% static 'datatables/jquery.dataTables.min.js' %}"></script>
42+
<script src="{% static 'datatables/dataTables.bootstrap4.min.js' %}"></script>
43+
<script type="text/javascript">
44+
$(document).ready(function() {
45+
$('#tb_quizlist').DataTable();
46+
});
47+
</script>
48+
{% endblock %}

django_school/classroom/templates/classroom/students/quiz_result.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
{% load quiz_extras %}
33

44
{% block content %}
5-
{% include 'classroom/students/_header.html' %}
5+
{% include 'classroom/students/_header.html' with active='taken' %}
66

77
<h2>{{quiz.name}}</h2>
88
{{ quiz.subject.get_html_badge }}
99

1010
<div class="progress">
1111
<div class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: {{percentage}}%" aria-valuenow="{{percentage}}" aria-valuemin="0" aria-valuemax="100">{{percentage}}%</div>
12-
</div>
13-
<hr>
12+
</div><br>
1413
{% for question in questions %}
1514
<div class="card">
1615
<div class="card-body">

django_school/classroom/templates/classroom/students/student_list.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
{% extends 'base.html' %}
33
{% load quiz_extras %}
44

5+
{% block css %}
6+
<style type="text/css">
7+
.media {
8+
margin-top: 10px
9+
}
10+
</style>
11+
{% endblock %}
12+
513
{% block content %}
614
{% include 'classroom/students/_header.html' with active='students' %}
715
<form method='GET'>

django_school/static/datatables/dataTables.bootstrap4.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

django_school/static/datatables/dataTables.bootstrap4.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)