Exemplo n.º 1
0
def handle_pid(request, gid="", pid=""):
    s = get_object_or_404(Studies, graph=gid)

    # check that the pid is valid
    p = getParticipantByPID(pid, gid)

    if p is None:
        return HttpResponseRedirect(urlLanding(gid, '1'))

    # a participant may use the tool from multiple browsers
    u, created = User.objects.get_or_create(pk=request.user.pk)

    # remember the participant's lazy signup id to rebuild progress
    Logins.objects.get_or_create(participant=p, user=u, study=s)

    # redirect to pre- or post-survey, as appropriate
    redirect = handleSurveys(p, gid)

    if redirect is None:
        if s.complete and p.isParticipant():
            redirect = urlComplete(gid)
        else:
            redirect = urlHome(gid)

    return HttpResponseRedirect(redirect)
Exemplo n.º 2
0
def handle_pid(request, gid="", pid=""):
    s = get_object_or_404(Studies, graph=gid)

     # check that the pid is valid
    p = getParticipantByPID(pid, gid)

    if p is None:
        return HttpResponseRedirect(urlLanding(gid, '1'))

    # a participant may use the tool from multiple browsers
    u, created = User.objects.get_or_create(pk=request.user.pk)

    # remember the participant's lazy signup id to rebuild progress
    Logins.objects.get_or_create(participant=p, user=u, study=s)

    # redirect to pre- or post-survey, as appropriate
    redirect = handleSurveys(p, gid)

    if redirect is None:
        if s.complete and p.isParticipant():
            redirect = urlComplete(gid)
        else:
            redirect = urlHome(gid)

    return HttpResponseRedirect(redirect)
Exemplo n.º 3
0
def postsurvey(request, gid=""):
    s = get_object_or_404(Studies, graph=gid)

    if not s.complete:
        return HttpResponseRedirect(urlHome(gid))

    p = getParticipantByUID(request.user.pk, gid)

    if p is None:
        return HttpResponseRedirect(urlLanding(gid))

    p.postsurvey = True
    p.save()

    return HttpResponseRedirect(urlComplete(gid))
Exemplo n.º 4
0
def postsurvey(request, gid=""):
    s = get_object_or_404(Studies, graph=gid)

    if not s.complete:
        return HttpResponseRedirect(urlHome(gid))

    p = getParticipantByUID(request.user.pk, gid)

    if p is None:
        return HttpResponseRedirect(urlLanding(gid))

    p.postsurvey = True
    p.save()

    return HttpResponseRedirect(urlComplete(gid))