300 likes | 389 Vues
Learn how to create dynamic surveys using Maintain language, allowing users to access surveys on any browser or smart device. Step-by-step guide includes creating input and output files, adding HTML elements, and saving data.
E N D
Building Interactive Surveys with Maintain Mark Derwin and Mark Rawls Information Builders
Creating Dynamic Surveys with MaintainOverview • These days, after every meal, service call or session you are asked to take a survey. • Most of these surveys follow a template of rating service, value and content. • The Maintain language is perfect for creating these surveys. • Create databases to dynamically build the forms. • Once deployed, users can access them from any browser: • IE, Firefox, Safari, Opera or Chrome • And any smart device: • iPad, iPhone, Droid, Blackberry, etc… • Presentation DOES include code!!
Creating Dynamic Surveys with MaintainLive Demo • Ask audience to call out up to 5 questions. • Select answers from drop down list. • Run the builder and show the created survey.
Creating Dynamic Surveys with MaintainInput and Output Files • The survey builder uses one file to contain the survey questions and another file to save the output. • Your structure can vary for your site.
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • We can create an application using Update Assist to allow any user to create a survey. • Highlight the Survey.mas file and select Update Assist
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • The file only has one segment. Select SURINFO. • Click Next >
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • On Top, select Add, Update and Delete • On Bottom, make Question and Question_Type visible and Changeable. • Click on Validation for Question_Type and select Static List
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • Enter: Input, YesNo, Range, and Range1to5 • You can create other answer types as well. • Click OK and Next >
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • Select Tree for the Navigation Option. • Click Next >
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • Select your favorite Template. • Click Next >
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • Click Next > on 5 of 6 • Uncheck Compile and Click Finish
Creating Dynamic Surveys with MaintainCreating the AddSurvey Application • Add new surveys. • Edit questions in existing surveys.
Creating Dynamic Surveys with MaintainAdding HTML to HTMLTable • Add a Radio Button to an HTMLTable to allow the user to make a selection • Use HTML Tags • Input Type: Radio • Value: Retrieve and Display • Values can be blank, static or dynamic • Dynamic not recommended. Too many options may get truncated • Use Form.GetHTMLField to retrieve the values from the HTMLTable. • You cannot resort this stack after you create the input field
Creating Dynamic Surveys with MaintainAdding HTML to HTMLTable • In this example we are adding a Yes / No radio button to a column of a stack. • AnswerType contains the HTML code. • Answer contains the value selected.
Creating Dynamic Surveys with MaintainAdding HTML to HTMLTable • The HTML table has 2 columns: AnswerType and Answer. • Set the Content Type of AnswerType to 1-HTML • Make the width 20.
Creating Dynamic Surveys with MaintainAdding HTML to HTMLTable • At runtime the HTML is displayed as the Radio Button. • Kicking off the SaveData Case saves and can display the data.
Creating Dynamic Surveys with MaintainUsing Stacks • All input and output to / from a Maintain application is done with Stacks. • Load a stack from a database and display it on the form. • Columns are database fields and rows are database values. • Save the data back to the database. • Use the INFER command to create a stack • Use the NEXT command to load data into a stack • The INCLUDE command saves data back to the database
Creating Dynamic Surveys with MaintainLoading the Survey List • Maintain code: • Set up 3 stacks to display survey list and save answers • Use Exec to get a unique list of surveys • DST works great • Set up and show the winform
Creating Dynamic Surveys with MaintainLoading the Questions / Question Types • When the user selects a survey name perform buildsurvey • Load all the questions and question_types into STK • Loop through all the questions • Dynamically create the HTML depending on type • Here we see Input and a radio button for Yes / No
Creating Dynamic Surveys with MaintainLoading the Questions / Question Types • Here we see a radio button range and drop list for 1 through 5. • By concatenating the counter to the object name, we create a unique name.
Creating Dynamic Surveys with MaintainAdding a Save Button • Finally we add a button to the bottom of the stack. • We add an IWCTrigger to SaveSurvey so clicking it passes control back to the Maintain code and saves the data. • Note: We can also add check boxes with similar code
Creating Dynamic Surveys with MaintainInside the Maintain Development Environment
Creating Dynamic Surveys with MaintainAdding the HTMLTable • The HTMLTable displays the data from STK • Use AlternameRowColor to make the rows look clearer • Remove the border and grid lines • Change the Font and Font size to stand out • Change Overflow to Visible so form scrolls without scrollbars
Creating Dynamic Surveys with MaintainAdding the HTMLTable • Add columns Question_No, Question and AnswerType from STK • Rename Question_No to No and make QUESTION width 50 & mixed case • Double click on AnswerType • Change the Title to Answer, Width to 45 and Content type to 1-HTML
Creating Dynamic Surveys with MaintainFinishing the Form • Add a Combobox to display ShowStk.Survey_Name • When the user makes a selection, perform BuildSurvey • Drag Tname onto the form and rename it Name • Add whatever image you want. • Change Form Title property to “Take a Survey”
Creating Dynamic Surveys with MaintainSaving the Data • Perform SaveSurvey when the user clicks the Save Button
Creating Dynamic Surveys with MaintainSaving the Data • Compute the selected survey_name into SaveStk • Next assign the unique Count • Now loop through the amount of questions and get the answers. • The GetHTMLField command is used to retrieve values. • Save all the information to the Database • If save fails, bump up the Count and do it again. • When done, Exit or display a Thank you screen.