-
Notifications
You must be signed in to change notification settings - Fork 17
Soft Block Javascript
Sometimes it is helpful to prevent workers from seeing particular contents of a HIT until after they accept it (e.g., a link to an off-site survey) as well as preventing workers from completing a HIT if you have (for whatever reason) deemed them ineligible. Qualifications (possibly with a Qualification Test) are the best ways to handle this. But, you can also "soft block" workers using javascript. This way, if they accept the HIT, they are prevented from completing it.
Note that this can backfire because workers have to return the HIT, which negatively affects one of their worker statistics. A better strategy is always to use qualifications. But, if your HIT properly describes that this "soft block" is in place and provides a way for workers to check whether they are eligible, this mechanism is relatively easy to setup and relatively painless from a worker perspective.
Here's some example code:
<script type="text/javascript">
// RETRIEVE URL
var fullurl=new String();
// THIS IS THE LINE TO CAPTURE THE ACTUAL URL:
var fullurl=document.location.href;
// FIND workerId IN THE URL PARAMETERS
var bits = new Array();
bits = fullurl.split("&");
var finalbit = new Array();
finalbit = bits[2].split("=");
// WHAT TO DO IF THE WORKER IS PREVIEWING THE HIT
if(finalbit[1]=="ASSIGNMENT_ID_NOT_AVAILABLE")
{
document.write("<p style='font-weight:bold;text-align:center;'>Link will become available once you accept the HIT.</p>");
}
// CHECK workerId AGAINST THE LIST OF INELIGIBLE WORKERS
else if (finalbit[1]=="A23JA6ICO4BPQ5" ||
finalbit[1]=="A3DTS2LSSZGK5W" ||
finalbit[1]=="A3JMPI8HZATQ4Q" ||
finalbit[1]=="AFIIFNK4FM7MZ"
)
{
document.write("<b>You have already completed this survey and are therefore ineligible to complete it again. Sorry.</b>");
}
// IF NOT IN THE ABOVE LIST AND NOT PREVIEWING, DISPLAY LINK
// COULD BE RECONFIGURED TO DO SOMETHING ELSE, BUT THIS IS A SIMPLE EXAMPLE
else {
var surveylink = new String("https://www.text.com/survey");
document.write("<a href=\"" + surveylink + "\" target=\"_blank\">Click here to complete the survey</a><br />");
}
</script>.