I'm designing a survey tool. The survey will be very static and because of that, I can avoid building some kind of table-driven survey designer to accommodate the 167 questions on the survey (all 1-5 rating questions in a radio box or checkbox layout).
我正在设计一个调查工具。调查将是非常静态的,因此,我可以避免建立某种表驱动的调查设计师来容纳调查中的167个问题(所有1-5个评级问题都在一个收音机框或复选框布局中)。
I was thinking of building the survey questions in a large XML file, but my non-technical co-worker that will be making frequent edits to the survey will likely do things that will break the integrity/validity of the raw xml file (think punctuation and special characters).
我正在考虑在一个大型XML文件中构建调查问题,但我的非技术工作人员将经常编辑调查,这可能会破坏原始xml文件的完整性/有效性(想想标点符号)和特殊字符)。
The XML file might look something like:
XML文件可能类似于:
<questions>
<question>
<type>checkbox</type>
<text>Which beers do you like most</text>
<choices>Bud,Miller,Piels</choices>
<Required>true</Required>
</question>
<question>
<type>radio</type>
<text>Which beer is your favorite</text>
<choices>Bud,Miller,Piels</choices>
<Required>true</Required>
</question>
</questions>
Please use your imagination that this structure will be a bit more complex and that there will be 165 more questions.
请用你的想象力来看这个结构会更复杂,还会有165个问题。
Complicating matters, I need these questions in some form of object-oriented layout so that I can take the results and align them to other stuff. I had considered hard-coding a very lengthy survey form with 167 questions, but I need the data in blocks so that I can parse out question 37 and align it to something else in some other feature, that is related to question 37.
使事情变得复杂,我需要以某种形式的面向对象布局来解决这些问题,以便我可以将结果与其他内容对齐。我曾经考虑过对一个包含167个问题的非常冗长的调查表进行硬编码,但我需要块中的数据,以便我可以解析问题37并将其与其他功能中的其他内容对齐,这与问题37有关。
Here's what I'd like to do in a .Net app:
这是我想在.Net应用程序中做的事情:
- Define a enumerable class for this.
-
Do something where I can manually fill an enumerable collection of this class with all of the data I need. Using the p-code that would be familiar in my .asp world . . .
做一些我可以用我需要的所有数据手动填充这个类的可枚举集合的东西。使用我的.asp世界中熟悉的p代码。 。 。
questions q = new questions() q.type = "checkbox"; q.text = "which beers do you enjoy"' q.choices = "Bud,Miller,Peils"; q.required = true; q.add q.type = "radio"; q.text = "what is your favorite beer"; q.choices = "Bud,Miller,Peils"; q.required = true; q.add
为此定义一个可枚举的类。
My hope is that this .cs file (though foreign looking to the lay person) would be much easier for my co-worker to maintain, without me having to worry about syntax errors.
我希望这个.cs文件(虽然外国人看起来很外行)对于我的同事来说更容易维护,而我不必担心语法错误。
So, I guess what I'm looking for some feedback on:
所以,我想我正在寻找一些反馈:
-
Is this just a dumb idea. Should I do this in XML and I'll just consume the XML file and be done with it.
这只是一个愚蠢的想法。我是否应该在XML中执行此操作,并且我将使用XML文件并完成它。
-
WWYD - What would you do? Is there an easier way to do this?
WWYD - 你会做什么?有更简单的方法吗?
- I don't care about performance as a relatively small number of users are using this.
- I don't care about maintainability, because we will write this feature properly in the summer.
- I just need to create a data structure that is not in a DB and that can be maintained by a non-technical person with a text-editor (for now).
我并不关心性能,因为相对较少的用户正在使用它。
我不关心可维护性,因为我们会在夏天正确地编写这个功能。
我只需要创建一个不在数据库中的数据结构,并且可以由非技术人员使用文本编辑器进行维护(目前)。
If anyone made it this far, I appreciate it.
如果有人做到这一点,我很感激。
6 个解决方案
#1
1
As permanent store XML is good.
But that does not mean the user needs to edit the XML directly.
I would build the ability to edit, add, and delete the questions in the app.
Yes a bit a trouble but if they hack the XML then that is also a lot of trouble.
永久存储XML是好的。但这并不意味着用户需要直接编辑XML。我将构建在应用程序中编辑,添加和删除问题的功能。有点麻烦,但如果他们破解XML那么这也是一个很大的麻烦。
How do you plan to save survey results?
How do you plan to collect the survey results?
There is more to this project than you are realizing.
Do you need to combine results from more than one device?
If more than one device then you need to separate the questions from the results so you can update the questions on more than one device.
您打算如何保存调查结果?您打算如何收集调查结果?这个项目还有比你意识到的更多。您需要合并多个设备的结果吗?如果有多个设备,则需要将问题与结果分开,以便您可以在多个设备上更新问题。
There are tools to read and write XML to disk.
Reading XML with the XmlReader
I don't agree with doug that you need to embed a database.
For a small number of questions I would use XML.
I would read all the XML into an object collection (A List).
You don't need a class the implements IEnumerable.
You put you objects in a a collections that implements IEnumerable.
有一些工具可以读写XML到磁盘。使用XmlReader读取XML我不同意doug您需要嵌入数据库。对于少数问题,我会使用XML。我会将所有XML读入对象集合(A List)。您不需要实现IEnumerable的类。您将对象放在实现IEnumerable的集合中。
I would go WPF over WinForms.
A ListBox with a DataTemplate.
On the DataTemplate you can have a dynamic selector in code behind but that is a real hassel.
Consider a single template that you manipulate in code behind.
So they are not RadioButtons but you uncheck the others in code behind.
For filtering I would go LINQ in public properties but there is also CollectionViewSource.
我会在WinForms上使用WPF。带有DataTemplate的ListBox。在DataTemplate上,你可以在代码后面有一个动态选择器,但这是一个真正的哈希。考虑一下您在代码后面操作的单个模板。所以他们不是RadioButtons,但你在代码背后取消选中其他人。对于过滤,我会在公共属性中使用LINQ,但也有CollectionViewSource。
Used XML for an app that was used to collect field measurements.
A lot like this in measuring devices could change and need to collect the measurements.
用于收集字段测量的应用程序使用的XML。在测量设备中很多这样的情况可能会改变并需要收集测量结果。
If you are set on user editing the questions directly then XML with XSD is the best I can think of.
如果您设置用户直接编辑问题,那么使用XSD的XML是我能想到的最好的。
#2
2
Everyone uses Excel...so consider using a CSV format which can be read by you as well as Excel which your counterpart will be using. One must specify to the user that the columns can't be changed, which is not a drawback per-se, but the user exports the dynamic changes to CSV which the program reads and can verify.
每个人都使用Excel ...因此请考虑使用CSV格式,您可以使用它以及您的对应方将使用的Excel。必须向用户指定不能更改列,这本身并不是一个缺点,但是用户将动态更改导出到程序读取并可以验证的CSV。
Plus the user does not have to be trained to use Excel so it is a win/win situation per your requirements not to use XMl.
此外,用户无需接受过使用Excel培训,因此根据您的要求不使用XMl是一种双赢局面。
#3
1
If you are looking for a simple human readable structured format, then you could be interrested by YAML.
如果您正在寻找一种简单的人类可读结构化格式,那么您可能会被YAML所吸引。
YAML is a human-readable data serialization format that takes concepts from programming languages such as C, Perl, and Python, and ideas from XML and the data format of electronic mail.
YAML是一种人类可读的数据序列化格式,它采用来自C,Perl和Python等编程语言的概念,以及来自XML的思想和电子邮件的数据格式。
Your question file would look like this:
您的问题文件如下所示:
questions:
- id: 1
type: checkbox
text: Which beers do you like most
choices: Bud,Miller,Piels
Required: true
- id: 2
type: radio
text: Which beer is your favorite
choices: Bud,Miller,Piels
Required: true
Some YAML libraries exists in .NET (from the article):
.NET中存在一些YAML库(来自文章):
https://github.com/aaubry/YamlDotNet
#4
1
There are plenty of xml editing tools out there that will actually make it easier to edit than editing a text file directly. I use XML Marker and it's pretty easy to use. http://symbolclick.com/
有很多xml编辑工具,实际上比直接编辑文本文件更容易编辑。我使用XML Marker,它很容易使用。 http://symbolclick.com/
It will be quicker to train them to edit using the tool than it will be to build one.
使用该工具训练它们比编译它更快。
#5
0
Two answers here;
这里有两个答案;
a: Write it to allow a proper admin interface, using a database to allow admin users to add/edit questions, response options and include appropriate security, auditing etc. You mention that this may not be feasible in the short term or that a 'proper' feature will be added soon, in which case, scrap this!
a:编写它以允许正确的管理界面,使用数据库允许管理员用户添加/编辑问题,响应选项并包括适当的安全性,审计等。您提到这可能在短期内不可行或者是'a'适当的'功能将很快添加,在这种情况下,废弃这个!
b: People say they have frequent edits/changes to make, but is this not a requirement which is co-related to a complete feature? Could you not in the short term, accept manual requests for change via email or something else documented, and make them yourself? Do you think the time taking to add a question/response or change some wording would be less than needing to parse XML manually to find a syntax error from someone who isn't familiar?
b:人们说他们经常进行编辑/更改,但这不是与完整功能相关的要求吗?您是否可以在短期内通过电子邮件或其他记录的方式接受手动更改请求,并自行制作?您是否认为添加问题/响应或更改某些措辞所花费的时间少于需要手动解析XML以查找不熟悉的人的语法错误?
You'll need to weigh up frequency of change with impact to yourself of making a change vs likelihood of user error, vs estimated time needed to identify and resolve a syntax error (plus the possible bad-will of having a change break things). Despite what some people think, users don't like making mistakes! putting them in a position where they have admin level powers over a system they don't have a full technical grasp of, could reduce confidence and future buy-in to the feature you're due to develop.
您需要权衡变化的频率与对自己产生影响的影响与用户错误的可能性相比,以及识别和解决语法错误所需的估计时间(加上可能出现更改的坏处)。尽管有些人认为,用户不喜欢犯错误!将他们置于一个他们对系统没有完全技术掌握的管理级别权限的位置,可能会降低您对将要开发的功能的信心和未来的支持。
TLDR; In my opinion, unless it's a major hassle, do the changes yourself in the short term, perhaps with a maximum amount of time you'll make them (I make one change set a week, on a Friday for example). Keep the system working perfectly, and involve the users without putting them in an uncomfortable position being an non voluntary early adopter for a feature which isn't finished.
TLDR;在我看来,除非这是一个很大的麻烦,否则你可以在短期内自己做一些改变,或许你可以用最长的时间来制作它们(例如,我每周做一次更改,例如星期五)。保持系统完美运行,并让用户参与,而不会让他们处于一个不自觉的位置,这是一个非自愿的早期采用者未完成的功能。
#6
0
I used my complete mastery over winforms to create a little mock GUI application that enables users to quickly create one dimensional non conditional lists of questions with different question types.
我使用我对winforms的完全掌握来创建一个小的模拟GUI应用程序,使用户能够快速创建具有不同问题类型的一维非条件问题列表。
Once you decided on an xml scheme you can easily import and export xml files.
Are you interested in further development of the magical survey creator? If so tell me and I will send you a practically finished prototype tomorrow morning. (You should provide me with an xml scheme though, otherwise I will do it in CSV)
I enjoy the exercise.
Picture related. Don't be put off by the colors, that's how I like it during development, to see the pixel exact boundaries of controls.
一旦确定了xml方案,就可以轻松导入和导出xml文件。您是否对魔法调查创建者的进一步发展感兴趣?如果这样告诉我,明天早上我会发给你一个实际完成的原型。 (你应该给我一个xml方案,否则我会用CSV做)我喜欢这个练习。图片相关。不要被颜色拖延,这是我在开发过程中喜欢它的方式,看看像素的精确控制边界。
Unless your coworkers have some experience with programming or xml editing they will hate you if you instruct them to edit any sort of "code".
Our secretaries put their hand in front of their faces and start chanting "no, no, no..." when I tell them how to operate VBA macros.
除非你的同事有编程或xml编辑的经验,否则如果你指示他们编辑任何类型的“代码”,他们会讨厌你。当我告诉他们如何操作VBA宏时,我们的秘书将他们的手放在他们的面前并开始念诵“不,不,不......”。
#1
1
As permanent store XML is good.
But that does not mean the user needs to edit the XML directly.
I would build the ability to edit, add, and delete the questions in the app.
Yes a bit a trouble but if they hack the XML then that is also a lot of trouble.
永久存储XML是好的。但这并不意味着用户需要直接编辑XML。我将构建在应用程序中编辑,添加和删除问题的功能。有点麻烦,但如果他们破解XML那么这也是一个很大的麻烦。
How do you plan to save survey results?
How do you plan to collect the survey results?
There is more to this project than you are realizing.
Do you need to combine results from more than one device?
If more than one device then you need to separate the questions from the results so you can update the questions on more than one device.
您打算如何保存调查结果?您打算如何收集调查结果?这个项目还有比你意识到的更多。您需要合并多个设备的结果吗?如果有多个设备,则需要将问题与结果分开,以便您可以在多个设备上更新问题。
There are tools to read and write XML to disk.
Reading XML with the XmlReader
I don't agree with doug that you need to embed a database.
For a small number of questions I would use XML.
I would read all the XML into an object collection (A List).
You don't need a class the implements IEnumerable.
You put you objects in a a collections that implements IEnumerable.
有一些工具可以读写XML到磁盘。使用XmlReader读取XML我不同意doug您需要嵌入数据库。对于少数问题,我会使用XML。我会将所有XML读入对象集合(A List)。您不需要实现IEnumerable的类。您将对象放在实现IEnumerable的集合中。
I would go WPF over WinForms.
A ListBox with a DataTemplate.
On the DataTemplate you can have a dynamic selector in code behind but that is a real hassel.
Consider a single template that you manipulate in code behind.
So they are not RadioButtons but you uncheck the others in code behind.
For filtering I would go LINQ in public properties but there is also CollectionViewSource.
我会在WinForms上使用WPF。带有DataTemplate的ListBox。在DataTemplate上,你可以在代码后面有一个动态选择器,但这是一个真正的哈希。考虑一下您在代码后面操作的单个模板。所以他们不是RadioButtons,但你在代码背后取消选中其他人。对于过滤,我会在公共属性中使用LINQ,但也有CollectionViewSource。
Used XML for an app that was used to collect field measurements.
A lot like this in measuring devices could change and need to collect the measurements.
用于收集字段测量的应用程序使用的XML。在测量设备中很多这样的情况可能会改变并需要收集测量结果。
If you are set on user editing the questions directly then XML with XSD is the best I can think of.
如果您设置用户直接编辑问题,那么使用XSD的XML是我能想到的最好的。
#2
2
Everyone uses Excel...so consider using a CSV format which can be read by you as well as Excel which your counterpart will be using. One must specify to the user that the columns can't be changed, which is not a drawback per-se, but the user exports the dynamic changes to CSV which the program reads and can verify.
每个人都使用Excel ...因此请考虑使用CSV格式,您可以使用它以及您的对应方将使用的Excel。必须向用户指定不能更改列,这本身并不是一个缺点,但是用户将动态更改导出到程序读取并可以验证的CSV。
Plus the user does not have to be trained to use Excel so it is a win/win situation per your requirements not to use XMl.
此外,用户无需接受过使用Excel培训,因此根据您的要求不使用XMl是一种双赢局面。
#3
1
If you are looking for a simple human readable structured format, then you could be interrested by YAML.
如果您正在寻找一种简单的人类可读结构化格式,那么您可能会被YAML所吸引。
YAML is a human-readable data serialization format that takes concepts from programming languages such as C, Perl, and Python, and ideas from XML and the data format of electronic mail.
YAML是一种人类可读的数据序列化格式,它采用来自C,Perl和Python等编程语言的概念,以及来自XML的思想和电子邮件的数据格式。
Your question file would look like this:
您的问题文件如下所示:
questions:
- id: 1
type: checkbox
text: Which beers do you like most
choices: Bud,Miller,Piels
Required: true
- id: 2
type: radio
text: Which beer is your favorite
choices: Bud,Miller,Piels
Required: true
Some YAML libraries exists in .NET (from the article):
.NET中存在一些YAML库(来自文章):
https://github.com/aaubry/YamlDotNet
#4
1
There are plenty of xml editing tools out there that will actually make it easier to edit than editing a text file directly. I use XML Marker and it's pretty easy to use. http://symbolclick.com/
有很多xml编辑工具,实际上比直接编辑文本文件更容易编辑。我使用XML Marker,它很容易使用。 http://symbolclick.com/
It will be quicker to train them to edit using the tool than it will be to build one.
使用该工具训练它们比编译它更快。
#5
0
Two answers here;
这里有两个答案;
a: Write it to allow a proper admin interface, using a database to allow admin users to add/edit questions, response options and include appropriate security, auditing etc. You mention that this may not be feasible in the short term or that a 'proper' feature will be added soon, in which case, scrap this!
a:编写它以允许正确的管理界面,使用数据库允许管理员用户添加/编辑问题,响应选项并包括适当的安全性,审计等。您提到这可能在短期内不可行或者是'a'适当的'功能将很快添加,在这种情况下,废弃这个!
b: People say they have frequent edits/changes to make, but is this not a requirement which is co-related to a complete feature? Could you not in the short term, accept manual requests for change via email or something else documented, and make them yourself? Do you think the time taking to add a question/response or change some wording would be less than needing to parse XML manually to find a syntax error from someone who isn't familiar?
b:人们说他们经常进行编辑/更改,但这不是与完整功能相关的要求吗?您是否可以在短期内通过电子邮件或其他记录的方式接受手动更改请求,并自行制作?您是否认为添加问题/响应或更改某些措辞所花费的时间少于需要手动解析XML以查找不熟悉的人的语法错误?
You'll need to weigh up frequency of change with impact to yourself of making a change vs likelihood of user error, vs estimated time needed to identify and resolve a syntax error (plus the possible bad-will of having a change break things). Despite what some people think, users don't like making mistakes! putting them in a position where they have admin level powers over a system they don't have a full technical grasp of, could reduce confidence and future buy-in to the feature you're due to develop.
您需要权衡变化的频率与对自己产生影响的影响与用户错误的可能性相比,以及识别和解决语法错误所需的估计时间(加上可能出现更改的坏处)。尽管有些人认为,用户不喜欢犯错误!将他们置于一个他们对系统没有完全技术掌握的管理级别权限的位置,可能会降低您对将要开发的功能的信心和未来的支持。
TLDR; In my opinion, unless it's a major hassle, do the changes yourself in the short term, perhaps with a maximum amount of time you'll make them (I make one change set a week, on a Friday for example). Keep the system working perfectly, and involve the users without putting them in an uncomfortable position being an non voluntary early adopter for a feature which isn't finished.
TLDR;在我看来,除非这是一个很大的麻烦,否则你可以在短期内自己做一些改变,或许你可以用最长的时间来制作它们(例如,我每周做一次更改,例如星期五)。保持系统完美运行,并让用户参与,而不会让他们处于一个不自觉的位置,这是一个非自愿的早期采用者未完成的功能。
#6
0
I used my complete mastery over winforms to create a little mock GUI application that enables users to quickly create one dimensional non conditional lists of questions with different question types.
我使用我对winforms的完全掌握来创建一个小的模拟GUI应用程序,使用户能够快速创建具有不同问题类型的一维非条件问题列表。
Once you decided on an xml scheme you can easily import and export xml files.
Are you interested in further development of the magical survey creator? If so tell me and I will send you a practically finished prototype tomorrow morning. (You should provide me with an xml scheme though, otherwise I will do it in CSV)
I enjoy the exercise.
Picture related. Don't be put off by the colors, that's how I like it during development, to see the pixel exact boundaries of controls.
一旦确定了xml方案,就可以轻松导入和导出xml文件。您是否对魔法调查创建者的进一步发展感兴趣?如果这样告诉我,明天早上我会发给你一个实际完成的原型。 (你应该给我一个xml方案,否则我会用CSV做)我喜欢这个练习。图片相关。不要被颜色拖延,这是我在开发过程中喜欢它的方式,看看像素的精确控制边界。
Unless your coworkers have some experience with programming or xml editing they will hate you if you instruct them to edit any sort of "code".
Our secretaries put their hand in front of their faces and start chanting "no, no, no..." when I tell them how to operate VBA macros.
除非你的同事有编程或xml编辑的经验,否则如果你指示他们编辑任何类型的“代码”,他们会讨厌你。当我告诉他们如何操作VBA宏时,我们的秘书将他们的手放在他们的面前并开始念诵“不,不,不......”。