numerous improvements
This commit is contained in:
@@ -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")
|
||||||
@@ -91,8 +91,9 @@ button a {
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#admin-link {
|
#admin-link, #logout-link, #profile-link {
|
||||||
float: right;
|
float: right;
|
||||||
|
padding-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.marking-list {
|
.marking-list {
|
||||||
|
|||||||
@@ -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 %}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Anatomy Quiz</title>
|
<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/anatomy.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'css/toastr.min.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>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
@@ -22,12 +24,24 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
{% if request.user.is_staff %}<span id="admin-link"><a
|
{% if request.user.is_authenticated %}
|
||||||
href="{% url 'admin:index' %}">Admin</a></span>{% endif %}
|
<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>
|
||||||
<div class="content container">
|
<div class="content container">
|
||||||
<a href="{% url 'anatomy:exam_list' %}">Exams</a>
|
<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:anatomy_question_view' %}">Questions</a> /
|
||||||
|
<a href="{% url 'anatomy:anatomy_question_create' %}" title="Create a new question">Create Question</a>
|
||||||
{% block navigation %}
|
{% block navigation %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{% extends 'anatomy/base.html' %}
|
{% extends 'anatomy/base.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<h1>Examinations</h1>
|
||||||
<div class="anatomy">
|
<div class="anatomy">
|
||||||
Active exams:<br/>
|
Active exams:<br/>
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="anatomy">
|
<div class="anatomy">
|
||||||
<h2>{{ exam.name }}</h2>
|
<h2>{{ exam.name }}</h2>
|
||||||
{% for user, value in user_answers_marks.items %}
|
{% 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: {{ user_answers_and_marks|get_item:user }}-->
|
||||||
Answers: {% for ans, score in user_answers_and_marks|get_item:user %}
|
Answers: {% for ans, score in user_answers_and_marks|get_item:user %}
|
||||||
{{ans}} ({{score}}),
|
{{ans}} ({{score}}),
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
{% block navigation %}
|
{% block navigation %}
|
||||||
<br/>
|
<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 %}
|
{% endblock %}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Examinations: {% for exam in question.exams.all %}
|
Examinations: {% for exam in question.exams.all %}
|
||||||
{{ exam.name }}
|
<a href="{% url 'anatomy:exam_overview' pk=exam.pk %}">{{ exam.name }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ app_name = "anatomy"
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('', views.question_list, name='question_list'),
|
# path('', views.question_list, name='question_list'),
|
||||||
path("", views.index, name="index"),
|
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/<int:pk>/", views.question_detail, name="question_detail"),
|
||||||
path("question/create/", views.AnatomyQuestionCreate.as_view(), name="anatomy_question_create"),
|
path("question/create/", views.AnatomyQuestionCreate.as_view(), name="anatomy_question_create"),
|
||||||
path("question/<int:pk>/update", views.AnatomyQuestionUpdate.as_view(), name="anatomy_question_update"),
|
path("question/<int:pk>/update", views.AnatomyQuestionUpdate.as_view(), name="anatomy_question_update"),
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ from .models import (
|
|||||||
#IncorrectAnswers,
|
#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
|
from collections import defaultdict
|
||||||
import os
|
import os
|
||||||
import base64
|
import base64
|
||||||
@@ -933,3 +939,10 @@ def get_structure_id(request):
|
|||||||
}
|
}
|
||||||
return HttpResponse(json.dumps(data), content_type='application/json')
|
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
|
||||||
@@ -19,12 +19,16 @@ from django.conf import settings
|
|||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
|
||||||
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls, name="admin"),
|
path("admin/", admin.site.urls, name="admin"),
|
||||||
path("anatomy/", include("anatomy.urls"), name="anatomy"),
|
path("anatomy/", include("anatomy.urls"), name="anatomy"),
|
||||||
#path("sbas/", include("sbas.urls"), name="sbas"),
|
#path("sbas/", include("sbas.urls"), name="sbas"),
|
||||||
#path("rapids/", include("rapids.urls"), name="rapids"),
|
#path("rapids/", include("rapids.urls"), name="rapids"),
|
||||||
path("accounts/", include("django.contrib.auth.urls")),
|
path("accounts/", include("django.contrib.auth.urls")),
|
||||||
|
path("accounts/profile", views.profile, name="profile"),
|
||||||
path("", TemplateView.as_view(template_name="index.html"), name="home"),
|
path("", TemplateView.as_view(template_name="index.html"), name="home"),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
from django.shortcuts import render, get_object_or_404, redirect
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
# from django.contrib.auth.models import User
|
||||||
|
from django.contrib.auth.decorators import login_required, user_passes_test
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
|
||||||
|
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
||||||
|
from django.views.generic import ListView
|
||||||
|
|
||||||
|
from django.db.models.functions import Lower
|
||||||
|
|
||||||
|
from django.core.cache import cache
|
||||||
|
|
||||||
|
from django.urls import reverse_lazy, reverse
|
||||||
|
|
||||||
|
from django.http import Http404, JsonResponse
|
||||||
|
|
||||||
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def profile(request):
|
||||||
|
user = request.user
|
||||||
|
return render(request, "profile.html", {"user": user})
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="anatomy">
|
||||||
|
<h1>Your profile</h1>
|
||||||
|
<div>
|
||||||
|
Username: {{ user.username }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Email: {{ user.email }}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Name: {{ user.first_name }}
|
||||||
|
{{ user.last_name }}
|
||||||
|
</div>
|
||||||
|
<a href="{% url 'password_change'%}">Change password</a>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -9,4 +9,6 @@
|
|||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
</form>
|
</form>
|
||||||
|
<p><a href="{% url 'password_reset' %}">Reset password</a></p>
|
||||||
|
<p><a href="{% url 'password_change' %}">Change password</a></p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user