diff options
Diffstat (limited to 'testapp/exam')
-rw-r--r-- | testapp/exam/forms.py | 1 | ||||
-rw-r--r-- | testapp/exam/models.py | 3 | ||||
-rw-r--r-- | testapp/exam/views.py | 4 |
3 files changed, 8 insertions, 0 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index f48a674..9bcd04f 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -133,6 +133,7 @@ class QuestionForm(forms.Form): type = forms.CharField(max_length=8, widget=forms.Select(choices=QUESTION_TYPE_CHOICES)) active = forms.BooleanField(required=False) tags = TagField(widget=TagAutocomplete(),required=False) + snippet = forms.CharField(widget = forms.Textarea(attrs={'cols': 40, 'rows': 1}),required=False) def save(self): summary = self.cleaned_data["summary"] diff --git a/testapp/exam/models.py b/testapp/exam/models.py index 04789da..708c7af 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -44,6 +44,9 @@ class Question(models.Model): # Is this question active or not. If it is inactive it will not be used # when creating a QuestionPaper. active = models.BooleanField(default=True) + + #Code Snippet + snippet = models.CharField(max_length=256) #Tags for the Question. tags = TaggableManager() diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 49f7bb9..a1e8ece 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -169,6 +169,7 @@ def edit_question(request): options = request.POST.getlist('options') type = request.POST.getlist('type') active = request.POST.getlist('active') + snippet = request.POST.getlist('snippet') tags = request.POST.getlist('tags') j = 0 for id_list in questions: @@ -181,6 +182,7 @@ def edit_question(request): question.type = type[j] edit_tags=tags[j] question.active = active[j] + question.snippet = snippet[j] question.save() for tag in question.tags.all(): question.tags.remove(tag) @@ -219,6 +221,7 @@ def add_question(request,question_id=None): d.options = form['options'].data d.type = form['type'].data d.active = form['active'].data + d.snippet = form['snippet'].data d.save() question = Question.objects.get(id=question_id) for tag in question.tags.all(): @@ -250,6 +253,7 @@ def add_question(request,question_id=None): form.initial['options'] = d.options form.initial['type'] = d.type form.initial['active'] = d.active + form.initial['snippet'] = d.snippet form_tags = d.tags.all() form_tags_split = form_tags.values('name') initial_tags = "" |