|
| 1 | +package com.emmyolusola.tableassessment; |
| 2 | + |
| 3 | +import android.support.v7.app.AppCompatActivity; |
| 4 | +import android.os.Bundle; |
| 5 | +import android.widget.Button; |
| 6 | +import android.widget.RadioButton; |
| 7 | +import android.widget.RadioGroup; |
| 8 | +import android.widget.TextView; |
| 9 | + |
| 10 | +import java.util.ArrayList; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +public class Questions extends AppCompatActivity { |
| 14 | + |
| 15 | + List<QuizObject> currentQuestionsList; |
| 16 | + int quizListPosition; |
| 17 | + RadioButton optionsButton1; |
| 18 | + RadioButton optionsButton2; |
| 19 | + RadioButton optionsButton3; |
| 20 | + RadioButton optionsButton4; |
| 21 | + private int currentQuestionPos; |
| 22 | + private TextView questTV; |
| 23 | + private RadioGroup group; |
| 24 | + private Button next; |
| 25 | + private Button prev; |
| 26 | + |
| 27 | + @Override |
| 28 | + protected void onCreate(Bundle savedInstanceState) { |
| 29 | + super.onCreate(savedInstanceState); |
| 30 | + setContentView(R.layout.activity_questions); |
| 31 | + |
| 32 | + quizListPosition = getIntent().getIntExtra("quizListPosition", 0); |
| 33 | + |
| 34 | + currentQuestionPos = getIntent().getIntExtra("quizListPosition", 0); //start pos |
| 35 | + initializeViews(); |
| 36 | + currentQuestionsList = loadQuestionsAtPos(quizListPosition); |
| 37 | + updateUI(currentQuestionPos); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Updates the Current Questions |
| 42 | + * |
| 43 | + * @param currentQuestionPos |
| 44 | + */ |
| 45 | + private void updateUI(int currentQuestionPos) { |
| 46 | + |
| 47 | + QuizObject quiz = currentQuestionsList.get(currentQuestionPos); |
| 48 | + questTV.setText(quiz.getQuestions()); |
| 49 | + |
| 50 | + for(String opt : quiz.getOptions().get(currentQuestionPos)){ |
| 51 | +// group.addView(new RadioButton()); |
| 52 | + } |
| 53 | +// optionsButton1.setText(quiz.getOptions()); |
| 54 | + QuizObject object; |
| 55 | + } |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + private void initializeViews() { |
| 60 | + questTV = (TextView)findViewById(R.id.text_question); |
| 61 | + group = (RadioGroup) findViewById(R.id.radio_group); |
| 62 | + optionsButton1 = (RadioButton)findViewById(R.id.option_a); |
| 63 | + optionsButton2 = (RadioButton)findViewById(R.id.option_b); |
| 64 | + optionsButton3 = (RadioButton)findViewById(R.id.option_c); |
| 65 | + optionsButton4 = (RadioButton)findViewById(R.id.option_d); |
| 66 | + next = (Button)findViewById(R.id.next_button); |
| 67 | + prev = (Button)findViewById(R.id.prev_button); |
| 68 | + } |
| 69 | + |
| 70 | + private List<QuizObject> loadQuestionsAtPos(int position){ |
| 71 | + |
| 72 | + List<QuizObject> loadedQuestionsList = new ArrayList<>(); |
| 73 | + |
| 74 | + switch (position){ |
| 75 | + case 0: |
| 76 | + String[] Q0 = getResources().getStringArray(R.array.Faith_Is_The_Substance); //array of loadQuestionsAtPos in faith is the substance |
| 77 | + |
| 78 | + List<String[]> options_arr0 = new ArrayList<>(); // list of options array |
| 79 | + |
| 80 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_one)); |
| 81 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_two)); |
| 82 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_three)); |
| 83 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_four)); |
| 84 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_five)); |
| 85 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_six)); |
| 86 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_seven)); |
| 87 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_eight)); |
| 88 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_nine)); |
| 89 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_ten)); |
| 90 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_eleven)); |
| 91 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_twelve)); |
| 92 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_thirteen)); |
| 93 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_fourteen)); |
| 94 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_fifteen)); |
| 95 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_sixteen)); |
| 96 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_seventeen)); |
| 97 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_eighteen)); |
| 98 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_nineteen)); |
| 99 | + options_arr0.add(getResources().getStringArray(R.array.Faith_Is_The_Substance_opt_twenty)); |
| 100 | + |
| 101 | + String[] A0 = getResources().getStringArray(R.array.Faith_Is_The_Substance_ans); |
| 102 | + |
| 103 | + for (int i = 0; i < Q0.length; i++){ |
| 104 | + loadedQuestionsList.add(new QuizObject(Q0[i], options_arr0, A0[i])); |
| 105 | + } |
| 106 | + |
| 107 | + for (int i = 0; i < options_arr0.get(0).length; i++){ |
| 108 | + optionsButton1.setText(options_arr0.get(0)[0]); |
| 109 | + optionsButton2.setText(options_arr0.get(1)[1]); |
| 110 | + optionsButton3.setText(options_arr0.get(2)[2]); |
| 111 | + optionsButton4.setText(options_arr0.get(3)[3]); |
| 112 | + } |
| 113 | + break; |
| 114 | + |
| 115 | + case 1: |
| 116 | + //array of loadQuestionsAtPos in The Manifestation of the Spirit |
| 117 | + String[] Q1 = getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit); |
| 118 | + |
| 119 | + List<String[]> options_arr1 = new ArrayList<>(); // list of options array |
| 120 | + //adding options array to list |
| 121 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_one)); |
| 122 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_two)); |
| 123 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_three)); |
| 124 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_four)); |
| 125 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_five)); |
| 126 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_six)); |
| 127 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_seven)); |
| 128 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_eight)); |
| 129 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_nine)); |
| 130 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_ten)); |
| 131 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_eleven)); |
| 132 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_twelve)); |
| 133 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_thirteen)); |
| 134 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_fourteen)); |
| 135 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_fifteen)); |
| 136 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_sixteen)); |
| 137 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_seventeen)); |
| 138 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_eighteen)); |
| 139 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_nineteen)); |
| 140 | + options_arr1.add(getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_opt_twenty)); |
| 141 | + |
| 142 | + String[] A1 = getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit_ans); |
| 143 | + |
| 144 | + for (int i = 0; i < Q1.length; i++){ |
| 145 | + loadedQuestionsList.add(new QuizObject(Q1[i], options_arr1, A1[i])); |
| 146 | + } |
| 147 | + break; |
| 148 | + |
| 149 | +// case 2: |
| 150 | +// //array of loadQuestionsAtPos in The Manifestation of the Spirit |
| 151 | +// String[] Q2 = getResources().getStringArray(R.array.The_Manifestation_Of_The_Spirit); |
| 152 | +// |
| 153 | +// List<String[]> options_arr2 = new ArrayList<>(); // list of options array |
| 154 | +// |
| 155 | +// options_arr2.add(getResources().getStringArray(R.array.Life_Of_Demons_And_Visions)); |
| 156 | + } |
| 157 | + return loadedQuestionsList; |
| 158 | + } |
| 159 | +} |
0 commit comments