34 lines
808 B
Python
Executable File
34 lines
808 B
Python
Executable File
from django.forms import (
|
|
Form,
|
|
ModelForm,
|
|
ModelMultipleChoiceField,
|
|
ModelChoiceField,
|
|
ChoiceField,
|
|
CharField,
|
|
)
|
|
from django.forms import inlineformset_factory
|
|
|
|
from .models import (
|
|
Question,
|
|
CidUserAnswer,
|
|
Exam,
|
|
)
|
|
|
|
from django.contrib.admin.widgets import FilteredSelectMultiple
|
|
from django.forms.widgets import RadioSelect, TextInput, Textarea
|
|
|
|
|
|
class CidUserAnswerForm(ModelForm):
|
|
class Meta:
|
|
model = CidUserAnswer
|
|
fields = ["answer"]
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(CidUserAnswerForm, self).__init__(*args, **kwargs)
|
|
self.fields['answer'].required = False
|
|
|
|
# This should be made generic?
|
|
class ExamForm(ModelForm):
|
|
class Meta:
|
|
model = Exam
|
|
fields = ["name", "time_limit", "exam_mode", "active"] |