"Oscad workshop feedback form.", "page callback" => "feedback_all", "access arguments" => array("access feedback"), "type" => MENU_CALLBACK ); $items["feedback/thank-you"] = array( "title" => "Thank you", "page callback" => "feedback_thank_you_all", "access arguments" => array("access feedback"), "type" => MENU_CALLBACK ); return $items; } function feedback_perm() { return array( "access feedback", ); } function feedback_form($form_state) { $form = array(); $form["wrapper"] = array( '#type' => "fieldset", "#title" => t(" (Feedback form for the Oscad workshop conducted on 10th May 2014 at PESIT, Bangalore.) "), "#prefix" => "
", "#suffix" => "
", ); $form["wrapper"]["first_name"] = array( "#type" => "textfield", "#title" => t("First name"), "#required" => TRUE ); $form["wrapper"]["last_name"] = array( "#type" => "textfield", "#title" => t("Last name"), "#required" => TRUE ); $form["wrapper"]["email"] = array( "#type" => "textfield", "#title" => t("Email"), "#required" => FALSE ); $form["wrapper"]["phone"] = array( "#type" => "textfield", "#title" => t("Phone"), "#required" => FALSE ); $form["wrapper"]["institution"] = array( "#type" => "textfield", "#title" => t("Institution/College"), "#required" => TRUE ); $form["wrapper"]["activities"] = array( "#type" => "checkboxes", "#title" => t(" 1. Which of the following activities are you interested to contribute to (Tick all that are applicable.)? "), "#options" => get_activities(), "#required" => TRUE ); $form["wrapper"]["rating"] = array( "#type" => "radios", "#title" => t(" 2. How would you rate this workshop on a scale of 5? "), "#options" => array_combine(range(1, 5), range(1, 5)), "#required" => TRUE ); $form["wrapper"]["liked"] = array( "#type" => "textarea", "#title" => t("3. Things that you liked in Oscad workshop"), "#required" => TRUE ); $form["wrapper"]["disliked"] = array( "#type" => "textarea", "#title" => t("4. Things that you disliked in Oscad workshop"), "#required" => TRUE ); $form["wrapper"]["difficulties"] = array( "#type" => "textarea", "#title" => t(" 5. Did you face any difficulties while using Oscad? "), "#required" => TRUE ); $form["wrapper"]["platform"] = array( "#type" => "radios", "#title" => t("6. On which platform do you use Oscad?"), "#options" => array( t("GNU/Linux"), t("Windows"), t("Both") ), "#required" => TRUE ); $form["wrapper"]["missing"] = array( "#type" => "textarea", "#title" => t("7. Any feature you find missing in Oscad?"), "#required" => TRUE ); $form["wrapper"]["workshop"] = array( "#type" => "radios", "#title" => t(" 8. Would you like to have a workshop on advanced features of Oscad? "), "#options" => array( t("Yes"), t("No") ), "#required" => TRUE ); $form["wrapper"]["future"] = array( "#type" => "radios", "#title" => t(" 9. Can we contact you in the future to know your experience with Oscad? "), "#options" => array( t("Yes"), t("No") ), "#required" => TRUE ); $form["wrapper"]["contact"] = array( "#type" => "textarea", "#title" => t(" 10. Please provide your contact details if you selected 'Yes' in question 8 or 9. "), "#required" => FALSE ); $form["wrapper"]["magazines"] = array( "#type" => "textarea", "#title" => t(" 11. In order to inform the college teachers and students about Oscad, we plan to place advertisements. Which technical magazines do you read? "), "#required" => FALSE ); $form["wrapper"]["suggestion"] = array( "#type" => "textarea", "#title" => t(" 12. Any other Suggestions / Feedback / Appreciation "), "#required" => FALSE ); $form["wrapper"]["submit"] = array( "#type" => "submit", "#value" => "Submit" ); return $form; } function feedback_form_validate($form, &$form_state) { /* making contact field required if 'Yes' in workshop/future field */ $v = $form_state["values"]; if(($v["workshop"] == 0 || $v["future"] == 0) && $v["contact"] == "") { form_set_error("contact", " 10. Please provide your contact details if you selected 'Yes' in question 8 or 9. This field is required since you selected 'Yes' in question 8 or 9. "); } if($v["email"] && !valid_email_address($v["email"])) { form_set_error("email", "Please enter a valid email id."); } if($v["phone"] && !is_numeric($v["phone"])) { form_set_error("phone", "Please enter a valid phone number. (Only digits allowed)"); } } function feedback_form_submit($form, &$form_state) { /* escaping special characters */ foreach($form_state["values"] as $key => $value) { if(gettype($value) == "string") { $form_state["values"][$key] = db_escape_string($value); } } $v = $form_state["values"]; $v["activities"] = implode(",", array_filter($v["activities"])); $query = " INSERT INTO feedback ( first_name, last_name, email, phone, institution, activities, rating, liked, disliked, difficulties, platform, missing, workshop, future, contact, magazines, suggestion ) VALUES ( '{$v["first_name"]}', '{$v["last_name"]}', '{$v["email"]}', '{$v["phone"]}', '{$v["institution"]}', '{$v["activities"]}', {$v["rating"]}, '{$v["liked"]}', '{$v["disliked"]}', '{$v["difficulties"]}', {$v["platform"]}, '{$v["missing"]}', {$v["workshop"]}, {$v["future"]}, '{$v["contact"]}', '{$v["magazines"]}', '{$v["suggestion"]}' ) "; $result = db_query($query); drupal_goto("feedback/thank-you"); } function feedback_all() { $page_content = ""; $page_content .= "
* Required
"; $page_content .= drupal_get_form("feedback_form"); return $page_content; } function feedback_thank_you_all() { $page_content = ""; $page_content .= "
"; $page_content .= l("Click here", "feedback"); $page_content .= " to submit another feedback."; drupal_set_message("Feedback recorded successfully."); return $page_content; } function feedback_init() { drupal_add_css(drupal_get_path("module", "feedback") . "/css/feedback.css"); } /* helper functions */ function get_activities() { return array( 1 => t("Creating a textbook companion (TBC)"), 2 => t("Migrating your lab to Oscad (LM)"), 3 => t("Adding to component library (CL)"), 4 => t("Doing projects (BE, M.Sc, ME, Ph.D) with Oscad"), 5 => t("Review of the above (TBC, LM, CL, projects)"), 6 => t("Building hardware using Oscad and testing"), 7 => t("Enhancing the capabilities of Oscad - need IT expertise"), 8 => t("Creation of Spoken Tutorials on Oscad"), 9 => t("Promoting Oscad"), ); } ?>