# # This example shows you how to implement a simple web survey. # import cgitb; cgitb.enable() from web_form import * # create the form form = WebForm("Student Signup", "submit_signup.py") form.new_section("New Student Signup") form.new_paragraph() form.write_text("Please fill in the following information. Your request to sign-up for this class will be saved on the server.") # student's name and email form.begin_question("Contact Information.") form.write_text("Name: ", bold=True) form.newline() form.add_input_text("name") form.new_paragraph() form.write_text("Email:", bold=True) form.newline() form.add_input_text("email") form.end_question() # # NOTE: # # You can actually use the scripts-cert server to automatically # and securely get the name and email of the person trying to sign up. # See sample4.py from recitation 10. # # academics form.begin_question("Academics.") form.write_text("What course(s) are you considering majoring in?", bold=True) form.newline() form.add_input_text("major") form.new_paragraph() form.write_text("What classes did you take last semester?", bold=True) form.newline() form.add_input_text("classes") form.end_question() # experience form.begin_question("Experience.") form.write_text("Do you have any prior programming experience?", bold=True) form.newline() choices_value = ["none", "some"] choices_text = ["None, or very little (this class is for you)", "I have programmed before"] form.add_input_multichoice("experience", choices_value, choices_text, newlines=True) form.new_paragraph() form.write_text("If you have programmed before:", bold=True) form.newline() form.write_text("I have programmed using: ") form.add_input_text("languages") form.newline() form.write_text("My programs were:") form.newline() choices_value = ["tens", "hundred", "toomany"] choices_text = ["tens of lines of code", "around a hundred lines of code", "hundreds of lines of code"] form.add_input_multichoice("codesize", choices_value, choices_text, newlines=True) form.end_question() # # output the HTML # form.print_html()