예제 #1
0
def list_all_questions(request):
    batch_id = request.GET.get('id', None)
    batch = Batch.get(pk=batch_id)
    # if request.is_ajax():
    json_dump = json.dumps(
        [{'id': q.id, 'identifier': q.identifier}
            for q in batch.all_questions], cls=DjangoJSONEncoder)
    return HttpResponse(json_dump, content_type='application/json')
예제 #2
0
def update_parameter_list(batch_question):
    # check if this group has been previously assigned to this Question set.
    from survey.models import Batch
    if batch_question.group and RespondentGroup.objects.filter(
            questions__qset__id=batch_question.qset.id,
            id=batch_question.group.id).exists():
        SurveyParameterList.update_parameter_list(
            Batch.get(pk=batch_question.qset.pk))
예제 #3
0
def update_parameter_list(batch_question):
    # check if this group has been previously assigned to this Question set.
    from survey.models import Batch
    if batch_question.group and RespondentGroup.objects.filter(
            questions__qset__id=batch_question.qset.id,
            id=batch_question.group.id).exists():
        SurveyParameterList.update_parameter_list(
            Batch.get(pk=batch_question.qset.pk))
예제 #4
0
def delete(request, survey_id, batch_id):
    try:
        batch = Batch.get(id=batch_id)
        QuestionSetView(model_class=Batch).delete(request, batch)
    except Exception as e:
        messages.warning(request, str(e))
    return HttpResponseRedirect(
        reverse('batch_index_page', args=(batch.survey.id, )))
예제 #5
0
def list_all_questions(request):
    batch_id = request.GET.get('id', None)
    batch = Batch.get(pk=batch_id)
    # if request.is_ajax():
    json_dump = json.dumps([{
        'id': q.id,
        'identifier': q.identifier
    } for q in batch.all_questions],
                           cls=DjangoJSONEncoder)
    return HttpResponse(json_dump, content_type='application/json')
예제 #6
0
def delete(request, survey_id, batch_id):
    try:
        batch = Batch.get(id=batch_id)
        QuestionSetView(model_class=Batch).delete(request, batch)
    except Exception as e:
        messages.warning(request, str(e))
    return HttpResponseRedirect(
        reverse(
            'batch_index_page',
            args=(
                batch.survey.id,
            )))
예제 #7
0
def list_batch_questions(request):
    batch_id = request.GET.get('id', None)
    batch = Batch.get(pk=batch_id)
    if request.is_ajax():
        json_dump = json.dumps([{
            'id': q.id,
            'identifier': q.identifier
        } for q in batch.flow_questions],
                               cls=DjangoJSONEncoder)
        return HttpResponse(json_dump, content_type='application/json')
    return HttpResponseRedirect(
        reverse('batch_index_page', args=(batch.survey.pk, )))
예제 #8
0
 def _get_name_references(qset):
     name_references = {}
     for question in qset.questions.all():
         name_references[question.identifier] = mark_safe('<output value="%s"/>' % get_node_path(question))
     try:
         qset = Batch.get(pk=qset.pk)
         if hasattr(qset, 'parameter_list'):
             for question in qset.parameter_list.questions.all():
                 name_references[question.identifier] = \
                     mark_safe('<output value="%s"/>' % get_group_question_path(qset, question))
     except Batch.DoesNotExist:
         pass
     return name_references
예제 #9
0
def list_batch_questions(request):
    batch_id = request.GET.get('id', None)
    batch = Batch.get(pk=batch_id)
    if request.is_ajax():
        json_dump = json.dumps(
            [{'id': q.id, 'identifier': q.identifier}
                for q in batch.flow_questions], cls=DjangoJSONEncoder)
        return HttpResponse(json_dump, content_type='application/json')
    return HttpResponseRedirect(
        reverse(
            'batch_index_page',
            args=(
                batch.survey.pk,
            )))
예제 #10
0
def edit(request, batch_id):
    batch = Batch.get(pk=batch_id)
    survey = batch.survey
    qset_view = QuestionSetView(model_class=Batch)
    qset_view.questionSetForm = BatchForm
    breadcrumbs = Batch.edit_breadcrumbs(survey=survey)
    cancel_url = '../'
    if breadcrumbs:
        request.breadcrumbs(breadcrumbs)
        cancel_url = breadcrumbs[-1][1]
    response = qset_view.edit(request,
                              batch,
                              extra_context={'cancel_url': cancel_url},
                              initial={'survey': survey.pk})
    if response.status_code == 302:
        response = HttpResponseRedirect(
            reverse('batch_index_page', args=(survey.pk, )))
    return response
예제 #11
0
def edit(request, batch_id):
    batch = Batch.get(pk=batch_id)
    survey = batch.survey
    qset_view = QuestionSetView(model_class=Batch)
    qset_view.questionSetForm = BatchForm
    breadcrumbs = Batch.edit_breadcrumbs(survey=survey)
    cancel_url = '../'
    if breadcrumbs:
        request.breadcrumbs(breadcrumbs)
        cancel_url = breadcrumbs[-1][1]
    response = qset_view.edit(
        request, batch, extra_context={
            'cancel_url': cancel_url}, initial={
            'survey': survey.pk})
    if response.status_code == 302:
        response = HttpResponseRedirect(
            reverse('batch_index_page', args=(survey.pk, )))
    return response