| | |
Multiple questions in a day
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 5
Reputation:
Solved Threads: 0
How do I display multiple questions per day? Also, I am using Visual Studio 2005 and am using a database to retrieve the data.
This is the sample code:
This is the sample code:
C# Syntax (Toggle Plain Text)
private string GetCurrentQuestion() { string str = ""; DataAccess da = new DataAccess(); DataSet ds = new DataSet(); da.Connect(); ds = da.GetData("select * from questions where qdate = #" + DateTime.Now.ToString("dd-MMM-yyyy") + "#"); if (ds.Tables[0].Rows.Count > 0) { str = "Question: " + ds.Tables[0].Rows[0]["ques"].ToString(); str += "\nA." + ds.Tables[0].Rows[0]["ans1"].ToString(); str += "\nB." + ds.Tables[0].Rows[0]["ans2"].ToString(); str += "\nC." + ds.Tables[0].Rows[0]["ans3"].ToString(); str += "\nD." + ds.Tables[0].Rows[0]["ans4"].ToString(); } else { str = "Sorry! No Questions Today! Try again Tomorrow!"; } da.Disconnect(); return str; }
•
•
Join Date: May 2008
Posts: 538
Reputation:
Solved Threads: 86
The current implementation only looks at the first record returned and builds an output string with the question and answer options.
If there was more than one question matched, how would it work?
Should this return all of the questions delimited in some fashion?
Should it always return a list of questions, that might be empty?
Should you pass a question index into this method and keep calling it until it returns something indicating no more questions?
How would the user interact with it?
Would all of the questions for the day be on the same page, or would you want one page per question?
If there was more than one question matched, how would it work?
Should this return all of the questions delimited in some fashion?
Should it always return a list of questions, that might be empty?
Should you pass a question index into this method and keep calling it until it returns something indicating no more questions?
How would the user interact with it?
Would all of the questions for the day be on the same page, or would you want one page per question?
•
•
Join Date: Dec 2008
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
The current implementation only looks at the first record returned and builds an output string with the question and answer options.
If there was more than one question matched, how would it work?
Should this return all of the questions delimited in some fashion?
Should it always return a list of questions, that might be empty?
Should you pass a question index into this method and keep calling it until it returns something indicating no more questions?
How would the user interact with it?
Would all of the questions for the day be on the same page, or would you want one page per question?
I am not sure how it would go, to put a sort of timing interval (eg. restrict 5 questions in 24 hours) into the coding but I am not sure on how to begin with.
•
•
Join Date: May 2008
Posts: 538
Reputation:
Solved Threads: 86
The current database search uses
You could extend that to have a 'morning', 'afternoon' and 'evening/night' questions using time...
The only other was to implement it would be to somehow get the information as to whether or not the current user has already seen a particular question. (Maybe you could keep a last date/question index for each user?)
If the last question date was today's date, then select the next index question (if any).
Note that the database would need to have a field to establish the order that questions would be presented during the day.
Also note that some entity must be populating the database with questions for future dates so that when the date arrives there is a question available. The entity would have to support adding more than one question for a given date, potentially including an order in which the questions were to be presented.
Now you put some effort into the problem if you want me to post any more, the "I just can't think of anything" is all worn out.
where qdate = #" + DateTime.Now.ToString("dd-MMM-yyyy") + "#" which limits the search to only find records for the given date.You could extend that to have a 'morning', 'afternoon' and 'evening/night' questions using time...
The only other was to implement it would be to somehow get the information as to whether or not the current user has already seen a particular question. (Maybe you could keep a last date/question index for each user?)
If the last question date was today's date, then select the next index question (if any).
Note that the database would need to have a field to establish the order that questions would be presented during the day.
Also note that some entity must be populating the database with questions for future dates so that when the date arrives there is a question available. The entity would have to support adding more than one question for a given date, potentially including an order in which the questions were to be presented.
Now you put some effort into the problem if you want me to post any more, the "I just can't think of anything" is all worn out.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
To restrict questions to x per day, or hour or whatever means you would have to log someones efforts.. or you select x questions that may run in a day and then randomize.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Nov 2008
Posts: 44
Reputation:
Solved Threads: 4
Well, I'm not so sure though. If this is just a random multiple question everyday then I would go with this design:
- We will show a label as question and a few Radiobox for answer.
- Select a random question which the last occured is more than a week or well, you decide it.
- A timer control, every second it go up, 1 point will be decrease from the total point.
Quick-And-Easy
DB
tblUser
All the information, their correct answer and total question they took.
tblQuestion
All the question and the last time it occured.
If you don't mind about how big your database is or how complex it is.
tblUser
--Well all the user information if neccesary
tblQuestion
--List of all questions
tblAnswers
--List of all answer
tblAnswersQuestion
--Link the answer table and question table
[B]tblResult[B]
--Store when the user answer the question, is that correct or not and how long it take him to answer that...
With this structure sure you could calculate the statistic easily. But I think it's over the top a bit.
- We will show a label as question and a few Radiobox for answer.
- Select a random question which the last occured is more than a week or well, you decide it.
- A timer control, every second it go up, 1 point will be decrease from the total point.
Quick-And-Easy
DB
tblUser
All the information, their correct answer and total question they took.
tblQuestion
All the question and the last time it occured.
If you don't mind about how big your database is or how complex it is.
tblUser
--Well all the user information if neccesary
tblQuestion
--List of all questions
tblAnswers
--List of all answer
tblAnswersQuestion
--Link the answer table and question table
[B]tblResult[B]
--Store when the user answer the question, is that correct or not and how long it take him to answer that...
With this structure sure you could calculate the statistic easily. But I think it's over the top a bit.
.Net Developer - 3D Game Designer
My Portfolio/Blog: http://www.hieu.co.uk
My Portfolio/Blog: http://www.hieu.co.uk
•
•
Join Date: Dec 2008
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
Well, I'm not so sure though. If this is just a random multiple question everyday then I would go with this design:
- We will show a label as question and a few Radiobox for answer.
- Select a random question which the last occured is more than a week or well, you decide it.
- A timer control, every second it go up, 1 point will be decrease from the total point.
Quick-And-Easy
DB
tblUser
All the information, their correct answer and total question they took.
tblQuestion
All the question and the last time it occured.
If you don't mind about how big your database is or how complex it is.
tblUser
--Well all the user information if neccesary
tblQuestion
--List of all questions
tblAnswers
--List of all answer
tblAnswersQuestion
--Link the answer table and question table
[B]tblResult[B]
--Store when the user answer the question, is that correct or not and how long it take him to answer that...
With this structure sure you could calculate the statistic easily. But I think it's over the top a bit.
I've actually added a DateTimePicker control and only allow the user to select the time so that the user can specify the timing of the question to be set on each day. However, its giving me a syntax error in the SQL insert into statement
sql = "insert into questions(qdate, ques, ans1, ans2, ans3, ans4, ans, prize, time) values('" +
dtpQues.Value.ToString("dd-MMM-yyyy") + "','" +
dtpTime.Value.ToString("hh:mm:ss tt") + "','" +
txtQues.Text + "','" +
txtAns1.Text + "','" +
txtAns2.Text + "','" +
txtAns3.Text + "','" +
txtAns4.Text + "','" +
right + "','" +
txtPrize.Text + "'" +
")";
I think the error lies in this:
dtpTime.Value.ToString("hh:mm:ss tt") + "','" +
It somehow complains about the format, but I have actually set the custom format to be hh:mm:ss tt.
Any ideas?
Thanks.
![]() |
Similar Threads
- Design Problem: Dealing with multiple time frames (C++)
- Alot of Feature (Post your Resume)
- 48 Hours - Celebrity Trivia - 100 Custom Audio Questions - Unique Concept (Websites for Sale)
- $1000+/month in profit (steadily for the past 2 months) - 300+ uniques/day - EWebProz (Websites for Sale)
- URGENT!! - Constructive Criticism needed on www.giftday.co.za (Website Reviews)
- I have some questions that I need help with (Networking Hardware Configuration)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- *** Press Release Offer *** (Post your Resume)
- looking for "real world" C++ code (C++)
- Best Hosting Method (Networking Hardware Configuration)
Other Threads in the C# Forum
- Previous Thread: image dragging in win mobile
- Next Thread: Read data from database using array
| Thread Tools | Search this Thread |
.net access ado.net algorithm animation array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datastructure datetime degrees development directrobot draganddrop drawing encryption enum event excel file form format forms function gdi+ hash httpwebrequest image index input install java label lisp list listbox mandelbrot math mouseclick mysql native operator path photoshop picturebox pixelinversion post print process programming radians regex remote remoting richtextbox safari serialization server sleep snooze socket sql statistics stream string table tables tcp text textbox thread time timer update usercontrol usercontrols validation visualstudio webbrowser windows winforms wpf xml






