diff options
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/forms.py | 8 | ||||
-rw-r--r-- | testapp/exam/models.py | 6 |
2 files changed, 4 insertions, 10 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index a8e3ae7..a43ba2c 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -128,12 +128,11 @@ class QuizForm(forms.Form): def __init__(self, *args, **kwargs): super(QuizForm, self).__init__(*args, **kwargs) - self.QUIZZES = [('', 'Select a prerequisite quiz')] - self.QUIZZES = self.QUIZZES + \ + QUIZZES = [('', 'Select a prerequisite quiz')] + QUIZZES = QUIZZES + \ list(Quiz.objects.values_list('id','description')) self.fields['prerequisite'] = forms.CharField(required=False, - widget=forms.Select(choices=self.QUIZZES)) - + widget=forms.Select(choices=QUIZZES)) start_date = forms.DateField(initial=datetime.date.today) duration = forms.IntegerField(help_text='Will be taken in minutes') @@ -144,7 +143,6 @@ class QuizForm(forms.Form): help_text='Will be taken as percentage') language = forms.CharField(widget=forms.Select(choices=LANGUAGES)) - def save(self): start_date = self.cleaned_data["start_date"] duration = self.cleaned_data["duration"] diff --git a/testapp/exam/models.py b/testapp/exam/models.py index 5bb94fd..eb270ae 100644 --- a/testapp/exam/models.py +++ b/testapp/exam/models.py @@ -119,7 +119,7 @@ class Quiz(models.Model): pass_criteria = models.FloatField("Passing percentage", default=40) # List of prerequisite quizzes to be passed to take this quiz - prerequisite = models.ForeignKey("self", null=True) + prerequisite = models.ForeignKey("Quiz", null=True) # Programming language for a quiz language = models.CharField(max_length=20, choices=LANGUAGES) @@ -161,7 +161,6 @@ class QuestionPaper(models.Model): for question_set in self.random_questions.all(): marks += question_set.marks * question_set.num_questions self.total_marks = marks - return None def _get_questions_for_answerpaper(self): """ Returns fixed and random questions for the answer paper""" @@ -324,7 +323,6 @@ class AnswerPaper(models.Model): """Updates the total marks earned by student for this paper.""" marks = sum([x.marks for x in self.answers.filter(marks__gt=0.0)]) self.marks_obtained = marks - return None def update_percent(self): """Updates the percent gained by the student for this paper.""" @@ -332,7 +330,6 @@ class AnswerPaper(models.Model): if self.marks_obtained is not None: percent = self.marks_obtained/self.question_paper.total_marks*100 self.percent = round(percent, 2) - return None def update_result(self): """ @@ -344,7 +341,6 @@ class AnswerPaper(models.Model): self.result = "PASSED" else: self.result = "FAILED" - return None def get_question_answers(self): """ |