Login Form

#573 – Insert script for answers

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.
Friday, 27 March 2015 20:24 AEDT
Kishan
Joomla! version: (3.3)


Hi Tim,


Please may i know where are the insert scripts present to insert the answers in the tables.
I need to change few things as per our requirements.

Exactly what i need is when user clicks submit button after answering the survey all answers are inserted in db. That particular insert script i need to alter. May i know which php file contains that query.


Thanks,
Kishan
 
Saturday, 28 March 2015 08:50 AEDT 5'
Tim
Everything Bundle, BF Quiz Plus 3 Years, BF Survey 12 Months
For BF Survey version 2, the file /administrator/components/com_bfsurvey/helpers/answertable.php is used to build the answer table and all the front end view files. The buildAnswerTables() is what creates the database table to store the results of the survey.

regards

Tim
Follow us on twitter http://twitter.com/tamlynsoftware
Monday, 30 March 2015 00:55 AEDT
Kishan
Hi Tim,


Thanks for your response.
Im able to find the alter and create table scripts in that method, but what I am looking at is Insert scripts,
which inserts the answers into #_bfsurvey_*results.

I need to get the survey id into my application and load it in the session once the survey results are submitted...
Kindly reply ASAP.


Regards,
Kishan
 
Tuesday, 31 March 2015 16:11 AEDT 15'
Tim
Everything Bundle, BF Quiz Plus 3 Years, BF Survey 12 Months
Hi Kishan,
You could potentially add some custom code to the model for the view, in the onAfterSave function.
Assuming you are looking at the first survey (category id 1), the file would be /components/com_bfsurvey/models/1results.php

//around line 411
	protected function onAfterSave(&$table)
	{
		$result = parent::onAfterSave($table);
		$catid = 1;
		$id=$table->bfsurvey_1result_id;


As you can see, we've just saved the record, and already have the id in the $id variable. You could chuck it into a session variable with something like:
$session = JFactory::getSession();
$session->set('id', $id);


Then retrieve it somewhere else with:
$session = JFactory::getSession();
$id=$session->get('id');


Just be aware that the front end views including this model file are dynamically created when you edit any questions, so you are probably best still editing the /administrator/components/com_bfsurvey/helpers/answertable.php like I originally suggested.
You will find the relevant code around line 3479

protected function onAfterSave(&$table)
{
$result = parent::onAfterSave($table);
$catid = ".$catid.";
$id=$table->bfsurvey_".$catid."result_id;


Note that any $ character needs to be replaced with & # 3 6 ; (ampersand hash 36 semicolon - no spaces) and > should be replaced with & g t ; (ampersand gt semicolon - no spaces)
so the code you insert might be more like this (I've added spaces before ampersand as my ticket system is converting this)

& #36;session = JFactory::getSession();
& #36;session-& gt;set('id', & #36;id);

regards

Tim
Follow us on twitter http://twitter.com/tamlynsoftware
Wednesday, 01 April 2015 16:45 AEDT
Kishan
Thanks Tim.


This is what we needed...

Even the steps you provided are easily understandable...


Thanks a lot again..


regards,
Kishan
 
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