Пример #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)
Пример #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)
Пример #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))
Пример #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))
Пример #5
0
def complete(request, gid=""):
    s = get_object_or_404(Spectators, study=gid)

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

    participantLogout(request.user, gid)
    return render_to_response("research-complete.html", 
                              {"gid":gid, "sid":s.pid},
                              context_instance=RequestContext(request))
Пример #6
0
def landing(request, gid="", err=0):
    if getParticipantByUID(request.user.pk, gid) is not None:
        return HttpResponseRedirect(urlHome(gid))

    try:
        s = Spectators.objects.get(study=gid)
    except Spectators.DoesNotExist:
        return HttpResponse(status=404)
    return render_to_response("research-landing.html", 
                              {"gid":gid,"sid":s.pid,"err":err},
                              context_instance=RequestContext(request))
Пример #7
0
def complete(request, gid=""):
    s = get_object_or_404(Spectators, study=gid)

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

    participantLogout(request.user, gid)
    return render_to_response("research-complete.html", {
        "gid": gid,
        "sid": s.pid
    },
                              context_instance=RequestContext(request))
Пример #8
0
def landing(request, gid="", err=0):
    if getParticipantByUID(request.user.pk, gid) is not None:
        return HttpResponseRedirect(urlHome(gid))

    try:
        s = Spectators.objects.get(study=gid)
    except Spectators.DoesNotExist:
        return HttpResponse(status=404)
    return render_to_response("research-landing.html", {
        "gid": gid,
        "sid": s.pid,
        "err": err
    },
                              context_instance=RequestContext(request))
Пример #9
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))
Пример #10
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))