├── app ├── .gitignore ├── questionnaire.gif ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable │ │ │ │ └── ic_arrow_back.xml │ │ │ └── layout │ │ │ │ ├── footer.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_radio_boxes.xml │ │ │ │ ├── fragment_check_boxes.xml │ │ │ │ ├── activity_question.xml │ │ │ │ └── activity_answers.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── spk │ │ │ │ └── questionnaire │ │ │ │ ├── questions │ │ │ │ ├── questionmodels │ │ │ │ │ ├── Data.java │ │ │ │ │ ├── QuestionDataModel.java │ │ │ │ │ ├── AnswerOptions.java │ │ │ │ │ └── QuestionsItem.java │ │ │ │ ├── widgets │ │ │ │ │ └── NoSwipeViewPager.java │ │ │ │ ├── adapters │ │ │ │ │ └── ViewPagerAdapter.java │ │ │ │ ├── qdb │ │ │ │ │ ├── QuestionDao.java │ │ │ │ │ ├── QuestionEntity.java │ │ │ │ │ ├── QuestionChoicesDao.java │ │ │ │ │ └── QuestionWithChoicesEntity.java │ │ │ │ ├── database │ │ │ │ │ └── AppDatabase.java │ │ │ │ ├── AnswersActivity.java │ │ │ │ ├── QuestionActivity.java │ │ │ │ └── fragments │ │ │ │ │ ├── RadioBoxesFragment.java │ │ │ │ │ └── CheckBoxesFragment.java │ │ │ │ ├── application │ │ │ │ └── QuestionnaireApp.java │ │ │ │ └── MainActivity.java │ │ ├── AndroidManifest.xml │ │ └── assets │ │ │ └── questions_example.json │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── spk │ │ │ └── questionnaire │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── spk │ │ └── questionnaire │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro ├── build.gradle └── schemas │ ├── com.spk.question.questions.database.AppDatabase │ └── 1.json │ └── com.spk.questionnaire.questions.database.AppDatabase │ └── 1.json ├── _config.yml ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENCE.txt /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/questionnaire.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/app/questionnaire.gif -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShashiPrasadKushwaha/Questionnaire/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/ShashiPrasadKushwaha/Questionnaire/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/ShashiPrasadKushwaha/Questionnaire/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/ShashiPrasadKushwaha/Questionnaire/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/ShashiPrasadKushwaha/Questionnaire/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | /.idea 8 | .DS_Store 9 | /build 10 | /captures 11 | .externalNativeBuild 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Sep 26 02:18:40 IST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Questionnaire 3 | Start Questionnaire 4 | Show Result 5 | Finish 6 | Next 7 | Previous 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_arrow_back.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #009688 4 | #00796B 5 | #FF4081 6 | 7 | #000 8 | #cacaca 9 | 10 | #585858 11 | #FFFFFF 12 | 13 | -------------------------------------------------------------------------------- /app/src/test/java/com/spk/questionnaire/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire; 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 | { 14 | @Test 15 | public void addition_isCorrect() 16 | { 17 | assertEquals(4, 2 + 2); 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/questionmodels/Data.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.questionmodels; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.List; 6 | 7 | public class Data 8 | { 9 | @SerializedName("questions") 10 | private List questions; 11 | 12 | public List getQuestions() 13 | { 14 | return questions; 15 | } 16 | 17 | public void setQuestions(List questions) 18 | { 19 | this.questions = questions; 20 | } 21 | } -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/widgets/NoSwipeViewPager.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.widgets; 2 | 3 | import android.content.Context; 4 | import androidx.viewpager.widget.ViewPager; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | 8 | public class NoSwipeViewPager extends ViewPager 9 | { 10 | public NoSwipeViewPager(Context context) { 11 | super(context); 12 | } 13 | 14 | public NoSwipeViewPager(Context context, AttributeSet attrs) { 15 | super(context, attrs); 16 | } 17 | 18 | @Override 19 | public boolean onInterceptTouchEvent(MotionEvent ev) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean onTouchEvent(MotionEvent ev) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /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 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true 16 | -------------------------------------------------------------------------------- /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/main/java/com/spk/questionnaire/questions/adapters/ViewPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.adapters; 2 | 3 | import java.util.ArrayList; 4 | 5 | import androidx.fragment.app.Fragment; 6 | import androidx.fragment.app.FragmentManager; 7 | import androidx.fragment.app.FragmentPagerAdapter; 8 | 9 | public class ViewPagerAdapter extends FragmentPagerAdapter 10 | { 11 | private final ArrayList fragments; 12 | 13 | public ViewPagerAdapter(FragmentManager fm, ArrayList fragments) { 14 | super(fm); 15 | this.fragments = fragments; 16 | } 17 | 18 | @Override 19 | public Fragment getItem(int position) { 20 | return this.fragments.get(position); 21 | } 22 | 23 | 24 | @Override 25 | public int getCount() { 26 | return this.fragments.size(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/spk/questionnaire/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire; 2 | 3 | import android.content.Context; 4 | 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | 8 | import androidx.test.InstrumentationRegistry; 9 | import androidx.test.runner.AndroidJUnit4; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest 20 | { 21 | @Test 22 | public void useAppContext() 23 | { 24 | // Context of the app under test. 25 | Context appContext = InstrumentationRegistry.getTargetContext(); 26 | 27 | assertEquals("com.spk.question", appContext.getPackageName()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/qdb/QuestionDao.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.qdb; 2 | 3 | import androidx.room.Dao; 4 | import androidx.room.Insert; 5 | import androidx.room.Query; 6 | 7 | import java.util.List; 8 | 9 | @Dao 10 | public interface QuestionDao 11 | { 12 | @Insert 13 | void insertAllQuestions(List questions); 14 | 15 | //@Query("UPDATE questions SET q_option_state = :selectState WHERE question_id = :questionId AND q_option_id =:optionId") 16 | //void updateQuestionWithChoice(String selectState, String questionId, String optionId); 17 | 18 | //@Query("SELECT q_option_state FROM questions WHERE question_id = :questionId AND q_option_id =:optionId") 19 | //String isChecked(String questionId, String optionId); 20 | 21 | @Query("SELECT * FROM questions") 22 | List getAllQuestions(); 23 | 24 | @Query("DELETE FROM questions") 25 | void deleteAllQuestions(); 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/application/QuestionnaireApp.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.application; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.stetho.Stetho; 6 | 7 | public class QuestionnaireApp extends Application 8 | { 9 | private static QuestionnaireApp sInstance; 10 | 11 | public static synchronized QuestionnaireApp getInstance() 12 | { 13 | return sInstance; 14 | } 15 | 16 | @Override 17 | public void onCreate() 18 | { 19 | super.onCreate(); 20 | 21 | sInstance = this; 22 | 23 | //Stetho is used to view the structure and values in Tables of Database. 24 | //Connect a device/emulator, run the app and complete the Questionnaire 25 | //then open Chrome browser and type this in address bar "chrome://inspect/#devices", 26 | //you will find connected device/emulator in below section of screen. 27 | Stetho.initializeWithDefaults(this); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/questionmodels/QuestionDataModel.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.questionmodels; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | public class QuestionDataModel 6 | { 7 | @SerializedName("data") 8 | private Data data; 9 | 10 | @SerializedName("message") 11 | private String message; 12 | 13 | @SerializedName("status") 14 | private boolean status; 15 | 16 | public Data getData() 17 | { 18 | return data; 19 | } 20 | 21 | public void setData(Data data) 22 | { 23 | this.data = data; 24 | } 25 | 26 | public String getMessage() 27 | { 28 | return message; 29 | } 30 | 31 | public void setMessage(String message) 32 | { 33 | this.message = message; 34 | } 35 | 36 | public boolean isStatus() 37 | { 38 | return status; 39 | } 40 | 41 | public void setStatus(boolean status) 42 | { 43 | this.status = status; 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/qdb/QuestionEntity.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.qdb; 2 | 3 | import androidx.room.ColumnInfo; 4 | import androidx.room.Entity; 5 | import androidx.room.PrimaryKey; 6 | 7 | @Entity(tableName = "questions") 8 | public class QuestionEntity 9 | { 10 | @PrimaryKey(autoGenerate = true) 11 | private long id; 12 | @ColumnInfo(name = "question_id") 13 | private int questionId; 14 | private String question; 15 | 16 | public long getId() 17 | { 18 | return id; 19 | } 20 | 21 | public void setId(long id) 22 | { 23 | this.id = id; 24 | } 25 | 26 | public int getQuestionId() 27 | { 28 | return questionId; 29 | } 30 | 31 | public void setQuestionId(int questionId) 32 | { 33 | this.questionId = questionId; 34 | } 35 | 36 | public String getQuestion() 37 | { 38 | return question; 39 | } 40 | 41 | public void setQuestion(String question) 42 | { 43 | this.question = question; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/qdb/QuestionChoicesDao.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.qdb; 2 | 3 | import androidx.room.Dao; 4 | import androidx.room.Insert; 5 | import androidx.room.Query; 6 | 7 | import java.util.List; 8 | 9 | @Dao 10 | public interface QuestionChoicesDao 11 | { 12 | @Insert 13 | void insertAllChoicesOfQuestion(List choices); 14 | 15 | @Query("UPDATE answer_choices SET ans_choice_state = :selectState WHERE question_id = :questionId AND ans_choice_pos =:optionId") 16 | void updateQuestionWithChoice(String selectState, String questionId, String optionId); 17 | 18 | @Query("SELECT ans_choice_state FROM answer_choices WHERE question_id = :questionId AND ans_choice_pos =:optionId") 19 | String isChecked(String questionId, String optionId); 20 | 21 | @Query("SELECT * FROM answer_choices WHERE ans_choice_state =:selected") 22 | List getAllQuestionsWithChoices(String selected); 23 | 24 | @Query("DELETE FROM answer_choices") 25 | void deleteAllChoicesOfQuestion(); 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/com/spk/questionnaire/questions/database/AppDatabase.java: -------------------------------------------------------------------------------- 1 | package com.spk.questionnaire.questions.database; 2 | 3 | import androidx.room.Database; 4 | import androidx.room.Room; 5 | import androidx.room.RoomDatabase; 6 | import android.content.Context; 7 | 8 | import com.spk.questionnaire.questions.qdb.QuestionChoicesDao; 9 | import com.spk.questionnaire.questions.qdb.QuestionDao; 10 | import com.spk.questionnaire.questions.qdb.QuestionEntity; 11 | import com.spk.questionnaire.questions.qdb.QuestionWithChoicesEntity; 12 | 13 | @Database(entities = {QuestionWithChoicesEntity.class, QuestionEntity.class}, version = 1) 14 | public abstract class AppDatabase extends RoomDatabase 15 | { 16 | private static final String DB_NAME = "question_db"; 17 | 18 | private static AppDatabase INSTANCE; 19 | 20 | public static synchronized AppDatabase getAppDatabase(Context context) 21 | { 22 | if (INSTANCE == null) 23 | { 24 | INSTANCE = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, DB_NAME) 25 | 26 | .fallbackToDestructiveMigration() 27 | .build(); 28 | } 29 | return INSTANCE; 30 | } 31 | 32 | public abstract QuestionChoicesDao getQuestionChoicesDao(); 33 | public abstract QuestionDao getQuestionDao(); 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/footer.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 |