Merge pull request #166 from secretrobotron/t163

Better score readout in quiz.
This commit is contained in:
Brian Mwadime 2016-07-15 15:31:07 +03:00 коммит произвёл GitHub
Родитель 60df975610 bb6f7d928c
Коммит 5e59413f52
5 изменённых файлов: 17 добавлений и 11 удалений

Просмотреть файл

@ -74,8 +74,8 @@ public class IconQuizActivity extends AppCompatActivity implements LoaderManager
private static final String TAG = makeLogTag(IconQuizActivity.class);
private static final int LOADER_ID = 0x02;
List<Question> quizList = new ArrayList<Question>();
int score=0;
int question_id=0;
int score = 0;
int question_id = 0;
Question currentQuestion;
private String mQuiz;
TextView quizStepView, quizStepScore;
@ -115,6 +115,7 @@ public class IconQuizActivity extends AppCompatActivity implements LoaderManager
if(checkedId != -1){
CheckableLinearLayout checkedView = (CheckableLinearLayout) findViewById(checkedId);
checkAnswer(checkedView);
quizStepScore.setText(getString(R.string.quiz_template_score, score, quizList.size()));
}
}
});
@ -177,7 +178,6 @@ public class IconQuizActivity extends AppCompatActivity implements LoaderManager
if(currentQuestion.getANSWER().equals(checkedView.getTag()))
{
score++;
quizStepScore.setText(getString(R.string.quiz_template_score, score));
correct = true;
}else {
correct = false;
@ -190,11 +190,13 @@ public class IconQuizActivity extends AppCompatActivity implements LoaderManager
Intent intent = new Intent(IconQuizActivity.this, ResultActivity.class);
Bundle scoreBundle = new Bundle();
scoreBundle.putInt("score", score);
scoreBundle.putInt("total", quizList.size());
intent.putExtras(scoreBundle); // Send user score to your next Intent
startActivity(intent);
finish();
}
quizGroup.clearCheck();
return correct;
}
@ -283,8 +285,10 @@ public class IconQuizActivity extends AppCompatActivity implements LoaderManager
quizList = randomizedQuizList;
score = 0;
currentQuestion = quizList.get(question_id);
setQuestionView(currentQuestion);
quizStepScore.setText(getString(R.string.quiz_template_score, score, quizList.size()));
}
}

Просмотреть файл

@ -33,10 +33,13 @@ public class ResultActivity extends AppCompatActivity {
ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);
TextView txtPoints = (TextView) findViewById(R.id.quizResult);
//get score
//get score and total
Bundle b = getIntent().getExtras();
int score = b.getInt("score");
txtPoints.setText(getString(R.string.quiz_template_points, score));
int total = b.getInt("total");
txtPoints.setText(getString(R.string.quiz_result_score, score, total));
Analytics.add("Icon Quiz Finished", new Integer(score).toString());

Просмотреть файл

@ -20,7 +20,7 @@
android:gravity="center_horizontal"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:layout_height="wrap_content"
android:text="@string/placeholder_quiz_score"
android:text="@string/quiz_template_score"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_gravity="center_horizontal"

Просмотреть файл

@ -22,7 +22,7 @@
android:textColor="@color/colorTextPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/quiz_template_points"
android:text="@string/quiz_result_score"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:layout_margin="@dimen/activity_horizontal_margin"

Просмотреть файл

@ -11,8 +11,7 @@
<string name="title_template_step">Step <xliff:g id="step_number">%1$d</xliff:g>: Lorem
Ipsum</string>
<string name="tutorial_template_step">Step <xliff:g id="current_step_number">%1$d</xliff:g> of <xliff:g id="total_step_number">%2$d</xliff:g></string>
<string name="quiz_template_score">Score: <xliff:g id="current_score">%1$d</xliff:g></string>
<string name="quiz_template_step">Question <xliff:g id="current_quiz_number">%1$d</xliff:g>/<xliff:g id="total_quiz_number">%2$d</xliff:g></string>
<string name="quiz_template_score">Score: <xliff:g id="quiz_score">%1$d</xliff:g> / <xliff:g id="quiz_total">%2$d</xliff:g></string>
<string name="action_previous">Previous</string>
<string name="action_next">Next</string>
<string name="action_finish">Finish</string>
@ -40,8 +39,8 @@
<string name="empty_tutorial">Oops! No content here. Please try the next tutorial.</string>
<string name="game_over_text">Game Over!</string>
<string name="play_again_text">Play Again</string>
<string name="quiz_template_points"><xliff:g id="current_step_number">%1$d</xliff:g> Points</string>
<string name="placeholder_quiz_score">Score: 0</string>
<string name="quiz_result_score">Score: <xliff:g id="quiz_score">%1$d</xliff:g> / <xliff:g id="quiz_total">%2$d</xliff:g></string>
<string name="placeholder_quiz_score"><xliff:g id="quiz_score">%1$d</xliff:g> / <xliff:g id="quiz_total">%2$d</xliff:g></string>
<string name="quiz_challenge_text">Ready for a challenge?</string>
<string name="quiz_title_text">Choose the icon&#8230;</string>
<string name="title_activity_iconquiz">Icon Quiz</string>