Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
Django forms for quiz app ( how to disable a form after submission )

I am creating a classroom app. Which has a exam section where students can give test. If a student wants to give a exam he/she has to select subject and then has to go in exam section. I want student to have access to exam form for one time.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One possibility to do this is as follows. Note that there are many more options available to you, which one is the easiest depends on your entire application.

Keep track of your students' exam results:

class ExamResult(Model):
    student = ForeignKey(User, related_name='exam_results')
    exam = ForeignKey(Exam, related_name='exam_results')
    ...

In your form template, check whether the student has already an ExamResult object associated with the exam. You could do this in two parts:

In your context builder, define a variable with all the new exams.

exams_taken = ExamResult.objects.filter(student=user).values_list('exam_id', flat=True)
new_exams = Exam.objects.exclude(id__in=exams_taken)

In your form, loop over the new_exams only.

{% for exam in new_exams %}
    {# show the form for this exam #}
{% endfor %}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!