実際にはケーキです。あなたがする必要があるのは、質問XMLファイルをループの中に作成し、その質問からヒットを作成することです。以下の例では、手作業で質問xmlを作成し、それがサンドボックスで機能していることを確認しました。私は質問をxmlファイルを部分a、b、cに分割して、変更しなかった部分に分割してから、私のループでxmlコードをテキストファイルに書き込みます。
- parta
- 質問の一部質問のこの場合の変更、画像
- partb 一部、この場合の変更、複数の選択肢
- がpartc
こと進歩の終わりに、私は開いて作成ヒットで使用する有効なXMLファイルを持っています。今私はこの質問が資格に関するものであることを知っていますが、アイデアはまったく同じです。
`` `
for hit_number in range(how_many):
print(hit_number)
my_emotions = sample(emotion_names,5)
my_emoji = sample(emoji_numbers,1)
HIT_image = <a url on S3 is convenient>
f_out = open('data/dynamic_question.xml', 'w')
f_out.write(parta)
f_out.close()
f_out = open('data/dynamic_question.xml', 'a')
f_out.write(' <DataURL>' + HIT_image + '</DataURL>' + '\n')
f_out.write(partb)
for emotion in my_emotions:
f_out.write(' <Selection>' + '\n')
f_out.write(' <SelectionIdentifier>' + emotion + '</SelectionIdentifier>' + '\n')
f_out.write(' <Text>' + emotion.capitalize() + '</Text>' + '\n')
f_out.write(' </Selection>' + '\n')
f_out.write(partc)
f_out.close()
with open("data/dynamic_question.xml") as f:
question = f.read()
# Create the HIT
response = client.create_hit(
` ``