In the previous post, we’ve covered the .NET application that connects to Confirmit APIs and closes a project.
Let’s see now what we need to do in order to actually call it from a Confirmit survey.
Since the topic is close a project when the quota is reached, we’ll first need a condition node, with a quota check qf(‘quota1’)
In the “then” branch, you continue to use your own scripts, set the respondent status SetStatus(‘quotafull’) and everything else you may have, but not do the redirect yet (if you’re using one)
Add an info question type with the following content. You can use the instruction area as well.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script type="text/javascript" src="http://jquery-jsonp.googlecode.com/files/jquery.jsonp-2.1.4.min.js"></script> <script> //hide navigationarea(s) $(function() { $('.navigationarea').hide(); }); function callback(data){ //if(typeof data.status!="undefined") //you can use the data.status here //show navigationarea back... $('.navigationarea').show(); //or redirect them to whatever URL you need } $.jsonp({url: "http://your domain to Confirmit Close Project/?projectID=^ProjectID()^",complete: function(data) {}}); </script>
As you can see the only parameter we send is the project ID.
There could be more to add, like showing a div with a message “Please wait!” or an ajax loading gif etc
For a better understanding on how everything works, as soon as the quota is reached, the first respondent who gets in the condition qf(‘quota1’), true now, will trigger the call to the .NET app that closes the study.
After this, it doesn’t mater how many respondents are currently on the link, no one else will made it to the end (of survey). If clicking on the “next” button, the system will answer with the standard message, “Sorry, but this survey has been closed.”
Check an older post, and find out how can you customize it for this particular study (you can also have a redirect right from the theme)