add create exam form to rapids

This commit is contained in:
Ross
2021-04-04 20:07:51 +01:00
parent 845ab6c377
commit 04596da2e4
7 changed files with 33 additions and 9 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ from django.forms import (
from django.forms import inlineformset_factory
from generic.models import (
Examination,
Examination
)
from django.contrib.admin.widgets import FilteredSelectMultiple
@@ -19,4 +19,4 @@ from django.forms.widgets import RadioSelect, TextInput, Textarea
class ExaminationForm(ModelForm):
class Meta:
model = Examination
fields = ["examination"]
fields = ["examination"]
+3 -3
View File
@@ -53,15 +53,15 @@ class ExamBase(models.Model):
#exam_questions = SortedManyToManyField(Long, related_name="exams", blank="true")
active = models.BooleanField(
help_text="If an exam should be available", default=True
help_text="If an exam should be available", default=False
)
exam_mode = models.BooleanField(
help_text="If an exam should be take in exam_mode", default=True
help_text="If an exam should be taken in exam mode", default=True
)
publish_results = models.BooleanField(
help_text="If an exams results should be available", default=True
help_text="If an exams results should be available", default=False
)
recreate_json = models.BooleanField(
+7 -1
View File
@@ -206,4 +206,10 @@ AnswerUpdateFormSet = inlineformset_factory(
can_delete=True,
extra=0,
max_num=10,
)
)
class ExamForm(ModelForm):
class Meta:
model = Exam
fields = ["name", "time_limit", "exam_mode"]
+12
View File
@@ -0,0 +1,12 @@
{% extends "rapids/base.html" %}
{% block content %}
<h2>Add Exam</h2>
<form action="" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit">
</form>
{% endblock %}
+1
View File
@@ -32,6 +32,7 @@ urlpatterns = [
path("exam/<int:pk>/toggle_results_published", views.RapidExamViews.exam_toggle_results_published, name="exam_toggle_results_published"),
path("exam/submit", views.RapidExamViews.postExamAnswers, name="exam_answers_submit"),
path("exam/", views.RapidExamViews.exam_list, name="exam_list"),
path("exam/create", views.ExamCreate.as_view(), name="exam_create"),
path("exam/json/", views.RapidExamViews.active_exams, name="active_exams"),
path("exam/json/<int:pk>", views.RapidExamViews.exam_json, name="exam_json"),
path("exam/json/<int:pk>/recreate", views.RapidExamViews.exam_json_recreate, name="exam_json_recreate"),
+5
View File
@@ -28,6 +28,7 @@ from .forms import (
ExaminationForm,
AnswerFormSet,
AnswerUpdateFormSet,
ExamForm
)
from .models import (
Rapid,
@@ -907,3 +908,7 @@ RapidExamViews = ExamViews(Exam, Rapid, "rapids", "rapid", loadJsonAnswer)
class ExamViewSet(viewsets.ModelViewSet):
queryset = Exam.objects.all().order_by('name')
serializer_class = ExamSerializer
class ExamCreate(LoginRequiredMixin, CreateView):
model = Exam
form_class = ExamForm
+3 -3
View File
@@ -5,15 +5,15 @@ def image_directory_path(instance, filename):
return u"wally/picture/{0}".format(filename)
class Specialty(models.Model):
specialty = models.CharField()
specialty = models.CharField(max_length=200)
# Create your models here.
class Candidate(models.Model):
age = models.PositiveIntegerField()
specialty = models.ForeignKey(Specialty)
specialty = models.ForeignKey(Specialty, on_delete=models.SET_NULL, null=True, blank=True)
class Response(models.Model):
question = models.ForeignKey("Question")
question = models.ForeignKey("Question", on_delete=models.SET_NULL, null=True, blank=True)
time_to_find = models.FloatField()
hit_point_x = models.FloatField()
hit_point_y = models.FloatField()