Online Quiz App || Part-5 || Android Project For Resume || Open Trivia Database || Android Studio

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] n [Music] welcome back once again in this video we are going to build this squeeze activity where you can actually play the game trust me you are going to learn lot of new things you can see we have a progress bar and here a timer also but before moving forward let me show you something as you can see 94 % of people who watched my video haven't subscribed and if you are among those Please Subscribe my channel because it keeps me motivated to make new videos and also we are very close to 700 subscribers so please subscribe for free now let's move to our project first we will create an activity for quiz so let's do it quickly okay it's done now we have to build the UI I spend lots of time to build as good as possible I will copy and paste the code from GitHub I suggest you to build yourself and then take help this way your progress will be better but if you want then it's okay to directly copy paste done with copy paste now we have errors to solve let's remove one by one these errors occurred because those files are missing let's add those missing [Music] [Music] files [Music] [Music] [Music] I guess we have resolved all the errors previous we created a quiz question data class and now we need to make it serializable because we have to pass list of this data class from one activity to another now let's open Quiz class and make some [Music] changes let's remove this interface because we don't don't need it anymore when we get questions successfully by calling this method then we want to start quiz activity and send questions to the quiz activity for that we first create an intent and then we put extra in [Music] [Music] it [Music] here we are getting an error because question list is of type list but we have have to pass error list so let's convert list to error list which is very simple and now there is no error finally we can start new activity let's call that function when we click on any item of recycler view let's pass 10 number of questions and for category let's pass ID and rest should be null so that it will be random all set let's move to piz activity and first we Implement view binding now let's receive question list which we passed from Main [Music] activity [Music] now we have list of questions then let's make a method which will display the question on the [Music] activity we need a position to access questions one by [Music] one after setting of questions let's create a method which will display the options here we have created a variable for the correct answer which is of type a string and a variable for option list which is of type list of strings here we have separate correct answer and list of incorrect answers so I want to create a method which will return list with correct answer and incorrect options and they are randomized let's quickly create this [Music] method and obviously we need to pass correct answer and the list of incorrect options so that we can mix them in a list and then create a random list first we add correct answer to this list and then we add one by one all the incorrect answers from the list and finally we will Shuffle the list so that all the options in the list get randomized and finally I want this function to return correct answer as well as the suffer option list pair is a good option if you want to return two values and now we can display the options on text View for the options we have created in the UI of this activity make sure to change the values during the copy paste currently we display only two options then we check if question type is of multiple if question is of multiple type then we first make third and fourth option text view visible then we display third and fourth options there and don't forget to make changes after copy and paste [Music] what if question is not of multiple type then it is of type Gan that means we only have two options that's why we need to hide last two options in this case we have a next button in quiz activity let's add functionality to it for that we create a method called on a [Music] next first we check if position is less than the size of the question list then we increase position by one and then display the question and option also now it's time to test our application uh something is fishy here questions and options are in something of different code for format so we need to find the solution how to correct [Music] it in order to find solution I gave Chad Gip the question and asked why this a string not normal and how can I fix it it says this string is HTML encoded and gives some methods to fix original string fix to original string so let's implement it in our project first we create a method which take HTML encoded a string and return normal a [Music] [Music] string let's use this method to fix our problem now it's time to test our application so let's see and all set we have removed our problem this position variable is complaining about something it says let's make it private now we are going to code timer then we will code for Progress bar we have used timer lots of time in our previous projects so it will be easy here to code first we created an object for countdown time timer now let's write a function to start the timer first we set the max value of countdown timer progress bar to 20 and its progress should also be 20 because we are going to decrease per [Music] second first value we need to pass here for how long countdown time will run and second value is how long one pick these values are in [Music] milliseconds for each tick which is of 1 second interval we decrease the progress of circular progress bar and display the remaining time in timer text view since it is millisecond so first we convert it in second by dividing by th000 and then convert it into a string now we want to a start timer when quiz activity starts or when we click on next button let's set the text for our progress bar which will indicate the position of question when we click on next button first we need to cancel the timer when we click on next button we also need to increase the [Music] progress in the end we will start the [Music] timer and I am forgetting to add maximum value for the progress bar which will display the question position it's the time to test our application and we can see timer is working fine let's see and progress part is also working good now we have to write code for options selection and making decision whether selected option is correct or not then change the option button color according to that first we will create an object for on click listener it will return the view which we click on and we only want to take action when allow first we have toop the timer then we select an option then we change the color of background of that button let's create a variable for the [Music] color by this way we can create an object of our drawable file I guess red background for button is not available in [Music] dyable so we have to create one let's do it [Music] quickly [Music] done with red button at last we have to show the correct answer let's create a method to show correct [Music] answer let's write code for Show correct answer method let's create an object for blue background color which will represent correct answer here also we have to create blue color background now we check which button holds the correct answer and change its background color to [Music] Blue [Music] [Music] [Music] let also create a method which will reset the background colors of buttons now we have to make some changes in on next method first we will change allow playing to true and we also need to reset the background color let's add on clicks listener to the buttons I forgeted earlier we also need to calculate a score based on our selection so let's make a function named set a score and here we will pass the view as a button we will check if the selected button is correct or not and if it is correct then we will set the a [Music] [Music] score we are going to assign a score B on three parameters first what is the type of the question second what is the difficulty level of the question that is easy medium or hard and lastly how fast you solve the question or how fast you selected the option if it's Boolean then we assign 0.5 marks and if it is multiple choice we will assign one marks out of 20 we calculate the fraction of time remaining and assign it to a score two now for the third score it will be decided by the difficulty level of the [Music] question finally we will return the sum of all three scores when it's time up we need to show the correct answer answer as well as stop the playing option now it's time to test our application let's see and yes it is working if we click on wrong option it will be read and the correct answer will be shown and if you click on correct answer it only shows blue let's wait for 20 second and see what's what will happen on times up okay when we out of time only correct answer will be shown in next video we are going to build result activity which will display the result but before that we need to prepare some data so that we can send it to result activity let's prepare that data so these are the data we need to pass from T activity to result activity and we need to make it serializable all we need to do is to make a object for result model and add it to a list and that list need to be passed to result activity [Music] [Music] [Music] [Music] that's it for this video if you learn something new please like this video And subscribe my channel if you haven't thank you and see you in the next video
Info
Channel: Develop Ideas
Views: 359
Rating: undefined out of 5
Keywords:
Id: Uhy7mQNch20
Channel Id: undefined
Length: 31min 49sec (1909 seconds)
Published: Sat Dec 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.