diff --git a/oef/templates/oef/base.html b/oef/templates/oef/base.html
index c734f7e4..eadcebc7 100644
--- a/oef/templates/oef/base.html
+++ b/oef/templates/oef/base.html
@@ -6,5 +6,6 @@
{% block navigation %}
Entries /
Formats /
+ Questions /
Replace Questions /
{% endblock %}
\ No newline at end of file
diff --git a/oef/templates/oef/entries_by_question.html b/oef/templates/oef/entries_by_question.html
new file mode 100644
index 00000000..333439d6
--- /dev/null
+++ b/oef/templates/oef/entries_by_question.html
@@ -0,0 +1,7 @@
+
+
+{% for entry in entries %}
+- {{entry.exam_name}}
+{% endfor %}
+
+
\ No newline at end of file
diff --git a/oef/templates/oef/questions.html b/oef/templates/oef/questions.html
new file mode 100644
index 00000000..d1328739
--- /dev/null
+++ b/oef/templates/oef/questions.html
@@ -0,0 +1,53 @@
+{% extends 'oef/base.html' %}
+{% block content %}
+Questions
+There are {{ questions|length }} question sets.
+
+
+ {% for question in questions %}
+ -
+
{{ question }}
+
+
+
+
+ {% endfor %}
+
+
+Diff:
+
+
+
+{% endblock content %}
+
+
+{% block css %}
+
+
+{% endblock css %}
+
\ No newline at end of file
diff --git a/oef/templates/oef/replace_questions.html b/oef/templates/oef/replace_questions.html
index 4a750ab5..939350e6 100644
--- a/oef/templates/oef/replace_questions.html
+++ b/oef/templates/oef/replace_questions.html
@@ -4,6 +4,9 @@
+
+
+
diff --git a/oef/urls.py b/oef/urls.py
index fad798b4..04070bfd 100644
--- a/oef/urls.py
+++ b/oef/urls.py
@@ -23,6 +23,15 @@ urlpatterns = [
path(
"entries/replace_questions", views.replace_questions, name="replace_questions"
),
+ path(
+ "entries/questions", views.questions, name="questions"
+ ),
+ path(
+ "entries/questions_diff", views.questions_diff, name="questions_diff"
+ ),
+ path(
+ "entries/entries_by_question", views.entries_by_question, name="entries_by_question"
+ ),
path(
"entries//update", views.EntryUpdateView.as_view(), name="entry_update"
),
diff --git a/oef/views.py b/oef/views.py
index f8ee3ef1..9c9c0d28 100644
--- a/oef/views.py
+++ b/oef/views.py
@@ -1,3 +1,4 @@
+from difflib import HtmlDiff
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.views.generic.edit import UpdateView, CreateView
@@ -77,7 +78,10 @@ def replace_questions(request):
if not search or not replace:
return HttpResponse("Please provide both search and replace values")
- entries = Entry.objects.filter(questions__contains=search)
+ if request.POST.get("exact", False):
+ entries = Entry.objects.filter(questions=search)
+ else:
+ entries = Entry.objects.filter(questions__contains=search)
for entry in entries:
entry.questions = entry.questions.replace(search, replace)
@@ -85,4 +89,32 @@ def replace_questions(request):
return HttpResponse(f"{entries.count()} questions replaced")
else:
- return render(request, "oef/replace_questions.html", {})
\ No newline at end of file
+ return render(request, "oef/replace_questions.html", {})
+
+def questions(request):
+ questions = set(Entry.objects.all().values_list("questions", flat=True))
+
+ questions = sorted(questions, key=lambda x: len(x))
+
+ return render(request, "oef/questions.html", {"questions": questions})
+
+def entries_by_question(request):
+
+ if request.method == "POST":
+ question = request.POST.get("question")
+ entries = Entry.objects.filter(questions=question)
+
+ return render(request, "oef/entries_by_question.html", {"entries": entries})
+
+ return HttpResponse("Please provide a question")
+
+def questions_diff(request):
+ if request.method == "POST":
+ question1 = request.POST.get("question1")
+ question2 = request.POST.get("question2")
+
+ html = HtmlDiff().make_table(question1.split("\n"), question2.split("\n"))
+
+ return HttpResponse(html)
+
+ return HttpResponse("Please provide two questions")
\ No newline at end of file