Search in sources :

Example 1 with FillBlankQuiz

use of com.google.samples.apps.topeka.model.quiz.FillBlankQuiz in project android-topeka by googlesamples.

the class CategoryAndroidTest method getQuizzes.

private static List<Quiz> getQuizzes() {
    List<Quiz> quizzes = new ArrayList<>();
    quizzes.add(new TrueFalseQuiz("huh?", true, false));
    quizzes.add(new FillBlankQuiz("so?", "yeah", "go", "stop", false));
    return quizzes;
}
Also used : FillBlankQuiz(com.google.samples.apps.topeka.model.quiz.FillBlankQuiz) Quiz(com.google.samples.apps.topeka.model.quiz.Quiz) TrueFalseQuiz(com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz) FillBlankQuiz(com.google.samples.apps.topeka.model.quiz.FillBlankQuiz) ArrayList(java.util.ArrayList) TrueFalseQuiz(com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz)

Example 2 with FillBlankQuiz

use of com.google.samples.apps.topeka.model.quiz.FillBlankQuiz in project android-topeka by googlesamples.

the class SolveQuizUtil method solveQuiz.

/**
     * Solves a given quiz.
     *
     * @param quiz Quiz to solve.
     */
public static void solveQuiz(Quiz quiz) {
    switch(quiz.getType()) {
        case ALPHA_PICKER:
            setAlphaPickerProgress((AlphaPickerQuiz) quiz);
            break;
        case PICKER:
            setPickerProgress((PickerQuiz) quiz);
            break;
        case FILL_BLANK:
            FillBlankQuiz fillBlankQuiz = (FillBlankQuiz) quiz;
            String siblingText = fillBlankQuiz.getStart();
            if (TextUtils.isEmpty(siblingText)) {
                siblingText = fillBlankQuiz.getEnd();
            }
            int viewId = R.id.quiz_edit_text;
            if (TextUtils.isEmpty(siblingText)) {
                siblingText = quiz.getQuestion();
                viewId = R.id.quiz_content;
            }
            typeAndCloseOnView(fillBlankQuiz.getAnswer(), siblingText, viewId);
            break;
        case FILL_TWO_BLANKS:
            FillTwoBlanksQuiz fillTwoBlanksQuiz = (FillTwoBlanksQuiz) quiz;
            typeAndCloseOnView(fillTwoBlanksQuiz.getAnswer()[0], R.id.quiz_edit_text);
            typeAndCloseOnView(fillTwoBlanksQuiz.getAnswer()[1], R.id.quiz_edit_text_two);
            break;
        case FOUR_QUARTER:
            testOptionsQuizWithType(quiz, GridView.class);
            break;
        case SINGLE_SELECT:
        case SINGLE_SELECT_ITEM:
        case MULTI_SELECT:
            testOptionsQuizWithType(quiz, ListView.class);
            break;
        case TOGGLE_TRANSLATE:
            ToggleTranslateQuiz toggleTranslateQuiz = (ToggleTranslateQuiz) quiz;
            for (int i : toggleTranslateQuiz.getAnswer()) {
                onData(equalTo(toggleTranslateQuiz.getReadableOptions()[i])).inAdapterView(allOf(instanceOf(AdapterView.class), withId(R.id.quiz_content), hasSiblingWith(quiz.getQuestion()))).perform(click());
            }
            break;
        case TRUE_FALSE:
            TrueFalseQuiz trueFalseQuiz = (TrueFalseQuiz) quiz;
            onView(allOf(isDescendantOfA(hasSibling(withText(quiz.getQuestion()))), withText(trueFalseQuiz.getAnswer() ? R.string.btn_true : R.string.btn_false))).perform(click());
            break;
    }
}
Also used : FillBlankQuiz(com.google.samples.apps.topeka.model.quiz.FillBlankQuiz) AdapterView(android.widget.AdapterView) ToggleTranslateQuiz(com.google.samples.apps.topeka.model.quiz.ToggleTranslateQuiz) FillTwoBlanksQuiz(com.google.samples.apps.topeka.model.quiz.FillTwoBlanksQuiz) TrueFalseQuiz(com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz)

Aggregations

FillBlankQuiz (com.google.samples.apps.topeka.model.quiz.FillBlankQuiz)2 TrueFalseQuiz (com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz)2 AdapterView (android.widget.AdapterView)1 FillTwoBlanksQuiz (com.google.samples.apps.topeka.model.quiz.FillTwoBlanksQuiz)1 Quiz (com.google.samples.apps.topeka.model.quiz.Quiz)1 ToggleTranslateQuiz (com.google.samples.apps.topeka.model.quiz.ToggleTranslateQuiz)1 ArrayList (java.util.ArrayList)1