Skip to content

Commit

Permalink
Question parser edited
Browse files Browse the repository at this point in the history
  • Loading branch information
goody-h committed Aug 16, 2018
1 parent 3715c80 commit d2820d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Binary file modified app/release/ges300_Quiz_App.apk
Binary file not shown.
15 changes: 6 additions & 9 deletions app/src/main/java/com/orsteg/ges300/TestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void run() {
int line = 0;
StringBuilder ex = new StringBuilder();
Question q = new Question();
String ans = "";

int p = 0;

try {
Expand All @@ -122,29 +122,26 @@ public void run() {

int l = line % 5;
if (l == 0){
q.question = ex.toString().replaceFirst("(\\d+)(\\.)(\\s+)", "");
q.question = ex.toString().replaceFirst("(\\s*)(\\d+)(\\.)(\\s*)", "");
} else if (l >= 1 && l <= 4) {

String s = ex.toString();
boolean a = s.indexOf('*') == 0;
boolean a = s.matches("(\\s*)(\\*)([abcd]+)(.*)");

String opt = s.replaceFirst("([*abcd]+)(\\.)(\\s+)", "");
int ind = rnd.nextInt(q.options.size()+1);
String opt = s.replaceFirst("(\\s*)([*abcd]+)(\\.)(\\s*)", "");

q.options.add(ind, opt);
q.options.add(opt);

if (a) ans = opt;
if (a) q.answer = q.options.size() - 1;


if (l == 4) {
q.answer = q.options.indexOf(ans);

int ind2 = rnd.nextInt(questions.size()+1);

questions.add(ind2, q);

q = new Question();
ans = "";
}
}

Expand Down

0 comments on commit d2820d6

Please sign in to comment.