示例#1
0
def portal(request):
    # Mturk
    p = None
    records = get_worker(request)
    if records:
        verified = check_records(records, "portal", noRedirect=True)
        if "redirect" in verified:
            return verified["redirect"]
        else:
            p = verified["participant"]

    hitId = request.GET.get(u"hitId")
    assignmentId = request.GET.get(u"assignmentId")
    workerId = request.GET.get(u"workerId")
    turkSubmitTo = request.GET.get(u"turkSubmitTo")
    if bool(hitId and assignmentId and workerId):
        if not p:
            p = Participant.create(
                group="mturk", hitId=hitId, assignmentId=assignmentId, workerId=workerId, turkSubmitTo=turkSubmitTo
            )
            p.save()
            request.session["part_num"] = p.id
        return render(request, "mturk_form.html", {"p": p})
    else:
        context = curb(Experiment.mturk())
        context["disabled"] = True
        return render(request, "portal.html", context)
示例#2
0
def basic(request):
    parts = []
    for i in range(3):
        p = Participant()
        p.save()
        parts.append(p)
    request.session["part_num"] = parts[0].pk

    exp = Experiment(time_limit=30)
    exp.save()
    treat = exp.new_treatment(parts)
    turn = parts[0].turn
    context = {}
    for i, p in enumerate(parts):
        context["context" + str(i)] = p.diagram_context
        context["form" + str(i)] = p.form_context
    return render(request, "main.html", context)
示例#3
0
def coop(request):
    now = datetime.utcnow().replace(tzinfo=utc)
    p = Participant(group="coop", started=now)
    p.save()
    request.session["part_num"] = p.id
    return render(request, "coop.html", curb(Experiment.coop()))