Пример #1
0
def createhollowqsets(questionnaire, qsets=None, highlights=None):

    if qsets == None:
        qsets = ordered_dict()

    rHighlights = None
    qhighlights = None

    if highlights != None:
        if "results" in highlights and runcode in highlights["results"]:
            rHighlights = highlights["results"][runcode]
        if "questions" in highlights:
            qhighlights = highlights["questions"]

    qsets_query = QuestionSet.objects.filter(questionnaire=questionnaire).order_by('sortid')

    for qset in qsets_query:
        if qset.sortid != 0 and qset.sortid != 99:
            question_group = QuestionGroup()
            question_group.sortid = qset.sortid
            question_group.qsid = qset.id

            qsets[qset.text] = question_group

    return qsets
Пример #2
0
def createhollowqsets(questionnaire, qsets=None, highlights=None):

    if qsets == None:
        qsets = ordered_dict()

    rHighlights = None
    qhighlights = None

    if highlights != None:
        if "results" in highlights and runcode in highlights["results"]:
            rHighlights = highlights["results"][runcode]
        if "questions" in highlights:
            qhighlights = highlights["questions"]

    qsets_query = QuestionSet.objects.filter(
        questionnaire=questionnaire).order_by('sortid')

    for qset in qsets_query:
        if qset.sortid != 0 and qset.sortid != 99:
            question_group = QuestionGroup()
            question_group.sortid = qset.sortid
            question_group.qsid = qset.id

            qsets[qset.text] = question_group

    return qsets
Пример #3
0
def createqset(runcode, qsid, qsets=None, clean=True, highlights=None):
    qsid = int(qsid)
    #print "Got into createqset!!" + str(qsid)

    try:
        fingerprint = Fingerprint.objects.get(fingerprint_hash=runcode)

        if qsets == None:
            qsets = ordered_dict()

        rHighlights = None
        qhighlights = None

        if highlights != None:
            if "results" in highlights and runcode in highlights["results"]:
                rHighlights = highlights["results"][runcode]
            if "questions" in highlights:
                qhighlights = highlights["questions"]

        fingerprint_ttype = fingerprint.questionnaire.pk

        db_owners = fingerprint.unique_users_string()

        try:
            qset = QuestionSet.objects.get(
                questionnaire=fingerprint.questionnaire, sortid=qsid)
            answers = Answer.objects.filter(fingerprint_id=fingerprint)

            (qsets, name) = handle_qset(fingerprint, clean, qsets, qset,
                                        answers, fingerprint_ttype,
                                        rHighlights, qhighlights)

        except QuestionSet.DoesNotExist:
            print "-- Error: The questionset you want does not exist"
        except QuestionSet.MultipleObjectsReturned:
            print "-- Error: Multiple objects returned, sortid ar supposed to be unique"

        return (qsets, name, db_owners, fingerprint_ttype)

    except Fingerprint.DoesNotExist:
        print "-- Error on createqset: Fingerprint " + str(
            runcode) + " does not exist"

    # Something is really wrong if it gets here
    return HttpResponse('Something is wrong on creating qset ' + qsid, 500)
Пример #4
0
def createqsets(runcode, qsets=None, clean=True, highlights=None, getAnswers=True,
    choosenqsets=None, fullmode=True, noprocessing=False, changeSearch=False):
    try:
        if fullmode:
            fingerprint = Fingerprint.objects.get(fingerprint_hash=runcode)
        else:
            fingerprint = runcode

        if qsets == None:
            qsets = ordered_dict()

        rHighlights = None
        qhighlights = None

        if highlights != None:
            if "results" in highlights and runcode in highlights["results"]:
                rHighlights = highlights["results"][runcode]
            if "questions" in highlights:
                qhighlights = highlights["questions"]

        fingerprint_ttype = fingerprint.questionnaire.pk

        db_owners = fingerprint.unique_users_string()

        qsets_query = None
        if choosenqsets != None:
            qsets_query = choosenqsets
        else:
            qsets_query = QuestionSet.objects.filter(questionnaire=fingerprint.questionnaire).order_by('sortid')

        answers = Answer.objects.filter(fingerprint_id=fingerprint)
        name = None
        for qset in qsets_query:
            if qset.sortid != 0 and qset.sortid != 99:
                (qsets, name) = handle_qset(fingerprint, clean, qsets, qset, answers, fingerprint_ttype, rHighlights, qhighlights, getAnswers, noprocessing=noprocessing, changeSearch=changeSearch)

        return (qsets, name, db_owners, fingerprint_ttype)

    except Fingerprint.DoesNotExist:
        print "-- Error on createqset: Fingerprint "+str(runcode)+" does not exist"

    # Something is really wrong if it gets here
    return HttpResponse('Something is wrong on creating qsets', 500)
