473,785 Members | 3,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help in designing a quiz

Hey everyone just designing a quiz for school and managed to write the
code for the questions and answers thou i have to add scores and at the
end an overall score does anyone have any idea what to do or what i am
talkin about

Apr 19 '06
16 4198
Puppet_Sock wrote:
If the code is likely to get included in a library, and have
change requests thrown like darts in a pub for years,
it is important to be fairly heavy on the design effort.


You have a typographical error there. You obviously intended to write
"should be fairly heavy on the unit test effort."

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 19 '06 #11
C++ Hell wrote:
Sorry guys yea its in C++ programmin in visual basic,


You lost me here.
Apr 20 '06 #12
On Thu, 20 Apr 2006 03:10:59 +0000, red floyd wrote:
C++ Hell wrote:
Sorry guys yea its in C++ programmin in visual basic,


You lost me here.


It's kind of like JavaScript programming in C++.

Apr 20 '06 #13
Phlip wrote:
Puppet_Sock wrote:
If the code is likely to get included in a library, and have
change requests thrown like darts in a pub for years,
it is important to be fairly heavy on the design effort.


You have a typographical error there. You obviously intended to write
"should be fairly heavy on the unit test effort."


These are not mutually exclusive, and in fact, contribute
to eachother. When it is code to go in a long-lived library,
you certainly want to do plenty-o unit tests. But you would
also want to be designing to make the unit tests easy,
effective, and obvious to understand. So you get such
things as self testing, regression testing, invariants in
classes, etc. etc.

But what I was getting at in the context you snipped was,
when code is expected to have a long life, you need to
work harder at accomodating expectable change requests.
Doing the design effort in advance in such a case means
you will, hopefully, save time over all. But it depends on
the code having a long life.
Socks

Apr 20 '06 #14
In article <1145468643.156 794.105730
@g10g2000cwb.go oglegroups.com> , jc*********@hot mail.com
says...
Sorry guys yea its in C++ programmin in visual basic, dont expect you
to write it for me just wonderin in which direction i can go,
#include <iostream>
using namespace std;
void main () {
cout << "FUN RUN QUIZ \n";
cout << " \n";
cout << "Instructio ns \n";


[ ... ]

You've gotten quite a few answers already, but hopefully
I can make it worth your time to read one more.

Most of the answers you've gotten have given roughly
similar advice -- basically that you separate the code
for presenting questions, collecting answers, etc., from
the data representing the questions and answers
themselves.

I'm going to suggest that while they have the right idea,
they generally haven't gone far enough. In particular,
I'd advise moving the data representing the questions and
answers out into a separate data file.

I'd design the data file something like this:

First question
3 2 // 3 = number of choices, 2 = correct answer
choice 1
choice 2
choice 3
second question
4 1
choice 1
choice 2
choice 3
choice 4

and so on for as many questions as you want in the test.
You can modify the exact structure to accommodate what
you need -- for example, if you're sure you're only ever
going to have three choices for every question, you can
skip over putting that number into the data file.
Likewise, there's nothing sacred about the order in which
I've arranged the fields. For example, if you wanted the
possible choices, then correct answer, and finally the
question, that would work perfectly well also.

Then design your program to read in this data file, and
present it to the user. You'd design a data structure to
hold the data for an individual question, something like
this:

struct question {
std::string q;
std::vector<std ::string> choices;
int answer;
};

Then you'd write some code to read one question in from
the file:

std::istream &
operator>>(std: :istream &is, question &q) {
std::getline(is , q.q);

int num_choices;
is >> num_choices;

// and so on for the rest of the data for one
// question.

return is;
}

Then you'd write some code to present a question to the
user. Even though this really only makes sense
interactively, it may be easiest to write it as a normal
operator<< for a 'question':

std::ostream &
operator<<(std: :ostream &os, question const &q) {
os << q.question << "\n";
// and so on for the remaining items in a question
// structure.
}

Then we'll want to handle all of asking a question --
present the question to the user, get their choice,
inform them whether their choice was correct, and return
a bool to indicate whether they gave the right answer:

bool ask(question const &q) {
std::cout << q;
int response;
std::cin >> response;

// ...give the user feedback about whether their choice
// was correct. return true to indicate a correct answer,
// or false to indicate an incorrect one.
}

Finally, put it all together: read the data for a test
into a vector, present the questions to the user in
order, and count up how many of their answers were
correct:

int main(int argc, char **argv) {
std::vector<que stion> test;

std::ifstream data("test.dat" );
std::copy(
std::istream_it erator<question >(data),
std::istream_it erator<question >(),
std::back_inser ter(test));

// If you're going to save the data from the test,
// right here is were you'd probably ask the user for
// their student ID number or whatever you're going to
// use to identify them.

// Ask each question and count the correct answers:
int correct_answers = std::count_if(
test.begin(), test.end(), ask);

// Here is where we'd do what we're going to with the
// student's score -- report it to them (either as a
// percentage or a letter grade) save it under their
// student ID, etc.

return 0;
}

Final point: if you're worried about the student reading
the data file, it's pretty easy to incorporate some
trivial encryption that will make the data file more
difficult to read. One well-known method is to simply XOR
each byte from the data file with a byte from a string.
As encryption goes, this is quite weak -- but it's still
enough that most people won't bother breaking it.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Apr 21 '06 #15
They pay per line :-)

