locked
Asking Help with Quiz Project RRS feed

  • Question

  • User-2060576634 posted

    Hi folks,
    I'm trying to design an online quiz project using asp.net web pages and SQL. I've already created my Questions database table with several columns containing QuestionId, Question, 1stChoice, 2ndChoice, 3rdChoice, 4thChoice, and CorrectAnswer. I've also created my student answers table containing StudentId, Q1, Q2, Q3, ... Q10.
    now for my quiz page I need a code to extract the 10 questions (all at once. not wizard style) along with their 4 choices and display choices as radio buttons and when the logged in user answers the question and  clicks the submit button i need the information to be stored in the answers table regarding each users row.

    I also have to mention that the user should have the option not to answer some questions so I also have to store the unanswerd questions as null. is this possible with radios? or I have to add another radio button stating "skip question" or should i totally chose another approach?   how is this thing done? thanks..

    Monday, January 5, 2015 10:22 AM

Answers

All replies

  • User-821857111 posted

    This article should give you some clues about managing radios for your scenario: http://www.mikesdotnetting.com/article/218/managing-checkboxes-and-radios-in-asp-net-razor-web-pages

    Radios would be the way I would do this, by the way.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 5, 2015 11:00 AM
  • User379720387 posted

    That is all possible.

    Check out one of these surveys to see how they do that. Think I remember seeing check boxes, but I am not sure.

    I would recommend that you add to your table the no answer scenario. It will be easier to display and manage later.

    Monday, January 5, 2015 11:04 AM
  • User-2060576634 posted

    which surveys? and whats the no answer scenario??

    Tuesday, January 6, 2015 1:26 PM
  • User-2060576634 posted

    I've read that article before Mike.. surely useful.. but not exactly what I'm looking for.. I Guess web pages doesn't have enough resources after all.. only 2 main tutorials on Asp.net website.. the movies website which is so simple that can be learned in a day or two.. but doesn't feature many functions..  and the officially-broken soccer website tutorial which is so sophisticated and overcrowded with Javascript and Jquery that the tutor misses the main point!.. is there any other tutorial in this universe simply describing the proper way of data handling??

    Tuesday, January 6, 2015 1:40 PM
  • User-821857111 posted

    What aspect of data handling are you struggling with?

    Tuesday, January 6, 2015 2:16 PM
  • User-2060576634 posted

    collecting user info (logged in users of course) by radio forms and storing in a table (along with their user ids)

    Tuesday, January 6, 2015 2:22 PM
  • User-821857111 posted

    It's pretty basic stuff in all honesty and covered in a combination of the article I linked to and the basic web pages tutorials you have already found. Short of writing a fully working example of a quiz project for you, I'm not sure what other help can be provided.

    Tuesday, January 6, 2015 2:37 PM
  • User-2060576634 posted

    yes .. it seems basic to me also.. but the first tutorial doesn't involve handling individual user input at all.. and the second one is too confusing.. I've decided to read a textbook i recently found about web pages and webmatrix ... i hope i can get on track as soon as possible..

    Tuesday, January 6, 2015 2:48 PM
  • User379720387 posted

    Why do you say the soccer websites is officialy-broken?

    Anyway, start with the starter site template.

    Create your tables.

    Create your form.

    Tuesday, January 6, 2015 3:31 PM
  • User-2060576634 posted

    I call it broken because the example code can't be downloaded.. the link is broken..  I downloaded it with the help of Mike.. by the way .. i know how to make a table .. i know how to make a form.. i just don't know how to pass the values chosen by the user to the table..

    Tuesday, January 6, 2015 3:57 PM
  • User-821857111 posted

    The data tutorial should help you: http://www.asp.net/web-pages/overview/data

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2015 4:38 PM
  • User-2060576634 posted

    it quite helps but it doesn't directly involve userId.. I'll give it a try anyway..

    Tuesday, January 6, 2015 4:46 PM
  • User-821857111 posted

    The security tutorials will cover that.

    http://www.asp.net/web-pages/overview/security

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 6, 2015 5:04 PM
  • User-2060576634 posted

    I'm looking for a resource that fully explains the following lines and functions .. I'm sure it has not been discussed in the mentioned articles..

     // Check if the user has logged on to the site.
        WebSecurity.RequireAuthenticatedUser();
      
           
        // Get the ID of the current logged on user.
        int userId = WebSecurity.CurrentUserId;

       
        // Check if this is a postback that requires the data to be updated.
        if (IsPost)
        {
                    // Check if user has a row in the MemberRides table for this match.
                        var existingRow = db.Query("SELECT * FROM MemberRides "
                            + "WHERE MemberId = @0 AND MatchId = @1",
                            userId, match.matchId);
                        if (existingRow.Count > 0)
                        {
                            // Update the existing row in the MemberRides table.
                            rowsAffected = db.Execute("UPDATE MemberRides "
                                + "SET SeatsAvailableOrRequired = @0 "
                                + "WHERE MemberId = @1 AND MatchId = @2",
                                ridesValue, userId, match.matchId);
                        }
                        else
                        {
                            // Add a new row to the MemberRides table.
                            rowsAffected= db.Execute("INSERT INTO MemberRides(MemberId, "
                                + "MatchId, SeatsAvailableOrRequired) VALUES (@0, @1, @2)",
                                userId, match.matchId, ridesValue);
                        }

    Tuesday, January 6, 2015 5:19 PM
  • User379720387 posted

    Try this

    Tuesday, January 6, 2015 5:50 PM
  • User-2060576634 posted

    I found this link offending mr. Wavemaster! I already know what google is! and that wasn't what i was looking for!

    Tuesday, January 6, 2015 6:01 PM
  • User379720387 posted

    Simply helping you along on your education path.

    You did ask non specific questions.  Our time has value too, so narrow things down and be specific  about your question.

    This is what you said:

    I'm looking for a resource that fully explains the following lines and functions .. I'm sure it has not been discussed in the mentioned articles..

     // Check if the user has logged on to the site.
        WebSecurity.RequireAuthenticatedUser();

    What is your question?

    Tuesday, January 6, 2015 6:39 PM
  • User-821857111 posted

    I would have thought the comments in the code do a pretty good job of explaining what each code section does. Beyond that, as wavemaster said, if you have specific questions about specific lines of code, please ask them. 

    Wednesday, January 7, 2015 1:58 AM
  • User-2060576634 posted

    OK..  sorry to take your valuable time.. I'll do a lot of study and come back with more specific questions..

    Wednesday, January 7, 2015 4:21 AM
  • User379720387 posted

    Another thing you could consider is running the code through Visual Studio in debug mode. You can see what is going on.

    Wednesday, January 7, 2015 5:40 AM