Make a random survey video solution with PHP and Examinare API.2018-12-30
In a study of videos and the effect it has on a person then you are at the right place to learn how to do advanced type of video displaying and use the powerful Examinare APi to play the videos for a person and then after show the questions that you want to show without autoplaying the videos again for the same person.
This solution is on the advanced level. We also deliver this kind of solution for you for a small fixed fee.
1. Step one, create the first survey that you want to use as a base.
This step sounds trivial but make sure that you get this step correct since we will be copying this survey with the Examinare API or inside the Examinare Survey Tool manually.
2. Add the player embedded code inside the “more information” on the question you want to use for player.
If you want the player to be alone and no questions under then use the question type “Instructions”. If you are using Youtube, Vimeo etc then use the embedded option with autoplay feature.
3. Test-drive the survey with the survey launched as a “Public websurvey” and make styling of the form as you wish.
If you have any questions then check our manual or create a support ticket by emailing us at email@example.com
When you are finished with the survey make sure you put it in “Private websurvey” mode.
4. Activate Examinare API and use the Examinare PHP Wrapper library.
Navigate into “Examinare API & SSL” section inside “Settings” tab and activate Examinare API.
Make sure you do not share this key with anyone. If you want to add a personalized API key then activate “Mobile API Tokens” and send the API Call with the credentials to your account.
- Use Mobile API - https://www.examinare.io/apidocs/setphoneid/
- Use Normal API-call https://www.examinare.io/apidocs/
Download the Examinare Wrapper library from here:
5. Use the PHP Wrapper Code for copy the survey and change the instructional text inside the survey with the questions number.
5.1 Get the question number of the place where you have put the You Tube code.
Use the following call and get the question number for the question where you have put the code of Youtube. Make sure you note that question number down.
5.2 Make a copy.
Now make a copy of the original survey and make sure you change the name of the survey so that you do not have 2 surveys with the same name, it can get really confusing after a while and make sure you save the surveyID of the new question.
5.3 Call the change question function and add the Youtube code.
If the code need new line-break make sure you use the line-break string explained in the instructions.
Repeat the steps again with the Examinare code until you have the amount you need.
Please observe that you will need a Unlimited Account to make more than 1 copy.
Alternative 5. If you do not want to code.
You can also copy the survey inside the account, if you choose this then make sure the design gets copied correctly and that you note down the SurveyID’s manually and publish all surveys after copy.
6. Create a simple sign-in page.
Well this step is up to you. Since you are a developer you have probably some preferences in this area. However we will give some links to what we feel is easiest to start with:
Bootstrap : https://getbootstrap.com/
7. Use create function to add the recipient after login.
When the subject is being signed into your website you can automatically create a user inside the Examinare API with the following function. Our tip is to populate the mandatory fields and add the username and password on a $_SESSION cookie in your website. This way you can check what this person has answered and not answered.
8. Randomize the surveys depending on the amount of votes it has.
So the following steps are to make sure you can get a even result of the surveys but it can also be used to randomize what survey the user gets.
Use the listSurveys: https://www.examinare.io/apidocs/listsurveys/
And put the surveyID’s into a Array and randomize an entry. The API call will also return the amount of answers inside the survey. So if you want to make sure you only randomize the ones not having any votes then check the “completedAnswers” variable.
If you want to make sure you not get too many redirects to the same survey you can use the following:
9. Mark a recipient active to the actual survey.
Use the above call to mark the recipient as redirected to the survey.
10. Get the link and redirect the use to the survey.
Get the link and redirect the use to the survey and set redirect back to the catch page.
Send this command together with contactID of the user so that you can get the personalized link for the survey.
Redirect with PHP Header.
There are 2 links inside the call. The “surveyLinkWeb” parameter will provide to the special design of your account. To force to a mobile only view then use the following parameter: “surveyLinkMobile”
11. Setup redirect back to the script.
There are 2 ways of redirecting back after the person has answered. You can set the redirect url inside the Settings – Layout – “Change link of thank you page” or you can add “return_url” parameter call inside the call to the survey link.
https://theurltoyoursurvey?return_url=your link goes here.
You will need to format your url with urlencode function found here: http://php.net/manual/en/function.urlencode.php
12. Catch the information and act on it.
When the catch page gets the call from Examinare on the save you will get 2 parmeters:
- Inforeg value gives the actual answers of the contact:
- ContactID value give you the info about the recipient so that you can check that no-one try to manipulate the data. https://www.examinare.io/apidocs/listrecipientbycontactid/
Optional step. Allow login of already created users.
Since all created recipients are listed inside the following API calls you can let the person login again by using the following info:
Last words about this solution
This tutorial is provided as is for the developer who want to know how to make their own voting site or study. We only support generic questions in our support. If you want us to integrate this solution for you then you will need an unlimted survey account and also pay for the integration and steps above. Today, the 2018-12-30 we charge 350 EURO to make these steps but this charge can be raised without any further notice. Make an inquiry on the page to get a quote today.
Find out how Examinare can help you! One of our Examinare experts will contact you shortly to discuss your needs and how you can benefit from Examinare Solutions.
Fill in the form and we will contact you shortly.