创建一个可编辑的C#多重选择测试程序 [英] Creating an Editable C# Mutliple Choice Test program

查看:41
本文介绍了创建一个可编辑的C#多重选择测试程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了本指南:
http://www.functionx.com/vcsharp2003/applications/mcq2.htm [ ^ ]

使用我的问题进行了多项选择题测试;但是,多个人需要能够在程序内部进行管理员登录"以手动更改问题,并将其保存以备后用,以便该程序可以使用多年,而无需我成为他们反复重写问题的方法. .

这是对定期更改的法规进行计算机测试的一种尝试,尽管我不像以前那样从事C#编程.

任何帮助将不胜感激.

I followed this guide:
http://www.functionx.com/vcsharp2003/applications/mcq2.htm[^]

Made the Multiple choice test using my questions; however, multiple people need to be able to "Admin Login" to change questions manually while inside the program and have it save for later on so this program can be used throughout the years without me needing to be their to rewrite the questions over and over.

This is an attempt to make a computerized test for Regulations that change regularly, though I am not as well as i used to be in C# Programming.

Any assistance will be much appreciated.

推荐答案

哦,男孩.
这是一个大问题!

问题:
Oh boy.
That is a large question!

Question:
"How do you do it at the moment so you can edit them?"


回复


Reply

"Through the source, currently."


这就是一个大问题了!

问题是您需要将问题和可能的答案存储在某种形式的非易失性存储中,而不是源代码中,这意味着您必须对应用程序进行重大更改,然后才能开始限制谁可以编辑它们,或者他们是如何做到的.

目前,您可能有单独的页面,问题和答案都被硬编码到其中,因此,您要做的第一件事就是使它能够从数据库或其他文件源中读取问题和可能的答案,并且显示它们.这可能很容易,也可能不容易,具体取决于您编写应用程序的方式以及您的经验和能力水平.我会选择一个数据库,因为这是一个自然的选择,并且省去了设计,读取和写入文件格式的麻烦.它还提供了一些安全性,否则您可能必须提供一些安全性.

因此,首先,请看建立数据库并显示问题和答案.有了这些,就可以进入下一个阶段.


That''s the bit that makes it a large question!

The problem is that you need to store the questions and possible answers in some form of non-volatile storage instead of the source code, and that means significant changes to your application before you can get anywhere near starting on limiting who can edit them, or how they do it.

At the moment, you probably have individual pages, which the questions and answered hard coded into them, so the first thing you have to do is make it so that you can read the question and potential answers from a database or other file source, and display them. This may or may not be easy, depending on how you have written your app, and your experience and ability level. I would go with a database, as it it a natural choice for this, and saves the hassle of designing, reading and writing your file format. It also provides some security which you would probably have to provide yourself otherwise.

So, to start, look at setting up a database, and displaying a question and answers from it. When you have that, you can move on to the next stage.


我基本上同意OriginalGriff,但宁愿认为数据库对于这个简单的问题来说可能是一个过大的杀伤力.一个简单的带有问题和答案的XML文件可以很好地解决这个问题.而且,您绝对不需要进行XML编程. Data Contract这样简单的事情将为您完成所有工作.您实际上并不需要使用XML.您所需要做的就是保持数据模型.

因此,您首先需要开发测试的数据模型.可以这样简单:包含一个问题,一个问题的列表或变体数组以及对正确问题的引用的类或结构.然后,您将需要一个这样的结构的列表来表示整个测试.

然后,将数据协定属性添加到您的类型和相关成员,并告诉数据协定为您持久化所有这些.我之前提到过参考资料. DataContractSerializer的优点是,它可以持久保存任意数据图,而不仅仅是树(也就是说,它可以持久保存具有循环引用的数据结构,而不会导致堆栈溢出).

现在,仅留一些参考.请参阅:
http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

另请参阅我过去关于以下主题的答案:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [
这是您可以使用的一种简单技术:您可以将数据模型放在单独的库程序集中,以供编辑应用程序和工作"应用程序或Web应用程序都引用,但是没有一个错误是一个项目仅引用了程序集的程序集.另一个应用程序.在.NET中,程序集就是程序集. "DLL"和"EXE"之间没有本质区别.

—SA
I basically agree with OriginalGriff but would rather think that database is maybe an overkill for this simple problem. Am simple XML file with questions and answers would to the trick perfectly. Moreover, you absolutely do not need to do XML programming. Such a simple thing as Data Contract will do it all for you. You don''t really need to work with XML; all you need is to persist your data model.

So, you first need to develop a data model of the test. It could be as simple as this: a class or structure containing: a question, a list or an array of variants for one question and a reference to a correct one. Then, you will need a list of such structure to represent a whole test.

Then, add data contract attributes to your types and relevant members, and tell Data Contract to persist it all for you. I mentioned reference before. What''s good about DataContractSerializer, it can persist an arbitrary data graph, not just a tree (that is, it can persist a data structure with circular references without falling to a stack overflow).

Now, it only leaves for some references. Please see:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past answers on the topic:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].



You also don''t have to edit XML file manually, even though this is also a valid variant: you can create some "demo" instance of the data structure just once and save it programmatically; it will give a clear template for creating new versions of test demo manually. If you want to make if a bit better, you can develop a simple stand-along UI application using the same data model used exclusively to editing of the test data. If could have buttons like "Add", "Edit" (new question or edit existing question), menu items "Save" and "Open", etc.

Here is one simple technique you can use: you can have you data model in a separate library assembly to be referenced by both editing application and your "working" application or Web application, but there is nothing wrong is one project simply references the assembly of another applications. In .NET, an assembly is assembly; there is no essential difference between "DLL" and "EXE".

—SA


您需要编程,无法在此


这篇关于创建一个可编辑的C#多重选择测试程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