.
This commit is contained in:
@@ -21,19 +21,19 @@
|
|||||||
Unmarked:
|
Unmarked:
|
||||||
<ul id="new-answer-list" class="answer-list">
|
<ul id="new-answer-list" class="answer-list">
|
||||||
{% for answer in user_answers %}
|
{% for answer in user_answers %}
|
||||||
<li><pre><span class="answer not-marked" title="{{answer}}">{{ answer }}</span></pre></li>
|
<li><pre><span class="answer not-marked" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
Marked:
|
Marked:
|
||||||
<ul id="marked-answer-list" class="answer-list">
|
<ul id="marked-answer-list" class="answer-list">
|
||||||
{% for answer in correct_answers %}
|
{% for answer in correct_answers %}
|
||||||
<li><pre><span class="answer correct" title="{{answer}}">{{ answer }}</span></pre></li>
|
<li><pre><span class="answer correct" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for answer in half_mark_answers %}
|
{% for answer in half_mark_answers %}
|
||||||
<li><pre><span class="answer half-correct" title="{{answer}}">{{ answer }}</span></pre></li>
|
<li><pre><span class="answer half-correct" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for answer in incorrect_answers %}
|
{% for answer in incorrect_answers %}
|
||||||
<li><pre><span class="answer incorrect" title="{{answer}}">{{ answer }}</span></pre></li>
|
<li><pre><span class="answer incorrect" title="{{answer}}" data-answerurl="{% url 'anatomy:question_user_answers_by_compare' question.pk answer %}">{{ answer }}</span></pre></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<div class="mark-buttons">
|
<div class="mark-buttons">
|
||||||
@@ -78,6 +78,7 @@
|
|||||||
<ul class="popovermenu">
|
<ul class="popovermenu">
|
||||||
<li><a href="https://www.google.com/search?q=${uri}" target="_blank">Google answer</a></li>
|
<li><a href="https://www.google.com/search?q=${uri}" target="_blank">Google answer</a></li>
|
||||||
<span class="copy-to-clipboard" data-text="${el.title}">Copy to clipboard</span>
|
<span class="copy-to-clipboard" data-text="${el.title}">Copy to clipboard</span>
|
||||||
|
<li><a href="${el.dataset.answerurl}" target="_blank">view answers</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>`)
|
</div>`)
|
||||||
$(el).before(popover)
|
$(el).before(popover)
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
{% extends 'anatomy/base.html' %}
|
{% extends 'anatomy/base.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<h2>{{question}}</h2>
|
||||||
|
|
||||||
|
{% if answer_compare %}
|
||||||
|
Filtering by answer: {{answer_compare}} <a href="{% url 'anatomy:question_user_answers' question.pk %}">[view all]</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for answer in answers %}
|
{% for answer in answers %}
|
||||||
<li><a href="{% url 'anatomy:user_answer_view' pk=answer.pk %}">{{answer}} [score: {{answer.score}}]</a></li>
|
<li><a href="{% url 'anatomy:user_answer_view' pk=answer.pk %}">{{answer}} [score: {{answer.score}}]</a></li>
|
||||||
|
|||||||
+1
-1
@@ -258,7 +258,7 @@ def mark(request, exam_pk, sk, unmarked_exam_answers_only=True, review=False):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
question = questions[sk]
|
question: AnatomyQuestion = questions[sk]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise Http404("Exam question does not exist")
|
raise Http404("Exam question does not exist")
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -2,7 +2,7 @@ from django.urls import path, include
|
|||||||
|
|
||||||
from generic.models import Examination
|
from generic.models import Examination
|
||||||
from . import views
|
from . import views
|
||||||
from generic.views import ExamViews as GenericExamViews
|
from generic.views import ExamViews as GenericExamViews, GenericViewBase
|
||||||
|
|
||||||
|
|
||||||
app_name = "generic"
|
app_name = "generic"
|
||||||
@@ -147,7 +147,7 @@ urlpatterns = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def generic_view_urls(generic_views):
|
def generic_view_urls(generic_views: GenericViewBase):
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(
|
path(
|
||||||
"user_answers/delete",
|
"user_answers/delete",
|
||||||
@@ -164,6 +164,11 @@ def generic_view_urls(generic_views):
|
|||||||
generic_views.question_user_answers,
|
generic_views.question_user_answers,
|
||||||
name="question_user_answers",
|
name="question_user_answers",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"question/<int:pk>/user_answers/<str:answer_compare>/str",
|
||||||
|
generic_views.question_user_answers_by_compare,
|
||||||
|
name="question_user_answers_by_compare",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"exam/<int:pk>/review",
|
"exam/<int:pk>/review",
|
||||||
generic_views.question_review,
|
generic_views.question_review,
|
||||||
|
|||||||
+13
-2
@@ -2322,16 +2322,27 @@ class GenericViewBase:
|
|||||||
{"question": question, "view_feedback": view_feedback},
|
{"question": question, "view_feedback": view_feedback},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# TODO: improve permissions on these
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def question_user_answers(self, request, pk):
|
def question_user_answers_by_compare(self, request, pk, answer_compare):
|
||||||
|
print(answer_compare)
|
||||||
|
return self.question_user_answers(request, pk, answer_compare)
|
||||||
|
|
||||||
|
@method_decorator(login_required)
|
||||||
|
def question_user_answers(self, request, pk, answer_compare=None):
|
||||||
|
print(locals())
|
||||||
question = get_object_or_404(self.question_object, pk=pk)
|
question = get_object_or_404(self.question_object, pk=pk)
|
||||||
|
|
||||||
|
if answer_compare is None:
|
||||||
answers = self.cid_user_answer_object.objects.filter(question__id=question.pk).prefetch_related("question", "exam", "user")
|
answers = self.cid_user_answer_object.objects.filter(question__id=question.pk).prefetch_related("question", "exam", "user")
|
||||||
|
else:
|
||||||
|
answers = self.cid_user_answer_object.objects.filter(question__id=question.pk, answer_compare=answer_compare).prefetch_related("question", "exam", "user")
|
||||||
|
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
f"{self.app_name}/question_user_answers.html",
|
f"{self.app_name}/question_user_answers.html",
|
||||||
{"question": question, "answers": answers},
|
{"question": question, "answers": answers, "answer_compare": answer_compare},
|
||||||
)
|
)
|
||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
|
|||||||
Reference in New Issue
Block a user