Commit 18dc766f authored by Anuththara18's avatar Anuththara18

Analysing factors added- Alternating Attention

parent fd0a8c64
...@@ -156,12 +156,16 @@ public class AACompleteScreen extends AppCompatActivity { ...@@ -156,12 +156,16 @@ public class AACompleteScreen extends AppCompatActivity {
dataList.add(new Alternating( dataList.add(new Alternating(
cursorEmployees.getInt(0), cursorEmployees.getInt(0),
cursorEmployees.getInt(1), cursorEmployees.getInt(1),
cursorEmployees.getInt(2), cursorEmployees.getString(2),
cursorEmployees.getInt(3), cursorEmployees.getString(3),
cursorEmployees.getInt(4), cursorEmployees.getString(4),
cursorEmployees.getInt(5), cursorEmployees.getInt(5),
cursorEmployees.getInt(6), cursorEmployees.getInt(6),
cursorEmployees.getInt(7) cursorEmployees.getInt(7),
cursorEmployees.getInt(8),
cursorEmployees.getInt(9),
cursorEmployees.getInt(10),
cursorEmployees.getString(11)
)); ));
} while (cursorEmployees.moveToNext()); } while (cursorEmployees.moveToNext());
} }
...@@ -177,7 +181,7 @@ public class AACompleteScreen extends AppCompatActivity { ...@@ -177,7 +181,7 @@ public class AACompleteScreen extends AppCompatActivity {
try { try {
writer = new CSVWriter(new FileWriter(csv)); writer = new CSVWriter(new FileWriter(csv));
String[] entries = {"id","child_gender","child_age","total_correct_responses","correct_responses","commission_errors","omission_errors","mean_reaction_time","total_duration","diagnosis"}; String[] entries = {"id","child_gender","child_age", "sequence_of_responses", "sequence_of_stimuli", "sequence_of_sides", "total_correct_responses","correct_responses","commission_errors","omission_errors","mean_reaction_time","total_duration","diagnosis"};
writer.writeNext(entries); writer.writeNext(entries);
List<String[]> data = new ArrayList<String[]>(); List<String[]> data = new ArrayList<String[]>();
...@@ -188,13 +192,16 @@ public class AACompleteScreen extends AppCompatActivity { ...@@ -188,13 +192,16 @@ public class AACompleteScreen extends AppCompatActivity {
data.add(new String[]{ String.valueOf(gameData.getId()), data.add(new String[]{ String.valueOf(gameData.getId()),
String.valueOf(String.valueOf(gameData.getChildID()).charAt(0)), String.valueOf(String.valueOf(gameData.getChildID()).charAt(0)),
String.valueOf(String.valueOf(gameData.getChildID()).charAt(1)), String.valueOf(String.valueOf(gameData.getChildID()).charAt(1)),
String.valueOf(gameData.getSequence_of_responses()),
String.valueOf(gameData.getSequence_of_stimuli()),
String.valueOf(gameData.getSequence_of_sides()),
String.valueOf(gameData.getTotalCorrectResponses()), String.valueOf(gameData.getTotalCorrectResponses()),
String.valueOf(gameData.getNoOfCorrectResponses()), String.valueOf(gameData.getNoOfCorrectResponses()),
String.valueOf(gameData.getNoOfCommissionErrors()), String.valueOf(gameData.getNoOfCommissionErrors()),
String.valueOf(gameData.getNoOfOmmissionErrors()), String.valueOf(gameData.getNoOfOmmissionErrors()),
String.valueOf(gameData.getMeanReactionTime()), String.valueOf(gameData.getMeanReactionTime()),
String.valueOf(gameData.getTotalDuration()), String.valueOf(gameData.getTotalDuration()),
String.valueOf(ParentDetailsActivity.diagnosis) String.valueOf(gameData.getDiagnosis())
}); });
} }
......
...@@ -4,56 +4,128 @@ public class Alternating { ...@@ -4,56 +4,128 @@ public class Alternating {
private int id; private int id;
private int childID; private int childID;
private String sequence_of_responses;
private String sequence_of_stimuli;
private String sequence_of_sides;
private int totalCorrectResponses; private int totalCorrectResponses;
private int noOfCorrectResponses; private int noOfCorrectResponses;
private int noOfCommissionErrors; private int noOfCommissionErrors;
private int noOfOmmissionErrors; private int noOfOmmissionErrors;
private int meanReactionTime; private int meanReactionTime;
private int totalDuration; private int totalDuration;
private String diagnosis;
public Alternating(int id, int childID, int totalCorrectResponses, int noOfCorrectResponses, int noOfCommissionErrors, int noOfOmmissionErrors, int meanReactionTime, int totalDuration) { public Alternating(int id, int childID, String sequence_of_responses, String sequence_of_stimuli, String sequence_of_sides, int totalCorrectResponses, int noOfCorrectResponses, int noOfCommissionErrors, int noOfOmmissionErrors, int meanReactionTime, int totalDuration, String diagnosis) {
this.id = id; this.id = id;
this.childID = childID; this.childID = childID;
this.sequence_of_responses = sequence_of_responses;
this.sequence_of_stimuli = sequence_of_stimuli;
this.sequence_of_sides = sequence_of_sides;
this.totalCorrectResponses = totalCorrectResponses; this.totalCorrectResponses = totalCorrectResponses;
this.noOfCorrectResponses = noOfCorrectResponses; this.noOfCorrectResponses = noOfCorrectResponses;
this.noOfCommissionErrors = noOfCommissionErrors; this.noOfCommissionErrors = noOfCommissionErrors;
this.noOfOmmissionErrors = noOfOmmissionErrors; this.noOfOmmissionErrors = noOfOmmissionErrors;
this.meanReactionTime = meanReactionTime; this.meanReactionTime = meanReactionTime;
this.totalDuration = totalDuration; this.totalDuration = totalDuration;
this.diagnosis = diagnosis;
} }
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) {
this.id = id;
}
public int getChildID() { public int getChildID() {
return childID; return childID;
} }
public void setChildID(int childID) {
this.childID = childID;
}
public String getSequence_of_responses() {
return sequence_of_responses;
}
public void setSequence_of_responses(String sequence_of_responses) {
this.sequence_of_responses = sequence_of_responses;
}
public String getSequence_of_stimuli() {
return sequence_of_stimuli;
}
public void setSequence_of_stimuli(String sequence_of_stimuli) {
this.sequence_of_stimuli = sequence_of_stimuli;
}
public String getSequence_of_sides() {
return sequence_of_sides;
}
public void setSequence_of_sides(String sequence_of_sides) {
this.sequence_of_sides = sequence_of_sides;
}
public int getTotalCorrectResponses() { public int getTotalCorrectResponses() {
return totalCorrectResponses; return totalCorrectResponses;
} }
public void setTotalCorrectResponses(int totalCorrectResponses) {
this.totalCorrectResponses = totalCorrectResponses;
}
public int getNoOfCorrectResponses() { public int getNoOfCorrectResponses() {
return noOfCorrectResponses; return noOfCorrectResponses;
} }
public void setNoOfCorrectResponses(int noOfCorrectResponses) {
this.noOfCorrectResponses = noOfCorrectResponses;
}
public int getNoOfCommissionErrors() { public int getNoOfCommissionErrors() {
return noOfCommissionErrors; return noOfCommissionErrors;
} }
public void setNoOfCommissionErrors(int noOfCommissionErrors) {
this.noOfCommissionErrors = noOfCommissionErrors;
}
public int getNoOfOmmissionErrors() { public int getNoOfOmmissionErrors() {
return noOfOmmissionErrors; return noOfOmmissionErrors;
} }
public void setNoOfOmmissionErrors(int noOfOmmissionErrors) {
this.noOfOmmissionErrors = noOfOmmissionErrors;
}
public int getMeanReactionTime() { public int getMeanReactionTime() {
return meanReactionTime; return meanReactionTime;
} }
public void setMeanReactionTime(int meanReactionTime) {
this.meanReactionTime = meanReactionTime;
}
public int getTotalDuration() { public int getTotalDuration() {
return totalDuration; return totalDuration;
} }
public void setTotalDuration(int totalDuration) {
this.totalDuration = totalDuration;
}
public String getDiagnosis() {
return diagnosis;
}
public void setDiagnosis(String diagnosis) {
this.diagnosis = diagnosis;
}
/* /*
CREATE TABLE sustainedAttention ( CREATE TABLE sustainedAttention (
id int NOT NULL AUTO_INCREMENT, id int NOT NULL AUTO_INCREMENT,
......
...@@ -15,6 +15,8 @@ import android.util.Log; ...@@ -15,6 +15,8 @@ import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
...@@ -24,6 +26,7 @@ import com.anuththara18.attentionassessment.R; ...@@ -24,6 +26,7 @@ import com.anuththara18.attentionassessment.R;
import com.anuththara18.attentionassessment.age.AgeActivity; import com.anuththara18.attentionassessment.age.AgeActivity;
import com.anuththara18.attentionassessment.db.Api; import com.anuththara18.attentionassessment.db.Api;
import com.anuththara18.attentionassessment.db.RequestHandler; import com.anuththara18.attentionassessment.db.RequestHandler;
import com.anuththara18.attentionassessment.details.ParentDetailsActivity;
import com.anuththara18.attentionassessment.focused.FACompleteScreen; import com.anuththara18.attentionassessment.focused.FACompleteScreen;
import com.anuththara18.attentionassessment.gender.GenderActivity; import com.anuththara18.attentionassessment.gender.GenderActivity;
import com.anuththara18.attentionassessment.home.NavigationDrawerActivity; import com.anuththara18.attentionassessment.home.NavigationDrawerActivity;
...@@ -32,6 +35,7 @@ import com.anuththara18.attentionassessment.language.LanguageSetter; ...@@ -32,6 +35,7 @@ import com.anuththara18.attentionassessment.language.LanguageSetter;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Random; import java.util.Random;
...@@ -43,14 +47,18 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -43,14 +47,18 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
public static final String DATABASE_NAME = "alternatingAttention"; public static final String DATABASE_NAME = "alternatingAttention";
SQLiteDatabase mDatabase; SQLiteDatabase mDatabase;
String sequence_of_stimuli ="", sequence_of_sides ="";
ImageView imageView1, imageView2, cross_btn; ImageView imageView1, imageView2, cross_btn;
//ImageButton red_btn_left, red_btn_right;
TextView textView; TextView textView;
public static ArrayList<String> sequence_of_responses;
Random random = new Random(); Random random = new Random();
int radomImage = 0; int radomImage = 0;
int randomSide; int randomSide;
String side; String side;
int missed = 0;
int i = 1; int i = 1;
private long startTime, clickedTime = 0; private long startTime, clickedTime = 0;
...@@ -110,6 +118,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -110,6 +118,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
mp = MediaPlayer.create(getApplicationContext(), R.raw.alternating); mp = MediaPlayer.create(getApplicationContext(), R.raw.alternating);
mp.start(); mp.start();
sequence_of_responses = new ArrayList<>();
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override @Override
...@@ -156,17 +166,25 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -156,17 +166,25 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
side ="right"; side ="right";
} }
if (missed == 0 || missed == 2) {
sequence_of_responses.add("M");
Log.d("%%%%%%%%%%%%%%%%%%", String.valueOf(sequence_of_responses));
}
missed = 0;
if( side.equals("left")) { if( side.equals("left")) {
radomImage = random.nextInt(4); radomImage = random.nextInt(4);
//imageView2.setVisibility(View.INVISIBLE); //imageView2.setVisibility(View.INVISIBLE);
imageView2.setImageResource(0); imageView2.setImageResource(0);
imageView1.setVisibility(View.VISIBLE); imageView1.setVisibility(View.VISIBLE);
sequence_of_sides = sequence_of_sides + side + ", ";
if (leftcount > 4 ){ if (leftcount > 4 ){
leftcount = 0; leftcount = 0;
} }
imageView1.setImageResource(left_images[leftcount]); imageView1.setImageResource(left_images[leftcount]);
imageView1.setEnabled(true); imageView1.setEnabled(true);
imageView2.setEnabled(true); imageView2.setEnabled(true);
sequence_of_stimuli = sequence_of_stimuli + getLeftStimuli(leftcount);;
leftcount++; leftcount++;
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
clickedSide = "left"; clickedSide = "left";
...@@ -182,12 +200,14 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -182,12 +200,14 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
//imageView1.setVisibility(View.INVISIBLE); //imageView1.setVisibility(View.INVISIBLE);
imageView1.setImageResource(0); imageView1.setImageResource(0);
imageView2.setVisibility(View.VISIBLE); imageView2.setVisibility(View.VISIBLE);
sequence_of_sides = sequence_of_sides + side + ", ";;
if (rightcount > 4 ){ if (rightcount > 4 ){
rightcount = 0; rightcount = 0;
} }
imageView2.setImageResource(right_images[rightcount]); imageView2.setImageResource(right_images[rightcount]);
imageView1.setEnabled(true); imageView1.setEnabled(true);
imageView2.setEnabled(true); imageView2.setEnabled(true);
sequence_of_stimuli = sequence_of_stimuli + getRightStimuli(rightcount);;
rightcount++; rightcount++;
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
clickedSide = "right"; clickedSide = "right";
...@@ -200,6 +220,12 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -200,6 +220,12 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
} }
else { else {
if ( i == 20) {
if (missed == 0 || missed == 2) {
sequence_of_responses.add("M");
Log.d("%%%%%%%%%%%%%%%%%%", String.valueOf(sequence_of_responses));
}
}
long gameEnd = System.currentTimeMillis(); long gameEnd = System.currentTimeMillis();
long seconds = (gameEnd - gameStart) / 1000; long seconds = (gameEnd - gameStart) / 1000;
if ( noOfCorrectResponses == 0 ) { if ( noOfCorrectResponses == 0 ) {
...@@ -217,7 +243,12 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -217,7 +243,12 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
Log.d("commissionErrors", String.valueOf(noOfCommissionErrors)); Log.d("commissionErrors", String.valueOf(noOfCommissionErrors));
Log.d("meanReactionTime", String.valueOf(meanReactionTime)); Log.d("meanReactionTime", String.valueOf(meanReactionTime));
Log.d("duration", String.valueOf(duration)); Log.d("duration", String.valueOf(duration));
saveDataToOnlineDB(); sequence_of_responses.remove(0);
Log.d("responses", String.valueOf(sequence_of_responses));
Log.d("sides", String.valueOf(sequence_of_sides));
Log.d("stimuli", String.valueOf(sequence_of_stimuli));
//saveDataToOnlineDB();
createTable(); createTable();
saveDataToLocalDB(); saveDataToLocalDB();
Intent intent = new Intent(getApplicationContext(), AACompleteScreen.class); Intent intent = new Intent(getApplicationContext(), AACompleteScreen.class);
...@@ -232,6 +263,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -232,6 +263,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
imageView1.setOnClickListener(new View.OnClickListener() { imageView1.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
imageView1.startAnimation(animZoomOut);
mp2 = MediaPlayer.create(getApplicationContext(), R.raw.button_click); mp2 = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp2.start(); mp2.start();
clickedTime = System.currentTimeMillis(); clickedTime = System.currentTimeMillis();
...@@ -240,11 +273,17 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -240,11 +273,17 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
totalReactionTime = totalReactionTime + reactionTime; totalReactionTime = totalReactionTime + reactionTime;
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime); Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++; noOfCorrectResponses++;
missed = 1;
sequence_of_responses.add("C");
Log.d("%%%%%%%%%%%%%%%%%%", String.valueOf(sequence_of_responses));
imageView1.setEnabled(false); imageView1.setEnabled(false);
} }
else { else {
Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime); Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime);
noOfCommissionErrors++; noOfCommissionErrors++;
missed = 2;
sequence_of_responses.add("W");
Log.d("%%%%%%%%%%%%%%%%%%", String.valueOf(sequence_of_responses));
} }
} }
}); });
...@@ -252,6 +291,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -252,6 +291,8 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
imageView2.setOnClickListener(new View.OnClickListener() { imageView2.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Animation animZoomOut = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
imageView2.startAnimation(animZoomOut);
mp3 = MediaPlayer.create(getApplicationContext(), R.raw.button_click); mp3 = MediaPlayer.create(getApplicationContext(), R.raw.button_click);
mp3.start(); mp3.start();
clickedTime = System.currentTimeMillis(); clickedTime = System.currentTimeMillis();
...@@ -260,11 +301,17 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -260,11 +301,17 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
totalReactionTime = totalReactionTime + reactionTime; totalReactionTime = totalReactionTime + reactionTime;
Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime); Log.d("correct " , startTime + " " + clickedTime + " " + reactionTime);
noOfCorrectResponses++; noOfCorrectResponses++;
missed = 1;
sequence_of_responses.add("C");
Log.d("%%%%%%%%%%%%%%%%%%", String.valueOf(sequence_of_responses));
imageView2.setEnabled(false); imageView2.setEnabled(false);
} }
else { else {
Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime); Log.d( "wrong" , startTime + " " + clickedTime + " " + reactionTime);
noOfCommissionErrors++; noOfCommissionErrors++;
missed = 2;
sequence_of_responses.add("W");
Log.d("%%%%%%%%%%%%%%%%%%", String.valueOf(sequence_of_responses));
} }
} }
}); });
...@@ -295,6 +342,36 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -295,6 +342,36 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
} }
private String getLeftStimuli(int leftcount) {
if (leftcount == 0) {
return "white bunny, ";
}else if (leftcount == 1) {
return "pink pig, ";
}else if (leftcount == 2) {
return "brown dog, ";
}else if (leftcount == 3) {
return "pale brown cat, ";
}else if (leftcount == 4) {
return "pink unicorn, ";
}
return "null";
}
private String getRightStimuli(int rightcount) {
if (rightcount == 0) {
return "red star, ";
}else if (rightcount == 1) {
return "red crab, ";
}else if (rightcount == 2) {
return "red fish, ";
}else if (rightcount == 3) {
return "blue fish, ";
}else if (rightcount == 4) {
return "brown octopus, ";
}
return "null";
}
/*************************************************************************************************/ /*************************************************************************************************/
@Override @Override
...@@ -427,12 +504,16 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -427,12 +504,16 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
"CREATE TABLE IF NOT EXISTS alternatingAttention (\n" + "CREATE TABLE IF NOT EXISTS alternatingAttention (\n" +
" id INTEGER PRIMARY KEY AUTOINCREMENT,\n" + " id INTEGER PRIMARY KEY AUTOINCREMENT,\n" +
" childID int NOT NULL,\n" + " childID int NOT NULL,\n" +
" sequence_of_responses text NOT NULL,\n" +
" sequence_of_stimuli text NOT NULL,\n" +
" sequence_of_sides text NOT NULL,\n" +
" totalCorrectResponses int NOT NULL,\n" + " totalCorrectResponses int NOT NULL,\n" +
" noOfCorrectResponses int NOT NULL,\n" + " noOfCorrectResponses int NOT NULL,\n" +
" noOfCommissionErrors int NOT NULL,\n" + " noOfCommissionErrors int NOT NULL,\n" +
" noOfOmmissionErrors int NOT NULL,\n" + " noOfOmmissionErrors int NOT NULL,\n" +
" meanReactionTime int NOT NULL,\n" + " meanReactionTime int NOT NULL,\n" +
" totalDuration int NOT NULL\n" + " totalDuration int NOT NULL,\n" +
" diagnosis text NOT NULL\n" +
");" ");"
); );
} }
...@@ -451,11 +532,11 @@ public class AlternatingAttentionGame1 extends AppCompatActivity { ...@@ -451,11 +532,11 @@ public class AlternatingAttentionGame1 extends AppCompatActivity {
int total_duration = duration; int total_duration = duration;
String insertSQL = "INSERT INTO alternatingAttention \n" + String insertSQL = "INSERT INTO alternatingAttention \n" +
"(childID, totalCorrectResponses, noOfCorrectResponses, noOfCommissionErrors, noOfOmmissionErrors, meanReactionTime, totalDuration)\n" + "(childID, sequence_of_responses, sequence_of_stimuli, sequence_of_sides, totalCorrectResponses, noOfCorrectResponses, noOfCommissionErrors, noOfOmmissionErrors, meanReactionTime, totalDuration, diagnosis)\n" +
"VALUES \n" + "VALUES \n" +
"(?, ?, ?, ?, ?, ?, ?);"; "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
mDatabase.execSQL(insertSQL, new Integer[]{child_ID, total_correct_responses, no_of_correct_responses, no_of_commission_errors, no_of_ommission_errors, mean_reaction_time, total_duration}); mDatabase.execSQL(insertSQL, new Object[]{child_ID, sequence_of_responses, sequence_of_stimuli, sequence_of_sides, total_correct_responses, no_of_correct_responses, no_of_commission_errors, no_of_ommission_errors, mean_reaction_time, total_duration, ParentDetailsActivity.diagnosis});
//Toast.makeText(this, "Data Added Successfully", Toast.LENGTH_SHORT).show(); //Toast.makeText(this, "Data Added Successfully", Toast.LENGTH_SHORT).show();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment