├── .DS_Store
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── codeql-analysis.yml
├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── modules.xml
└── vcs.xml
├── CheckboxQuestion
├── .gitignore
├── .idea
│ ├── .name
│ ├── codeStyles
│ │ └── Project.xml
│ ├── gradle.xml
│ ├── jarRepositories.xml
│ ├── misc.xml
│ ├── runConfigurations.xml
│ └── vcs.xml
├── CheckboxQuestion
│ ├── .gitignore
│ ├── build.gradle
│ ├── consumer-rules.pro
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── aadyad
│ │ │ └── checkboxquestion
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── aadyad
│ │ │ │ └── checkboxquestion
│ │ │ │ ├── OnAnswerChangedListener.java
│ │ │ │ ├── Question.java
│ │ │ │ ├── QuestionList.java
│ │ │ │ ├── QuestionListSettings.java
│ │ │ │ └── Views
│ │ │ │ ├── MultipleAnswerQuestion.java
│ │ │ │ ├── MultipleChoiceQuestion.java
│ │ │ │ └── YesOrNoQuestion.java
│ │ └── res
│ │ │ ├── layout
│ │ │ ├── multiple_answer_question.xml
│ │ │ ├── multiple_choice_question.xml
│ │ │ └── yes_or_no_question.xml
│ │ │ └── values
│ │ │ └── attrs.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── aadyad
│ │ └── checkboxquestion
│ │ └── ExampleUnitTest.java
├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── com
│ │ │ └── aadyad
│ │ │ └── checkboxquestions_library
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── aadyad
│ │ │ │ └── checkboxquestions_library
│ │ │ │ └── MainActivity.java
│ │ └── res
│ │ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── drawable
│ │ │ └── ic_launcher_background.xml
│ │ │ ├── layout
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ │ ├── 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
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── com
│ │ └── aadyad
│ │ └── checkboxquestions_library
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── LICENSE
└── README.md
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EunoiaC/Checkbox-Questions/c4accf0037ab27b4af84abf9b26b7177b31f1011/.DS_Store
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/workflows/codeql-analysis.yml:
--------------------------------------------------------------------------------
1 | # For most projects, this workflow file will not need changing; you simply need
2 | # to commit it to your repository.
3 | #
4 | # You may wish to alter this file to override the set of languages analyzed,
5 | # or to provide custom queries or build logic.
6 | #
7 | # ******** NOTE ********
8 | # We have attempted to detect the languages in your repository. Please check
9 | # the `language` matrix defined below to confirm you have the correct set of
10 | # supported CodeQL languages.
11 | #
12 | name: "CodeQL"
13 |
14 | on:
15 | push:
16 | branches: [ main ]
17 | pull_request:
18 | # The branches below must be a subset of the branches above
19 | branches: [ main ]
20 | schedule:
21 | - cron: '15 18 * * 0'
22 |
23 | jobs:
24 | analyze:
25 | name: Analyze
26 | runs-on: ubuntu-latest
27 | permissions:
28 | actions: read
29 | contents: read
30 | security-events: write
31 |
32 | strategy:
33 | fail-fast: false
34 | matrix:
35 | language: [ 'java' ]
36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37 | # Learn more:
38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39 |
40 | steps:
41 | - name: Checkout repository
42 | uses: actions/checkout@v2
43 |
44 | # Initializes the CodeQL tools for scanning.
45 | - name: Initialize CodeQL
46 | uses: github/codeql-action/init@v1
47 | with:
48 | languages: ${{ matrix.language }}
49 | # If you wish to specify custom queries, you can do so here or in a config file.
50 | # By default, queries listed here will override any specified in a config file.
51 | # Prefix the list here with "+" to use these queries and those in the config file.
52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main
53 |
54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55 | # If this step fails, then you should remove it and run the build manually (see below)
56 | - name: Autobuild
57 | uses: github/codeql-action/autobuild@v1
58 |
59 | # ℹ️ Command-line programs to run using the OS shell.
60 | # 📚 https://git.io/JvXDl
61 |
62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63 | # and modify them (or add more) to build your code if your project
64 | # uses a compiled language
65 |
66 | #- run: |
67 | # make bootstrap
68 | # make release
69 |
70 | - name: Perform CodeQL Analysis
71 | uses: github/codeql-action/analyze@v1
72 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 | *.aab
5 |
6 | # Files for the ART/Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 | # Generated files
13 | bin/
14 | gen/
15 | out/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | # IntelliJ
37 | *.iml
38 | .idea/workspace.xml
39 | .idea/tasks.xml
40 | .idea/gradle.xml
41 | .idea/assetWizardSettings.xml
42 | .idea/dictionaries
43 | .idea/libraries
44 | .idea/caches
45 |
46 | # Keystore files
47 | # Uncomment the following lines if you do not want to check your keystore files in.
48 | #*.jks
49 | #*.keystore
50 |
51 | # External native build folder generated in Android Studio 2.2 and later
52 | .externalNativeBuild
53 |
54 | # Google Services (e.g. APIs or Firebase)
55 | google-services.json
56 |
57 | # Freeline
58 | freeline.py
59 | freeline/
60 | freeline_project_description.json
61 |
62 | # fastlane
63 | fastlane/report.xml
64 | fastlane/Preview.html
65 | fastlane/screenshots
66 | fastlane/test_output
67 | fastlane/readme.md
68 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/.name:
--------------------------------------------------------------------------------
1 | LibraryCreate
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/jarRepositories.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 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/CheckboxQuestion/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 30
5 | buildToolsVersion "30.0.3"
6 |
7 | defaultConfig {
8 | minSdkVersion 16
9 | targetSdkVersion 30
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | consumerProguardFiles "consumer-rules.pro"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: "libs", include: ["*.jar"])
27 | implementation 'androidx.appcompat:appcompat:1.2.0'
28 | testImplementation 'junit:junit:4.12'
29 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
30 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
31 |
32 | }
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EunoiaC/Checkbox-Questions/c4accf0037ab27b4af84abf9b26b7177b31f1011/CheckboxQuestion/CheckboxQuestion/consumer-rules.pro
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/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
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/src/androidTest/java/com/aadyad/checkboxquestion/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.aadyad.checkboxquestion;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
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 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.aadyad.checkboxquestion.test", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | /
5 |
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/src/main/java/com/aadyad/checkboxquestion/OnAnswerChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.aadyad.checkboxquestion;
2 |
3 | import java.util.ArrayList;
4 |
5 | public interface OnAnswerChangedListener {
6 | public void onAnswerChanged(int selectedAnswerIndex, String selectedAnswerText);
7 | public void onAnswerChanged(ArrayList listOfSelectedAnswerIndexes);
8 | }
9 |
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/src/main/java/com/aadyad/checkboxquestion/Question.java:
--------------------------------------------------------------------------------
1 | package com.aadyad.checkboxquestion;
2 |
3 | import android.util.Log;
4 |
5 | import java.util.ArrayList;
6 |
7 | public class Question {
8 |
9 | //TODO: Create MultipleAnswerQuestions
10 |
11 | public static final String MULTIPLE_CHOICE_QUESTION = "MultipleChoiceQuestion";
12 | public static final String YES_OR_NO_QUESTION = "YesOrNoQuestion";
13 | public static final String MULTIPLE_ANSWER_QUESTION = "MultipleAnswerQuestion";
14 | public static final int LEFT = 0;
15 | public static final int HORIZONTAL = 0;
16 | public static final int VERTICAL = 1;
17 | public static final int FULL_VERTICAL = 3;
18 | public static final int NO_ANSWER = 0;
19 | public static final int SPLIT_VERTICAL = 1;
20 | public static final int CENTER = 1;
21 | public static final int RIGHT = 2;
22 | public static final int AUTO = 2;
23 |
24 | String question;
25 | String type;
26 | int correctAnswer;
27 | ArrayList multipleCorrectAnswer;
28 | String[] options = new String[]{"Yes", "No"};
29 |
30 | public Question(String question, int correctAnswer, String type, String... options) {
31 | this.question = question;
32 | this.type = type;
33 | if (options != null){
34 | this.options = options;
35 | }
36 | this.correctAnswer = correctAnswer;
37 | }
38 |
39 | public Question(String question, ArrayList correctAnswer, String type, String... options) {
40 | this.question = question;
41 | this.type = type;
42 | if (options != null){
43 | this.options = options;
44 | }
45 | this.multipleCorrectAnswer = correctAnswer;
46 | }
47 |
48 | public Question(String question, String correctAnswer, String type, String... options) {
49 | this.question = question;
50 | this.type = type;
51 | if (options != null){
52 | this.options = options;
53 | }
54 | this.correctAnswer = getIndexOfString(correctAnswer) + 1;
55 | }
56 |
57 | private int getIndexOfString(String s) {
58 | for (int i = 0; i < options.length; i++) {
59 | if (options[i].equals(s)) {
60 | Log.d("Question", "getIndexOfString: " + i);
61 | return i;
62 | }
63 | }
64 | Log.d("TAG", "answer not found: " + s);
65 | return -1;
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/CheckboxQuestion/CheckboxQuestion/src/main/java/com/aadyad/checkboxquestion/QuestionList.java:
--------------------------------------------------------------------------------
1 | package com.aadyad.checkboxquestion;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 | import android.view.View;
6 | import android.widget.LinearLayout;
7 |
8 | import com.aadyad.checkboxquestion.Views.MultipleAnswerQuestion;
9 | import com.aadyad.checkboxquestion.Views.MultipleChoiceQuestion;
10 | import com.aadyad.checkboxquestion.Views.YesOrNoQuestion;
11 |
12 | import java.util.ArrayList;
13 | import java.util.Arrays;
14 | import java.util.Collections;
15 |
16 | public class QuestionList {
17 |
18 | String[] questions;
19 | ArrayList choiceQuestions;
20 | LinearLayout linearLayout;
21 | QuestionListSettings settings;
22 | Context context;
23 | int orientation;
24 |
25 | public QuestionList(ArrayList questions, QuestionListSettings settings, Context context) {
26 | choiceQuestions = questions;
27 | this.settings = settings;
28 | this.context = context;
29 | this.orientation = settings.getCheckBoxOrientation();
30 | linearLayout = new LinearLayout(context);
31 | }
32 |
33 | public QuestionList(String[] questions, QuestionListSettings settings, Context context) {
34 | this.questions = questions;
35 | this.settings = settings;
36 | this.orientation = settings.getCheckBoxOrientation();
37 | this.context = context;
38 | linearLayout = new LinearLayout(context);
39 | }
40 |
41 | public void createQuestionViews() {
42 | int i = 1;
43 | linearLayout = new LinearLayout(context);
44 | linearLayout.setOrientation(LinearLayout.VERTICAL);
45 | if (questions == null) {
46 | for (Question q : choiceQuestions) {
47 | switch (q.type) {
48 | case Question.MULTIPLE_CHOICE_QUESTION:
49 | Log.d("TAG", "createQuestionViews: " + Arrays.toString(q.options));
50 | MultipleChoiceQuestion multipleChoiceQuestion = new MultipleChoiceQuestion(context);
51 | multipleChoiceQuestion.init(q.question, String.valueOf(i), settings.isNumEnabled(), settings.getSpacing(), this.orientation, settings.getCheckBoxLocation(), settings.getQuestionTextSize(), settings.getCheckBoxTextSize(), q.correctAnswer, q.options);
52 | linearLayout.addView(multipleChoiceQuestion);
53 | break;
54 | case Question.YES_OR_NO_QUESTION:
55 | YesOrNoQuestion yesOrNoQuestion = new YesOrNoQuestion(context);
56 | yesOrNoQuestion.init(q.question, String.valueOf(i), settings.isNumEnabled(), settings.getSpacing(), this.orientation, settings.getCheckBoxLocation(), settings.getQuestionTextSize(), settings.getCheckBoxTextSize(), q.correctAnswer);
57 | linearLayout.addView(yesOrNoQuestion);
58 | break;
59 | case Question.MULTIPLE_ANSWER_QUESTION:
60 | MultipleAnswerQuestion multipleAnswerQuestion = new MultipleAnswerQuestion(context);
61 | multipleAnswerQuestion.init(q.question, String.valueOf(i), settings.isNumEnabled(), settings.getSpacing(), this.orientation, settings.getCheckBoxLocation(), settings.getQuestionTextSize(), settings.getCheckBoxTextSize(), q.options);
62 | multipleAnswerQuestion.setCorrectAnswer(q.multipleCorrectAnswer);
63 | linearLayout.addView(multipleAnswerQuestion);
64 | break;
65 | default:
66 | throw new RuntimeException("Type " + q.type + " does not exist.");
67 | }
68 | i++;
69 | }
70 | } else {
71 | for (String q : questions) {
72 | i++;
73 | YesOrNoQuestion yesOrNoQuestion = new YesOrNoQuestion(context);
74 | yesOrNoQuestion.init(q, String.valueOf(i), settings.isNumEnabled(), settings.getSpacing(), this.orientation, settings.getCheckBoxLocation(), settings.getQuestionTextSize(), settings.getCheckBoxTextSize(), Question.NO_ANSWER);
75 | linearLayout.addView(yesOrNoQuestion);
76 | }
77 | }
78 |
79 | }
80 |
81 | public void setLayoutOrientation(int orientation) {
82 | this.orientation = orientation;
83 | for (int i = 0; i < linearLayout.getChildCount(); i++) {
84 | YesOrNoQuestion yesOrNoQuestion;
85 | MultipleChoiceQuestion multipleChoiceQuestion;
86 | MultipleAnswerQuestion multipleAnswerQuestion;
87 |
88 | try {
89 | yesOrNoQuestion = (YesOrNoQuestion) getQuestion(i);
90 | yesOrNoQuestion.setCheckboxOrientation(orientation);
91 | } catch (ClassCastException ignored) {
92 |
93 | }
94 |
95 | try {
96 | multipleChoiceQuestion = (MultipleChoiceQuestion) getQuestion(i);
97 | multipleChoiceQuestion.setCheckboxOrientation(orientation);
98 | } catch (ClassCastException ignored) {
99 |
100 | }
101 |
102 | try {
103 | multipleAnswerQuestion = (MultipleAnswerQuestion) getQuestion(i);
104 | multipleAnswerQuestion.setCheckboxOrientation(orientation);
105 | } catch (ClassCastException ignored) {
106 |
107 | }
108 | }
109 | createQuestionViews();
110 | }
111 |
112 | public float getPercentageOfCorrectAnswers() {
113 | int correctAnswers = 0;
114 | int allAnswers = linearLayout.getChildCount();
115 | for (int i = 0; i < linearLayout.getChildCount(); i++) {
116 | YesOrNoQuestion yesOrNoQuestion;
117 | MultipleChoiceQuestion multipleChoiceQuestion;
118 | MultipleAnswerQuestion multipleAnswerQuestion;
119 |
120 | try {
121 | yesOrNoQuestion = (YesOrNoQuestion) getQuestion(i);
122 | int answer = yesOrNoQuestion.getSelectedAnswer();
123 | Log.d("TAG", "answer: " + answer);
124 | int correctAnswer = choiceQuestions.get(i).correctAnswer;
125 | Log.d("TAG", "correct answer: " + correctAnswer);
126 | if (correctAnswer == Question.NO_ANSWER) {
127 | allAnswers--;
128 | } else if (answer == correctAnswer) {
129 | correctAnswers++;
130 | }
131 | } catch (ClassCastException ignored) {
132 |
133 | }
134 |
135 | try {
136 | multipleChoiceQuestion = (MultipleChoiceQuestion) getQuestion(i);
137 | int answer = multipleChoiceQuestion.getSelectedAnswer();
138 | Log.d("TAG", "answer: " + answer);
139 | int correctAnswer = choiceQuestions.get(i).correctAnswer;
140 | Log.d("TAG", "correct answer: " + correctAnswer);
141 | if (correctAnswer == Question.NO_ANSWER) {
142 | allAnswers--;
143 | } else if (answer == correctAnswer) {
144 | correctAnswers++;
145 | }
146 | } catch (Exception ignored) {
147 |
148 | }
149 |
150 | try {
151 | multipleAnswerQuestion = (MultipleAnswerQuestion) getQuestion(i);
152 | ArrayList answer = multipleAnswerQuestion.getSelectedAnswers();
153 | Collections.sort(answer);
154 | Log.d("TAG", "answer: " + answer);
155 | ArrayList correctAnswer = choiceQuestions.get(i).multipleCorrectAnswer;
156 | Collections.sort(correctAnswer);
157 | Log.d("TAG", "correct answer: " + correctAnswer);
158 | if (correctAnswer.size() == Question.NO_ANSWER || correctAnswer == null) {
159 | allAnswers--;
160 | } else if (answer.equals(correctAnswer)) {
161 | correctAnswers++;
162 | }
163 | } catch (ClassCastException ignored) {
164 |
165 | }
166 | }
167 | Log.d("TAG", "getPercentageOfCorrectAnswers: " + correctAnswers);
168 | Log.d("TAG", "getPercentageOfCorrectAnswers: " + allAnswers);
169 | return (float) correctAnswers / allAnswers;
170 | }
171 |
172 | public ArrayList