Open source survey management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

68 lines
1.8 KiB

  1. <?php
  2. require_once("survey_func.php");
  3. $survey = new OpenForm;
  4. $survey->conn = mysqli_connect("127.0.0.1", "survey_user", "yourpass", "surveys");
  5. $survey->table = "results";
  6. $survey->id = "first";
  7. $survey->add_module("Name", "What is your name?", "name", ModuleType::TEXTBOX, null, null, null);
  8. $radio = array(
  9. "Linux" => "lin",
  10. "Windows" => "win",
  11. "Mac OS" => "mac"
  12. );
  13. $survey->add_module("Operating System", "What OS do you use?", "choice_os", ModuleType::RADIO, $radio, null, null);
  14. $chkbox = array(
  15. "CS" => "cs",
  16. "Art" => "art",
  17. "Business" => "business"
  18. );
  19. $survey->add_module("Major", "What are you majoring in?", "major", ModuleType::CHECKBOX, $chkbox, null, null);
  20. $survey->add_module("Age", "How old are you?", "age", ModuleType::NUM_INPUT, null, null, "years");
  21. $rankings = array(
  22. 5 => "Strongly agree",
  23. 4 => "Agree",
  24. 3 => "Neutral",
  25. 2 => "Disagree",
  26. 1 => "Strongly Disagree"
  27. );
  28. $ranking_questions = array(
  29. "foss" => "I believe in FOSS ideology",
  30. "rms" => "Richard Stallman is the one true god"
  31. );
  32. $survey->add_module("Ranking", "Please rank the following from strongly agree to strongly disagree", null, ModuleType::RANKING, $ranking_questions, $rankings, null);
  33. $countries = array(
  34. "CA" => "Canada",
  35. "US" => "United States",
  36. "DE" => "Germany",
  37. "OT" => "Other"
  38. );
  39. $survey->add_module("Country", "What country do you live in?", "country", ModuleType::DROPDOWN , $countries, null, null);
  40. $survey->add_module("Meta", "How do you feel about this question?", "metaquestion", ModuleType::TEXTAREA, null, null, null);
  41. $res = $survey->create("Stephen's Survey", "This is my survey");
  42. if ($res == 2)
  43. {
  44. echo "<b>There was an error submitting your query to the database.</b>";
  45. }
  46. elseif ($res == 1)
  47. {
  48. echo "<b>Success! Your response has been received.</b>";
  49. }
  50. ?>