-
Notifications
You must be signed in to change notification settings - Fork 3
Survey Interface Implementation
Myeong Lee edited this page Jun 8, 2018
·
2 revisions
This page is a survey interfact that is shown to organizations for filling out the forms (the source of our data).
- The layout of the public survey interface is implemented at
/templates/survey/tp_survey.php -
http://www.opendataimpactmap.org/survey calls
survey/startfunction in theindex.phpfile using the Slim framework.
- It has following two queries:
- retrieve max object id from the
org_surveystable - Insert a new object id with id as maxId + 1 into org_surveys table
- Pass the last inserted survey id to
survey/:surveyId/formwhere surveyId is the passed surveyId
- retrieve max object id from the
-
:surveyId/formfunction callssurvey/tp_survey.phpfile - When a user submits the form,
survey/tp_survey.phpcallssurvey/2du/:surveyIdfunction in index.php - All the insertion of data using MySQL queries is done in
2du/:surveyIdfunction. It first prepare data based on the data passed from the form, and insert to each table one by one.
- All the database operations for the input data provided by user in the form is done in this function.
- Checks whether
org_hq_country_locodeis already registered in theorg_country_infotable. If so, get thecountry_idfrom the table. This table follows ISO2 standard from the World Bank. If not found here, that means the country code is not available from the list (so will be remain asnull). - Checks org_locations_info table whether the location data (e.g., city and province) is already registered. If not, insert the location data into the table.
- Insert information into org_profiles table along with profile id as survey id of the form and location_id.
- Insert into org_contact table all survey_contact related data along with profile id as survey id
- Insert into data_applications table based on "applications" data.
- Insert int org_data_use table. i. First, retrieve country information for each data_use case. If available, it links to the country_id. ii. The followings deal with data_type when some values are available or null.
- After all the DB operations, it redirects to
/survey/submitted/:surveyId/function, then, callssurvey/:surveyId/thankyoufunction. - All survey related information along with profile id is passed to
survey/tp_thankyou.phpfrom/:surveyId/thankyoufunction
- This interface is used by the internal researcher in ODE (not by an outside guest). E.g., A researcher interviews an organization and puts the organization data by himself/herself (rather than the organization's person does the survey).
- The interface calls
/:surveyId/form/internal/add/function in index.php file using the Slim framework. - The layout of the internal survey interface is implemented at
/templates/survey/tp_survey_less_req.php - The rest of the operations are same to the public one.
-
survey/edit/:profile_idis called from/survey/tp_thankyou.phpfile or a pop-up menu from the map visualization.
- It first retrieves
org_namefrom theorg_profilestable using profile id - Calls
survey/tp_profile_edit_msg.phpfile and passesorg_nameinformation. -
survey/tp_profile_edit_msg.phpfile callssurvey/edit/:profileId/formfunction fromindex.phpfile
- Retrieve all information from
org_profilestable based on profile id, and joinorg_locations,org_country_info, anddata_applicationstables. - Retrieve
org_data_usebased on profile id. - Insert into org_surveys with a new
survey_id. - Sends all retrieved information to
survey/tp_profile_edit.phpfile along with a newprofile_id - In
survey/tp_profile_edit.phpfile, it displays all information received from/edit/:profile_id/formfunction - After submission of the edited form, it calls
survey/2du/:surveyIdfunction and process all information as described above for/2du/:surveyIdfunction.
Update languages by adding a new language
- gettext installed on server, development environment
- Create directory for language files in
Localedirectory
cd odesurvey
mkdir -p html/map/survey/Locale/[language]/LC_MESSAGES
touch html/map/survey/Locale/[language]/LC_MESSAGES/messages.po
- Copy content from Hackpad (or other source) into
../[language]/LC_MESSAGES/messages.po
- Test format of messages.po is correct and generate the file (use
sudoif necessary)
cd odesurvey/html/map/survey/Locale/de_DE/LC_MESSAGES
/usr/local/Cellar/gettext/0.19.4/bin/msgfmt messages.po
[vagrant@odesurvey LC_MESSAGES]$ cd /var/www/html/map/survey/Locale/de_DE/LC_MESSAGES
[vagrant@odesurvey LC_MESSAGES]$ msgfmt messages.po
messages.po:511: end-of-line within string
msgfmt: found 1 fatal error
[vagrant@odesurvey LC_MESSAGES]$ msgfmt messages.po
msgfmt: error while opening "messages.mo" for writing: Permission denied
[vagrant@odesurvey LC_MESSAGES]$ sudo msgfmt messages.po
[vagrant@odesurvey LC_MESSAGES]$
- Add language entry to
$langsarray in PHP template fileshtml/map/survey/templates/survey/tp_survey.phpandhtml/map/survey/templates/survey/tp_survey_gettext.php
$langs = array('es_MX' => 'Español', 'fr_FR' => 'Français', 'de_DE' => 'German', 'ru_RU' => 'Russkiy');
- Commit to repo
- Push repo
- See update_website.md
- Login into target server
- Run the following commands
sudo service apache2 restart
-
Implementations
-
Deployment and Update