Presenter:Bob Tabor (from LearnVisualStudio.NET)
In this lesson, you will begin to lay out the web pages for the Quiz Engine and create some of the initial code required. This will allow you to exercise the skills developed in the earlier videos.
Click here to go to original video page
The following text is a software generated transcript of the video. Click on a minute link to jump to a location within the video
Minute 0
It is your start looking at the snapshots for the development of our ASP net 2 0 quiz engine but just recap the previous video a snapshot is the present state of the application at a given moment in time to reach our to development on the stop working or save off the current state of the code and then I ll explain what is accomplished soon this viewer to look at the first three snapshots the first snapshot took about two hours and what I accomplished during that two hour timeframe well as you can see here I ve added a number of pages to a project we have the full page to questions page recover password results and starts to look at each of these recover preferably the start page
Minute 1
And then finally the results page and as you can see the each have kind of a similar look and feel of basically created one as a template use the table for layout purposes and then copy that table from page to page changing the graphics and some of the text in each of the pages the graphics I used from what my friend provided for me the graphic artist for some of the the titles like the results of this starting quiz now graphic question graphics so one as I merely just with drag and drop from the images folder each individual item into place on my little table template files over to the exercise of applying the cascading style sheet that my friend graphic arts critic for me as resolve the previous video and applied that every control
Minute 2
And the taxable see this of a primarily within the default aspx page where the Texas I typed in Persepolis will login a passage here as well to all the text in all the given properties that modify the very language aspects of each of the controls of those had to be modified to a loan to the cascading style sheet tags that were great for me and that is a considerable amount of time to go to locate all those properties and change them appropriately but if the majority of the time on the default aspx page and what I decided to do here was combine several the operational elements of the site onto the single page and I did after the use of the login so if I as we saw mocked out there were different pages for login for register a new user and then ultimately the default page where the user can see their test history and the available on a cat
Minute 3
Us that they can take what I did was combine those all together into a single login views what you re looking at right now is the view of the page as a user comes in and is not authenticated have not logged in yet once they successfully logged in to the website however we want to do is in display the logged in template which will show the available tests the test result history of allow them to perform some basic account maintenance like change the password and so on solicit a look at what this accomplished local go ahead run button to start debugging button on our own or a toolbar and we can see our application pop opened for going to login using admin
Minute 4
RG and then the number one so uppercase tea lowercase a access the asked symbol lowercased WOR TV one so passed at were one and click the login button and then our login view will display the available tests the test results a stream so one is see here we have our little on a control that allows us to see if the current user or we been able to change that tax based on whether or not they are authenticated and so on and we do that through the use of this login name control to limit also have a lot instead is controlled allows them to your login or logout based on what authenticated are not currently on the site so basically what we did was just tackle a lot of the easy stuff first answer to ease into the development process saw essentially create the skeleton of the application in
Minute 5
Out one of dive into some specific parts of the application and more fully flush them out and so the next thing that really felt like I needed to do was address the database and real look at that in the next snapshot sewer currently to look at snapshot number two and the only thing that really did with in the last half hour 45 minutes of the snapshot was to create our quiz MDF database and in that database I added three tables the quiz table question table and the user quiz will take a look at each of these tables in just a moment talk a high level about the relationship between the quiz MDF and the ASP net TB MDF to recall this file is four for more produce discussions while it s the database that will contain the values for the membership rolls
Minute 6
Of functionality within it has begun it to auto whenever we go to the aesthetic configuration tool D website administration tool and click security and go to manager users and looked Re at a user called admin here that that data in the roles that that user is associated with are stored in that ASP net TB MDF file or go to want associate certain elements of our quiz back to the users within our table we are within our guest event DB MDF file particularly each user will have the historical results of the quizzes they ve taken stored within our quiz database Cubs taken these three tables this question quiz and user quiz tables and add them to the ASP net TB MDF file I think I could ve done that now just for separation purposes because also comfortable with modifying the file just yet I
Minute 7
Decided as a design decision to keep them in their own MDF file as ramifications for that decision and I ll point those out in just a moment but until comfortable with changing or adulterating this automatically generated ASP net TB MDF a file because again working with a beta version of the software and as we all know things can change out from under us additionally had a moral lock myself into any specific implementation and case in future versions of the software the database schema changes so that s just a design decision I made it was a difficult choice to make however it s one that I may know how to live with and there are some ramifications I noticed a moment ago not the least of which is when I try to associate back all the values the historical values for a given quiz for a given user of the less first multi look at the quiz table
Minute 8
Very simple straightforward simply a a primary key called quiz ID and the title of the quiz and we may well come back to this little a little later in a future snapshot and change or add some values here so that we can guess more scripted text about a given quiz does the work for now each quiz has a number of questions that are associated with it here s where another typical design decision came in below here that we see some typical stop the question ID the primary key at the very bottom had the quiz ID which is the 14 back to the quiz tables of quizzes will have one or more questions associate with them you ll see that there is the title which will be the actual question and then there s a series of answers one to three and four and this is where the difficult decision came in the database designer within me felt it would be appropriate to put the answers in their own table the software developer and sodomy decided that it be easier if I just Dean normalized them back into a very ominous wharf
Minute 9
Last structure for my table and put each of the answers in their own given columns make it very easy when I go to pull those answers are the database to the display on my question aspx page now as a result of that design decision I basically locked myself into a certain specific implementation of the words ignore the multiple choice and there have to be essentially for her questions there can t be farther campy 30 or rather answers that only be for answers ABC NT and so for my purposes in this little application that works just fine however it s less than robust less than feature filled when compared to some commercial versions of quiz engines that are available on the market today but it s a decision that I m going to have to live with for this time so eerie we have the
Minute 10
Available answers in this holds a saying that goes something like this normalize until it hurts denormalized until it works so I ve decided to take the latter route and to normalize those symptoms to look at it in the correct answer which will be the one to three or four the answer explanation which can be any long screen that explains why I get an answer is correct or incorrect the ordinal value the question orders so a given quiz has a number of questions this will keep track of the order that those questions should appear to the user and as we boarded looked at the quiz idea to foreign key field back to the quiz to not is a look at the user quiz table this will again store the historical results of a given user taking a given test so many of these fields are basically for associative purposes the user quiz ID is our primary key we have two
Minute 11
ID which associates back to a given quiz and then the username with associates with the ASP net DB MDF and if we were to drove down and take a look at the gift tables there is a table called as peanut users and within that there is a field called username so this will be essentially a non relational database and forced constraints so we ll have a of enforced this can strengthen our own code because SQL Server doesn t necessarily six first edition does allow constraints across multiple databases and if it does then it s a fairly complex procedure soul merely just do this well in code which comes with its own particular challenges it will really pay attention those at this point but that s essentially how were going to associate a historical quiz with how many correct answers of
Minute 12
Were from bad to that the quiz session and the date and time that the quiz was completed okay so that finishes up the second snapshot I remove on the third snapshot and try to take a first crack at some of this functionality is so you re in the third snapshot missed him about another hour and a half hour 45 minutes or so and my focus in this snapshot was to I get the process of displaying and retrieving the the questions and the answers are strictly from the user and sold most of the work that I did in that task was project that we reviewed in the previous video really came into play here if recall from that discussion we had to make a decision about how we re going to store the information from question question and others number of different ways of going about it could distort the values as a user goes for question one
Minute 13
Rushing to the question three for a given quiz could have persisted those within the database persisted them in XML or there s a number of ways we can persisted them in memory such as the view state object but we chose to use the session object because we ve been assured by the Senate to a team that this is something that we can rely on it will not be heavy burden from server perspectives or going to ahead and use and also we know that for our purposes is not to be a very high traffic website and quite honestly a more complex augmentation will take a lot of time a luxury that we simply don t have this point so there are three pages are involved in this process to start page questions page and results page user will start on the start page and the start button to get started with Clinton to look at the code behind and see what happens magically on this page personal notice that we needed some mechanism to hold onto the answers each
Minute 14
Asserted that the user gave so and we know the restored session but basically where did I came up with this solution where I want to use 18 with domain specific object class called question arms are recalled answer to save the values of each individual answerer that will then collect out and review on the final page the results page so close to start here the answer class has a question ID the correct answer and then the users answer in a read only property called result which will displace either contractor and correct depending on whether the user s answer was equal to the correct answer sold basically be using this object this answer object as its created after each question is answered by the user and added into a collection or use an array list
Minute 15
To store oldies individual answer objects at the very end of the process of of going through in and answer each of the individual questions will essentially iterate through each of these individual answer objects in our array list and then read the display them to the user and store them in to the database that so we re going to use this answer object beginning in the questions that is just paid for it if you re when you do first is to basically says to Emory aside for a new instance of our array list which were calling answer list and then we ve also created another session variable called the quiz ID and this will be very important as all the mystery here on the questions page okay so again for more discussion in the test was project which was sort of our scratchpad for coming up with some ideas of how will
Minute 16
Delay and allow the user to interact with each of the individual questions in our quizzes him that we re going to take slightly different approach than what might be out there normally just for brevity s sake and since we re going to use a detail view to display the question and the four answers and these will be displayed from our SQL data source and look at that as source in just a moment and then the usual be able to select the rancher from this combo boxes drop down list if we were to select the little tasks aero and select edit items you see that we hardcoded database or 1234 and the values are respectively one to three and four and those will be evaluated against the correct answer at the end of the process and cancel that for now and so Lessig look then add the question aspx VB and look at the page load
Minute 17
Is to have question details data binds all that happens there so the question comes in how does it know which set of questions to display we haven t told it what what quiz of the users currently taking and also we need to tell it at some point as well what the next question is a should be displayed to the user so both of these questions can be will resolve in how we implemented the SQL data sort go and click the configure data source select the next button and click next again and here you can see that we define a custom select statement solo question ID title answer one answer to registrants for correct answer or shorter from the question table where the quiz ID equals as parameter at quiz in that order by question order so high we send in this
Minute 18
Parameter this quiz ID will this were the the configure data source was erred in it s really cool and that is through the use of our session quiz ID measure recall in the a stark aspx thoughts VB page that we create a new session verbal culpas idea and we hardcoded this point to value one will change that up in the future but will hold from that value here in order populates this parameter so that s one of the neat things that doesn t require a lot of code we write were able to wire that up fairly quickly and easily just aren t referencing a given of a given field of our session object now we could ve grabbed that value from a cookie from a control from a form from the profile object
Minute 19
From query string however we chose to go the route of session and so on to choose the appropriate field and go him to cancel here so one big changes to that so as the page loads the SQL data source will look for the the quiz ID parameter find in the session retrieve all of the questions for this given quiz and then display the first one in our little at details view grid user clicks the next button was going to take a look at the code behind for the unwashed click event essentially what we need to do is create a new instance of our answer objects and add that to our answer list array list so here were doing is creating a new answer objects are our answer object looked old ago to test the
Minute 20
Properties question ID correct answer user answer in a read only result answer a pencils to back your recruiting of this record the question ID which will pull from the question order from the current row of data in our question details to the current data item in our a detail view control regret the correct answer is well from that from that data row view and then grabbed whatever the user selected in the answer drop down list Marina do is retrieve our answer list and add our new answer to it and then save it back in the sessions organized grab down plot the new answer and save back in the memory finally we need to tell of the next
Minute 21
Age what it should be displaying so again we want to set the page index for our question detail object that little grid for her that will display the details so based on the current page index and the number of pages that are in our rather retrieved by her data source and will either increment the of the page index or will just do a response redirect to the results noticed if it got so also take a look at the results of its guest page is fairly straightforward first thing that we see here is we talked a grid that will display each of the individual question numbers with the correct answer was with the user s answer was and then weather was correct or incorrect when the user selects an individual row to review the answer to display the question over the question
Minute 22
Four possible answers the correct answer in the explanation all pulled from the database of this data would be pulled directly from our answer list data rate was that we been holding onto her session object when the user selects one of the rows will combine it with the list of questions from our question database so will filter was displayed here by the selection care how we accomplished that will most take a look first of all what we did and select the edit columns to concede that we just created a four Brownfields question correct answer your answer and result making sure that the data field is set correctly to what we called it in our answer objects and these are all properties of our answer object user answer seas will be bound to automatically by ASP net shadow
Minute 23
Colt s cancel that somewhere is a select column comparable really to look at the properties solicit a four close first Citta for a keyboard the brim for properties window and you take a look at this auto generate select button set equal to true that s what adds this selects column here with you one other thing in that it is to change the on let s see if an owner ago Jackie James feels it has to be said to assess what is the equivalent of the primary key in this case is going to question ID the unique identifier that separates one question from the next question so in that case within our answer object that s the question ID field so that we select one or will have a unique result will be displayed below okay so now will save a look at this sequel data source is really nothing special is goes on to
Minute 24
At all what is retrieving all of the columns except look was that he was a big mistake to come back and fix from the question to cancel that and will no tear that our details view is then bound to does data source or we want to display just any row from our data support source we only want displayed the role that was selected here in the select button column on our data grid house that accomplished was to go look at the results for you to and look at the result grid_selected and exchanged event will see that we apply a filter expression to the SQL data source said that that he feel that question ID equal to whatever the selected value was of that grid so give her pulling weather was one to three or four arrests and mats to this the
Minute 25
To expression for only this way a corresponding question with all the answers correct answer all that information here in this grid solo single in the salesforce okay so here we go where going to run our application and get the start page to start button and so we ve got a bunch of silly questions that I just entered for the purpose of testing this from a famous Monty Python skit soulless start selecting some answers to some questions here click the finish button and we can see now how many answers are correct and incorrect with the correct answer was versus what our answer was and then by solar
Minute 26
Ping one of the items here we can review it here in the bottom along with with the correct answer was in the explanation for that given item okay so everything is coming along very nicely made a lot of progress here s a couple of hours for some refinements that need to be addressed and sold to do in the next video or two as we continue on looking at further snapshots or we have left to do actually got quite a bit to do first of all we haven t really recorded any of the results into the database and remain to do that here in the results aspx page then we haven t displayed in the default aspx page would have displayed on any of the and political theater s go to the login template this still need to be fleshed out the available tests to test result history and so on so got so credited to want at smaller features as well
Minute 27
But were also great start in sword and conclude this video for now thank you
Thursday, May 29, 2008
Video: Building a Quiz Engine 2
Labels:
quiz engine
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment