You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MTurk技术问询:使用外部调查链接创建项目时,如何仅在接受HIT后显示链接?

解决MTurk HIT接受后才显示外部调查链接的问题

Got it, I totally get what you're aiming for here—you want the external survey link to only show up after a Worker accepts your HIT, right? No one should be able to jump straight to the survey without committing to the task first.

It sounds like you tried Crowd HTML Elements but didn't get it working, which is super common if you're not leveraging the right state checks or component events. Let's walk through a couple reliable solutions that should do the trick:

方案1:利用MTurk全局turk对象做条件渲染

MTurk自动在HIT页面注入一个全局turk对象,其中的assignmentId字段可以判断Worker是否已接受HIT:

  • 当Worker还没接受时,assignmentId的值是ASSIGNMENT_ID_NOT_AVAILABLE
  • 接受后,这个值会变成一个有效的唯一分配ID

你可以用这个逻辑来控制链接的显示/隐藏:

<script>
  // 页面加载完成后检查状态
  document.addEventListener('DOMContentLoaded', function() {
    const surveyContainer = document.getElementById('survey-link');
    const prompt = document.getElementById('accept-prompt');

    if (turk.assignmentId !== 'ASSIGNMENT_ID_NOT_AVAILABLE') {
      // 已接受HIT,显示链接
      surveyContainer.style.display = 'block';
      prompt.style.display = 'none';
    } else {
      // 未接受,显示提示
      surveyContainer.style.display = 'none';
      prompt.style.display = 'block';
    }
  });
</script>

<div id="accept-prompt" style="padding: 1rem; border: 1px solid #ccc; border-radius: 4px;">
  请先接受此HIT,才能获取调查链接哦。
</div>
<div id="survey-link" style="display: none; margin-top: 1rem;">
  <p>请点击下方链接完成调查:</p>
  <a href="https://your-survey-url-here.com" target="_blank" style="color: #0066c0;">前往外部调查</a>
</div>

方案2:使用Crowd HTML Elements的crowd-assignment组件监听状态变化

如果你更倾向于用官方的Crowd组件,可以用crowd-assignment来监听HIT分配状态的变化,适合动态场景(比如Worker接受后实时显示链接):

<crowd-assignment id="assignment-tracker"></crowd-assignment>

<script>
  const assignmentTracker = document.getElementById('assignment-tracker');
  const surveyContainer = document.getElementById('survey-link');
  const prompt = document.getElementById('accept-prompt');

  // 监听分配状态变更事件
  assignmentTracker.addEventListener('assignmentChange', (event) => {
    if (event.detail.assignmentId !== 'ASSIGNMENT_ID_NOT_AVAILABLE') {
      surveyContainer.style.display = 'block';
      prompt.style.display = 'none';
    } else {
      surveyContainer.style.display = 'none';
      prompt.style.display = 'block';
    }
  });
</script>

<div id="accept-prompt" style="padding: 1rem; border: 1px solid #ccc; border-radius: 4px;">
  请先接受此HIT,才能获取调查链接哦。
</div>
<div id="survey-link" style="display: none; margin-top: 1rem;">
  <p>请点击下方链接完成调查:</p>
  <a href="https://your-survey-url-here.com" target="_blank" style="color: #0066c0;">前往外部调查</a>
</div>

重要注意事项

  • 不要用MTurk默认的「External Survey Link」字段:那个字段会在HIT预览时直接显示链接,完全绕过你的控制逻辑。把链接放在自定义HTML里即可。
  • 测试方法:使用MTurk的「Worker Preview」模式,点击「Accept HIT」就能验证链接是否正常显示。
  • 完成流程提示:记得在调查末尾提醒Worker回到MTurk页面提交HIT,或者在HTML里添加crowd-form组件的提交按钮,确保Worker能正确完成任务并获取报酬。

内容的提问来源于stack exchange,提问作者user3821012

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:37:16