diff --git a/anatomy/models.py b/anatomy/models.py
index c65eec9a..25f50297 100644
--- a/anatomy/models.py
+++ b/anatomy/models.py
@@ -396,7 +396,6 @@ class Exam(ExamBase):
markers = models.ManyToManyField(
settings.AUTH_USER_MODEL,
blank=True,
- null=True,
help_text="Authorised markers for the exam",
related_name="anatomy_exam_markers",
)
diff --git a/atlas/models.py b/atlas/models.py
index 3a9b4f64..cd31a5d7 100644
--- a/atlas/models.py
+++ b/atlas/models.py
@@ -796,7 +796,6 @@ class CaseCollection(ExamOrCollectionGenericBase):
markers = models.ManyToManyField(
settings.AUTH_USER_MODEL,
blank=True,
- null=True,
help_text="Authorised markers for the exam",
related_name="casecollection_markers",
)
diff --git a/longs/models.py b/longs/models.py
index f0963dae..c7281ce2 100644
--- a/longs/models.py
+++ b/longs/models.py
@@ -449,7 +449,6 @@ class Exam(ExamBase):
markers = models.ManyToManyField(
settings.AUTH_USER_MODEL,
blank=True,
- null=True,
help_text="Authorised markers for the exam",
related_name="long_exam_markers",
)
diff --git a/oef/models.py b/oef/models.py
index 5c69a43c..dab727d3 100644
--- a/oef/models.py
+++ b/oef/models.py
@@ -21,7 +21,7 @@ class Entry(models.Model):
return self.exam_name
def get_absolute_url(self):
- return reverse("oef:entry_update", kwargs={"pk": self.pk})
+ return reverse("oef:entry_detail", kwargs={"pk": self.pk})
def clean(self) -> None:
self.questions = self.questions.replace("\r\n", "\n")
diff --git a/oef/templates/oef/base.html b/oef/templates/oef/base.html
index 96f909ec..c734f7e4 100644
--- a/oef/templates/oef/base.html
+++ b/oef/templates/oef/base.html
@@ -6,4 +6,5 @@
{% block navigation %}
Entries /
Formats /
+ Replace Questions /
{% endblock %}
\ No newline at end of file
diff --git a/oef/templates/oef/entry_detail_formats.html b/oef/templates/oef/entry_detail_formats.html
new file mode 100644
index 00000000..aa143a93
--- /dev/null
+++ b/oef/templates/oef/entry_detail_formats.html
@@ -0,0 +1,8 @@
+The following formats match:
+{% for format in matching_formats %}
+
Format: {{ format.name }}
+
+{{ format.get_format }}
+
+{% endfor %}
+
\ No newline at end of file
diff --git a/oef/templates/oef/entry_detail_view.html b/oef/templates/oef/entry_detail_view.html
new file mode 100644
index 00000000..05a7869d
--- /dev/null
+++ b/oef/templates/oef/entry_detail_view.html
@@ -0,0 +1,23 @@
+{% extends 'oef/base.html' %}
+
+{% block content %}
+{{ entry.name }}
+Edit
+
+Modality: {{ entry.modality }}
+Exam code: {{ entry.exam_code }}
+
+Questions:
+
+{{ entry.questions }}
+
+
+
+Comments: {{ entry.comments }}
+
+
+Check formats
+{% endblock content %}
\ No newline at end of file
diff --git a/oef/templates/oef/formats_apply.html b/oef/templates/oef/formats_apply.html
index 5eccb562..1e755228 100644
--- a/oef/templates/oef/formats_apply.html
+++ b/oef/templates/oef/formats_apply.html
@@ -14,7 +14,7 @@ The format {{format.name}} exists in the following {{ entries.count }} entries:
{% for entry, text in entry_list %}
-
+
{% endfor %}
diff --git a/oef/templates/oef/replace_questions.html b/oef/templates/oef/replace_questions.html
new file mode 100644
index 00000000..4028fb9e
--- /dev/null
+++ b/oef/templates/oef/replace_questions.html
@@ -0,0 +1,13 @@
+{% extends 'oef/base.html' %}
+{% block content %}
+
+
+
+{% endblock content %}
\ No newline at end of file
diff --git a/oef/urls.py b/oef/urls.py
index d9f4fa90..fad798b4 100644
--- a/oef/urls.py
+++ b/oef/urls.py
@@ -20,9 +20,18 @@ urlpatterns = [
path(
"formats/create", views.FormatsCreateView.as_view(), name="format_create"
),
+ path(
+ "entries/replace_questions", views.replace_questions, name="replace_questions"
+ ),
path(
"entries//update", views.EntryUpdateView.as_view(), name="entry_update"
),
+ path(
+ "entries//detail", views.EntryDetailView.as_view(), name="entry_detail"
+ ),
+ path(
+ "entries//detail/formats", views.entry_detail_formats, name="entry_detail_formats"
+ ),
path(
"formats//update", views.FormatsUpdateView.as_view(), name="format_update"
),
diff --git a/oef/views.py b/oef/views.py
index 5aca606e..f8ee3ef1 100644
--- a/oef/views.py
+++ b/oef/views.py
@@ -1,5 +1,7 @@
+from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.views.generic.edit import UpdateView, CreateView
+from django.views.generic.detail import DetailView
from .models import Entry, Formats
# Create your views here.
@@ -14,6 +16,10 @@ class EntryUpdateView(UpdateView):
template_name = "oef/entry_update_view.html"
fields = ['modality', 'exam_code', 'exam_name', 'questions', 'comments']
+class EntryDetailView(DetailView):
+ model = Entry
+ template_name = "oef/entry_detail_view.html"
+
class FormatsCreateView(CreateView):
model = Formats
template_name_suffix = "_update_form"
@@ -47,3 +53,36 @@ def formats_apply(request, pk):
for entry in entries:
entry_list.append((entry, entry.questions.replace(search_text, "")))
return render(request, "oef/formats_apply.html", {"format": format, "entry_list": entry_list, "entries": entries})
+
+def entry_detail_formats(request, pk):
+ entry = get_object_or_404(Entry, pk=pk)
+ formats = Formats.objects.all()
+
+ questions = entry.questions
+
+ matching_formats = []
+ for format in formats:
+ if format.get_format() in questions:
+ matching_formats.append(format)
+
+ matching_formats = sorted(matching_formats, key=lambda x: len(x.get_format()))
+
+ return render(request, "oef/entry_detail_formats.html", {"entry": entry, "matching_formats": matching_formats})
+
+def replace_questions(request):
+ if request.method == "POST":
+ search = request.POST.get("search")
+ replace = request.POST.get("replace")
+
+ if not search or not replace:
+ return HttpResponse("Please provide both search and replace values")
+
+ entries = Entry.objects.filter(questions__contains=search)
+
+ for entry in entries:
+ entry.questions = entry.questions.replace(search, replace)
+ entry.save()
+
+ return HttpResponse(f"{entries.count()} questions replaced")
+ else:
+ return render(request, "oef/replace_questions.html", {})
\ No newline at end of file
diff --git a/physics/models.py b/physics/models.py
index bbfc6a53..11f87819 100644
--- a/physics/models.py
+++ b/physics/models.py
@@ -170,7 +170,6 @@ class Exam(ExamBase):
markers = models.ManyToManyField(
settings.AUTH_USER_MODEL,
blank=True,
- null=True,
help_text="Authorised markers for the exam",
related_name="physics_exam_markers",
)
diff --git a/rapids/models.py b/rapids/models.py
index f9c688a7..e8a2e705 100644
--- a/rapids/models.py
+++ b/rapids/models.py
@@ -632,7 +632,6 @@ class Exam(ExamBase):
markers = models.ManyToManyField(
settings.AUTH_USER_MODEL,
blank=True,
- null=True,
help_text="Authorised markers for the exam",
related_name="rapid_exam_markers",
)
diff --git a/sbas/models.py b/sbas/models.py
index dc370310..d60638b2 100644
--- a/sbas/models.py
+++ b/sbas/models.py
@@ -188,7 +188,6 @@ class Exam(ExamBase):
markers = models.ManyToManyField(
settings.AUTH_USER_MODEL,
blank=True,
- null=True,
help_text="Authorised markers for the exam",
related_name="sba_exam_markers",
)