diff --git a/generic/forms.py b/generic/forms.py index 88f82f5c..fe75517d 100755 --- a/generic/forms.py +++ b/generic/forms.py @@ -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"] \ No newline at end of file + fields = ["examination"] diff --git a/generic/models.py b/generic/models.py index 01d29e30..81828e53 100644 --- a/generic/models.py +++ b/generic/models.py @@ -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( diff --git a/rapids/forms.py b/rapids/forms.py index 7ea25e63..8c19f772 100755 --- a/rapids/forms.py +++ b/rapids/forms.py @@ -206,4 +206,10 @@ AnswerUpdateFormSet = inlineformset_factory( can_delete=True, extra=0, max_num=10, -) \ No newline at end of file +) + + +class ExamForm(ModelForm): + class Meta: + model = Exam + fields = ["name", "time_limit", "exam_mode"] \ No newline at end of file diff --git a/rapids/templates/rapids/exam_form.html b/rapids/templates/rapids/exam_form.html new file mode 100755 index 00000000..ea39f778 --- /dev/null +++ b/rapids/templates/rapids/exam_form.html @@ -0,0 +1,12 @@ +{% extends "rapids/base.html" %} + +{% block content %} +

Add Exam

+
+ {% csrf_token %} + + {{ form.as_table }} +
+ +
+{% endblock %} diff --git a/rapids/urls.py b/rapids/urls.py index a6fef11e..87eb5198 100755 --- a/rapids/urls.py +++ b/rapids/urls.py @@ -32,6 +32,7 @@ urlpatterns = [ path("exam//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/", views.RapidExamViews.exam_json, name="exam_json"), path("exam/json//recreate", views.RapidExamViews.exam_json_recreate, name="exam_json_recreate"), diff --git a/rapids/views.py b/rapids/views.py index cb9eceba..a2a85062 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -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 \ No newline at end of file diff --git a/wally/models.py b/wally/models.py index 3344cfa5..8e067e26 100644 --- a/wally/models.py +++ b/wally/models.py @@ -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()