.
This commit is contained in:
+7
-7
@@ -20,20 +20,20 @@ class ImageColumn(tables.Column):
|
|||||||
|
|
||||||
|
|
||||||
class CidUserTable(tables.Table):
|
class CidUserTable(tables.Table):
|
||||||
#edit = tables.LinkColumn(
|
# edit = tables.LinkColumn(
|
||||||
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
# "anatomy:anatomy_question_update", text="Edit", args=[A("pk")], orderable=False
|
||||||
#)
|
# )
|
||||||
#view = tables.LinkColumn(
|
# view = tables.LinkColumn(
|
||||||
# "anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
# "anatomy:question_detail", text="View", args=[A("pk")], orderable=False
|
||||||
#)
|
# )
|
||||||
#image = ImageColumn("image", orderable=False)
|
# image = ImageColumn("image", orderable=False)
|
||||||
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
# clone = tables.LinkColumn('anatomy:anatomy_question_clone',
|
||||||
# text='Clone',
|
# text='Clone',
|
||||||
# args=[A('pk')],
|
# args=[A('pk')],
|
||||||
# orderable=False)
|
# orderable=False)
|
||||||
physics_exams = tables.ManyToManyColumn(verbose_name="Physics Exams")
|
physics_exams = tables.ManyToManyColumn(verbose_name="Physics Exams")
|
||||||
rapid_exams = tables.ManyToManyColumn(verbose_name="Rapid Exams")
|
rapid_exams = tables.ManyToManyColumn(verbose_name="Rapid Exams")
|
||||||
sbas_exams = tables.ManyToManyColumn(verbose_name="SBA Exams")
|
sba_exams = tables.ManyToManyColumn(verbose_name="SBA Exams")
|
||||||
longs_exams = tables.ManyToManyColumn(verbose_name="Long Exams")
|
longs_exams = tables.ManyToManyColumn(verbose_name="Long Exams")
|
||||||
anatomy_exams = tables.ManyToManyColumn(verbose_name="Anatomy Exams")
|
anatomy_exams = tables.ManyToManyColumn(verbose_name="Anatomy Exams")
|
||||||
|
|
||||||
@@ -47,4 +47,4 @@ class CidUserTable(tables.Table):
|
|||||||
"passcode",
|
"passcode",
|
||||||
"active",
|
"active",
|
||||||
)
|
)
|
||||||
#sequence = ("view")
|
# sequence = ("view")
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<span>
|
<span>
|
||||||
Sba Exams<br/>
|
Sba Exams<br/>
|
||||||
<select id="sbas-exams" multiple="multiple">
|
<select id="sbas-exams" multiple="multiple">
|
||||||
{% for name, id in sbas_exams %}
|
{% for name, id in sba_exams %}
|
||||||
<option value="{{id}}">{{name}}</option>
|
<option value="{{id}}">{{name}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
number: $("#add-number").get(0).value,
|
number: $("#add-number").get(0).value,
|
||||||
physics_exams: JSON.stringify($("#physics-exams").val()),
|
physics_exams: JSON.stringify($("#physics-exams").val()),
|
||||||
rapid_exams: JSON.stringify($("#rapid-exams").val()),
|
rapid_exams: JSON.stringify($("#rapid-exams").val()),
|
||||||
sbas_exams: JSON.stringify($("#sbas-exams").val()),
|
sba_exams: JSON.stringify($("#sbas-exams").val()),
|
||||||
longs_exams: JSON.stringify($("#longs-exams").val()),
|
longs_exams: JSON.stringify($("#longs-exams").val()),
|
||||||
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
anatomy_exams: JSON.stringify($("#anatomy-exams").val()),
|
||||||
},
|
},
|
||||||
|
|||||||
+5
-5
@@ -936,7 +936,7 @@ class CidUserView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
|||||||
(i.name, i.pk) for i in PhysicsExam.objects.filter(archive=False)
|
(i.name, i.pk) for i in PhysicsExam.objects.filter(archive=False)
|
||||||
]
|
]
|
||||||
rapid_exams = [(i.name, i.pk) for i in RapidExam.objects.filter(archive=False)]
|
rapid_exams = [(i.name, i.pk) for i in RapidExam.objects.filter(archive=False)]
|
||||||
sbas_exams = [(i.name, i.pk) for i in SbasExam.objects.filter(archive=False)]
|
sba_exams = [(i.name, i.pk) for i in SbasExam.objects.filter(archive=False)]
|
||||||
longs_exams = [(i.name, i.pk) for i in LongExam.objects.filter(archive=False)]
|
longs_exams = [(i.name, i.pk) for i in LongExam.objects.filter(archive=False)]
|
||||||
anatomy_exams = [
|
anatomy_exams = [
|
||||||
(i.name, i.pk) for i in PhysicsExam.objects.filter(archive=False)
|
(i.name, i.pk) for i in PhysicsExam.objects.filter(archive=False)
|
||||||
@@ -944,7 +944,7 @@ class CidUserView(LoginRequiredMixin, SingleTableMixin, FilterView):
|
|||||||
|
|
||||||
context["physics_exams"] = physics_exams
|
context["physics_exams"] = physics_exams
|
||||||
context["rapid_exams"] = rapid_exams
|
context["rapid_exams"] = rapid_exams
|
||||||
context["sbas_exams"] = sbas_exams
|
context["sba_exams"] = sba_exams
|
||||||
context["longs_exams"] = longs_exams
|
context["longs_exams"] = longs_exams
|
||||||
context["anatomy_exams"] = anatomy_exams
|
context["anatomy_exams"] = anatomy_exams
|
||||||
return context
|
return context
|
||||||
@@ -956,7 +956,7 @@ def create_cid_users(request):
|
|||||||
number = int(request.POST.get("number"))
|
number = int(request.POST.get("number"))
|
||||||
physics_exams = json.loads(request.POST.get("physics_exams"))
|
physics_exams = json.loads(request.POST.get("physics_exams"))
|
||||||
rapid_exams = json.loads(request.POST.get("rapid_exams"))
|
rapid_exams = json.loads(request.POST.get("rapid_exams"))
|
||||||
sbas_exams = json.loads(request.POST.get("sbas_exams"))
|
sba_exams = json.loads(request.POST.get("sba_exams"))
|
||||||
longs_exams = json.loads(request.POST.get("longl_exams"))
|
longs_exams = json.loads(request.POST.get("longl_exams"))
|
||||||
anatomy_exams = json.loads(request.POST.get("anatomy_exams"))
|
anatomy_exams = json.loads(request.POST.get("anatomy_exams"))
|
||||||
|
|
||||||
@@ -972,8 +972,8 @@ def create_cid_users(request):
|
|||||||
if rapid_exams:
|
if rapid_exams:
|
||||||
c.rapid_exams.set(rapid_exams)
|
c.rapid_exams.set(rapid_exams)
|
||||||
c.save()
|
c.save()
|
||||||
if sbas_exams:
|
if sba_exams:
|
||||||
c.sbas_exams.set(sbas_exams)
|
c.sba_exams.set(sba_exams)
|
||||||
c.save()
|
c.save()
|
||||||
if longs_exams:
|
if longs_exams:
|
||||||
c.longs_exams.set(longs_exams)
|
c.longs_exams.set(longs_exams)
|
||||||
|
|||||||
+30
-20
@@ -58,6 +58,7 @@ import json
|
|||||||
|
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
|
||||||
|
|
||||||
def feedback_checker(user):
|
def feedback_checker(user):
|
||||||
return user.groups.filter(name="feedback_checker").exists()
|
return user.groups.filter(name="feedback_checker").exists()
|
||||||
|
|
||||||
@@ -109,13 +110,13 @@ def cid_scores(request, pk):
|
|||||||
anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids, **kwargs)
|
anatomy_exams = AnatomyExam.objects.filter(id__in=anatomy_exam_ids, **kwargs)
|
||||||
|
|
||||||
rapids_exam_ids = rapids_answers.values_list("exam").distinct()
|
rapids_exam_ids = rapids_answers.values_list("exam").distinct()
|
||||||
rapids_exams = RapidsExam.objects.filter(id__in=rapids_exam_ids, **kwargs)
|
rapid_exams = RapidsExam.objects.filter(id__in=rapids_exam_ids, **kwargs)
|
||||||
|
|
||||||
longs_exam_ids = longs_answers.values_list("exam").distinct()
|
longs_exam_ids = longs_answers.values_list("exam").distinct()
|
||||||
longs_exams = LongsExam.objects.filter(id__in=longs_exam_ids, **kwargs)
|
longs_exams = LongsExam.objects.filter(id__in=longs_exam_ids, **kwargs)
|
||||||
|
|
||||||
sbas_exam_ids = sbas_answers.values_list("exam").distinct()
|
sbas_exam_ids = sbas_answers.values_list("exam").distinct()
|
||||||
sbas_exams = SbasExam.objects.filter(id__in=sbas_exam_ids, **kwargs)
|
sba_exams = SbasExam.objects.filter(id__in=sbas_exam_ids, **kwargs)
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
@@ -123,9 +124,9 @@ def cid_scores(request, pk):
|
|||||||
{
|
{
|
||||||
"physics_exams": physics_exams,
|
"physics_exams": physics_exams,
|
||||||
"anatomy_exams": anatomy_exams,
|
"anatomy_exams": anatomy_exams,
|
||||||
"rapids_exams": rapids_exams,
|
"rapid_exams": rapid_exams,
|
||||||
"longs_exams": longs_exams,
|
"longs_exams": longs_exams,
|
||||||
"sbas_exams": sbas_exams,
|
"sba_exams": sba_exams,
|
||||||
"cid": cid,
|
"cid": cid,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -150,6 +151,7 @@ def active_exams(request):
|
|||||||
|
|
||||||
return JsonResponse(active_exams)
|
return JsonResponse(active_exams)
|
||||||
|
|
||||||
|
|
||||||
def active_exams_unbased(request):
|
def active_exams_unbased(request):
|
||||||
anatomy_exams = AnatomyExamViews.active_exams(request, False, False)
|
anatomy_exams = AnatomyExamViews.active_exams(request, False, False)
|
||||||
rapid_exams = RapidExamViews.active_exams(request, False, False)
|
rapid_exams = RapidExamViews.active_exams(request, False, False)
|
||||||
@@ -181,6 +183,7 @@ def exam_submit(request):
|
|||||||
# postExamAnswers
|
# postExamAnswers
|
||||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||||
|
|
||||||
|
|
||||||
def feedback_create(request, question_type, pk):
|
def feedback_create(request, question_type, pk):
|
||||||
if question_type == "anatomy":
|
if question_type == "anatomy":
|
||||||
question = AnatomyQuestion
|
question = AnatomyQuestion
|
||||||
@@ -192,13 +195,11 @@ def feedback_create(request, question_type, pk):
|
|||||||
return JsonResponse({"success": False, "error": "Invalid exam type"})
|
return JsonResponse({"success": False, "error": "Invalid exam type"})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AddQuestionNote(CreateView):
|
class AddQuestionNote(CreateView):
|
||||||
model = QuestionNote
|
model = QuestionNote
|
||||||
form_class = QuestionNoteForm
|
form_class = QuestionNoteForm
|
||||||
|
|
||||||
#fields = ("author", "note_type", "note")
|
# fields = ("author", "note_type", "note")
|
||||||
|
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super(AddQuestionNote, self).get_form_kwargs()
|
kwargs = super(AddQuestionNote, self).get_form_kwargs()
|
||||||
@@ -214,14 +215,13 @@ class AddQuestionNote(CreateView):
|
|||||||
question, content_type = get_question_and_content_type(self.question_type)
|
question, content_type = get_question_and_content_type(self.question_type)
|
||||||
|
|
||||||
self.question = get_object_or_404(question, pk=pk)
|
self.question = get_object_or_404(question, pk=pk)
|
||||||
return { "content_type" : content_type,
|
return {"content_type": content_type, "object_id": pk}
|
||||||
"object_id" : pk }
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# This can also be accessed via view.**** in the template
|
# This can also be accessed via view.**** in the template
|
||||||
context = super(AddQuestionNote, self).get_context_data(**kwargs)
|
context = super(AddQuestionNote, self).get_context_data(**kwargs)
|
||||||
context['question'] = self.question
|
context["question"] = self.question
|
||||||
context['question_type'] = self.question_type
|
context["question_type"] = self.question_type
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
@@ -237,6 +237,7 @@ class AddQuestionNote(CreateView):
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@user_passes_test(lambda u: u.is_superuser)
|
@user_passes_test(lambda u: u.is_superuser)
|
||||||
def feedback_note_delete(request, pk):
|
def feedback_note_delete(request, pk):
|
||||||
q = get_object_or_404(QuestionNote, pk=pk)
|
q = get_object_or_404(QuestionNote, pk=pk)
|
||||||
@@ -244,17 +245,22 @@ def feedback_note_delete(request, pk):
|
|||||||
|
|
||||||
return redirect(q.get_object_url())
|
return redirect(q.get_object_url())
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def feedback_mark_complete(request, pk):
|
def feedback_mark_complete(request, pk):
|
||||||
q = get_object_or_404(QuestionNote, pk=pk)
|
q = get_object_or_404(QuestionNote, pk=pk)
|
||||||
|
|
||||||
if request.user not in q.question.author.all() and not request.user.groups.filter(name="feedback_checker").exists():
|
if (
|
||||||
|
request.user not in q.question.author.all()
|
||||||
|
and not request.user.groups.filter(name="feedback_checker").exists()
|
||||||
|
):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
|
|
||||||
q.complete = True
|
q.complete = True
|
||||||
q.save()
|
q.save()
|
||||||
return redirect(q.get_object_url())
|
return redirect(q.get_object_url())
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def answer_suggestion_submit(request):
|
def answer_suggestion_submit(request):
|
||||||
if request.is_ajax and request.method == "POST":
|
if request.is_ajax and request.method == "POST":
|
||||||
@@ -279,7 +285,6 @@ def answer_suggestion_submit(request):
|
|||||||
if AnswerModel.objects.filter(answer=answer_string, question=q):
|
if AnswerModel.objects.filter(answer=answer_string, question=q):
|
||||||
return JsonResponse({"success": False, "error": "Answer already exists"})
|
return JsonResponse({"success": False, "error": "Answer already exists"})
|
||||||
|
|
||||||
|
|
||||||
a = AnswerModel(question=q, answer=answer_string, status=status, proposed=True)
|
a = AnswerModel(question=q, answer=answer_string, status=status, proposed=True)
|
||||||
a.save()
|
a.save()
|
||||||
return JsonResponse({"success": True, "error": "Answer submited"})
|
return JsonResponse({"success": True, "error": "Answer submited"})
|
||||||
@@ -287,6 +292,7 @@ def answer_suggestion_submit(request):
|
|||||||
# postExamAnswers
|
# postExamAnswers
|
||||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def answer_submit(request):
|
def answer_submit(request):
|
||||||
if request.is_ajax and request.method == "POST":
|
if request.is_ajax and request.method == "POST":
|
||||||
@@ -311,13 +317,13 @@ def answer_submit(request):
|
|||||||
if AnswerModel.objects.filter(answer=answer_string, question=q):
|
if AnswerModel.objects.filter(answer=answer_string, question=q):
|
||||||
return JsonResponse({"success": False, "error": "Answer already exists"})
|
return JsonResponse({"success": False, "error": "Answer already exists"})
|
||||||
|
|
||||||
|
|
||||||
a = AnswerModel(question=q, answer=answer_string, status=status)
|
a = AnswerModel(question=q, answer=answer_string, status=status)
|
||||||
a.save()
|
a.save()
|
||||||
return JsonResponse({"success": True, "error": "Answer added"})
|
return JsonResponse({"success": True, "error": "Answer added"})
|
||||||
|
|
||||||
return JsonResponse({"success": False, "error": "Invalid data"})
|
return JsonResponse({"success": False, "error": "Invalid data"})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def answer_suggestion_confirm(request):
|
def answer_suggestion_confirm(request):
|
||||||
if request.is_ajax and request.method == "POST":
|
if request.is_ajax and request.method == "POST":
|
||||||
@@ -340,6 +346,7 @@ def answer_suggestion_confirm(request):
|
|||||||
answer.save()
|
answer.save()
|
||||||
return JsonResponse({"success": True, "error": "Answer changed"})
|
return JsonResponse({"success": True, "error": "Answer changed"})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@user_passes_test(feedback_checker)
|
@user_passes_test(feedback_checker)
|
||||||
def view_feedback(request):
|
def view_feedback(request):
|
||||||
@@ -355,24 +362,27 @@ def view_feedback(request):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# HTTP Error 400
|
# HTTP Error 400
|
||||||
def page_not_found(request, exception):
|
def page_not_found(request, exception):
|
||||||
response = render(request, '404.html', {})
|
response = render(request, "404.html", {})
|
||||||
|
|
||||||
#response.status_code = 404
|
# response.status_code = 404
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def page_forbidden(request, exception):
|
def page_forbidden(request, exception):
|
||||||
response = render(request, '403.html', {})
|
response = render(request, "403.html", {})
|
||||||
|
|
||||||
#response.status_code = 404
|
# response.status_code = 404
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def server_error(request):
|
def server_error(request):
|
||||||
response = render(request, '500.html', {})
|
response = render(request, "500.html", {})
|
||||||
|
|
||||||
#response.status_code = 404
|
# response.status_code = 404
|
||||||
|
|
||||||
return response
|
return response
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 3.2.8 on 2021-12-12 08:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('generic', '0017_alter_ciduser_cid'),
|
||||||
|
('rapids', '0039_exam_valid_users'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='exam',
|
||||||
|
name='valid_users',
|
||||||
|
field=models.ManyToManyField(blank=True, related_name='rapid_exams', to='generic.CidUser'),
|
||||||
|
),
|
||||||
|
]
|
||||||
+1
-1
@@ -546,7 +546,7 @@ class Exam(ExamBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
valid_users = models.ManyToManyField(
|
valid_users = models.ManyToManyField(
|
||||||
CidUser, blank=True, related_name="rapids_exams"
|
CidUser, blank=True, related_name="rapid_exams"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_normal_abnormal_breakdown(self):
|
def get_normal_abnormal_breakdown(self):
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if rapids_exams %}
|
{% if rapid_exams %}
|
||||||
<h3>Rapids</h3>
|
<h3>Rapids</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for exam in rapids_exams %}
|
{% for exam in rapid_exams %}
|
||||||
<li><a href="{% url 'rapids:exam_scores_cid_user' pk=exam.pk cid=cid %}">{{exam.name}}</a></li>
|
<li><a href="{% url 'rapids:exam_scores_cid_user' pk=exam.pk cid=cid %}">{{exam.name}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if sbas_exams %}
|
{% if sba_exams %}
|
||||||
<h3>SBAs</h3>
|
<h3>SBAs</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for exam in sbas_exams %}
|
{% for exam in sba_exams %}
|
||||||
<li><a href="{% url 'sbas:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
|
<li><a href="{% url 'sbas:exam_scores_cid_user' pk=exam.pk sk=cid %}">{{exam.name}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user