Exemple #1
0
def questionnaire(request, project_id):
    manager = get_database_manager(request.user)
    if request.method == 'GET':
        questionnaire = Project.get(manager, project_id)
        if questionnaire.is_void():
            return HttpResponseRedirect(settings.HOME_PAGE + "?deleted=true")
        fields = questionnaire.fields
        existing_questions = json.dumps(fields, default=field_to_json)
        project_links = make_project_links(questionnaire)
        success, error = submission_stats(manager, questionnaire.form_code)
        project_has_submissions = (success + error > 0)
        in_trial_mode = _in_trial_mode(request)
        is_success = False
        active_language = request.LANGUAGE_CODE
        if "success" in [m.message for m in messages.get_messages(request)]:
            is_success = True
        return render_to_response(
            'project/questionnaire.html', {
                "existing_questions": repr(existing_questions),
                'questionnaire_code': questionnaire.form_code,
                'project': questionnaire,
                'project_has_submissions': project_has_submissions,
                'project_links': project_links,
                'is_quota_reached': is_quota_reached(request),
                'in_trial_mode': in_trial_mode,
                'is_success': is_success,
                'active_language': active_language,
                'post_url': reverse(edit_project, args=[project_id]),
                'unique_id_types': get_unique_id_types(manager),
                'preview_links': get_preview_and_instruction_links()
            },
            context_instance=RequestContext(request))
Exemple #2
0
def get_submission_breakup(request, project_id):
    dbm = get_database_manager(request.user)
    questionnaire = Project.get(dbm, project_id)
    submission_success, submission_errors = submission_stats(
        dbm, questionnaire.id)
    response = json.dumps([submission_success, submission_errors])
    return HttpResponse(response)
Exemple #3
0
def get_submission_breakup(request, project_id):
    dbm = get_database_manager(request.user)
    project = Project.load(dbm.database, project_id)
    form_model = FormModel.get(dbm, project.qid)
    submission_success, submission_errors = submission_stats(dbm, form_model.form_code)
    response = json.dumps([submission_success, submission_errors])
    return HttpResponse(response)
Exemple #4
0
def project_has_data(request, questionnaire_code=None):
    manager = get_database_manager(request.user)
    form_model = get_form_model_by_code(manager, questionnaire_code)
    success, error = submission_stats(manager, form_model.form_code)
    return HttpResponse(encode_json({'has_data': (success + error > 0)}))