Commit c8d7fd80 authored by Gaurav Arora (gaa721)'s avatar Gaurav Arora (gaa721)
Browse files

Indentationa and fixed date bug

parent 3762af67
......@@ -85,7 +85,7 @@ PrintWriter writer;
FileWriter fw ;
BufferedWriter bw;
String folderName ;
String tempQuestion,tempType="";
String tempQuestion, tempType="";
boolean tempQAnswered = false;
boolean tempTAnswered = false;
// D)
......@@ -121,22 +121,27 @@ ArrayList<Question> questions ;
char tempFiler = 'F';
void setup()
{
createGUI();
startMenu = true;
tempQAnswered = false;
tempTAnswered = false;
questionToBeSaved.setVisible(false);
QuestionType.setVisible(false);
textfield2.setVisible(false);
setupInside();
createGUI();
startMenu = true;
tempQAnswered = false;
tempTAnswered = false;
background(255, 255, 255);
questionToBeSaved.setVisible(false);
QuestionType.setVisible(false);
textfield2.setVisible(false);
setupInside();
fill(0);
textSize(20);
text("Welcome to the Attention Study.\n In this part of the study There will be a drawing made on screen and then after sometime there will be a black screen. Black screen would mean that you are not attentive at that time. After the Black Screen there would be Questions asking what do you think happened when you were not attentive that is when where was a black screen. Press Enter when you want to start.", displayWidth/2, displayHeight/2+200, 400, 400);
}
void setupInside()
{
QuestionCounter = 0;
button1.setVisible(false);
// createGUI1();
frameCounter = 0;
......@@ -152,7 +157,6 @@ void setupInside()
questionSaving = false;
questions = new ArrayList<Question>();
changingFile = false;
if (questionSaving)
{
......@@ -217,7 +221,6 @@ void setupInside()
*/
rectMode(RADIUS);
moving=false;
background(255, 255, 255);
p = new Person("gaurav", 0, 0, 255);
i=1;
......@@ -287,63 +290,59 @@ void setupInside()
return;
}
}
// eof = false;
// if (!questionSaving && !saveornot)
// {
// try {
// while (!eof)
// {
// Question tempQuest = (Question) inQ.readObject();
// print(QuestiontoString(tempQuest));
// questions.add(tempQuest);
// }
// }
// catch(ClassNotFoundException i) {
// }
//
// catch(java.io.EOFException ex1)
// {
// eof=true;
// }
// catch(IOException i)
// {
// i.printStackTrace();
// return;
// }
//}
if(!questionSaving && !saveornot)
{
for(int i=0;i<questionandanswers[((int)tempFiler) - 70].length;i++)
questions.add(questionandanswers[((int)tempFiler) - 70][i]);
// eof = false;
// if (!questionSaving && !saveornot)
// {
// try {
// while (!eof)
// {
// Question tempQuest = (Question) inQ.readObject();
// print(QuestiontoString(tempQuest));
// questions.add(tempQuest);
// }
// }
// catch(ClassNotFoundException i) {
// }
//
// catch(java.io.EOFException ex1)
// {
// eof=true;
// }
// catch(IOException i)
// {
// i.printStackTrace();
// return;
// }
//}
if (!questionSaving && !saveornot)
{
for (int i=0;i<questionandanswers[((int)tempFiler) - 70].length;i++)
questions.add(questionandanswers[((int)tempFiler) - 70][i]);
}
}
//questions.add(questionandanswers[0]);
//questions.add(questionandanswers[0]);
//print(p.shapes.size());
// for (Shape s: p.shapes)
// {
// //print(s.data.shape);
// }
}
public String Recshow1(Rectangle r){
return "new Rectangle(" + r.p1.show() + "," + r.p2.show() +")";
public String Recshow1(Rectangle r) {
}
String QuestiontoString(Question q )
{
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "," + Recshow1(q.answer) ;
}
return "new Rectangle(" + r.p1.show() + "," + r.p2.show() +")";
}
String QuestiontoString(Question q )
{
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "," + Recshow1(q.answer) ;
}
void draw()
{
if (!changingFile)
{
......@@ -366,12 +365,12 @@ void draw()
{
attention = false;
///when saving questions reverse
drawing();
background(0, 0, 0);
/////////////////////////////////////////////////
background(0, 0, 0);
/////////////////////////////////////////////////
if (p.Ecounter>=p.e.e.size()-3 )
timer= 200;
......@@ -380,26 +379,24 @@ void draw()
timer = 0;
Stime = (int)totalShapesandTrailCount;
drawing();
question = true;
question = true;
textSize(20);
fill(0, 0, 0);
if (!questionSaving)
text(questions.get(QuestionCounter).getQuestion(), 600, 600);
else
{
tempType = showInputDialog("Please enter the type");
tempQuestion = showInputDialog("Please enter the Question");
if (tempType.equals("Text" ))
{
tempType = showInputDialog("Please enter the type");
tempQuestion = showInputDialog("Please enter the Question");
if(tempType.equals("Text" ))
{
//questionToBeSaved.setVisible(true);
}
}
//questionToBeSaved.setVisible(true);
}
}
}
}
}
......@@ -421,7 +418,7 @@ void draw()
popMatrix();
if (!questionSaving)
text(questions.get(QuestionCounter).getQuestion(), 600, 600);
rectMode(CORNERS);
fill(0, 0, 0, 80);
// rect(questionBoxX, questionBoxY, sqrt(sq(mouseX-questionBoxX) + sq(mouseY - questionBoxY)), sqrt(sq(mouseX-questionBoxX) + sq(mouseY - questionBoxY)));
......@@ -435,7 +432,6 @@ void draw()
else
drawing();
}
}
......@@ -476,8 +472,8 @@ void mousePressed()
void mouseReleased()
{
Rectangle r1=null;
Rectangle r1=null;
if (mp && !question)
{
......@@ -492,96 +488,93 @@ void mouseReleased()
// rectMode(CORNER);
// fill(0,0,0,80);
// rect(questionBoxX,questionBoxX,mouseX,mouseY);
if(questionSaving && tempType.equals("Rectangle"))
{
print("yippee");
questionMouse = true;
question = false;
r1 = new Rectangle(questionBoxX, questionBoxY, mouseX, mouseY);
//print(questionBoxX + " " +questionBoxY + " " +mouseX + " " +mouseY);
r1.show();
}
else if (!questionSaving )
{
if(questions.get(QuestionCounter).type.equals( "Rectangle") )
{
questionMouse = true;
question = false;
r1 = new Rectangle(questionBoxX, questionBoxY, mouseX, mouseY);
//print(questionBoxX + " " +questionBoxY + " " +mouseX + " " +mouseY);
r1.show();
}
}
//if( (!questionSaving && questions.get(QuestionCounter).type.equals( "Text") ) || questionSaving && tempType.equals("Text"))
//{
// questionMouse = true;
// question = false;
// textfield2.setVisible(true);
//
//
//}
if (!questionSaving)
if (questionSaving && tempType.equals("Rectangle"))
{
if(questions.get(QuestionCounter).type.equals( "Rectangle"))
print("yippee");
questionMouse = true;
question = false;
r1 = new Rectangle(questionBoxX, questionBoxY, mouseX, mouseY);
//print(questionBoxX + " " +questionBoxY + " " +mouseX + " " +mouseY);
r1.show();
}
else if (!questionSaving )
{
// questions.get(QuestionCounter).answer.show();
double intersection = r1.getIntersectionPercent(r1,questions.get(QuestionCounter).answer );
double bigRecRatio = (r1.getArea()/questions.get(QuestionCounter).answer.getArea());
print(intersection);
String rightorwronng = "";
if ( intersection > 70.0 && bigRecRatio <2.00)
if (questions.get(QuestionCounter).type.equals( "Rectangle") )
{
rightorwronng = "Correct";
}
else if ( intersection > 40.0 && bigRecRatio <2.00)
{
rightorwronng = "Maybe";
questionMouse = true;
question = false;
r1 = new Rectangle(questionBoxX, questionBoxY, mouseX, mouseY);
//print(questionBoxX + " " +questionBoxY + " " +mouseX + " " +mouseY);
r1.show();
}
else if (intersection > 70.0)
rightorwronng = "overFlow Correct";
else if ( intersection > 40.0)
rightorwronng = "overFlow maybe";
else rightorwronng = "Incorrect";
writer.println("Date " + date.toString() + " Timestamp: " + millis() + " Partipation ID: " + participationID +" Trial number: " + tempFiler + (QuestionCounter+1) + " Correct Answer: " + RectoString(questions.get(QuestionCounter).answer) + " Answer Given: " + RectoString(r1) +" Intersection Percentage: " + intersection + " Answer Given/ Answer Ratio: "+ bigRecRatio +" Comment: " + rightorwronng );
pushMatrix();
textSize(20);
fill(0, 0, 0);
text( "participationID: " + participationID, 200, 200);
popMatrix();
save(folderName + "/" + day()+"-"+month()+"-"+year()+"-"+ hour()+"-"+minute() +"-"+second()+ "-" +millis() +"-"+ participationID +"-" + tempFiler + (QuestionCounter+1)+ ".png");
QuestionCounter++;
if (QuestionCounter>=questions.size())
}
//if( (!questionSaving && questions.get(QuestionCounter).type.equals( "Text") ) || questionSaving && tempType.equals("Text"))
//{
// questionMouse = true;
// question = false;
// textfield2.setVisible(true);
//
//
//}
if (!questionSaving)
{
if (questions.get(QuestionCounter).type.equals( "Rectangle"))
{
background(255, 255, 255);
// questions.get(QuestionCounter).answer.show();
double intersection = r1.getIntersectionPercent(r1, questions.get(QuestionCounter).answer );
double bigRecRatio = (r1.getArea()/questions.get(QuestionCounter).answer.getArea());
print(intersection);
String rightorwronng = "";
if ( intersection > 70.0 && bigRecRatio <2.00)
{
rightorwronng = "Correct";
}
else if ( intersection > 40.0 && bigRecRatio <2.00)
{
rightorwronng = "Maybe";
}
else if (intersection > 70.0)
rightorwronng = "overFlow Correct";
else if ( intersection > 40.0)
rightorwronng = "overFlow maybe";
else rightorwronng = "Incorrect";
date = new Date();
writer.println("Date " + date.toString() + " Timestamp: " + millis() + " Partipation ID: " + participationID +" Trial number: " + tempFiler + (QuestionCounter+1) + " Correct Answer: " + RectoString(questions.get(QuestionCounter).answer) + " Answer Given: " + RectoString(r1) +" Intersection Percentage: " + intersection + " Answer Given/ Answer Ratio: "+ bigRecRatio +" Comment: " + rightorwronng );
pushMatrix();
textSize(20);
text("Thanks", 200, 200);
// createGUI1();
button1.setVisible(true);
changingFile = true;
// noLoop();
}
}
fill(0, 0, 0);
text( "participationID: " + participationID, 200, 200);
popMatrix();
save(folderName + "/" + day()+"-"+month()+"-"+year()+"-"+ hour()+"-"+minute() +"-"+second()+ "-" +millis() +"-"+ participationID +"-" + tempFiler + (QuestionCounter+1)+ ".png");
QuestionCounter++;
if (QuestionCounter>=questions.size())
{
background(255, 255, 255);
textSize(20);
text("Thanks", 200, 200);
// createGUI1();
button1.setVisible(true);
changingFile = true;
// noLoop();
}
}
}
else
{
if(tempType.equals( "Rectangle"))
if (tempType.equals( "Rectangle"))
try {
outQ.writeObject(new Question(tempType,tempQuestion,r1));
outQ.writeObject(new Question(tempType, tempQuestion, r1));
}
catch(IOException i) {
}
......@@ -684,8 +677,6 @@ void drawing()
if (timer<=100 )
{
}
else if (timer>=200 )
......@@ -845,8 +836,6 @@ void drawing()
p.drawAll();
}
......@@ -874,5 +863,4 @@ public String RectoString(Rectangle r)
......@@ -8,14 +8,14 @@ class Question implements Serializable
Rectangle answer;
public Question(String type ,String quest, Rectangle ans)
public Question(String type, String quest, Rectangle ans)
{
this.type = type;
this.question = quest;
this.answer = ans;
}
public Question( String type,String quest)
public Question( String type, String quest)
{
this.type = type;
this.question = quest;
......
......@@ -54,8 +54,6 @@ public class Rectangle implements Serializable {
System.out.println("Point p1 is : " + p1.show());
System.out.println("Point p2 is : " + p2.show());
System.out.println("new Rectangle(" + p1.show() + "," + p2.show() +")");
}
public boolean validate() {
......@@ -161,5 +159,4 @@ public class Rectangle implements Serializable {
Date Wed Sep 09 12:20:14 GMT-06:00 2015 Timestamp: 20862 Partipation ID: 12 Trial number: F1 Correct Answer: Point 1: X: 245.0 Y: 245.0 Point 2: X: 359.0 Y: 330.0 Answer Given: Point 1: X: 255.0 Y: 244.0 Point 2: X: 362.0 Y: 322.0 Intersection Percentage: 95.95015576323988 Answer Given/ Answer Ratio: 0.8613003095975232 Comment: Correct
Date Wed Sep 09 15:50:30 GMT-06:00 2015 Timestamp: 17895 Partipation ID: 12 Trial number: F1 Correct Answer: Point 1: X: 245.0 Y: 245.0 Point 2: X: 359.0 Y: 330.0 Answer Given: Point 1: X: 250.0 Y: 243.0 Point 2: X: 354.0 Y: 323.0 Intersection Percentage: 97.5 Answer Given/ Answer Ratio: 0.8586171310629515 Comment: Correct
Date Wed Sep 09 15:50:48 GMT-06:00 2015 Timestamp: 36131 Partipation ID: 12 Trial number: F2 Correct Answer: Point 1: X: 365.0 Y: 609.0 Point 2: X: 398.0 Y: 655.0 Answer Given: Point 1: X: 392.0 Y: 602.0 Point 2: X: 370.0 Y: 650.0 Intersection Percentage: 85.41666666666666 Answer Given/ Answer Ratio: 0.6956521739130435 Comment: Correct
Date Wed Sep 09 15:51:11 GMT-06:00 2015 Timestamp: 58642 Partipation ID: 12 Trial number: F3 Correct Answer: Point 1: X: 1033.0 Y: 179.0 Point 2: X: 1138.0 Y: 275.0 Answer Given: Point 1: X: 1040.0 Y: 176.0 Point 2: X: 1129.0 Y: 273.0 Intersection Percentage: 96.90721649484536 Answer Given/ Answer Ratio: 0.8564484126984127 Comment: Correct
Date Wed Sep 09 15:51:35 GMT-06:00 2015 Timestamp: 82523 Partipation ID: 12 Trial number: F4 Correct Answer: Point 1: X: 1124.0 Y: 419.0 Point 2: X: 1237.0 Y: 348.0 Answer Given: Point 1: X: 1237.0 Y: 349.0 Point 2: X: 1121.0 Y: 418.0 Intersection Percentage: 0.0 Answer Given/ Answer Ratio: 0.9976318085504176 Comment: Incorrect
Date Wed Sep 09 15:52:16 GMT-06:00 2015 Timestamp: 22735 Partipation ID: draw Trial number: F1 Correct Answer: Point 1: X: 245.0 Y: 245.0 Point 2: X: 359.0 Y: 330.0 Answer Given: Point 1: X: 353.0 Y: 320.0 Point 2: X: 253.0 Y: 248.0 Intersection Percentage: 100.0 Answer Given/ Answer Ratio: 0.7430340557275542 Comment: Correct
Date Wed Sep 09 15:52:36 GMT-06:00 2015 Timestamp: 43249 Partipation ID: draw Trial number: F2 Correct Answer: Point 1: X: 365.0 Y: 609.0 Point 2: X: 398.0 Y: 655.0 Answer Given: Point 1: X: 393.0 Y: 641.0 Point 2: X: 367.0 Y: 610.0 Intersection Percentage: 100.0 Answer Given/ Answer Ratio: 0.530961791831357 Comment: Correct
Date Wed Sep 09 15:52:57 GMT-06:00 2015 Timestamp: 64035 Partipation ID: draw Trial number: F3 Correct Answer: Point 1: X: 1033.0 Y: 179.0 Point 2: X: 1138.0 Y: 275.0 Answer Given: Point 1: X: 1150.0 Y: 258.0 Point 2: X: 1033.0 Y: 184.0 Intersection Percentage: 0.0 Answer Given/ Answer Ratio: 0.8589285714285714 Comment: Incorrect
Date Wed Sep 09 15:53:20 GMT-06:00 2015 Timestamp: 87166 Partipation ID: draw Trial number: F4 Correct Answer: Point 1: X: 1124.0 Y: 419.0 Point 2: X: 1237.0 Y: 348.0 Answer Given: Point 1: X: 1126.0 Y: 423.0 Point 2: X: 1232.0 Y: 352.0 Intersection Percentage: 94.36619718309859 Answer Given/ Answer Ratio: 0.9380530973451328 Comment: Correct
......@@ -5,9 +5,9 @@
* designer and care should be taken when editing this file.
* Only add/edit code inside the event handlers i.e. only
* use lines between the matching comment tags. e.g.
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
// It is safe to enter your event code here
// It is safe to enter your event code here
} //_CODE_:button1:12356:
* Do not rename this tab!
......@@ -68,45 +68,40 @@ public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:9830
// tempFiler = (char)((int)(tempFiler-1);
tempFiler++;
if((int)tempFiler > 73)
if ((int)tempFiler > 73)
{
noLoop();
background(255);
text("Thanks",200,200);
text("Thanks", 200, 200);
source.setVisible(false);
}
else
setupInside();
setupInside();
// loop();
} //_CODE_:button1:983045:
public void textfield2_change1(GTextField source, GEvent event) { //_CODE_:questionToBeSaved:568734:
println("question - GTextField >> GEvent." + event + " @ " + millis());
if (event == GEvent.ENTERED)
{
tempQuestion = source.getText();
tempQuestion = source.getText();
source.setVisible(false);
}
} //_CODE_:questionToBeSaved:568734:
public void textfield2_change2(GTextField source, GEvent event) { //_CODE_:QuestionType:844807:
println("QuestionType - GTextField >> GEvent." + event + " @ " + millis());
if (event == GEvent.ENTERED)
{
tempType = source.getText();
source.setVisible(false);
loop();
}
} //_CODE_:QuestionType:844807:
public void textfield2_change3(GTextField source, GEvent event) { //_CODE_:textfield2:870671:
......@@ -117,11 +112,11 @@ public void textfield2_change3(GTextField source, GEvent event) { //_CODE_:textf
// Create all the GUI controls.
// autogenerated do not edit
public void createGUI(){
public void createGUI() {
G4P.messagesEnabled(false);
G4P.setGlobalColorScheme(GCScheme.BLUE_SCHEME);
G4P.setCursor(ARROW);
if(frame != null)
if (frame != null)
frame.setTitle("Sketch Window");
label1 = new GLabel(this, 63, 195, 122, 24);
label1.setText("Enter Participation ID:");
......
......@@ -130,6 +130,9 @@ void setup()
QuestionType.setVisible(false);