Multiple questions in a day

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2008
Posts: 5
Reputation: randr is an unknown quantity at this point 
Solved Threads: 0
randr randr is offline Offline
Newbie Poster

Multiple questions in a day

 
0
  #1
Dec 9th, 2008
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:

  1.  
  2. private string GetCurrentQuestion()
  3. {
  4. string str = "";
  5. DataAccess da = new DataAccess();
  6. DataSet ds = new DataSet();
  7. da.Connect();
  8. ds = da.GetData("select * from questions where qdate = #" + DateTime.Now.ToString("dd-MMM-yyyy") + "#");
  9. if (ds.Tables[0].Rows.Count > 0)
  10. {
  11. str = "Question: " + ds.Tables[0].Rows[0]["ques"].ToString();
  12. str += "\nA." + ds.Tables[0].Rows[0]["ans1"].ToString();
  13. str += "\nB." + ds.Tables[0].Rows[0]["ans2"].ToString();
  14. str += "\nC." + ds.Tables[0].Rows[0]["ans3"].ToString();
  15. str += "\nD." + ds.Tables[0].Rows[0]["ans4"].ToString();
  16. }
  17. else
  18. {
  19. str = "Sorry! No Questions Today! Try again Tomorrow!";
  20. }
  21. da.Disconnect();
  22. return str;
  23. }
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: Multiple questions in a day

 
0
  #2
Dec 9th, 2008
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: randr is an unknown quantity at this point 
Solved Threads: 0
randr randr is offline Offline
Newbie Poster

Re: Multiple questions in a day

 
0
  #3
Dec 10th, 2008
Originally Posted by Murtan View Post
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?
Its simply to implement more than 1 question for a day. Its like a quiz application, allowing the user to choose several questions to be answered.

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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: Multiple questions in a day

 
0
  #4
Dec 10th, 2008
The current database search uses 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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Multiple questions in a day

 
0
  #5
Dec 10th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 44
Reputation: hieuuk is an unknown quantity at this point 
Solved Threads: 4
hieuuk hieuuk is offline Offline
Light Poster

Re: Multiple questions in a day

 
0
  #6
Dec 10th, 2008
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.
.Net Developer - 3D Game Designer
My Portfolio/Blog: http://www.hieu.co.uk
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Multiple questions in a day

 
0
  #7
Dec 10th, 2008
Well with the questions per day thing you could dump their previous count each morning at midnight.
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: randr is an unknown quantity at this point 
Solved Threads: 0
randr randr is offline Offline
Newbie Poster

Re: Multiple questions in a day

 
0
  #8
Dec 15th, 2008
Originally Posted by hieuuk View Post
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.
Thanks for all the help guys, I've solved it with placing a new column named time in the database file.

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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: Multiple questions in a day

 
0
  #9
Dec 15th, 2008
Is time a reserved word? Could you name the column qtime like you did qdate?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: randr is an unknown quantity at this point 
Solved Threads: 0
randr randr is offline Offline
Newbie Poster

Re: Multiple questions in a day

 
0
  #10
Dec 15th, 2008
Originally Posted by Murtan View Post
Is time a reserved word? Could you name the column qtime like you did qdate?
I do not think so, I have tried and its still the same. I think it might have something to do with the SQL statement because I tried following the same format to display the date and its giving me syntax error.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC