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;
|
||||
}
|
||||
|
||||
#admin-link {
|
||||
#admin-link, #logout-link, #profile-link {
|
||||
float: right;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.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>
|
||||
<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,6 +1,7 @@
|
||||
{% extends 'anatomy/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Examinations</h1>
|
||||
<div class="anatomy">
|
||||
Active exams:<br/>
|
||||
<ul>
|
||||
|
||||
@@ -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}}),
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
@@ -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
|
||||
@@ -19,12 +19,16 @@ from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", admin.site.urls, name="admin"),
|
||||
path("anatomy/", include("anatomy.urls"), name="anatomy"),
|
||||
#path("sbas/", include("sbas.urls"), name="sbas"),
|
||||
#path("rapids/", include("rapids.urls"), name="rapids"),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path("accounts/profile", views.profile, name="profile"),
|
||||
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 }}
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
<p><a href="{% url 'password_reset' %}">Reset password</a></p>
|
||||
<p><a href="{% url 'password_change' %}">Change password</a></p>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user