This project demonstrates that a single VB6 program can be used on several PCs on the same LAN without a separate server program or database in common. This sort of thing is much easier to write and the product is less confusing to maintain if done as two separate client and server programs though.
Pure TCP is used and a UDP discovery technique is implemented so the PCs do not need to be members of the same Workgroup or Domain, no name service is required, and yet no IP addresses need to be entered either.
Preparation
Multiple PCs on a LAN together will need the compiled program installed. You could create a formal installer - the P&D Wizard is good enough. Or an XCopy deployment package could be created using Reg-Free COM tools like the popular MMM ("Make My Manifest") though this requires experience most VB6 programmers don't have.
Nothing stops you from testing by running two copies of Quizzer.exe on your development PC for testing though.
Both MSHFLXGD.OCX and MSWINSCK.OCX (in addition to ADO 2.5, already in Windows) are used by this demo program.
Operation
Some user must play "proctor" and administer the quiz. This person puts his Quizzer.exe into "proctor mode" which opens an extra Form, and from there chooses a quiz file for the quiz to run. After that the proctor starts the quiz and fires each question and then "calls time" when all submitted answers get scored. The proctor can also end the quiz early.
The proctor can also take the quiz himself or just act as an observer/administrator.
Other users won't get the second admin Form, and once someone has taken on the proctor role the "Become Proctor" button will disappear from their quiz Form.
All participants (including the proctor if he chooses to be a participant) must register with a unique name when they first run Quizzer.exe, which they are prompted for. User can leave out this name and just choose to be an observer as well.
Once the proctor has taken charge and picked a quiz he can wait for participants to register. Then he can start the quiz, and begin sending questions. The proctor sends each question, waits the allotted time, and then "calls time" on the question. This scores the submitted answers and reports back to everyone's scoreboard.
Participants wait for questions which are presented along with a multiple-choice list of answers. The pick an answer and click Submit to send their answer to the proctor. Once the proctor calls time, score updates are reported back and the correct answer is pointed out to all particpants and observers.
Once the quiz is finished everyone is left with the scores and rankings to look at until they close Quizzer. The proctor can also optionally save the scores to a CSV file before quitting Quizzer.
Here "Mr. Bill" is acting as proctor. He has just clicked the "Call Time" button,
which has become the "Next Question" button.
Just A Demo
Quizzer isn't perfect.
There are many features that might be added. There may be some features that are not needed that could be ripped out.
The question file format is a bit rough (see the comments in Globals.InitProctor). This discovery protocol's UDP port is hard-coded (see Globals.PROCTOR_UDP_PORT). And so on and so on...
And of course there may still be any number of bugs in it yet, as well as plenty of imperfect exception handling. Not everything has been thoroughly tested.
How Quizzer Works
Without going into detail (though I'll admit the code itself can be rough to follow)...
There are two Forms, one called MainForm and the other ProctorForm.
MainForm is basically a user interface for displaying the scoreboard, displaying questions, and accepting answers.
ProctorForm is a sort of "reverse TCP server." It tracks everything, runs the quiz, maintains the "database" in memory using a pair of ADO Recordsets, and manages TCP connections to all of the MainForm instances on the LAN.
ADO Stream objects are heavily used for serializing and deserializing messages sent both ways over the TCP connections.
Discovery is accomplished by having each MainForm send UDP broadcasts out to the LAN containing the registration name of the user, his IP address, and the TCP port he is listening on. Once there is a ProctorForm running and it sees such a broadcast database entries are made and then ProctorForm connects back to the remote MainForm. When MainForm gets the connection established it stops broadcasting its announcements and is ready for the quiz to begin.
Large amounts of code and data used by both Forms is kept in Globals.bas in an attempt to make the code in the two Forms a little less cluttered.
There are also two other Forms: RegisterDlg and ProctorDlg. These are used as simple dialogs for getting information before carrying on with the business of the bigger Forms.
Last edited by dilettante; Aug 30th, 2013 at 07:46 AM.
Reason: typos
I should have added that most users running Quizzer the first time will get a prompt from the firewall (assuming they haven't disabled it).
For testing copies on the same PC you can go ahead and block Quizzer, but to test across the LAN or even between your desktop and a copies of Windows in a VM you will have to grant permission.
As far as I know Quizzer should run as written on Windows 95 (assuming ADO 2.5 or later was ever installed) up through Windows 8.1.
The only likely grief will come if you compile it on Windows 7 SP1 and don't have the workaround installed for the ADO breakage Win7's SP1 caused.
Oh! And no, the quiz file for the quiz being run does not need to be on every machine, only the proctor's PC.
Sorry, I should have been much clearer about this.
Quizzer uses the UDP "limited broadcast" address to locate the active proctor. This means it will only work within a local area network, and even then it may only work within a smaller part of a LAN.
Many companies operate what they still call a LAN even though what they have is an in-house "internet" (small letter "i") that connects several smaller networks through smart switches, routers, and other traffic distribution devices. These devices do not typically forward Quizzer broadcasts because they are not supposed to, and one of their goals is to prevent broadcasts from consuming bandwidth all over the organization.
And so there is no chance at all of getting this to work across the broader Internet (capital "I").
Setting all the bits of an IP address to one, or 255.255.255.255, forms the limited broadcast address. Sending a UDP datagram to this address delivers the message to any host on the local network segment. Because routers never forward messages sent to this address, only hosts on the network segment receive the broadcast message.
The approach Quizzer uses does have serious limitations. However one advantage that it does have is the ability to work without a dedicated server machine, tables of DNS names or IP addresses configured statically, etc. You could use Quizzer or a program communicating in a similar manner in a classroom, at home, with a group of people gathered near a WiFi access point, and so on.
Quizzer isn't innovative in this, UDP discovery broadcast techniques have been used by a lot of members here for this very kind of thing. If your search skills are good enough you may even turn up some other samples here in the CodeBank, some a decade old or older.
I played around with quizzer and I really liked it. My problem is that I work at a school that does not let Staff install certain components on their supplied school laptops for security reasons, .... so I was wondering if ....
Could ADO not be used and instead:
The proctor (teacher) creates their own encrypted and compiled question bank resource files and then have quizzer encrypt simple text answers back to the proctors (teachers) computer. So like every student downloads the program files joins the test, selects the questions from a compiled resource file on their own computers. They do the test and then the simple encrypted text file answers go to the proctor (server) on the teacher's laptop in a save-able Listview or Flexgrid. Also could there be a Rich Text box used for the question bank, so that one could have a choice of including one picture, as well as text questions?
At present, the school which I teach in uses an external web based system for testing, which is very sluggish, unreliable when the internet goes down and overloaded. Using the Lan during school hours is a much better local solution.
As I said earlier, I was really impressed by Quizzer, but due to other people having control of system resources I could not try it out in a real life situation. So I am limited in what I can do. I see great potential for the Quizzer program, but in my situation I need to tweak things to make things workable.