teaching machines

Homework1 – Quizzle

September 29, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

Overview:

After bouncing around a few ideas, I finally settled on a simple quiz application in a bit of a “Who Wants To Be A Millionaire” format (1 question, 4 answers).

                          

Right now I have 10 default questions loaded in the game.  A user can either cycle through the questions and answer specific ones first using the “Next” and “Prev” buttons in the corners, or they can guess an answer by pressing one of the buttons.  After the user places a guess, a sound plays whether or not they were correct, and then the text on the answer buttons highlight an appropriate color to show the user the correct answers.  Once a user places a guess, the answer buttons are disabled so they cannot re-guess.  Once every question has had a guess placed, the app moves to a summary screen in which the question stats are listed and then given a rank based on their guess percentage.

When the user clicks on the question textView, Android’s built in Text-To-Speech reads out the question, followed by each of the possible answers.  When I first heard of this capability I though it would be pretty difficult but it was actually very easy!

private TextToSpeech tts = new TextToSpeech(this, this); –>Placed in my activity onCreate
tts.speak(String s, TextToSpeech.QUEUE_ADD, null); –> In my textView onClickListener
And that’s it!

One other thing I ran into was sharing information between activities.  I needed to communicate with my summary activity how many questions the user got right, as well as how many questions there were total.  This is done by placing “Extras” in the intent:

intent.putExtra(“CORRECT_ANSWERS”, correctQuestions());
intent.putExtra(“TOTAL_QUESTIONS”, questions.size());

Then on the summary activity end, I can pull the extras down by accessing the keys I created:

Bundle extras = getIntent().getExtras();
int correct = extras.getInt(“CORRECT_ANSWERS”);
int total = extras.getInt(“TOTAL_QUESTIONS”);

In the future I could implement a Sound preference to turn on and off the text to speech and the answer sound effects.  I could also include a way for the user to edit the questions and answers through a dialog interface.