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

django-anonsurve的Python项目详细描述


anonsurvey是一个django应用程序,用于创建基于web的匿名调查。

快速启动

  1. 将“anonsurvey”添加到已安装的应用程序设置中,如下所示:

    INSTALLED_APPS = (
        ...
        'anonsurvey',
    )
    
    维护管理还取决于:

    'tinymce', “sorl.缩略图”, 'MCE_文件浏览器',

  2. 在项目url.py中包含anonsurvey urlconf,如下所示:

    url(r'^survey/', include('anonsurvey.urls')),
    
  3. 运行python manage.py syncdb以创建anonsurvey模型。

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

  5. 访问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.

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

首先,显示调查标题和简介文本。 然后根据排序索引值按顺序呈现问题。 如果问题属于问题组,则显示组的标题。 然后组的每个任务都在该组内呈现。 如果问题不属于任何组,则仅呈现该问题。 每个问题都会显示其文本。 在问题的下面,答案是按排序的顺序呈现的 索引值。 如果输入问题类型,则呈现输入字段。 在显示输入字段文本前缀之前。输入字段文本后 苏菲克斯展示。如果定义了默认值,则将呈现该值 在输入框内。 如果选择问题类型,则提供的答案显示为 广播组。每个收音机都是一个提供的答案,并显示其文本。 如果问题类型是多项选择,则显示提供的答案 作为复选框。每个复选框是一个提供的答案,其文本是 显示。 如果quesiton类型是带input的choice或带input的multiple choice 然后每一个答案都显示在上面供选择或多项选择 问题类型。这里答案的类型是相关的。如果类型是 输入然后其单选或复选框包含 呈现的问题类型与输入的问题类型相同。

提交完成的调查验证时:

  • 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.

在包中,有一些最简单的模板可用于 拥有。 用于测量显示 {%使用survey=survey%}的include“anonsurvey/survey_form.thml”。 此模板提供了一种根据 关于调查定义。你可以原样使用,也可以作为 你的模板。

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

推荐PyPI第三方库


热门话题
java在JavaFX TableView中设置行高   java生成范围内的随机数   ProcessBuilder或DefaultExecutor启动的“RunAs”子进程的java读取标准输出   java ExoPlayer播放多个视频   基于匹配器的java Mockito ArgumentCaptor捕获条件   java正在创建更新程序。更新/下载部分   java请求。getAttribute()在servlet中不起作用   java Android Http请求:我不理解以下代码:   java ArrayList Failfast ConcurrentModificationException   if语句Java/LWJGL Pong AI问题   使用Oracle 10g长字段填充Grails域对象时的java空指针   当用户触摸屏时,java按钮不从左上角移动到右下角   未捕获javasocket读取IOException?   用Java绘制一段圆的几何图形?