Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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.
Posted
Comments
OriginalGriff 22-Jun-12 14:09pm    
And?
What is your problem?
Where are you stuck?
C# Beginner Nick 22-Jun-12 14:19pm    
I'm not sure how to make the whole form editable for other "admin users" to switch all the answers through the executable instead of changing the source for every change.
OriginalGriff 22-Jun-12 14:31pm    
How do you do it at the moment so you can edit them?
C# Beginner Nick 22-Jun-12 14:33pm    
Through the source, currently.
SASS_Shooter 22-Jun-12 15:19pm    
Is there a reason you kept the questions in source code instead of externalizing them into a file or database?

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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Jun-12 0:04am    
Basically agree, my 5, but, in my opinion, a database could be an overkill. Please see my answer for a viable alternative.
--SA
Shahin Khorshidnia 23-Jun-12 3:16am    
Right.
My +5
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...[^].

[EDIT]

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
 
Share this answer
 
v2
Comments
Shahin Khorshidnia 23-Jun-12 3:15am    
Good explanation.
+5
Sergey Alexandrovich Kryukov 23-Jun-12 11:59am    
Thank you, Shahin.
--SA
Espen Harlinn 23-Jun-12 8:55am    
Good reply :-D
Sergey Alexandrovich Kryukov 23-Jun-12 11:58am    
Thank you, Espen.
--SA
You need to program, this can't be answered in this
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900