├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ │ ├── drawable-v24
│ │ │ │ ├── quizeicon.jpg
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ ├── ic_launcher_round.png
│ │ │ │ └── ic_launcher_foreground.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── array.xml
│ │ │ │ └── strings.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── roundable.xml
│ │ │ │ ├── roundable2.xml
│ │ │ │ ├── circular.xml
│ │ │ │ ├── ic_iconfinder.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ │ ├── settings_activity.xml
│ │ │ │ ├── fragment_answers.xml
│ │ │ │ ├── fragment_questions.xml
│ │ │ │ ├── activity_solution.xml
│ │ │ │ ├── alert_dialog.xml
│ │ │ │ ├── relative.xml
│ │ │ │ ├── activity_home.xml
│ │ │ │ └── activity_quiz.xml
│ │ │ └── xml
│ │ │ │ └── settings_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── immadisairaj
│ │ │ │ └── quiz
│ │ │ │ ├── api
│ │ │ │ ├── Api.java
│ │ │ │ ├── ApiCount.java
│ │ │ │ ├── QuizQuestions.java
│ │ │ │ ├── CategoryQuestionCount.java
│ │ │ │ └── Result.java
│ │ │ │ ├── question
│ │ │ │ └── Question.java
│ │ │ │ ├── solution
│ │ │ │ ├── QuestionsFragment.java
│ │ │ │ ├── SimpleFragmentPagerAdapter.java
│ │ │ │ ├── AnswersFragment.java
│ │ │ │ ├── QuestionsAdapter.java
│ │ │ │ └── AnswerAdapter.java
│ │ │ │ ├── SettingActivity.java
│ │ │ │ ├── SolutionActivity.java
│ │ │ │ ├── QuizActivity.java
│ │ │ │ └── HomeActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── immadisairaj
│ │ │ └── quiz
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── immadisairaj
│ │ └── quiz
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── screenshots
├── 1.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
├── 5.jpg
├── 6.jpg
├── 7.jpg
└── 8.jpg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── gradle.xml
├── misc.xml
└── codeStyles
│ └── Project.xml
├── .gitignore
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── PULL_REQUEST_TEMPLATE.md
├── gradle.properties
├── .travis.yml
├── LICENSE
├── CONTRIBUTING.md
├── gradlew.bat
├── CODE_OF_CONDUCT.md
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/screenshots/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/1.jpg
--------------------------------------------------------------------------------
/screenshots/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/2.jpg
--------------------------------------------------------------------------------
/screenshots/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/3.jpg
--------------------------------------------------------------------------------
/screenshots/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/4.jpg
--------------------------------------------------------------------------------
/screenshots/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/5.jpg
--------------------------------------------------------------------------------
/screenshots/6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/6.jpg
--------------------------------------------------------------------------------
/screenshots/7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/7.jpg
--------------------------------------------------------------------------------
/screenshots/8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/screenshots/8.jpg
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/quizeicon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/drawable-v24/quizeicon.jpg
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArjiBhandhavi/Quiz/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 | /.idea/*
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #5663a4
4 | #1f295c
5 | #5663a4
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 | 70dp
4 | 10dp
5 | 15sp
6 | 30dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/immadisairaj/quiz/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/roundable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
10 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/settings_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/roundable2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
13 |
18 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an feature for the project
4 |
5 | ---
6 |
7 | **Describe the feature you'd like**
8 |
9 |
10 |
11 | **Additional context**
12 |
13 |
14 |
15 | **Screenshots**
16 |
17 |
18 |
19 | **Would you like to work on the issue?**
20 |
21 |
22 |
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Fixes #[Add issue number here. Note: This will automatically close the issue. If you do not solve the issue entirely, please change the message e.g. "First steps for issues #IssueNumber]
2 |
3 | Changes: [Add here what changes were made in this issue and if possible provide links.]
4 |
5 | Please make sure these boxes are checked before submitting your pull request - thanks you!
6 |
7 | - [ ] Run unit tests with `./gradlew check` to make sure you didn't break anything
8 |
9 | - [ ] If you have multiple commits please combine them into a single commit by squashing them.
10 |
11 | Please add screenshots/GIFs here if there are any changes to the UI.
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/api/Api.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.api;
2 |
3 | import retrofit2.Call;
4 | import retrofit2.http.GET;
5 | import retrofit2.http.Query;
6 |
7 | public interface Api {
8 |
9 | String BASE_URL = "https://opentdb.com/";
10 |
11 | @GET("api.php")
12 | Call getQuizQuestions(
13 | @Query("encode") String encode,
14 | @Query("amount") Integer amount,
15 | @Query("difficulty") String difficulty,
16 | @Query("category") Integer category);
17 |
18 | @GET("api_count.php")
19 | Call getQuizQuestions(
20 | @Query("category") Integer category);
21 |
22 | }
--------------------------------------------------------------------------------
/app/src/main/res/xml/settings_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_answers.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_questions.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 |
3 | language: android
4 | android:
5 | components:
6 | # The BuildTools version used by your project
7 | - build-tools-28.0.3
8 | # The SDK version used to compile your project
9 | - android-28
10 | - android-22
11 | - sys-img-armeabi-v7a-android-22
12 |
13 | before_install:
14 | - yes | sdkmanager "platforms;android-28"
15 | - chmod +x gradlew
16 |
17 | script:
18 | - ./gradlew build connectedCheck
19 | - ./gradlew build jacocoTestReport
20 |
21 | before_script:
22 | - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
23 | - emulator -avd test -no-audio -no-window &
24 | - android-wait-for-emulator
25 | - adb shell input keyevent 82 &
26 |
27 | after_success:
28 | - bash <(curl -s https://codecov.io/bash)
29 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/api/ApiCount.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.api;
2 | import com.google.gson.annotations.SerializedName;
3 |
4 | public class ApiCount {
5 |
6 | @SerializedName("category_id")
7 | private int categoryId;
8 |
9 | @SerializedName("category_question_count")
10 | private CategoryQuestionCount categoryQuestionCount;
11 |
12 | public void setCategoryId(int categoryId){
13 | this.categoryId = categoryId;
14 | }
15 |
16 | public int getCategoryId(){
17 | return categoryId;
18 | }
19 |
20 | public void setCategoryQuestionCount(CategoryQuestionCount categoryQuestionCount){
21 | this.categoryQuestionCount = categoryQuestionCount;
22 | }
23 |
24 | public CategoryQuestionCount getCategoryQuestionCount(){
25 | return categoryQuestionCount;
26 | }
27 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/immadisairaj/quiz/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.immadisairaj.quiz", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/api/QuizQuestions.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.api;
2 |
3 | import java.util.List;
4 |
5 | import com.google.gson.annotations.Expose;
6 | import com.google.gson.annotations.SerializedName;
7 |
8 | public class QuizQuestions {
9 |
10 | @SerializedName("response_code")
11 | @Expose
12 | private Integer responseCode;
13 | @SerializedName("results")
14 | @Expose
15 | private List results = null;
16 |
17 |
18 | public QuizQuestions() {
19 | }
20 |
21 | public QuizQuestions(Integer responseCode, List results) {
22 | super();
23 | this.responseCode = responseCode;
24 | this.results = results;
25 | }
26 |
27 | public Integer getResponseCode() {
28 | return responseCode;
29 | }
30 |
31 | public List getResults() {
32 | return results;
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_solution.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a bug report to help us improve
4 |
5 | ---
6 |
7 | **Describe the bug**
8 |
9 |
10 |
11 | **Expected Behaviour**
12 |
13 |
14 |
15 | **Steps to reproduce it**
16 |
17 |
18 |
19 | **LogCat for the issue**
20 |
21 |
22 |
23 | **Screenshots of the issue**
24 |
25 |
26 |
27 | **Smartphone Info:**
28 |
29 | | | |
30 | |---------------|-|
31 | |Device ||
32 | |Android Version| |
33 |
34 | **Would you like to work on the issue?**
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/question/Question.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.question;
2 |
3 | import android.content.Context;
4 |
5 | import com.example.immadisairaj.quiz.api.Result;
6 |
7 | import java.io.Serializable;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | public class Question implements Serializable {
12 |
13 | public transient Context context;
14 | public List results;
15 |
16 | public List question;
17 |
18 |
19 | public List optA;
20 | public List optB;
21 | public List optC;
22 | public List optD;
23 | public List Answer;
24 |
25 | public Question() {
26 |
27 | }
28 |
29 | public Question(Context context) {
30 | this.context = context;
31 | question = new ArrayList<>();
32 | results = new ArrayList<>();
33 | optA = new ArrayList<>();
34 | optB = new ArrayList<>();
35 | optC = new ArrayList<>();
36 | optD = new ArrayList<>();
37 | Answer = new ArrayList<>();
38 | }
39 |
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Sai Rajendra Immadi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/solution/QuestionsFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.solution;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | import com.example.immadisairaj.quiz.R;
13 | import com.example.immadisairaj.quiz.SolutionActivity;
14 |
15 | import butterknife.BindView;
16 | import butterknife.ButterKnife;
17 |
18 |
19 | public class QuestionsFragment extends Fragment {
20 |
21 | @BindView(R.id.rv_questions)
22 | RecyclerView solutions;
23 |
24 | @Nullable
25 | @Override
26 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
27 | View view = inflater.inflate(R.layout.fragment_questions, container, false);
28 |
29 | ButterKnife.bind(this, view);
30 |
31 | QuestionsAdapter questionsAdapter = new QuestionsAdapter(SolutionActivity.getQuestion());
32 | solutions.setAdapter(questionsAdapter);
33 |
34 | return view;
35 | }
36 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/api/CategoryQuestionCount.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.api;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | public class CategoryQuestionCount{
6 |
7 | @SerializedName("total_hard_question_count")
8 | private int totalHardQuestionCount;
9 |
10 | @SerializedName("total_easy_question_count")
11 | private int totalEasyQuestionCount;
12 |
13 | @SerializedName("total_medium_question_count")
14 | private int totalMediumQuestionCount;
15 |
16 | @SerializedName("total_question_count")
17 | private int totalQuestionCount;
18 |
19 | public void setTotalHardQuestionCount(int totalHardQuestionCount){
20 | this.totalHardQuestionCount = totalHardQuestionCount;
21 | }
22 |
23 | public int getTotalHardQuestionCount(){
24 | return totalHardQuestionCount;
25 | }
26 |
27 | public void setTotalEasyQuestionCount(int totalEasyQuestionCount){
28 | this.totalEasyQuestionCount = totalEasyQuestionCount;
29 | }
30 |
31 | public int getTotalEasyQuestionCount(){
32 | return totalEasyQuestionCount;
33 | }
34 |
35 | public void setTotalMediumQuestionCount(int totalMediumQuestionCount){
36 | this.totalMediumQuestionCount = totalMediumQuestionCount;
37 | }
38 |
39 | public int getTotalMediumQuestionCount(){
40 | return totalMediumQuestionCount;
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/alert_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
25 |
26 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/solution/SimpleFragmentPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.solution;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentPagerAdapter;
8 |
9 | import com.example.immadisairaj.quiz.R;
10 |
11 | public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
12 |
13 | private Context mContext;
14 |
15 | public SimpleFragmentPagerAdapter(Context context, FragmentManager fm) {
16 | super(fm);
17 | mContext = context;
18 | }
19 |
20 | @Override
21 | public Fragment getItem(int i) {
22 | if (i == 0) {
23 | return new AnswersFragment();
24 | } else {
25 | return new QuestionsFragment();
26 | }
27 | }
28 |
29 | @Nullable
30 | @Override
31 | public CharSequence getPageTitle(int position) {
32 | switch(position) {
33 | case 0:
34 | return mContext.getString(R.string.answers);
35 | case 1:
36 | return mContext.getString(R.string.q_reference);
37 | default:
38 | return null;
39 | }
40 | }
41 |
42 | @Override
43 | public int getCount() {
44 | return 2;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/relative.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
29 |
30 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
17 |
21 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/circular.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
10 |
11 |
12 |
17 |
18 |
19 |
20 | -
21 |
26 |
27 |
32 |
33 |
34 |
39 |
40 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/solution/AnswersFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.solution;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.annotation.NonNull;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 |
13 | import com.example.immadisairaj.quiz.R;
14 | import com.example.immadisairaj.quiz.SolutionActivity;
15 | import com.example.immadisairaj.quiz.question.Question;
16 |
17 | import java.util.ArrayList;
18 |
19 | import butterknife.BindView;
20 | import butterknife.ButterKnife;
21 |
22 |
23 | public class AnswersFragment extends Fragment {
24 |
25 | @BindView(R.id.rv_answers)
26 | RecyclerView solutions;
27 |
28 | Question q;
29 |
30 | @Nullable
31 | @Override
32 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
33 | View view = inflater.inflate(R.layout.fragment_answers, container, false);
34 |
35 | ButterKnife.bind(this, view);
36 |
37 | ArrayList Answers = SolutionActivity.getAnswer();
38 |
39 | AnswerAdapter answerAdapter = new AnswerAdapter(Answers,
40 | SolutionActivity.getAnswers(),
41 | SolutionActivity.getOptA(),
42 | SolutionActivity.getOptB(),
43 | SolutionActivity.getOptC(),
44 | SolutionActivity.getOptD());
45 | solutions.setAdapter(answerAdapter);
46 |
47 | return view;
48 | }
49 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/api/Result.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.api;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 | import com.google.gson.annotations.Expose;
6 | import com.google.gson.annotations.SerializedName;
7 |
8 | public class Result implements Serializable {
9 |
10 | @SerializedName("category")
11 | @Expose
12 | private String category;
13 | @SerializedName("type")
14 | @Expose
15 | private String type;
16 | @SerializedName("difficulty")
17 | @Expose
18 | private String difficulty;
19 | @SerializedName("question")
20 | @Expose
21 | private String question;
22 | @SerializedName("correct_answer")
23 | @Expose
24 | private String correctAnswer;
25 | @SerializedName("incorrect_answers")
26 | @Expose
27 | private List incorrectAnswers = null;
28 |
29 |
30 | public Result() {
31 | }
32 |
33 | public Result(String category, String type, String difficulty, String question, String correctAnswer, List incorrectAnswers) {
34 | super();
35 | this.category = category;
36 | this.type = type;
37 | this.difficulty = difficulty;
38 | this.question = question;
39 | this.correctAnswer = correctAnswer;
40 | this.incorrectAnswers = incorrectAnswers;
41 | }
42 |
43 | public String getCategory() {
44 | return category;
45 | }
46 |
47 | public String getType() {
48 | return type;
49 | }
50 |
51 | public String getDifficulty() {
52 | return difficulty;
53 | }
54 |
55 | public String getQuestion() {
56 | return question;
57 | }
58 |
59 | public String getCorrectAnswer() {
60 | return correctAnswer;
61 | }
62 |
63 | public List getIncorrectAnswers() {
64 | return incorrectAnswers;
65 | }
66 |
67 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_iconfinder.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
18 |
19 |
27 |
28 |
38 |
39 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/solution/QuestionsAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.solution;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.example.immadisairaj.quiz.R;
11 |
12 | import java.util.List;
13 |
14 | import butterknife.BindView;
15 | import butterknife.ButterKnife;
16 |
17 | public class QuestionsAdapter extends RecyclerView.Adapter {
18 | private List Questions;
19 |
20 | QuestionsAdapter(List questions) {
21 | Questions = questions;
22 | }
23 |
24 | @NonNull
25 | @Override
26 | public QuestionsAdapter.QuestionsViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
27 | return new QuestionsAdapter.QuestionsViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.relative, viewGroup, false));
28 | }
29 |
30 | @Override
31 | public void onBindViewHolder(@NonNull QuestionsAdapter.QuestionsViewHolder questionsViewHolder, int i) {
32 | String qus ="Q."+(i + 1);
33 | String question = Questions.get(i);
34 |
35 | questionsViewHolder.question.setText(qus);
36 | questionsViewHolder.answered.setText(question);
37 | questionsViewHolder.correct.setVisibility(View.GONE);
38 | }
39 |
40 | @Override
41 | public int getItemCount() {
42 | return Questions.size();
43 | }
44 |
45 | class QuestionsViewHolder extends RecyclerView.ViewHolder {
46 |
47 | @BindView(R.id.tv_question)
48 | TextView question;
49 |
50 | @BindView(R.id.tv_answered)
51 | TextView answered;
52 |
53 | @BindView(R.id.tv_correct)
54 | TextView correct;
55 |
56 | QuestionsViewHolder(@NonNull View itemView) {
57 | super(itemView);
58 |
59 | ButterKnife.bind(this, itemView);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## How to Contribute
2 |
3 | ### Raising an issue:
4 | This is an Open Source project and we would be happy to see contributors who report bugs and file feature requests submitting pull requests as well.
5 | This project adheres to the Contributor Covenant code of conduct.
6 | By participating, you are expected to uphold this code style.
7 | Please report issues here [Issues - immadisairaj/Quiz](https://github.com/immadisairaj/Quiz/issues)
8 |
9 | ### Branch Policy
10 |
11 | #### Sending pull requests:
12 |
13 | Go to the repository on github at https://github.com/immadisairaj/Quiz .
14 |
15 | Click the “Fork” button at the top right.
16 |
17 | You’ll now have your own copy of the original Quiz repository in your github account.
18 |
19 | Open a terminal/shell.
20 |
21 | Type
22 |
23 | `$ git clone https://github.com/username/Quiz`
24 |
25 | where 'username' is your username.
26 |
27 | You’ll now have a local copy of your version of the original Quiz repository.
28 |
29 | #### Change into that project directory (Quiz):
30 |
31 | `$ cd Quiz`
32 |
33 | #### Add a connection to the original Quiz repository.
34 |
35 | `$ git remote add upstream https://github.com/immadisairaj/Quiz`
36 |
37 | #### To check this remote add set up:
38 |
39 | `$ git remote -v`
40 |
41 | #### Make changes to files.
42 |
43 | `git add` and `git commit` those changes
44 |
45 | `git push` them back to github. These will go to your version of the repository.
46 |
47 |
48 | #### Now Create a PR (Pull Request)
49 |
50 | Go to your version of the repository on github.
51 |
52 | Click the “New pull Request” button at the top.
53 |
54 | Note that your friend’s repository will be on the left and your repository will be on the right.
55 |
56 | Click the green button “Create pull request”. Give a succinct and informative title, in the comment field give a short explanation of the changes and click the green button “Create pull request” again.
57 |
58 | #### Pulling others’ changes
59 | Before you make further changes to the repository, you should check that your version is up to date relative to original version.
60 |
61 | Go into the directory for the project and type:
62 |
63 | `$ git checkout development`
64 | `$ git pull upstream development --rebase`
65 |
66 | This will pull down and merge all of the changes that have been made in the original Quiz repository.
67 |
68 | Now push them back to your github repository.
69 |
70 | `$ git push origin development`
71 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.example.immadisairaj.quiz"
7 | minSdkVersion 17
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | debug {
15 | testCoverageEnabled true
16 | }
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'jacoco'
26 |
27 | jacoco {
28 | toolVersion = '0.8.0'
29 | }
30 |
31 | tasks.withType(Test) {
32 | jacoco.includeNoLocationClasses = true
33 | }
34 |
35 | task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
36 |
37 | reports {
38 | xml.enabled = true
39 | html.enabled = true
40 | }
41 |
42 | def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
43 | def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/debug", excludes: fileFilter)
44 | def mainSrc = "$project.projectDir/src/main/java"
45 |
46 | sourceDirectories = files([mainSrc])
47 | classDirectories = files([debugTree])
48 | executionData = fileTree(dir: project.buildDir, includes: [
49 | 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec'
50 | ])
51 | }
52 |
53 | dependencies {
54 | implementation fileTree(dir: 'libs', include: ['*.jar'])
55 | implementation 'com.android.support:appcompat-v7:28.0.0'
56 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
57 | testImplementation 'junit:junit:4.12'
58 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
59 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
60 | implementation 'com.android.support:design:28.0.0'
61 | implementation 'com.android.support:recyclerview-v7:28.0.0'
62 | implementation 'com.jakewharton:butterknife:8.8.1'
63 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
64 | implementation 'com.squareup.retrofit2:retrofit:2.3.0'
65 | implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
66 | }
67 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/SettingActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz;
2 |
3 | import android.content.SharedPreferences;
4 |
5 | import android.preference.ListPreference;
6 | import android.preference.Preference;
7 | import android.preference.PreferenceFragment;
8 | import android.preference.PreferenceManager;
9 | import android.support.annotation.Nullable;
10 | import android.support.v7.app.AppCompatActivity;
11 | import android.os.Bundle;
12 |
13 | public class SettingActivity extends AppCompatActivity {
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.settings_activity);
19 | }
20 |
21 | public static class QuizPreferenceFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener {
22 | @Override
23 | public void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | addPreferencesFromResource(R.xml.settings_main);
26 | Preference list_preference_difficulty = findPreference(getString(R.string.difficulty_key));
27 | Preference list_preference_category = findPreference(getString(R.string.category_key));
28 | list_preference_difficulty.setOnPreferenceChangeListener(this);
29 | list_preference_category.setOnPreferenceChangeListener(this);
30 | bindPreferenceSummaryToValue(list_preference_difficulty);
31 | bindPreferenceSummaryToValue(list_preference_category);
32 | }
33 |
34 | private void bindPreferenceSummaryToValue(Preference preference) {
35 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(preference.getContext());
36 | String value = sharedPreferences.getString(preference.getKey(), " ");
37 | onPreferenceChange(preference, value);
38 |
39 | }
40 |
41 | @Override
42 | public boolean onPreferenceChange(Preference preference, Object newValue) {
43 | String stringValue = newValue.toString();
44 | ListPreference listPreference = (ListPreference) preference;
45 | int prefIndex = listPreference.findIndexOfValue(stringValue);
46 | if (prefIndex >= 0) {
47 | CharSequence[] labels = listPreference.getEntries();
48 | preference.setSummary(labels[prefIndex]);
49 | }
50 | return true;
51 | }
52 |
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/SolutionActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.design.widget.TabLayout;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.AppCompatActivity;
9 |
10 | import com.example.immadisairaj.quiz.solution.SimpleFragmentPagerAdapter;
11 |
12 | import java.util.ArrayList;
13 |
14 | import butterknife.BindView;
15 | import butterknife.ButterKnife;
16 |
17 | public class SolutionActivity extends AppCompatActivity {
18 |
19 | static ArrayList Answers;
20 | static ArrayList Question;
21 | static ArrayList optA;
22 | static ArrayList optB;
23 | static ArrayList optC;
24 | static ArrayList optD;
25 | static ArrayList Answer;
26 |
27 | @BindView(R.id.viewpager)
28 | ViewPager viewPager;
29 |
30 | @BindView(R.id.sliding_tabs)
31 | TabLayout tabLayout;
32 |
33 | @Override
34 | protected void onCreate(@Nullable Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_solution);
37 | ButterKnife.bind(this);
38 |
39 | Answers = getIntent().getIntegerArrayListExtra("Answer");
40 | Answer = getIntent().getIntegerArrayListExtra("Answers");
41 | Question = getIntent().getStringArrayListExtra("Question");
42 | optA = getIntent().getStringArrayListExtra("optA");
43 | optB = getIntent().getStringArrayListExtra("optB");
44 | optC = getIntent().getStringArrayListExtra("optC");
45 | optD = getIntent().getStringArrayListExtra("optD");
46 |
47 | SimpleFragmentPagerAdapter adapter = new SimpleFragmentPagerAdapter(this, getSupportFragmentManager());
48 | viewPager.setAdapter(adapter);
49 |
50 | tabLayout.setupWithViewPager(viewPager);
51 | }
52 |
53 | @Override
54 | public void onBackPressed() {
55 | Intent intent = new Intent(this,HomeActivity.class);
56 | startActivity(intent);
57 | }
58 |
59 | public static ArrayList getAnswer() {
60 | return Answers;
61 | }
62 |
63 | public static ArrayList getAnswers() {
64 | return Answer;
65 | }
66 |
67 | public static ArrayList getQuestion() {
68 | return Question;
69 | }
70 |
71 | public static ArrayList getOptA() {
72 | return optA;
73 | }
74 |
75 | public static ArrayList getOptB() {
76 | return optB;
77 | }
78 |
79 | public static ArrayList getOptC() {
80 | return optC;
81 | }
82 |
83 | public static ArrayList getOptD() {
84 | return optD;
85 | }
86 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/array.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - @string/easy
5 | - @string/medium
6 | - @string/hard
7 |
8 |
9 |
10 | - @string/easy_value
11 | - @string/medium_value
12 | - @string/hard_value
13 |
14 |
15 |
16 | - @string/any_category
17 | - @string/gk
18 | - @string/entertainment_books
19 | - @string/entertainment_film
20 | - @string/entertainment_music
21 | - @string/entertainment_musical_theatres
22 | - @string/entertainment_television
23 | - @string/entertainment_video
24 | - @string/entertainment_board
25 | - @string/science_nature
26 | - @string/science_computer
27 | - @string/science_maths
28 | - @string/mythology
29 | - @string/sports
30 | - @string/geography
31 | - @string/history
32 | - @string/politics
33 | - @string/arts
34 | - @string/celebrity
35 | - @string/animal
36 | - @string/vehicles
37 | - @string/entertainment_comics
38 | - @string/science_gadgets
39 | - @string/entertainment_japanese
40 | - @string/entertainment_cartoon
41 |
42 |
43 |
44 | - @string/any_category_value
45 | - @string/gk_value
46 | - @string/entertainment_books_value
47 | - @string/entertainment_film_value
48 | - @string/entertainment_music_value
49 | - @string/entertainment_musical_theatres_value
50 | - @string/entertainment_television_value
51 | - @string/entertainment_video_value
52 | - @string/entertainment_board_value
53 | - @string/science_nature_value
54 | - @string/science_computer_value
55 | - @string/science_maths_value
56 | - @string/mythology_value
57 | - @string/sports_value
58 | - @string/geography_value
59 | - @string/history_value
60 | - @string/politics_value
61 | - @string/arts_value
62 | - @string/celebrity_value
63 | - @string/animal_value
64 | - @string/vehicles_value
65 | - @string/entertainment_comics_value
66 | - @string/science_gadgets_value
67 | - @string/entertainment_japanese_value
68 | - @string/entertainment_cartoon_value
69 |
70 |
71 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at immadirajendra.sai@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | xmlns:android
11 |
12 | ^$
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | xmlns:.*
22 |
23 | ^$
24 |
25 |
26 | BY_NAME
27 |
28 |
29 |
30 |
31 |
32 |
33 | .*:id
34 |
35 | http://schemas.android.com/apk/res/android
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | .*:name
45 |
46 | http://schemas.android.com/apk/res/android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | name
56 |
57 | ^$
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 | style
67 |
68 | ^$
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | .*
78 |
79 | ^$
80 |
81 |
82 | BY_NAME
83 |
84 |
85 |
86 |
87 |
88 |
89 | .*
90 |
91 | http://schemas.android.com/apk/res/android
92 |
93 |
94 | ANDROID_ATTRIBUTE_ORDER
95 |
96 |
97 |
98 |
99 |
100 |
101 | .*
102 |
103 | .*
104 |
105 |
106 | BY_NAME
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/solution/AnswerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz.solution;
2 |
3 | import android.graphics.Color;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 | import com.example.immadisairaj.quiz.R;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 |
19 | public class AnswerAdapter extends RecyclerView.Adapter {
20 | private ArrayList Answers;
21 | private List Answer;
22 | private List optA;
23 | private List optB;
24 | private List optC;
25 | private List optD;
26 |
27 | AnswerAdapter(ArrayList answers, List answer, List optionsA, List optionsB, List optionsC, List optionsD) {
28 | Answers = answers;
29 | Answer = answer;
30 | optA = optionsA;
31 | optB = optionsB;
32 | optC = optionsC;
33 | optD = optionsD;
34 | }
35 |
36 | @Override
37 | public int getItemCount() {
38 | return Answer.size();
39 | }
40 |
41 | @Override
42 | public void onBindViewHolder(@NonNull AnswerViewHolder answerViewHolder, int i) {
43 | String qus = "Q."+(i + 1);
44 | String ans;
45 | String corr = null;
46 |
47 | switch (Answers.get(i)) {
48 | default:
49 | ans = "Not Attempted";
50 | break;
51 | case 1:
52 | ans = 1 + ". " + optA.get(i);
53 | break;
54 | case 2:
55 | ans = 2 + ". " + optB.get(i);
56 | break;
57 | case 3:
58 | ans = 3 + ". " + optC.get(i);
59 | break;
60 | case 4:
61 | ans = 4 + ". " + optD.get(i);
62 | break;
63 | }
64 |
65 | switch (Answer.get(i)) {
66 | case 1:
67 | corr = 1 + ". " + optA.get(i);
68 | break;
69 | case 2:
70 | corr = 2 + ". " + optB.get(i);
71 | break;
72 | case 3:
73 | corr = 3 + ". " + optC.get(i);
74 | break;
75 | case 4:
76 | corr = 4 + ". " + optD.get(i);
77 | break;
78 | }
79 |
80 | answerViewHolder.question.setText(qus);
81 | answerViewHolder.answered.setText(ans);
82 | answerViewHolder.correct.setText(corr);
83 |
84 | if ( Answer.get(i).equals(Answers.get(i)) )
85 | answerViewHolder.answered.setTextColor(Color.GREEN);
86 | else
87 | answerViewHolder.answered.setTextColor(Color.RED);
88 | }
89 |
90 | @NonNull
91 | @Override
92 | public AnswerViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
93 | return new AnswerViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.relative, viewGroup, false));
94 | }
95 |
96 |
97 | class AnswerViewHolder extends RecyclerView.ViewHolder {
98 |
99 | @BindView(R.id.tv_question)
100 | TextView question;
101 |
102 | @BindView(R.id.tv_answered)
103 | TextView answered;
104 |
105 | @BindView(R.id.tv_correct)
106 | TextView correct;
107 |
108 | AnswerViewHolder(@NonNull View itemView) {
109 | super(itemView);
110 |
111 | ButterKnife.bind(this, itemView);
112 | }
113 | }
114 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Quiz
3 | Next
4 | Prev
5 | Submit
6 | View Answer
7 |
8 | Answers
9 | Questions
10 | Take Quiz
11 |
12 | // labels of list preference
13 | Easy
14 | Medium
15 | Hard
16 |
17 | General Knowledge
18 | Politics
19 | History
20 | Sports
21 | Geography
22 | Any Category
23 | Entertainment: Film
24 | Entertainment: Books
25 | Entertainment: Music
26 |
27 | Entertainment: Television
28 | Entertainment: Video Games
29 | Entertainment: Board Games
30 |
31 | Science: Computers
32 | Science: Maths
33 | Mythology
34 | Arts
35 | Celebrities
36 | Animals
37 | Vehicles
38 | Entertainment: Comics
39 | Science: Gadgets
40 |
41 |
42 |
43 | //keys of list preference
44 | easy
45 | medium
46 | hard
47 |
48 |
49 | 9
50 | 24
51 | 23
52 | 21
53 | 22
54 | 0
55 | 11
56 | 10
57 | 12
58 | 13>
59 | 14
60 | 15
61 | 16
62 | 17
63 | 18
64 | 19
65 | 20
66 | 25
67 | 26
68 | 27
69 | 28
70 | 29
71 | 30
72 | 31
73 | 32
74 |
75 |
76 | // list preference key and title
77 | Difficulty
78 | difficulty
79 |
80 | Category
81 | category
82 |
83 | Filter
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Quiz Android App
2 |
3 | [](https://GitHub.com/immadisairaj/Quiz/watchers/)
4 | [](https://GitHub.com/immadisairaj/Quiz/stargazers/)
5 | [](https://GitHub.com/immadisairaj/Quiz/network/members/)
6 |
7 |
8 | [](https://opensource.org/licenses/MIT)
9 | [](https://gitter.im/immadisairaj/Quiz?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
10 | [](https://travis-ci.org/immadisairaj/Quiz)
11 | [](https://codecov.io/gh/immadisairaj/Quiz)
12 | [](https://GitHub.com/immadisairaj/Quiz/issues/)
13 | [](https://GitHub.com/immadisairaj/Quiz/pulls/)
14 | [](https://GitHub.com/immadisairaj/Quiz/graphs/contributors/)
15 |
16 | ## Communication
17 |
18 | Our chat channel is on gitter [here](https://gitter.im/immadisairaj/Quiz)
19 |
20 | ## Development
21 |
22 | A native Android app using Java for writing code.
23 |
24 | ### Installing
25 |
26 | - Fork the repository.
27 | - Clone the repo using the terminal command. Make sure you replace `username` with your GitHub username.
28 | ```bash
29 | git clone https://github.com/username/Quiz.git
30 | ```
31 |
32 | First time contributors can read [CONTRIBUTION.md](https://github.com/immadisairaj/Quiz/blob/master/CONTRIBUTING.md) file for help regarding creating issues and sending pull requests.
33 |
34 | ### Setting up the Android Project
35 |
36 | 1. Download the Quiz project source. You can do this either by forking and cloning the repository (recommended if you plan on pushing changes) or by downloading it as a ZIP file and extracting it.
37 |
38 | 2. Open Android Studio, you will see a Welcome to Android window. Under Quick Start, select _Import Project (Eclipse ADT, Gradle, etc.)_
39 |
40 | 3. Navigate to the directory where you saved the Quiz project, select the root folder of the project (the folder named "Quiz"), and hit OK. Android Studio should now begin building the project with Gradle.
41 |
42 | 4. Once this process is complete and Android Studio opens, check the Console for any build errors.
43 |
44 | - _Note:_ If you receive a Gradle sync error titled, "failed to find ...", you should click on the link below the error message (if available) that says _Install missing platform(s) and sync project_ and allow Android studio to fetch you what is missing.
45 |
46 | 5. Once all build errors have been resolved, you should be all set to build the app and test it.
47 |
48 | 6. To Build the app, go to _Build>Make Project_ (or alternatively press the Make Project icon in the toolbar).
49 |
50 | 7. If the app was built successfully, you can test it by running it on either a real device or an emulated one by going to _Run>Run 'app'_ or pressing the Run icon in the toolbar.
51 |
52 |
53 | ### Libraries used and their documentation
54 |
55 | - Retrofit [Docs](http://square.github.io/retrofit/2.x/retrofit/)
56 | - Butter Knife [Docs](https://github.com/JakeWharton/butterknife/)
57 | - GSON Converter [Docs](https://github.com/square/retrofit/tree/master/retrofit-converters/gson/)
58 |
59 | ### API Used
60 |
61 | Open Trivia [Docs](https://opentdb.com/api_config.php/)
62 |
63 | Used Encoding `encode=url3986`
64 |
65 |
66 | ## Screenshots
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | ## Built With
87 |
88 | - Android Studio 3.4.1
89 | - Gradle 3.2.1
90 |
91 | ## Code of Conduct
92 |
93 | This project Code of Conduct is under the Contributor Covenant, see the [CODE_OF_CONDUCT.md](https://github.com/immadisairaj/Quiz/blob/master/CODE_OF_CONDUCT.md) for more details.
94 |
95 | ## License
96 |
97 | This project is licensed under the MIT License, see the [LICENSE.md](https://github.com/immadisairaj/Quiz/blob/master/LICENSE) for more details.
98 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_quiz.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
22 |
23 |
36 |
37 |
50 |
51 |
54 |
55 |
60 |
61 |
69 |
70 |
78 |
79 |
85 |
86 |
94 |
95 |
104 |
105 |
114 |
115 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/QuizActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.Intent;
5 | import android.graphics.drawable.Drawable;
6 | import android.os.Bundle;
7 | import android.support.v7.app.AlertDialog;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.widget.Button;
12 | import android.widget.ProgressBar;
13 | import android.widget.RadioButton;
14 | import android.widget.RadioGroup;
15 | import android.widget.TextView;
16 | import android.widget.Toast;
17 |
18 | import com.example.immadisairaj.quiz.question.Question;
19 |
20 | import java.util.ArrayList;
21 |
22 | import butterknife.BindView;
23 | import butterknife.ButterKnife;
24 |
25 | public class QuizActivity extends AppCompatActivity {
26 |
27 | Question qAndA = new Question();
28 |
29 | int ques, score, ans, nextC;
30 | float percentage;
31 | boolean submit;
32 |
33 | ArrayList Answers;
34 |
35 |
36 | String q_nos;
37 |
38 | @BindView(R.id.q_numbers)
39 | TextView q_no;
40 |
41 | @BindView(R.id.question)
42 | TextView questions;
43 |
44 | @BindView(R.id.optionA)
45 | RadioButton opA;
46 |
47 | @BindView(R.id.optionB)
48 | RadioButton opB;
49 |
50 | @BindView(R.id.optionC)
51 | RadioButton opC;
52 |
53 | @BindView(R.id.optionD)
54 | RadioButton opD;
55 |
56 | @BindView(R.id.options)
57 | RadioGroup optionsGroup;
58 |
59 | @BindView(R.id.prev)
60 | Button prevButton;
61 |
62 | @Override
63 | protected void onCreate(Bundle savedInstanceState) {
64 | super.onCreate(savedInstanceState);
65 | setContentView(R.layout.activity_quiz);
66 |
67 | ButterKnife.bind(this);
68 | Intent i = getIntent();
69 | qAndA = (Question) i.getSerializableExtra("question");
70 | q_nos = "Question: " + 1 + "/" + qAndA.question.size();
71 | questions = findViewById(R.id.question);
72 | questions.setText("Quiz");
73 | prevButton.setVisibility(View.GONE);
74 | Answers = new ArrayList<>();
75 |
76 | ques = -1;
77 | score = 0;
78 | ans = 0;
79 | nextC = 0;
80 | submit = true;
81 | goNext();
82 | }
83 |
84 | public void goNext() {
85 | ques++;
86 |
87 | if (ques >= qAndA.question.size()) {
88 | ques = qAndA.question.size() - 1;
89 | }
90 |
91 | q_no.setVisibility(View.VISIBLE);
92 | opA.setVisibility(View.VISIBLE);
93 | opB.setVisibility(View.VISIBLE);
94 |
95 | if (qAndA.results.get(ques).getType().equals("boolean")) {
96 | opC.setVisibility(View.GONE);
97 | opD.setVisibility(View.GONE);
98 | } else {
99 | opC.setVisibility(View.VISIBLE);
100 | opD.setVisibility(View.VISIBLE);
101 | }
102 |
103 | q_nos = "Question: " + (ques + 1) + "/" + qAndA.question.size();
104 | q_no.setText(q_nos);
105 | questions.setText(qAndA.question.get(ques));
106 | opA.setText(qAndA.optA.get(ques));
107 | opB.setText(qAndA.optB.get(ques));
108 | opC.setText(qAndA.optC.get(ques));
109 | opD.setText(qAndA.optD.get(ques));
110 | try {
111 | if (Answers.get(ques) == 1) {
112 | opA.setChecked(true);
113 | } else if (Answers.get(ques) == 2) {
114 | opB.setChecked(true);
115 | } else if (Answers.get(ques) == 3) {
116 | opC.setChecked(true);
117 | } else if (Answers.get(ques) == 4) {
118 | opD.setChecked(true);
119 | } else {
120 | optionsGroup.clearCheck();
121 | }
122 | } catch (Exception e) {
123 | optionsGroup.clearCheck();
124 | }
125 | }
126 |
127 | public void clickPrev(View view) {
128 |
129 | int selectedId = optionsGroup.getCheckedRadioButtonId();
130 | switch (selectedId) {
131 | case R.id.optionA:
132 | ans = 1;
133 | break;
134 | case R.id.optionB:
135 | ans = 2;
136 | break;
137 | case R.id.optionC:
138 | ans = 3;
139 | break;
140 | case R.id.optionD:
141 | ans = 4;
142 | break;
143 | default:
144 | ans = 0;
145 | }
146 | if (ques >= 0) {
147 | try {
148 | Answers.set(ques, ans);
149 | } catch (Exception e) {
150 | Answers.add(ques, ans);
151 | }
152 | }
153 | if (ques < qAndA.question.size() - 1) {
154 | goPrev();
155 | } else if (ques == qAndA.question.size() - 1) {
156 | Button button = findViewById(R.id.next);
157 | button.setVisibility(View.VISIBLE);
158 | button = findViewById(R.id.submit);
159 | button.setVisibility(View.INVISIBLE);
160 | optionsGroup.clearCheck();
161 | goPrev();
162 | }
163 | if (ques == 0)
164 | prevButton.setVisibility(View.GONE);
165 | nextC--;
166 | ans = 0;
167 | }
168 |
169 | public void goPrev() {
170 | ques--;
171 |
172 | q_no.setVisibility(View.VISIBLE);
173 | opA.setVisibility(View.VISIBLE);
174 | opB.setVisibility(View.VISIBLE);
175 |
176 | if (qAndA.results.get(ques).getType().equals("boolean")) {
177 | opC.setVisibility(View.GONE);
178 | opD.setVisibility(View.GONE);
179 | } else {
180 | opC.setVisibility(View.VISIBLE);
181 | opD.setVisibility(View.VISIBLE);
182 | }
183 |
184 | q_nos = "Question: " + (ques + 1) + "/" + qAndA.question.size();
185 | q_no.setText(q_nos);
186 | questions.setText(qAndA.question.get(ques));
187 | opA.setText(qAndA.optA.get(ques));
188 | opB.setText(qAndA.optB.get(ques));
189 | opC.setText(qAndA.optC.get(ques));
190 | opD.setText(qAndA.optD.get(ques));
191 | try {
192 | if (Answers.get(ques) == 1) {
193 | opA.setChecked(true);
194 | } else if (Answers.get(ques) == 2) {
195 | opB.setChecked(true);
196 | } else if (Answers.get(ques) == 3) {
197 | opC.setChecked(true);
198 | } else if (Answers.get(ques) == 4) {
199 | opD.setChecked(true);
200 | } else {
201 | optionsGroup.clearCheck();
202 | }
203 | } catch (Exception e) {
204 | optionsGroup.clearCheck();
205 |
206 | }
207 | }
208 |
209 | public void clickSubmit(final View view) {
210 | AlertDialog.Builder alertConfirm = new AlertDialog.Builder(this);
211 | alertConfirm.setTitle("Confirm Submission");
212 | alertConfirm.setMessage("Do you want to submit quiz?");
213 | alertConfirm.setCancelable(true);
214 | alertConfirm.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
215 | @Override
216 | public void onClick(DialogInterface dialog, int which) {
217 |
218 | }
219 | });
220 | alertConfirm.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
221 | @Override
222 | public void onClick(DialogInterface dialog, int which) {
223 | submit(view);
224 | }
225 | });
226 | AlertDialog dialog = alertConfirm.create();
227 | dialog.show();
228 | }
229 |
230 | public void submit(View view) {
231 | clickNext(view);
232 | if (submit)
233 | checkScore();
234 | submit = false;
235 | percentage = (float) (score * 100) / qAndA.question.size();
236 | prevButton.setVisibility(View.INVISIBLE);
237 | opA.setClickable(false);
238 | opB.setClickable(false);
239 | opC.setClickable(false);
240 | opD.setClickable(false);
241 | LayoutInflater inflater = getLayoutInflater();
242 | View alertLayout = inflater.inflate(R.layout.alert_dialog, null);
243 | final ProgressBar progressBar = alertLayout.findViewById(R.id.circularProgressbar);
244 | final TextView textView = alertLayout.findViewById(R.id.tv);
245 | Drawable drawable = getResources().getDrawable(R.drawable.circular);
246 | progressBar.setMax(qAndA.question.size());
247 | progressBar.setSecondaryProgress(qAndA.question.size());
248 | progressBar.setProgress(score);
249 | progressBar.setProgressDrawable(drawable);
250 | textView.setText((int) percentage + "%");
251 |
252 | AlertDialog.Builder alert = new AlertDialog.Builder(this);
253 |
254 | alert.setTitle("RESULT");
255 | alert.setMessage("You scored " + score + " out of " + qAndA.question.size() + " questions.");
256 | alert.setView(alertLayout);
257 | alert.setCancelable(false);
258 |
259 | alert.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
260 |
261 | @Override
262 | public void onClick(DialogInterface dialog, int which) {
263 | moveTaskToBack(true);
264 | android.os.Process.killProcess(android.os.Process.myPid());
265 | System.exit(1);
266 | }
267 | });
268 |
269 | alert.setPositiveButton("View Solutions", new DialogInterface.OnClickListener() {
270 | @Override
271 | public void onClick(DialogInterface dialog, int which) {
272 | clickSolutions();
273 | }
274 | });
275 | AlertDialog dialog = alert.create();
276 | dialog.show();
277 | }
278 |
279 | public void clickNext(View view) {
280 |
281 | int selectedId = optionsGroup.getCheckedRadioButtonId();
282 | switch (selectedId) {
283 | case R.id.optionA:
284 | ans = 1;
285 | break;
286 | case R.id.optionB:
287 | ans = 2;
288 | break;
289 | case R.id.optionC:
290 | ans = 3;
291 | break;
292 | case R.id.optionD:
293 | ans = 4;
294 | break;
295 | default:
296 | ans = 0;
297 | }
298 |
299 | if (ques >= 0) {
300 | try {
301 | Answers.set(ques, ans);
302 | } catch (Exception e) {
303 | Answers.add(ques, ans);
304 | }
305 | }
306 | if (ques < qAndA.question.size() - 2) {
307 | optionsGroup.clearCheck();
308 | goNext();
309 | } else if (ques == qAndA.question.size() - 2) {
310 | Button button = findViewById(R.id.next);
311 | button.setVisibility(View.INVISIBLE);
312 | button = findViewById(R.id.submit);
313 | button.setVisibility(View.VISIBLE);
314 | optionsGroup.clearCheck();
315 | goNext();
316 | }
317 | if (ques > 0)
318 | prevButton.setVisibility(View.VISIBLE);
319 |
320 | nextC++;
321 | ans = 0;
322 | }
323 |
324 | public void checkScore() {
325 | if (ques != -1)
326 | for (int i = 0; i < Answers.size(); i++) {
327 | if (qAndA.Answer.get(i).equals(Answers.get(i))) {
328 | score++;
329 | }
330 | }
331 | }
332 |
333 | public void clickSolutions() {
334 | Intent solutions = new Intent(this, SolutionActivity.class);
335 | solutions.putIntegerArrayListExtra("Answer", Answers);
336 | solutions.putStringArrayListExtra("Question", (ArrayList) qAndA.question);
337 | solutions.putStringArrayListExtra("optA", (ArrayList) qAndA.optA);
338 | solutions.putStringArrayListExtra("optB", (ArrayList) qAndA.optB);
339 | solutions.putStringArrayListExtra("optC", (ArrayList) qAndA.optC);
340 | solutions.putStringArrayListExtra("optD", (ArrayList) qAndA.optD);
341 | solutions.putIntegerArrayListExtra("Answers", (ArrayList) qAndA.Answer);
342 | startActivity(solutions);
343 | }
344 |
345 | @Override
346 | public void onBackPressed() {
347 | Toast.makeText(this, "Back Press is not allowed", Toast.LENGTH_LONG).show();
348 | }
349 | }
350 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/immadisairaj/quiz/HomeActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.immadisairaj.quiz;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.os.Bundle;
6 | import android.preference.PreferenceManager;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.ProgressBar;
12 | import android.widget.Toast;
13 |
14 | import com.example.immadisairaj.quiz.api.Api;
15 | import com.example.immadisairaj.quiz.api.ApiCount;
16 | import com.example.immadisairaj.quiz.api.QuizQuestions;
17 | import com.example.immadisairaj.quiz.api.Result;
18 | import com.example.immadisairaj.quiz.question.Question;
19 |
20 | import java.io.UnsupportedEncodingException;
21 | import java.util.List;
22 | import java.util.Random;
23 |
24 | import retrofit2.Call;
25 | import retrofit2.Callback;
26 | import retrofit2.Response;
27 | import retrofit2.Retrofit;
28 | import retrofit2.converter.gson.GsonConverterFactory;
29 |
30 | public class HomeActivity extends AppCompatActivity {
31 | Button start;
32 | Button filter;
33 | ProgressBar progressBar;
34 | Question q;
35 | String difficulty;
36 | String category;
37 | View.OnClickListener onClickListener = new View.OnClickListener() {
38 | @Override
39 | public void onClick(View view) {
40 | if (view.getId() == R.id.home_start) {
41 | progressBar.setVisibility(View.VISIBLE);
42 | q = new Question(getApplicationContext());
43 | view.setClickable(false);
44 | fetchQuestionCount();
45 | } else if (view.getId() == R.id.home_filter) {
46 | Intent intent = new Intent(getApplicationContext(), SettingActivity.class);
47 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
48 | startActivity(intent);
49 | }
50 | }
51 | };
52 |
53 | @Override
54 | protected void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | setContentView(R.layout.activity_home);
57 | setFilterDefaultValues();
58 | start = findViewById(R.id.home_start);
59 | filter = findViewById(R.id.home_filter);
60 | progressBar = findViewById(R.id.progressBar2);
61 | start.setOnClickListener(onClickListener);
62 | filter.setOnClickListener(onClickListener);
63 |
64 | SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
65 | category = sharedPrefs.getString(
66 | getString(R.string.category_key),
67 | getString(R.string.medium_value)
68 | );
69 |
70 | difficulty = sharedPrefs.getString(
71 | getString(R.string.difficulty_key),
72 | getString(R.string.medium_value)
73 | );
74 | }
75 |
76 | private void setFilterDefaultValues() {
77 | SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
78 | difficulty = sharedPrefs.getString(
79 | getString(R.string.difficulty_key),
80 | null
81 | );
82 | category = sharedPrefs.getString(
83 | getString(R.string.category_key),
84 | null
85 | );
86 | if (difficulty == null) {
87 | sharedPrefs
88 | .edit()
89 | .putString(getString(R.string.difficulty_key), getString(R.string.easy_value))
90 | .apply();
91 | }
92 | if (category == null) {
93 | sharedPrefs
94 | .edit()
95 | .putString(getString(R.string.category_key), getString(R.string.any_category_value))
96 | .apply();
97 | }
98 | }
99 |
100 | private void fetchQuestionCount() {
101 | int category_value = Integer.valueOf(category);
102 |
103 | Retrofit retrofit = new Retrofit.Builder()
104 | .baseUrl(Api.BASE_URL)
105 | .addConverterFactory(GsonConverterFactory.create())
106 | .build();
107 | Api api = retrofit.create(Api.class);
108 | Call call = api.getQuizQuestions(category_value);
109 | call.enqueue(new Callback() {
110 | @Override
111 | public void onResponse(Call call, Response response) {
112 | switch (difficulty) {
113 | case "easy":
114 | fetchQuestionAPI(response.body().getCategoryQuestionCount().getTotalEasyQuestionCount());
115 | break;
116 | case "medium":
117 | fetchQuestionAPI(response.body().getCategoryQuestionCount().getTotalMediumQuestionCount());
118 | break;
119 | case "hard":
120 | fetchQuestionAPI(response.body().getCategoryQuestionCount().getTotalHardQuestionCount());
121 | break;
122 | }
123 | }
124 |
125 | @Override
126 | public void onFailure(Call call, Throwable t) {
127 | Toast.makeText(getApplicationContext(), "No Internet Connection", Toast.LENGTH_SHORT).show();
128 | progressBar.setVisibility(View.INVISIBLE);
129 | start.setClickable(true);
130 | }
131 | });
132 | }
133 |
134 | public void fetchQuestionAPI(int categoryCount) {
135 | int category_value = Integer.valueOf(category);
136 | Retrofit retrofit = new Retrofit.Builder()
137 | .baseUrl(Api.BASE_URL)
138 | .addConverterFactory(GsonConverterFactory.create())
139 | .build();
140 | Api api = retrofit.create(Api.class);
141 | Call call = api.getQuizQuestions("url3986", categoryCount >= 10 ? 10 : categoryCount - 1, difficulty, category_value);
142 | call.enqueue(new Callback() {
143 | @Override
144 | public void onResponse(Call call, Response response) {
145 |
146 | Log.v("url-----", call.request().url().toString());
147 |
148 | QuizQuestions quizQuestions = response.body();
149 |
150 | if (quizQuestions.getResponseCode() == 0) {
151 |
152 | q.results = quizQuestions.getResults();
153 |
154 | if (q.results != null) {
155 | for (Result r : q.results) {
156 | try {
157 | q.question.add(java.net.URLDecoder.decode(r.getQuestion(), "UTF-8"));
158 | } catch (UnsupportedEncodingException e) {
159 | e.printStackTrace();
160 | }
161 | Random random = new Random();
162 | // For Boolean Type Questions, only 2 possible options (True/False)
163 | // For multiple choices, 4 options are required.
164 | int ran = r.getType().equals("boolean")
165 | ? random.nextInt(2)
166 | : random.nextInt(4);
167 | setOptions(r, ran);
168 | q.Answer.add(ran + 1);
169 | }
170 | Log.v("answers", q.Answer.toString());
171 | }
172 | }
173 | progressBar.setVisibility(View.INVISIBLE);
174 | start.setClickable(true);
175 | Intent intent = new Intent(HomeActivity.this, QuizActivity.class);
176 | intent.putExtra("question", q);
177 | startActivity(intent);
178 | }
179 |
180 | @Override
181 | public void onFailure(Call call, Throwable t) {
182 | Toast.makeText(getApplicationContext(), "No Internet Connection", Toast.LENGTH_SHORT).show();
183 | progressBar.setVisibility(View.INVISIBLE);
184 | start.setClickable(true);
185 | }
186 | });
187 | }
188 |
189 | void setOptions(Result r, int ran) {
190 | List wrong;
191 | switch (ran) {
192 | case 0:
193 | try {
194 | q.optA.add(java.net.URLDecoder.decode(r.getCorrectAnswer(), "UTF-8"));
195 | } catch (UnsupportedEncodingException e) {
196 | e.printStackTrace();
197 | }
198 |
199 | wrong = r.getIncorrectAnswers();
200 | try {
201 | q.optB.add(java.net.URLDecoder.decode(wrong.get(0), "UTF-8"));
202 | } catch (UnsupportedEncodingException e) {
203 | e.printStackTrace();
204 | }
205 | // Options C, D are not applicable for Boolean Type Questions.
206 | if (r.getType().equals("boolean")) {
207 | q.optC.add("false");
208 | q.optD.add("false");
209 | return;
210 | }
211 | try {
212 | q.optC.add(java.net.URLDecoder.decode(wrong.get(1), "UTF-8"));
213 | } catch (UnsupportedEncodingException e) {
214 | e.printStackTrace();
215 | }
216 | try {
217 | q.optD.add(java.net.URLDecoder.decode(wrong.get(2), "UTF-8"));
218 | } catch (UnsupportedEncodingException e) {
219 | e.printStackTrace();
220 | }
221 | break;
222 | case 1:
223 | try {
224 | q.optB.add(java.net.URLDecoder.decode(r.getCorrectAnswer(), "UTF-8"));
225 | } catch (UnsupportedEncodingException e) {
226 | e.printStackTrace();
227 | }
228 |
229 | wrong = r.getIncorrectAnswers();
230 | try {
231 | q.optA.add(java.net.URLDecoder.decode(wrong.get(0), "UTF-8"));
232 | } catch (UnsupportedEncodingException e) {
233 | e.printStackTrace();
234 | }
235 | // Options C, D are not applicable for Boolean Type Questions.
236 | if (r.getType().equals("boolean")) {
237 | q.optC.add("false");
238 | q.optD.add("false");
239 | return;
240 | }
241 | try {
242 | q.optC.add(java.net.URLDecoder.decode(wrong.get(1), "UTF-8"));
243 | } catch (UnsupportedEncodingException e) {
244 | e.printStackTrace();
245 | }
246 | try {
247 | q.optD.add(java.net.URLDecoder.decode(wrong.get(2), "UTF-8"));
248 | } catch (UnsupportedEncodingException e) {
249 | e.printStackTrace();
250 | }
251 | break;
252 | case 2:
253 | try {
254 | q.optC.add(java.net.URLDecoder.decode(r.getCorrectAnswer(), "UTF-8"));
255 | } catch (UnsupportedEncodingException e) {
256 | e.printStackTrace();
257 | }
258 |
259 | wrong = r.getIncorrectAnswers();
260 | try {
261 | q.optA.add(java.net.URLDecoder.decode(wrong.get(0), "UTF-8"));
262 | } catch (UnsupportedEncodingException e) {
263 | e.printStackTrace();
264 | }
265 | try {
266 | q.optB.add(java.net.URLDecoder.decode(wrong.get(1), "UTF-8"));
267 | } catch (UnsupportedEncodingException e) {
268 | e.printStackTrace();
269 | }
270 | try {
271 | q.optD.add(java.net.URLDecoder.decode(wrong.get(2), "UTF-8"));
272 | } catch (UnsupportedEncodingException e) {
273 | e.printStackTrace();
274 | }
275 | break;
276 | case 3:
277 | try {
278 | q.optD.add(java.net.URLDecoder.decode(r.getCorrectAnswer(), "UTF-8"));
279 | } catch (UnsupportedEncodingException e) {
280 | e.printStackTrace();
281 | }
282 |
283 | wrong = r.getIncorrectAnswers();
284 | try {
285 | q.optA.add(java.net.URLDecoder.decode(wrong.get(0), "UTF-8"));
286 | } catch (UnsupportedEncodingException e) {
287 | e.printStackTrace();
288 | }
289 | try {
290 | q.optB.add(java.net.URLDecoder.decode(wrong.get(1), "UTF-8"));
291 | } catch (UnsupportedEncodingException e) {
292 | e.printStackTrace();
293 | }
294 | try {
295 | q.optC.add(java.net.URLDecoder.decode(wrong.get(2), "UTF-8"));
296 | } catch (UnsupportedEncodingException e) {
297 | e.printStackTrace();
298 | }
299 | break;
300 | }
301 | }
302 | }
--------------------------------------------------------------------------------