cloudyr / MTurkR

R Client for the MTurk Requester API
https://cloud.r-project.org/package=MTurkR
91 stars 18 forks source link

Mturk Randomization Issue #116

Closed christianzihlmann closed 7 years ago

christianzihlmann commented 8 years ago

Dear Thomas, We want to conduct a behavioral experiment at the University of Switzerland. To do so, we applied your randomization code (external survey link) and tested it on Mturk Sandbox. In preview mode, the code seems to work. However, as soon as our sandbox worker clicks on "Accept HIT", no Hyperlink with the survey link appears. Is this due to sandbox or what have we done wrong? We very appreciate your help.


<!-- For help on using this template, see the blog post: https://blog.mturk.com/editing-the-survey-link-project-template-in-the-ui-7c75285105fb#.py7towsdx --><!-- HIT template: SurveyLink-v3.0 --><!-- The following snippet enables the 'responsive' behavior on smaller screens -->
<meta content="width=device-width,initial-scale=1" name="viewport" />
<section class="container" id="SurveyLink"><!-- Instructions -->
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="panel panel-primary"><!-- WARNING: the ids "collapseTrigger" and "instructionBody" are being used to enable expand/collapse feature --><a class="panel-heading" href="javascript:void(0);" id="collapseTrigger"><strong>Instructions</strong> <span class="collapse-text">(Click to expand)</span> </a>
<div class="panel-body" id="instructionBody">
<p>Instructions:<br />
&bull; Copy text exactly as it appears in the scanned image into the respective answer fields.&nbsp;<br />
</p>
<h5><strong>Make sure to leave this window open as you complete the survey. When you are finished, you will return to this page to paste the code into the box.</strong></h5>
</div>
</div>
</div>
</div>
</section>

<script type="text/javascript">
/* DEFINE FUNCTION TO EXTRACT PARAMETERS FROM URL */
function turkGetParam( name ) { 
  var regexS = "[\?&]"+name+"=([^&#]*)"; 
  var regex = new RegExp( regexS ); 
  var tmpURL = fullurl; 
  var results = regex.exec( tmpURL ); 
  if( results == null ) { 
    return ""; 
  } else { 
    return results[1];    
  } 
}

/* THIS IS THE LINE TO CAPTURE THE ACTUAL URL: */
var fullurl = window.location.href;

/* ASSIGNS THE URL PARAMETERS TO JAVASCRIPT VARIABLES */
var assign = turkGetParam('assignmentId');
var hit = turkGetParam('hitId');
var worker = turkGetParam('workerId');

/* WHAT TO DO IF THE WORKER IS PREVIEWING THE HIT: */
if(assign=="ASSIGNMENT_ID_NOT_AVAILABLE")
    {
    document.write("<p style='font-weight:bold;text-align:center;'>Link will become available once you accept the HIT.</p>");
    }
else {
/* THE BELOW RANDOMIZES INTO A TREATMENT CONDITION */
/* DEPENDING ON THE EXPERIMENT THE "rtext[i]" RANDOMIZATION COULD BE USED TO DO MULTIPLE THINGS */
var rtext = new Array ();
/* THE NUMBER OF VALUES HERE DEPENDS ON NUMBER OF CONDITIONS */
rtext[0] = "BW889K5";
rtext[1] = "BWBB53B";
rtext[2] = "BW2KYFK";
/* THE MULTIPLIER WILL DEPEND ON THE NUMBER OF CONDITIONS */
var i = Math.floor(3*Math.random());
/* RECORDS THE RANDOMIZATION IN A HIDDEN FORM FIELD */
document.getElementById("random").value = rtext[i];
/* DISPLAY RANDOMIZED LINK */
var surveylink = new String("https://www.surveymonkey.de/r/" + rtext[i]);
document.write("<a href=\"" + surveylink + "\">Complete this task</a><br/>");
}
</script>

<div class="row" id="workContent">
<div class="col-xs-12 col-md-6 col-md-offset-3"><!-- End Content for Worker --><!-- Input from Worker -->
<div class="form-group"><label for="surveycode">Provide the completion code here:</label> <input class="form-control" id="surveycode" name="surveycode" placeholder="e.g. 123456" required="" type="text" /></div>
<!-- End input from Worker --></div>
</div>
<!-- End Survey Link Layout --><!-- Please note that Bootstrap CSS/JS and JQuery are 3rd party libraries that may update their url/code at any time. Amazon Mechanical Turk (MTurk) is including these libraries as a default option for you, but is not responsible for any changes to the external libraries --><!-- External CSS references -->
<link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" integrity="sha384-IS73LIqjtYesmURkDE9MXKbXqYA8rvKEp/ghicjem7Vc3mGRdQRptJSz60tvrB6+" rel="stylesheet" /><!-- Open internal style sheet -->
<style type="text/css">#collapseTrigger{
  color:#fff;
  display: block;
  text-decoration: none;
}
#submitButton{
  white-space: normal;
}
.image{
  margin-bottom: 15px; 
}
/* CSS for breaking long words/urls */
.dont-break-out {
  overflow-wrap: break-word;
  word-wrap: break-word;
  -ms-word-break: break-all;
  word-break: break-all;
  word-break: break-word;
  -ms-hyphens: auto;
  -moz-hyphens: auto;
  -webkit-hyphens: auto;
  hyphens: auto;
}
</style>
<!-- Close internal style sheet --><!-- External JS references --><script src="https://code.jquery.com/jquery-3.1.0.min.js"   integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s="   crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" integrity="sha384-s1ITto93iSMDxlp/79qhWHi+LsIi9Gx6yL+cOKDuymvihkfol83TYbLbOw+W/wv4" crossorigin="anonymous"></script><!-- Open internal javascript --><script>
  $(document).ready(function() {
    // Instructions expand/collapse
    var content = $('#instructionBody');
    var trigger = $('#collapseTrigger');
    content.hide();
    $('.collapse-text').text('(Click to expand)');
    trigger.click(function(){
      content.toggle();
      var isVisible = content.is(':visible');
      if(isVisible){
        $('.collapse-text').text('(Click to collapse)');
      }else{
        $('.collapse-text').text('(Click to expand)');
      }
    });
    // end expand/collapse
  });
</script><!-- Close internal javascript -->
leeper commented 8 years ago

Does it display "Link will become available once you accept the HIT." or nothing at all?

christianzihlmann commented 8 years ago

Dear Thomas, It does display that in preview mode, and then nothing at all after the worker clicks on Accept HIT.

On 05 Oct 2016, at 09:43, Thomas J. Leeper notifications@github.com wrote:

Does it display "Link will become available once you accept the HIT." or nothing at all?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

leeper commented 7 years ago

Hey, sorry. I lost track of this. Did you ever get it figured out?

eskrav commented 6 years ago

Hi,

I have the exact same problem. Is there any solution to this?