Register

Button appearing on condition

Questions regarding the authoring of Viewlets, installation or possible bugs with our products. For urgent issues, please use our support form on our website: http://www.qarbon.com/help/helpme.php
User
User avatar
Posts: 7
Joined: Fri Nov 02, 2012 4:38 pm

Button appearing on condition

Postby Jovana » Tue May 21, 2013 2:06 pm

Hi there,

I'm using VB7 Enterprise and would like to know if there is a way to make a button appear only if the user achieved an overall minimum score on all the quiz questions?

Basically, we want to user to click a button which would launch their email client so they are able to send a pre-populated email to their manager. What we don't want is that user to have the option to send an email to their manager if they haven't achieved a overall minimum score of 70%. So, we'd like to have the button only appear if the user scored 70%.

Is there a way to do this?

Thanks in advance.

User
User avatar
Posts: 50
Joined: Mon May 29, 2006 12:47 am
Location: Dolny Kubin, Slovakia

Re: Button appearing on condition

Postby Michal » Wed May 22, 2013 12:35 am

Hello,

it's not possible to display a button based on user score, but there is a workaround for this, that could be achieved with JavaScript.

You can create two versions of the "last" slide, where the button should be displayed, one with the button and the second without the button. Then after the last question you need to call custom JavaScript method, which will send you to proper slide.

It's an advanced topic of authoring and you need to have at least basic JavaScript knowledge. You can read more info about this topic here:
- viewtopic.php?f=62&t=1406&p=4188&hilit=custom+javascript#p4188
- viewtopic.php?f=37&t=596&p=1906&hilit=custom+javascript#p1906
- http://www.qarbon.com/faqs/viewletbuilder7/ - look for "How do I call ActionScript methods in a Viewlet from JavaScript?"

Best regards,
Michal
Michal

Site Admin
User avatar
Posts: 1072
Joined: Fri May 26, 2006 3:15 pm
Location: San Jose, CA

Re: Button appearing on condition

Postby James » Wed May 22, 2013 3:45 pm

Michal,

Would code like this work?

Code: Select all
if($CURRENT_SCORE$ > 70)
viewletGotoSlide(slideNum);


Where slideNum = x

User
User avatar
Posts: 50
Joined: Mon May 29, 2006 12:47 am
Location: Dolny Kubin, Slovakia

Re: Button appearing on condition

Postby Michal » Thu May 23, 2013 4:36 am

Attached is a working example. The ZIP file includes the a "javascript_sample.qvp" project and "JumpSlide.qframe" HTML frame with the javascript method to jump to correct slide. This sample project asks you, if you'd like to jump to a button slide or no. The "Yes" answer is for "7" points (just something above 5) and "No" is for zero.

The second slide has the button, which links to the http://www.qarbon.com website. The third slide is a simple slide, with just a short message.

The important point is the "Submit" button, which has a javascript call added after the submit action. This javascript has only one line, call to a jumpSlide() method, implemented in the HTML frame.

This is the js method:
Code: Select all
function jumpSlide()
    {
       var fl = document.getElementById("$VIEWLET_NAME$");

       if(fl.viewletGetVariable("CURRENT_SCORE") > 5)
         fl.viewletGotoSlide(2);
       else
         fl.viewletGotoSlide(3);
    }


The "$VIEWLET_NAME$" string is replaced during the viewlet publish and will contain the flash id.
Attachments
js_sample.zip
(26.22 KiB) Downloaded 232 times
Michal

User
User avatar
Posts: 7
Joined: Fri Nov 02, 2012 4:38 pm

Re: Button appearing on condition

Postby Jovana » Fri May 24, 2013 8:29 am

Thanks a lot for your suggestions, guys!

I will be trying these out shortly and will let you know what the outcome is (or if I get stuck)!

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 1 guest