TOPIC:

Quiz type ability 3 months 1 week ago #260239

  • Topic Author
  • ALRA1
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 169
  • Thanks: 0
I was wondering if BreezingForms is able have a questionnaire and based on the answers results in a pass/fail message at the end of it.

It is something along the lines of someone answering a Covid-19 questionnaire and depending on answers to those questions deems whether a person can enter a premise.

Is BF capable of something like this?

Please Log in or Create an account to join the conversation.

Quiz type ability 3 months 1 week ago #260241

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 6928
  • Karma: 3
  • Thanks: 494
Hi,

here is example how to make a quiz with radio group:
crosstec.org/en/forums/3-breezingforms-f....html?start=0#228275

Let me know if you need more help

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Quiz type ability 3 months 1 week ago #260310

  • Topic Author
  • ALRA1
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 169
  • Thanks: 0
Thanks for the link.

I was wondering along those lines but in my current use case (Covid-19 questionnaire) it's a little simpler.

If any one of a series of questions is a yes, then the result is a FAIL. Once the user submits, they will get a message on the screen and an email indicating this.

If the answer is No to all the questions, a pass PASS appears on screen upon submitting as well as an email indicating this.

Is this possible?

Please Log in or Create an account to join the conversation.

Quiz type ability 3 months 1 week ago #260314

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 6928
  • Karma: 3
  • Thanks: 494
Hi,

1) go to your form->Advanced->More options->Scripts->Submitted Script->check Custom->Create Code framwork, and then you will see this code:
function ff_formname_submitted(status, message)
{
    switch (status) {
        case FF_STATUS_OK:
           // do whatever desired on success
           break;
        case FF_STATUS_UNPUBLISHED:
        case FF_STATUS_SAVERECORD_FAILED:
        case FF_STATUS_SAVESUBRECORD_FAILED:
        case FF_STATUS_UPLOAD_FAILED:
        case FF_STATUS_ATTACHMENT_FAILED:
        case FF_STATUS_SENDMAIL_FAILED:
        default:
           alert(message);
    } // switch
} // ff_formname_submitted
Below
case FF_STATUS_OK:
break;
add:
if(ff_getElementByName('question1').value=='yes' || ff_getElementByName('question2')=='yes') {
alert('Fail');
}
else if(ff_getElementByName('question1').value=='no' && ff_getElementByName('question2')=='no') {
alert('Good');
}
The full code looks like:
function ff_formname_submitted(status, message)
{
    switch (status) {
        case FF_STATUS_OK:
if(ff_getElementByName('question1').value=='yes' || ff_getElementByName('question2')=='yes') {
alert('Fail');
}
else if(ff_getElementByName('question1').value=='no' && ff_getElementByName('question2')=='no') {
alert('Good');
}
           // do whatever desired on success
           break;
        case FF_STATUS_UNPUBLISHED:
        case FF_STATUS_SAVERECORD_FAILED:
        case FF_STATUS_SAVESUBRECORD_FAILED:
        case FF_STATUS_UPLOAD_FAILED:
        case FF_STATUS_ATTACHMENT_FAILED:
        case FF_STATUS_SENDMAIL_FAILED:
        default:
           alert(message);
    } // switch
} // ff_formaname_submitted
This is example for only two radio group (question1 and question2 is name of radio group (not title)), replace it with yours

On submit you will see alert with message for good or for fail.

2) if you want to email users for good or for fail submission, then you should to use custom php mail.
In Properties of your form uncheck the Mail notification checkbox. Also, in the Advanced options of element where user enters his email uncheck the Mailback checkbox if it was checked (I guess you have a email element in user can enter his email).

Go to your form->Advanced->More options->Submit pieces->End Submit -> check Custom and put:
$this->execPieceByName('ff_InitLib');
$from = 'address@domain.com';
$fromname = 'From Name';
$subject = 'Your Email Subject'; // Change to your preferred Email subject

$recipient = ff_getSubmit('email');

$sel1 = ff_getSubmit('question1'); // replace question1 with the Name of your radiogroup element
$sel2=ff_getSubmit('question2'); //replace question2 with the Name of your second radiogroup element, and so on for each radiogroup

$body = '';
foreach ($this->maildata as $data) {
  $body .= $data[_FF_DATA_TITLE].": ".$data[_FF_DATA_VALUE].nl() . "\r\n"; 
}
$this->sendMail($from, $fromname, 'adminemail@test.com', $subject, $body );  // replace adminemail@test.com with your admin email

//Define content of the  emails for fail or good submissions 

$body1 = 'This is the first email for good ';
$body2 = 'This is the first email for fail';

if($sel1 == "no" && $sel2=="no")
{
$this->sendMail($from, $fromname, $recipient, $subject, $body1 ); 
}
if($sel1=="yes" || $sel2=="yes") {
$this->sendMail($from, $fromname, $recipient, $subject, $body2); 
}
//in the code above replace yes, no with values of your options in your radio group

NOTE: You have to adjust the code for your form following the instructions in comments.

P.S: this is a small example for two radio group, on same way you can do this for more radio group

I hope I exaplained it well

Let me know if you need more help

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Quiz type ability 3 months 1 week ago #260347

  • Topic Author
  • ALRA1
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 169
  • Thanks: 0
Thanks Tihana!!

I will give this a try. I just have a couple of questions:

1. Instead of an alert is it possible to add the result as part of the "Thank you page" on page 2)

Update: I tried to embed some php into the thank-you edit page, but I think I'm not pulling in the correct data.

2. The email instructions were great! I managed to get it to work,.

Update 2: My revised question: Is it possible to format the message with html, so I can add line breaks and possible bold some of the words?

Alex

Please Log in or Create an account to join the conversation.

Last edit: Post by ALRA1. Reason: Revised question

Quiz type ability 3 months 1 week ago #260352

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 6928
  • Karma: 3
  • Thanks: 494
Hi,

1) I think so, but I will test it, and get back to you

UPDATE:
1) in last page which is thank you, go to Properties->Description->click on Edit and put:
<div id="test"> </div>
<div id="test1"> </div>
P.S: put this for each question (I added it for two questions (radio group)).

1a) then go to your form->Advanced->More options->End submit->check Custom and put:
$session = JFactory::getSession();
$qu1=ff_getSubmit('question1'); //question1 is name for first radio group (not title)
$qu2=ff_getSubmit('question2'); //question2 is name for second radio group (not title), and so on for each question
$session->set('test', $qu1); //test is div from thank you page for question1
$session->set('test1', $qu2); //test1 is div from thank you page  for question2

if you have a code for email here, just put it below the email code

1b) then go to your form->Advanced->More options->Form pieces->Before form->check Custom and put:
$session = JFactory::getSession();
if (JRequest::getInt('ff_status', -1) == 0) {
$que1 = $session->get('test',$qu1); //get values from end submit $qu1 you have in end submit
$que2 = $session->get('test1',$qu2); //same here
if($que1=='no' && $que2=='no') {
echo 'This is ok';
}
if($que1=='yes' || $que2=='yes') {
echo 'This is not ok';
}
}

I hope I explained it well

2) yes, it is possible, please check this:
crosstec.org/en/forums/3-breezingforms-f....html?start=0#192715

You can add html in email on this way.

Just add this too:
$isHtml = true;
And then call this in:
$this->sendMail($from, $fromname, $recipient, $subject, $body, $isHtml);
and that is it

Let me know if you need more help

Regards,
Tihana

Please Log in or Create an account to join the conversation.

Last edit: Post by tihana.krivic.
Moderators: ForumSupport
Time to create page: 0.052 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!