Beispiel #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)
Beispiel #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)
Beispiel #3
0
def presurvey(request, gid=""):
    p = getParticipantByUID(request.user.pk, gid)

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

    p.presurvey = True
    p.save()

    return HttpResponseRedirect(urlHome(gid))
Beispiel #4
0
def presurvey(request, gid=""):
    p = getParticipantByUID(request.user.pk, gid)

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

    p.presurvey = True
    p.save()

    return HttpResponseRedirect(urlHome(gid))
Beispiel #5
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))
Beispiel #6
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))
Beispiel #7
0
def logout(request, gid=""):
    participantLogout(request.user, gid)
    return HttpResponseRedirect(urlLanding(gid))
Beispiel #8
0
def logout(request, gid=""):
    participantLogout(request.user, gid)
    return HttpResponseRedirect(urlLanding(gid))