Apr 24 '06 #16
In article <1145899782.684 067.119110
@u72g2000cwu.go oglegroups.com> , jo********@gmai l.com
says...
They pay per line :-)


Oh, so _that's_ why I was writing all those comments...

--
Later,
Jerry.

The universe is a figment of its own imagination.
Apr 26 '06 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1855
by: Carolyn Gill | last post by:
I have already created an asp login/database for a learning/quiz section on a small site. There will be multiple quizzes through the site and what I need now would be help: tutorials or advice that a complete novice can understand/follow to create the following: A small simple quiz--for now each has just one question with 5 multi-choice buttons. On submit should send the answer to A) a database (using access for now) to track scoring...
5
5758
by: Vandana Rola | last post by:
Hello Everyone, I am a beginner in Javascript.I want to create fun quiz tool using javascript (no database). The feature of that tool is every question has five choices. The user needs to select three best choices. If they do, a message window pops up which says good choices or something and take them to next question. If they don't choose all of the best choices they get another message like try again but these are not the best choices...
4
7468
by: DAL | last post by:
I want to build my kid a program that cycles through questions (using a label for the question), and lets him choose one of two radio buttons for the right answer. How do I get every set of questions and answers to cycle through until the last question? Also, how can I give him the score after the last question. Thank you in advance. DAL. P.S. As a beginner, I figured I couldn't pass up the chance to learn something new, and to practice...
0
1653
by: philip | last post by:
hello, i am now developing a quiz application for my school using ASP.NET and SQL SERVER 2005, here is a senario: It will have 20 students for taking a quiz in a classroom, they have to answer randomly generated 100 questions in 90 minutes from database, each of those questions may have a picture (approximately 200K), and the picture is stored in the database as image type. i have 2 methods for retrieving 100 questions for each student.
2
3429
by: kenny | last post by:
I'm making a quiz to be posted on the internet. but I'm facing difficulties in finding a simple timer for the quiz (unlimited timing) which will keep on running regardless to the change of the page throughout the quiz. And well how to display the result of the quiz and te grade of the person who has taken the quiz....
0
4579
NoPeasHear
by: NoPeasHear | last post by:
I don't know what I am doing wrong... I used this tutorial... http://www.permadi.com/tutorial/flashMXQuiz/index.html It works with their quiz.xml file, but when I add an option for multiple correct answers, the results page always gives me a response of 0. What would I change from the tutorial to have multiple correct responses reflect in the results? <?xml version="1.0"?>
1
3092
by: korr | last post by:
Hi there, i'm trying to develop a quiz in flash. Searching on the net, I found a quiz in flashkit from sephiroth.it by Alessandro Crugnola. His quiz has a script that puts the questions and the answers in random order. What i'm looking for is to not select the answers by clicking the mouse, but using the keyPress handler. Using the keyPress handler the script selects only the first answer I tried a lot but i didn't find any solution.. 2...
5
7217
by: pefok | last post by:
Hello everyone, One of my course works is to implement a java based quiz system. the program consists of two modules one for the teacher to create, set questions , answers and the number of questions to be published, and the other one is to allow the student to run the quiz. the data for the quiz is stored in text files and the correct answers are encrypted. everytime the students take a quiz the result has to be stored and a report...
3
2218
by: empiresolutions | last post by:
I am building a app that creates quizzes. This is how it goes - - Create Quiz - Provide up to 10 different types of Quiz Results - Give up to 50 Questions - Each Question has up to 10 possible Answers. - Each Answer is assigned a Weighted value.... for each type of Quiz Result. - Weighted values are in the range of -6, 0, +6. - Each Quiz will also apply the same Weight range for if a M/F is taking and what of 6 age groups the taker is...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.