Ejemplo n.º 1
0
def insert_question(src, q_info):
    q_idx, i_idx, order, txt = q_info
    try:
        q = Question.objects.get(source=src, order=order)
    except Question.DoesNotExist:
        q = Question(source=src, order=order)
    q.text = txt
    q.save()

    for i in range(0, 7):
        try:
            opt = Option.objects.get(question=q, order=i)
        except Option.DoesNotExist:
            opt = Option(question=q, order=i)
        opt.name = OPTION_NAMES[i]
        opt.save()
Ejemplo n.º 2
0
def insert_question(src, q_info):
    q_idx, i_idx, order, txt = q_info
    try:
        q = Question.objects.get(source=src, order=order)
    except Question.DoesNotExist:
        q = Question(source=src, order=order)
    q.text = txt
    q.save()

    for i in range(0, 7):
        try:
            opt = Option.objects.get(question=q, order=i)
        except Option.DoesNotExist:
            opt = Option(question=q, order=i)
        opt.name = OPTION_NAMES[i]
	opt.save()
Ejemplo n.º 3
0
def add_question(src, qtext, q_idx, atext_list):
    if q_idx in SKIP_QUESTIONS:
        return
    try:
        q = Question.objects.get(source=src, order=q_idx)
    except Question.DoesNotExist:
        q = Question(source=src, order=q_idx)
    q.text = qtext
    q.save()

    for idx, atext in enumerate(atext_list):
        try:
            opt = Option.objects.get(question=q, order=idx)
        except Option.DoesNotExist:
            opt = Option(question=q, order=idx)
        opt.name = atext
        opt.save()
Ejemplo n.º 4
0
def add_question(src, qtext, q_idx, atext_list):
    if q_idx in SKIP_QUESTIONS:
        return
    try:
        q = Question.objects.get(source=src, order=q_idx)
    except Question.DoesNotExist:
        q = Question(source=src, order=q_idx)
    q.text = qtext
    q.save()

    for idx, atext in enumerate(atext_list):
        try:
            opt = Option.objects.get(question=q, order=idx)
        except Option.DoesNotExist:
            opt = Option(question=q, order=idx)
        opt.name = atext
        opt.save()
Ejemplo n.º 5
0
def add_question(src, qtext, q_idx, atext_list):
    if not q_idx in q_dict:
        try:
            q = Question.objects.get(source=src, order=q_idx)
            assert q.text == qtext
        except Question.DoesNotExist:
            q = Question(source=src, order=q_idx)
        q.text = qtext
        q.save()
        q.opt_dict = {}
        q_dict[q_idx] = q
    else:
        q = q_dict[q_idx]
        assert q.text == qtext

    for idx, atext in enumerate(atext_list):
        if not idx in q.opt_dict:
            try:
                opt = Option.objects.get(question=q, order=idx)
                assert opt.name == atext
            except Option.DoesNotExist:
                opt = Option(question=q, order=idx)
            opt.name = atext
            opt.save()
            q.opt_dict[idx] = opt
        else:
            assert q.opt_dict[idx].name == atext
    return q
Ejemplo n.º 6
0
def add_question(src, qtext, q_idx, atext_list):
    if not q_idx in q_dict:
        try:
            q = Question.objects.get(source=src, order=q_idx)
            assert q.text == qtext
        except Question.DoesNotExist:
            q = Question(source=src, order=q_idx)
        q.text = qtext
        q.save()
        q.opt_dict = {}
        q_dict[q_idx] = q
    else:
        q = q_dict[q_idx]
        assert q.text == qtext

    for idx, atext in enumerate(atext_list):
        if not idx in q.opt_dict:
            try:
                opt = Option.objects.get(question=q, order=idx)
                assert opt.name == atext
            except Option.DoesNotExist:
                opt = Option(question=q, order=idx)
            opt.name = atext
            opt.save()
            q.opt_dict[idx] = opt
        else:
            assert q.opt_dict[idx].name == atext
    return q