一个创建基于网络的匿名调查的django应用程序

django-anonsurvey3的Python项目详细描述


anonsurvey是一个django应用程序,通过https://github.com/darko-poljak/django-anonsurvey创建基于web的匿名调查。

anonsurvey3是一个fork,它支持python 3并添加更多的问题类型,如audio。

快速启动

  1. 从此回购协议安装django anonsurvey:

    mkvirtualenv survey
    git clone https://github.com/boltomli/django-anonsurvey.git
    cd django-anonsurvey
    python setup.py bdist_wheel
    pip install --upgrade dist/django_anonsurvey*.whl
    
  2. 将“anonsurvey3”添加到已安装的应用程序设置中,如下所示:

    INSTALLED_APPS = [
        ...
        'anonsurvey3',
    ]
    
    SURVEYS_PAGE_SIZE = 5 # for paginator
    STATIC_ROOT = os.path.join(BASE_DIR, 'static') # optional for collectstatic
    
  3. 在项目url.py中包含anonsurvey urlconf,如下所示:

    from django.conf.urls import url, include
    url(r'^survey/', include('anonsurvey3.urls')),
    
  4. 创建anonsurvey模型:

    python manage.py makemigrations anonsurvey3
    python manage.py migrate
    
  5. 启动开发服务器并访问http://127.0.0.1:8000/admin/ 创建调查(需要启用管理应用程序)。

    python manage.py createsuperuser
    python manage.py runserver
    
  6. 访问http://127.0.0.1:8000/survey/列出调查。

创建调查

首先输入调查主数据:

  • title
  • name (which is a slug initialy created from title)
  • introduction text
  • active state (False by default).

然后你可以输入问题。对于每个问题,您都可以输入 问题所属的问题组。问题组是可选的。 问题数据是:

  • survey the question belongs to

  • optional question group

  • type of the question:

    -   input - input type text
    -   choice - input type radio group
    -   multiple choice - input type checkboxes
    -   choice with input - input type radio group with one radio
        input with type text
    -   multiple choice with input - input type checkboxes with
        one checkbox with input type text
    
  • text of the question

  • requires answer

  • sort index - questions are sorted by this number ascending.

问题组包含它所属的调查和问题组 文本。

为每个问题定义答案或提供多个答案。回答 数据是:

  • type - input or choice - it is relevant only for choice with input and multiple choice with input question types
  • text prefix - displayed before input field of input type answer
  • text - displayed for choice type of answer
  • text sufix - displayed after input field of input type answer
  • default value - for input type of answer
  • validation regex - for input type of answer; regex is a valid python regex
  • sort index - answers are sorted by this number ascending.

根据调查定义,调查问题和提供的答案是 以不同的方式呈现。

首先,显示调查标题和简介文本。那么问题是 根据排序索引值按顺序呈现。如果问题属于 若要询问组,则显示组的标题。那么每一个问题 for组在该组内呈现。如果问题不属于任何人 组,则其单独呈现。对于每个问题,它的文本是 显示。在问题的下面,答案是按定义的顺序呈现的 按排序索引值。如果输入问题类型,则输入字段为 提供。在显示输入字段文本前缀之前。输入字段后 显示文本sufix。如果定义了默认值,则该值为 在输入字段中呈现。如果选择问题类型,则提供 答案显示为广播组。每台收音机都有一个答案 并显示其文本。如果问题类型是多项选择,则 提供的答案显示为复选框。每个复选框都提供一个 显示答案及其文本。如果quesiton类型是带输入的选项 或多选输入,则每个答案显示为 选择题或多项选择题。这里答案的类型是 相关的。如果type是input,则其单选或复选框包含 与问题的输入类型呈现相同的字段。

提交完成的调查验证时:

  • if question requires answer then answer must be suplied
  • if answer type is input and validation regex is supplied then answer value must match defined regex (note that regex is prefixed and sufixe with ^ and $ so that whole string match is checked).

提交的答案数据是:

  • client_id - in the format <current_timestamp>@<remote_ip> (by this value you can group answers to one client that completed the survey)
  • datetime - current timestamp answer is saved
  • answer - foreign key to offered answer that is input/selected
  • text - input value for input type of offered answer.

在包中,有一些最简单的模板可用于 拥有。对于测量显示{%包括“anonsurvey3/survey_form.thml”和 使用survey=survey%}。此模板提供了一种呈现 调查表取决于调查定义。你可以按原样使用,或者 可以将其用作构建您的模板。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java中是否有数字的默认类型   java调用一个类的方法来使用另一个类的实例   java HtmlUnit不适用于javascript处理   java需要帮助才能连接MongoDB   java如何从Maven中的src/main/resources复制文件?   java保存Int值(共享首选项)   从另一个类调用方法时,java Autowired组件出现空指针异常   java Spring JPA:PropertyAccessException 1:。。。MethodInvocationException:。'driverClassName'。。。org/postgresql/Driver:不支持的专业。次要版本52.0   java使用增强的JDO模型类在Eclipse中运行Junit测试   java如何使用eclipse IDE为junit创建可运行的jar文件   java如何在安卓中检测应用程序的启动和退出   java在其他线程可以访问静态映射时从数据库更新静态映射   java@Entitty和@EntityScan不起作用。我正在使用SpringBoot和jpa存储库,发生了很多次   java如何与google日历集成?