Пример #5
0
def createqset(runcode, qsid, qsets=None, clean=True, highlights=None):
    qsid = int(qsid)
    #print "Got into createqset!!" + str(qsid)

    try:
        fingerprint = Fingerprint.objects.get(fingerprint_hash=runcode)

        if qsets == None:
            qsets = ordered_dict()

        rHighlights = None
        qhighlights = None

        if highlights != None:
            if "results" in highlights and runcode in highlights["results"]:
                rHighlights = highlights["results"][runcode]
            if "questions" in highlights:
                qhighlights = highlights["questions"]

        fingerprint_ttype = fingerprint.questionnaire.pk

        db_owners = fingerprint.unique_users_string()

        try:
            qset = QuestionSet.objects.get(questionnaire=fingerprint.questionnaire, sortid=qsid)
            answers = Answer.objects.filter(fingerprint_id=fingerprint)

            (qsets, name) = handle_qset(fingerprint, clean, qsets, qset, answers, fingerprint_ttype, rHighlights, qhighlights)

        except QuestionSet.DoesNotExist:
            print "-- Error: The questionset you want does not exist"
        except QuestionSet.MultipleObjectsReturned:
            print "-- Error: Multiple objects returned, sortid ar supposed to be unique"

        return (qsets, name, db_owners, fingerprint_ttype)

    except Fingerprint.DoesNotExist:
        print "-- Error on createqset: Fingerprint "+str(runcode)+" does not exist"


    # Something is really wrong if it gets here
    return HttpResponse('Something is wrong on creating qset '+qsid, 500)
Пример #6
0
def createqsets(runcode,
                qsets=None,
                clean=True,
                highlights=None,
                getAnswers=True,
                choosenqsets=None,
                fullmode=True,
                noprocessing=False,
                changeSearch=False):
    try:
        if fullmode:
            fingerprint = Fingerprint.objects.get(fingerprint_hash=runcode)
        else:
            fingerprint = runcode

        if qsets == None:
            qsets = ordered_dict()

        rHighlights = None
        qhighlights = None

        if highlights != None:
            if "results" in highlights and runcode in highlights["results"]:
                rHighlights = highlights["results"][runcode]
            if "questions" in highlights:
                qhighlights = highlights["questions"]

        fingerprint_ttype = fingerprint.questionnaire.pk

        db_owners = fingerprint.unique_users_string()

        qsets_query = None
        if choosenqsets != None:
            qsets_query = choosenqsets
        else:
            qsets_query = QuestionSet.objects.filter(
                questionnaire=fingerprint.questionnaire).order_by('sortid')

        answers = Answer.objects.filter(fingerprint_id=fingerprint)
        name = None
        for qset in qsets_query:
            if qset.sortid != 0 and qset.sortid != 99:
                (qsets, name) = handle_qset(fingerprint,
                                            clean,
                                            qsets,
                                            qset,
                                            answers,
                                            fingerprint_ttype,
                                            rHighlights,
                                            qhighlights,
                                            getAnswers,
                                            noprocessing=noprocessing,
                                            changeSearch=changeSearch)

        return (qsets, name, db_owners, fingerprint_ttype)

    except Fingerprint.DoesNotExist:
        print "-- Error on createqset: Fingerprint " + str(
            runcode) + " does not exist"

    # Something is really wrong if it gets here
    return HttpResponse('Something is wrong on creating qsets', 500)