numerous improvements

This commit is contained in:
Ross
2020-12-09 22:59:07 +00:00
parent 55cb599364
commit d7766a7d95
15 changed files with 146 additions and 9 deletions
+10
View File
@@ -0,0 +1,10 @@
import django_filters
from .models import AnatomyQuestion
class AnatomyQuestionFilter(django_filters.FilterSet):
class Meta:
model = AnatomyQuestion
fields = ("question_type", "examination", "modality", "region",
"body_part", "created_date", "open_access", "author")
+2 -1
View File
@@ -91,8 +91,9 @@ button a {
color: inherit;
}
#admin-link {
#admin-link, #logout-link, #profile-link {
float: right;
padding-left: 10px;
}
.marking-list {
+26
View File
@@ -0,0 +1,26 @@
import django_tables2 as tables
from django_tables2.utils import A
from .models import AnatomyQuestion
class AnatomyQuestionTable(tables.Table):
edit = tables.LinkColumn('anatomy:anatomy_question_update',
text='Edit',
args=[A('pk')],
orderable=False)
view = tables.LinkColumn('anatomy:question_detail',
text='View',
args=[A('pk')],
orderable=False)
#clone = tables.LinkColumn('anatomy:anatomy_question_clone',
# text='Clone',
# args=[A('pk')],
# orderable=False)
class Meta:
model = AnatomyQuestion
template_name = "django_tables2/bootstrap4.html"
fields = ("question_type", "description", "examination", "modality", "region",
"body_part", "created_date", "open_access", "author")
sequence = ("view", )
@@ -0,0 +1,18 @@
{% extends 'anatomy/base.html' %}
{% load render_table from django_tables2 %}
{% block css %}
{% endblock %}
{% block content %}
<div id="view-filter-options">
<h3>Filter Anatomy Questions</h3>
<form action="" method="get">
{{ filter.form }}
<input class="btn btn-primary btn-sm mt-1 mb-1" type="submit" />
</form>
</div>
{% render_table table %}
{% endblock %}
+18 -4
View File
@@ -3,6 +3,8 @@
<head>
<title>Anatomy Quiz</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="{% static 'tagulous/lib/select2-3/select2.css' %}">
<link rel="stylesheet" href="{% static 'css/anatomy.css' %}">
<link rel="stylesheet" href="{% static 'css/toastr.min.css' %}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@@ -22,12 +24,24 @@
<body>
<div class="page-header">
{% if request.user.is_staff %}<span id="admin-link"><a
href="{% url 'admin:index' %}">Admin</a></span>{% endif %}
{% if request.user.is_authenticated %}
<span id="logout-link">
<a href="{% url 'logout' %}">Logout</a>
</span>
<span id="profile-link">
<a href="{% url 'profile' %}">Profile</a>
</span>
{% endif %}
{% if request.user.is_staff %}
<span id="admin-link">
<a href="{% url 'admin:index' %}">Admin</a>
</span>
{% endif %}
</div>
<div class="content container">
<a href="{% url 'anatomy:exam_list' %}">Exams</a>
<a href="{% url 'anatomy:anatomy_question_create' %}" title="Create a new question">Create Question</a>
<a href="{% url 'anatomy:exam_list' %}">Exams</a> /
<a href="{% url 'anatomy:anatomy_question_view' %}">Questions</a> /
<a href="{% url 'anatomy:anatomy_question_create' %}" title="Create a new question">Create Question</a>
{% block navigation %}
{% endblock %}
<div class="row">
+1
View File
@@ -1,6 +1,7 @@
{% extends 'anatomy/base.html' %}
{% block content %}
<h1>Examinations</h1>
<div class="anatomy">
Active exams:<br/>
<ul>
+1 -1
View File
@@ -4,7 +4,7 @@
<div class="anatomy">
<h2>{{ exam.name }}</h2>
{% for user, value in user_answers_marks.items %}
<h3>Candidate: {{ user_names|get_item:user }}</h3>
<h3>Candidate: <a href="{% url 'anatomy:cid_scores' user %}">{{ user_names|get_item:user }}</a></h3>
<!-- Answers: {{ user_answers_and_marks|get_item:user }}-->
Answers: {% for ans, score in user_answers_and_marks|get_item:user %}
{{ans}} ({{score}}),
+1 -1
View File
@@ -2,5 +2,5 @@
{% block navigation %}
<br/>
{{exam.name}}-> <a href="{% url 'anatomy:exam_overview' pk=exam.pk %}">Overview</a> <a href="{% url 'anatomy:mark_overview' pk=exam.pk %}">Mark</a> <a href="{% url 'anatomy:exam_scores_cid' pk=exam.pk %}">Scores</a>
{{exam.name}}-> <a href="{% url 'anatomy:exam_overview' pk=exam.pk %}">Overview</a> / <a href="{% url 'anatomy:mark_overview' pk=exam.pk %}">Mark</a> / <a href="{% url 'anatomy:exam_scores_cid' pk=exam.pk %}">Scores</a>
{% endblock %}
@@ -23,7 +23,7 @@
</div>
<div>
Examinations: {% for exam in question.exams.all %}
{{ exam.name }}
<a href="{% url 'anatomy:exam_overview' pk=exam.pk %}">{{ exam.name }}</a>
{% endfor %}
</div>
<div>
-12
View File
@@ -1,12 +0,0 @@
{% extends '../anatomy/base.html' %}
{% block title %}Login{% endblock %}
{% block content %}
<h2>Login</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Login</button>
</form>
{% endblock %}
+1
View File
@@ -6,6 +6,7 @@ app_name = "anatomy"
urlpatterns = [
# path('', views.question_list, name='question_list'),
path("", views.index, name="index"),
path("question/", views.AnatomyQuestionView.as_view(), name="anatomy_question_view"),
path("question/<int:pk>/", views.question_detail, name="question_detail"),
path("question/create/", views.AnatomyQuestionCreate.as_view(), name="anatomy_question_create"),
path("question/<int:pk>/update", views.AnatomyQuestionUpdate.as_view(), name="anatomy_question_update"),
+14 -1
View File
@@ -32,6 +32,12 @@ from .models import (
#IncorrectAnswers,
)
from .tables import AnatomyQuestionTable
from .filters import AnatomyQuestionFilter
from django_tables2 import SingleTableView, SingleTableMixin
from django_filters.views import FilterView
from collections import defaultdict
import os
import base64
@@ -932,4 +938,11 @@ def get_structure_id(request):
'structure_id': structure_id,
}
return HttpResponse(json.dumps(data), content_type='application/json')
return HttpResponse("/")
return HttpResponse("/")
class AnatomyQuestionView(SingleTableMixin, FilterView):
model = AnatomyQuestion
table_class = AnatomyQuestionTable
template_name = "anatomy/anatomy_question_view.html"
filterset_class = AnatomyQuestionFilter