.
This commit is contained in:
+17
-1
@@ -1,6 +1,22 @@
|
|||||||
import django_filters
|
import django_filters
|
||||||
|
|
||||||
from .models import AnatomyQuestion
|
from .models import AnatomyQuestion, CidUserAnswer
|
||||||
|
|
||||||
|
#from generic.filters import UserAnswerFilter
|
||||||
|
|
||||||
|
|
||||||
|
class AnatomyUserAnswerFilter(django_filters.FilterSet):
|
||||||
|
class Meta:
|
||||||
|
model= CidUserAnswer
|
||||||
|
fields = (
|
||||||
|
"cid",
|
||||||
|
"question",
|
||||||
|
"answer",
|
||||||
|
#"answer_compare",
|
||||||
|
"exam",
|
||||||
|
"created",
|
||||||
|
"updated",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AnatomyQuestionFilter(django_filters.FilterSet):
|
class AnatomyQuestionFilter(django_filters.FilterSet):
|
||||||
|
|||||||
@@ -310,41 +310,6 @@ class Exam(ExamBase):
|
|||||||
return exam_json
|
return exam_json
|
||||||
|
|
||||||
|
|
||||||
# class UserAnswer(models.Model):
|
|
||||||
# question = models.ForeignKey(
|
|
||||||
# AnatomyQuestion, related_name="user_answers", on_delete=models.CASCADE
|
|
||||||
# )
|
|
||||||
# answer = models.TextField(max_length=500, blank=True)
|
|
||||||
# user = models.ForeignKey(
|
|
||||||
# settings.AUTH_USER_MODEL, null=True, blank=True, on_delete=models.SET_NULL
|
|
||||||
# )
|
|
||||||
|
|
||||||
# cid = models.BigIntegerField(blank=True, null=True, help_text="Candidate ID (limitied by BigIntegerField size)")
|
|
||||||
|
|
||||||
# # Each user answer is associated with a particular exam
|
|
||||||
# exam = models.ForeignKey(
|
|
||||||
# Exam, related_name="exam", on_delete=models.CASCADE, null=True
|
|
||||||
# )
|
|
||||||
|
|
||||||
# flagged = models.BooleanField(default=False)
|
|
||||||
|
|
||||||
# created = models.DateTimeField(auto_now_add=True)
|
|
||||||
# updated = models.DateTimeField(auto_now=True)
|
|
||||||
|
|
||||||
# def __str__(self):
|
|
||||||
# try:
|
|
||||||
# exam = self.exam
|
|
||||||
# except (Exam.DoesNotExist, KeyError) as e:
|
|
||||||
# exam = "None"
|
|
||||||
# return "{}/{}/{}: {}".format(
|
|
||||||
# exam, self.cid, self.question.GetPrimaryAnswer(), self.answer
|
|
||||||
# )
|
|
||||||
|
|
||||||
# def clean(self):
|
|
||||||
# if self.answer:
|
|
||||||
# self.answer = self.answer.strip()
|
|
||||||
|
|
||||||
|
|
||||||
class CidUserAnswer(models.Model):
|
class CidUserAnswer(models.Model):
|
||||||
"""User answers by candidate"""
|
"""User answers by candidate"""
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -1,7 +1,7 @@
|
|||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
from django_tables2.utils import A
|
from django_tables2.utils import A
|
||||||
|
|
||||||
from .models import AnatomyQuestion
|
from .models import AnatomyQuestion, CidUserAnswer
|
||||||
|
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
|
||||||
@@ -9,6 +9,23 @@ from easy_thumbnails.files import get_thumbnailer
|
|||||||
|
|
||||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||||
|
|
||||||
|
#from generic.tables import UserAnswerTable
|
||||||
|
|
||||||
|
|
||||||
|
class AnatomyUserAnswerTable(tables.Table):
|
||||||
|
class Meta:
|
||||||
|
model = CidUserAnswer
|
||||||
|
template_name = "django_tables2/bootstrap4.html"
|
||||||
|
fields = (
|
||||||
|
"cid",
|
||||||
|
"question",
|
||||||
|
"answer",
|
||||||
|
#"answer_compare",
|
||||||
|
"exam",
|
||||||
|
"created",
|
||||||
|
"updated",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ImageColumn(tables.Column):
|
class ImageColumn(tables.Column):
|
||||||
def render(self, value):
|
def render(self, value):
|
||||||
|
|||||||
@@ -51,4 +51,5 @@ urlpatterns = [
|
|||||||
path("examination/ajax/get_examination_id",
|
path("examination/ajax/get_examination_id",
|
||||||
views.get_examination_id,
|
views.get_examination_id,
|
||||||
name="get_examination_id"),
|
name="get_examination_id"),
|
||||||
|
path("user_answers/", views.AnatomyUserAnswerView.as_view(), name="anatomy_user_answer_view"),
|
||||||
]
|
]
|
||||||
|
|||||||
+9
-2
@@ -46,8 +46,8 @@ from .models import (
|
|||||||
from generic.models import Examination
|
from generic.models import Examination
|
||||||
from generic.views import ExamViews
|
from generic.views import ExamViews
|
||||||
|
|
||||||
from .tables import AnatomyQuestionTable
|
from .tables import AnatomyQuestionTable, AnatomyUserAnswerTable
|
||||||
from .filters import AnatomyQuestionFilter
|
from .filters import AnatomyQuestionFilter, AnatomyUserAnswerFilter
|
||||||
|
|
||||||
from django_tables2 import SingleTableView, SingleTableMixin
|
from django_tables2 import SingleTableView, SingleTableMixin
|
||||||
from django_filters.views import FilterView
|
from django_filters.views import FilterView
|
||||||
@@ -919,6 +919,13 @@ class AnatomyQuestionView(SingleTableMixin, FilterView):
|
|||||||
|
|
||||||
filterset_class = AnatomyQuestionFilter
|
filterset_class = AnatomyQuestionFilter
|
||||||
|
|
||||||
|
class AnatomyUserAnswerView(SingleTableMixin, FilterView):
|
||||||
|
model = CidUserAnswer
|
||||||
|
table_class = AnatomyUserAnswerTable
|
||||||
|
template_name = "anatomy/anatomy_question_view.html"
|
||||||
|
|
||||||
|
filterset_class = AnatomyUserAnswerFilter
|
||||||
|
|
||||||
|
|
||||||
def question_save_annotation(request, pk):
|
def question_save_annotation(request, pk):
|
||||||
if request.is_ajax() and request.method == "POST":
|
if request.is_ajax() and request.method == "POST":
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import django_filters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#class UserAnswerFilter(django_filters.FilterSet):
|
||||||
|
# class Meta:
|
||||||
|
# #model = AnatomyQuestion
|
||||||
|
# abstract = True
|
||||||
|
# fields = (
|
||||||
|
# "cid",
|
||||||
|
# "question",
|
||||||
|
# "answer",
|
||||||
|
# #"answer_compare",
|
||||||
|
# "exam",
|
||||||
|
# "created",
|
||||||
|
# "updateded",
|
||||||
|
# "created_date",
|
||||||
|
# )
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import django_tables2 as tables
|
||||||
|
from django_tables2.utils import A
|
||||||
|
|
||||||
|
from django.utils.html import format_html
|
||||||
|
|
||||||
|
from easy_thumbnails.files import get_thumbnailer
|
||||||
|
|
||||||
|
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||||
|
|
||||||
|
|
||||||
|
class ImageColumn(tables.Column):
|
||||||
|
def render(self, value):
|
||||||
|
try:
|
||||||
|
thumbnailer = get_thumbnailer(value)
|
||||||
|
return format_html('<img src="/media/{}" />', thumbnailer["exam-list"])
|
||||||
|
except InvalidImageFormatError:
|
||||||
|
return format_html('<span title="{}">Invalid image url<span>', value)
|
||||||
|
|
||||||
|
|
||||||
|
#class UserAnswerTable(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
|
||||||
|
# #)
|
||||||
|
# #image = ImageColumn("image", orderable=False)
|
||||||
|
# # clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||||
|
# # text='Clone',
|
||||||
|
# # args=[A('pk')],
|
||||||
|
# # orderable=False)
|
||||||
|
# #exams = tables.ManyToManyColumn(verbose_name="Exams")
|
||||||
|
#
|
||||||
|
# class Meta:
|
||||||
|
# #model = AnatomyQuestion
|
||||||
|
# abstract = True
|
||||||
|
# template_name = "django_tables2/bootstrap4.html"
|
||||||
|
# fields = (
|
||||||
|
# "cid",
|
||||||
|
# "question",
|
||||||
|
# "answer",
|
||||||
|
# #"answer_compare",
|
||||||
|
# "exam",
|
||||||
|
# "created",
|
||||||
|
# "updated",
|
||||||
|
# )
|
||||||
|
# #sequence = ("view")
|
||||||
Reference in New Issue
Block a user