Login Form

#696 – Identifying Participants via UURL/Username

Posted in ‘BF Survey’
This is a public ticket. Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Thursday, 20 August 2015 05:28 AEST
roolark
Joomla! version: 3.3.6

Hi,

I am trying to accomplish a way to send an email invite from BF Survey using the {uurl} option so that the Joomla users in a group get the emails with unique links/ID's to the survey. Then, when the survey is submitted, I am trying to match the uurl and/or encoded username in the uurl with the person who took the survey. Unfortunately, I can't seem to find where the UID/Username/UURL info gets saved with the survey.

Example:
John Doe has a user account on my joomla installation called user1 and an email address john.doe@dot.com. He belongs to a group called test.
Jane Smith has a user account on my joomla installation called user2 and an email address jane.smith@dot.com. She also belongs to the group called test.
These people cannot have their email address and/or real names stored in the survey tables, but it IS OK to store their usernames (user1, user2) or some other randomized ID associated with them in the survey tables.

I will be using the Invite Email Template to send the invite email to the group test, which will send the email to both users. In the body of the email, I include the {uurl} option, which generates a unique link to the survey that the documentation says includes their encoded username (I'm assuming this is the encoded version of user1, user2). The person will click on the link, take the survey, and submit. The survey is not allowed to ask them to input their names/email addresses. Also, the users are not aware of what their usernames are.

Using the above scenario, when I look at the survey results or generate a survey report, I am unable to find a field that shows their username being saved or a UID that is capable of being associated with the person that took the survey.

I've considered including the individual username for each email invite in the body of the email, but realized that I can't use the email template to send Jane Smith and John Doe an email where only their own usernames appear. If this was possible, I could have a question on the survey asking them to paste or type in the username they received via email.

Is there already a solution to accomplish saving the username of the participate when they click the uurl, or another solution that would accomplish the same or similar objective?
Thursday, 20 August 2015 11:36 AEST 30'
Tim
BF Quiz Plus 3 Years, BF Survey 12 Months
Hi Andrew,
The unique url that is inserted using UURL is created by encrypting the user id, username and password. You can see this code in /administrator/components/com_bfsurvey/helpers/bfsurvey.php

//line 343
return md5($user->id . $user->username . $user->password);


Note that this code is based off how Akeeba release systems authenticates a user and determines if they can download the product or not.

Essentially, when the survey is loaded via this unique url, the encrypted portion is sent to the getUserFromDownloadID($dlid) function, which basically loops through all the users on your site, and does the same encryption of the id, username and password. It compares this to the one in the URL, and if they match then the survey software knows which user is taking the survey. Essentially this is the same as logging in before you take the survey, and the name and email are automatically populated on the form. At no point is the unique encrypted id stored with the result, as it's not needed as we already have the name and email.

Now in your case where you only want username, and not the email and name, then I think you will need to make some customizations to the software, as it's not going to do that by default.

You can see the front end code in the model for your survey, for instance /components/com_bfsurvey/models/1results.php

				//check if uuid supplied
				$uuid=JFactory::getApplication()->input->get('uuid','','STRING');
				if($uuid)
				{
					require_once JPATH_ADMINISTRATOR.'/components/com_bfsurvey/helpers/bfsurvey.php';
					$user = BFSurveyHelperBfsurvey::getUserFromDownloadID($uuid);
					$this->_formData['Name']=$user->name;
					$this->_formData['Email']=$user->email;
				}


This code is auto generated in answertable.php in the backend. Anyway, essentially once you've authenticated the user using getUserFromDownloadID, you could populate a hidden username field instead of the Name and Email fields.

Anyway, I hope this helps.

regards

Tim
Follow us on twitter http://twitter.com/tamlynsoftware
Friday, 21 August 2015 05:11 AEST
roolark
Hi Tim,

Thank you for this valuable information. After looking at your response and the code, I was able to figure out a solution that works for me. In the survey category, I had "name" and "email" set to not be displayed, and "enable anonymous responses" set to "no". In the survey results database, since Name and Email were not being displayed, the information for Name and Email from the UURL was also not being saved.

Because it is not permissible for me to have the participants' names stored on my joomla server, and because the BF Survey software is already coded to save Name or Email or both from the URRL, I simply populated the randomly generated usernames into the names section in the Joomla users' module, told BF Survey to display the "Name" field, changed the text of the Name field to something akin to "Do Not Change This Field" and verified that the data in that field that is prepopulated by the Invite Email UURL is the randomly generated username and that it does get saved with the record submission.

Thanks again for your help.
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.
Go to top