Commit f368d89e authored by unknown's avatar unknown
Browse files

Updated to proc 3.0, Commenting, Modularity, TrailQuestion

parent 42f1e99c
.DS_Store
applet
application.linux32
application.linux64
application.windows32
application.windows64
application.macosx
\ No newline at end of file
String user = "gaa721" ;
Box p, q ;
Box2DProcessing box2d;
ArrayList<Boundary> boundaries;
boolean attention;
Person p1, p2;
String events, events1 ;
String participationID;
char[] a, a1;
int eventcheck, eventcheck1;
char keyed;
float timer, Stime;
float questionBoxX, questionBoxY;
boolean question, questionMouse;
boolean saving;
boolean eof;
int pointCounter, pointCounter1;
int drawDelay;
ObjectOutputStream out, outE, outQ;
ObjectInputStream in, inE, inQ;
OutputStream os;
FileOutputStream fileOut, fileOutE, fileOutQ;
FileInputStream fileIn, fileInE, fileInQ;
ArrayList<Point> pointsP1, pointsP2, printPoint;
int frameCounter;
boolean startMenu ;
String dataSet;
boolean left1, right1, up1, down1;
boolean left2, right2, up2, down2;
String tempQuestion, tempType="";
boolean tempQAnswered = false;
boolean tempTAnswered = false;
Date date = new Date();
//File logfile ;// new File("c:/Users/gaa721/Desktop/" + date.toString() + "-" + participationID );
PrintWriter writer;
FileWriter fw ;
BufferedWriter bw;
String folderName ;
boolean changingFile;
int QuestionCounter;
char tempFiler = 'B';
String tempAnswer = "";
boolean questionSaving;
ArrayList<Question> questions ;
boolean trailAnswerSaving = true;
\ No newline at end of file
//
//
//boolean similarityQuestiont(float [] x,float[] correct)
//{
// int sCheck=0;
// for(int i=0;i<correct.length;i++)
// {
//
// for(int j=0;j<x.length;j++)
// {
// if(x[j] == (correct[i]))
// sCheck++;
//
// }
//
//
//
// }
//
// print(sCheck);
// if(sCheck > 0.75*correctX.length)
// return true;
// else
// return false;
//
//
//}
public String PointtoString(Rectangle.Point p)
{
return "X: " + p.x + " Y: " + p.y;
}
public String RectoString(Rectangle r)
{
return "Point 1: " + PointtoString(r.p1) + " Point 2: " + PointtoString(r.p2) ;
}
//int min3(unsigned int a, unsigned int b, unsigned int c)
//{
// unsigned int m = a;
// if (m > b) m = b;
// if (m > c) m = c;
// return m;
//}
public static double similarity(String s1, String s2) {
String longer = s1, shorter = s2;
if (s1.length() < s2.length()) { // longer should always have greater length
longer = s2;
shorter = s1;
}
int longerLength = longer.length();
if (longerLength == 0) {
return 1.0; /* both strings are zero length */
}
/* // If you have StringUtils, you can use it to calculate the edit distance:
return (longerLength - StringUtils.getLevenshteinDistance(longer, shorter)) /
(double) longerLength; */
return (longerLength - editDistance(longer, shorter)) / (double) longerLength;
}
public static int editDistance(String s1, String s2) {
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
int[] costs = new int[s2.length() + 1];
for (int i = 0; i <= s1.length(); i++) {
int lastValue = i;
for (int j = 0; j <= s2.length(); j++) {
if (i == 0)
costs[j] = j;
else {
if (j > 0) {
int newValue = costs[j - 1];
if (s1.charAt(i - 1) != s2.charAt(j - 1))
newValue = Math.min(Math.min(newValue, lastValue),
costs[j]) + 1;
costs[j - 1] = lastValue;
lastValue = newValue;
}
}
}
if (i > 0)
costs[s2.length()] = lastValue;
}
return costs[s2.length()];
}
\ No newline at end of file
import java.io.*;
import java.util.ArrayList;
class Question implements Serializable
{
String type;
String question;
Rectangle answer;
String tAnswer;
public Question(String type, String quest, Rectangle ans)
{
this.type = type;
this.question = quest;
this.answer = ans;
}
public Question( String type, String quest)
{
this.type = type;
this.question = quest;
}
public Question(String type, String quest, String ans)
{
this.type = type;
this.question = quest;
this.tAnswer = ans;
}
//
// public Question(String quest)
// {
// this.question = quest;
// this.answer = ans;
// }
public String getQuestion()
{
return question;
}
public void setQuestion(String quest)
{
this.question = quest;
}
public void setQuestion (Rectangle ans)
{
this.answer = ans;
}
}
import java.io.*;
import java.util.ArrayList;
class Question implements Serializable
{
String quest;
public Question( String quest)
{
this.quest = quest;
}
public String getQuestion()
{
return quest;
}
public void setQuestion(String quest)
{
this.quest = quest;
}
public void presentQuestion()
{
}
public String getType()
{
return "";
}
public Rectangle getAnswer()
{
return null;
}
}
\ No newline at end of file
Question [][] questionandanswers = {
{
new Question( "Rectangle", "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(649.0, 299.0, 701.0, 342.0)),
new Question( "Rectangle", "When you were non attentive tanks were moved. Did blue tank bounce? If yes, then Mark the position where it bounced if no mark the blue tank. ", new Rectangle(207.0, 247.0, 278.0, 308.0))
}
,
{
new Question( "Text", "When you were not attentive, Blue tank rotated in som direction.Was it clockise,anticlockwise, or you are not sure?", "clockwise"),
new Question( "Text", "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Blue")
}
,
{
new Question( "Rectangle", "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(130.0, 116.0, 166.0, 150.0)),
new Question( "Rectangle", "When you were non attentive tanks were moved. Did blue tank bounce? If yes, then Mark the position where it bounced if no mark the blue tank. ", new Rectangle(352.0, 934.0, 417.0, 993.0))
}
,
{
new Question( "Text", "When you were not attnetivem Blue tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure.", "Anticlockwise"),
new Question( "Text", "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Green")
}
,
{
new Question( "Rectangle", "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(876.0, 390.0, 918.0, 433.0)),
new Question( "Rectangle", "When you were non attentive tanks were moved. Did green tank bounce? If yes, then Mark the position where it bounced if no, mark the green tank.", new Rectangle(7.0, 672.0, 65.0, 729.0))
}
,
{
new Question( "Text", "When you were not attentive green tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure.", "clockwise"),
new Question( "Text", "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Green")
}
,
{
new Question( "Text", "When you were not attentive Blue tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure.", "Anticlockwise"),
new Question( "Text", "When you were not attentive both the tanks were moved. Which of the tank travelled more distance. ", "Green")
}
,
{
new Question( "Rectangle", "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(120.0, 153.0, 164.0, 193.0)),
new Question( "Rectangle", "When you were non attentive tanks were moved. Did green tank bounce? If yes, then Mark the position where it bounced if no mark the green tank.", new Rectangle(541.0, 389.0, 614.0, 448.0))
}
,
{
new Question( "Text", "When you were not attentive Blue tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure. ", "anticlockwise"),
new Question( "Text", "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Green"),
}
,
{
new Question( "Rectangle", "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(903.0, 140.0, 935.0, 170.0)),
new Question( "Rectangle", "When you were non attentive tanks were moved. Did blue tank bounce? If yes, then Mark the position where it bounced if no mark the blue tank.", new Rectangle(531.0, 142.0, 610.0, 207.0))
}
};
Question [][] questionandanswers = {
{
new RectangleQuestion( "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(649.0, 299.0, 701.0, 342.0)),
new RectangleQuestion( "When you were non attentive tanks were moved. Did blue tank bounce? If yes, then Mark the position where it bounced if no mark the blue tank. ", new Rectangle(207.0, 247.0, 278.0, 308.0))
}
,
{
//new TrailQuestion( "When you were not attentive, Blue tank rotated in som direction.Was it clockise,anticlockwise, or you are not sure?", "clockwise"),
new TrailQuestion( "When you were not attentive, Blue tank rotated in som direction.Was it clockise,anticlockwise, or you are not sure?"),
new TextQuestion( "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Blue")
}
,
{
new RectangleQuestion( "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(130.0, 116.0, 166.0, 150.0)),
new RectangleQuestion( "When you were non attentive tanks were moved. Did blue tank bounce? If yes, then Mark the position where it bounced if no mark the blue tank. ", new Rectangle(352.0, 934.0, 417.0, 993.0))
}
,
{
new TextQuestion( "When you were not attnetivem Blue tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure.", "Anticlockwise"),
new TextQuestion( "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Green")
}
,
{
new RectangleQuestion( "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(876.0, 390.0, 918.0, 433.0)),
new RectangleQuestion( "When you were non attentive tanks were moved. Did green tank bounce? If yes, then Mark the position where it bounced if no, mark the green tank.", new Rectangle(7.0, 672.0, 65.0, 729.0))
}
,
{
new TextQuestion( "When you were not attentive green tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure.", "clockwise"),
new TextQuestion( "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Green")
}
,
{
new TextQuestion( "When you were not attentive Blue tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure.", "Anticlockwise"),
new TextQuestion( "When you were not attentive both the tanks were moved. Which of the tank travelled more distance. ", "Green")
}
,
{
new RectangleQuestion( "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(120.0, 153.0, 164.0, 193.0)),
new RectangleQuestion( "When you were non attentive tanks were moved. Did green tank bounce? If yes, then Mark the position where it bounced if no mark the green tank.", new Rectangle(541.0, 389.0, 614.0, 448.0))
}
,
{
new TextQuestion( "When you were not attentive Blue tank was rotated in some direction. Was it clockwise,anticlockwise or you are not sure. ", "anticlockwise"),
new TextQuestion( "When you were not attentive both the tanks were moved. Which of the tank travelled more distance.", "Green"),
}
,
{
new RectangleQuestion( "When you were not attentive tanks were moved. Mark the initial position of the green tank.", new Rectangle(903.0, 140.0, 935.0, 170.0)),
new RectangleQuestion( "When you were non attentive tanks were moved. Did blue tank bounce? If yes, then Mark the position where it bounced if no mark the blue tank.", new Rectangle(531.0, 142.0, 610.0, 207.0))
}
};
\ No newline at end of file
class RectangleQuestion extends Question {
Rectangle answer;
public RectangleQuestion(String question, Rectangle answer)
{
super(question);
this.answer = answer;
}
public void presentQuestion()
{
text(questions.get(QuestionCounter).getQuestion(), 500, (displayHeight/2)+170, 500, displayHeight-100);
if (!questionMouse)
{
if (mousePressed )
{
pushMatrix();
background(255);
for (Boundary wall : boundaries) {
wall.display();
}
// for (int i=0;i<pointCounter;i++)
p1.drawPoints();
p2.drawPoints();
Point p = pointsP1.get(pointCounter-1);
pushMatrix();
translate(p.x, p.y);
rotate(-p.angle);
fill(p1.r, p1.g, p1.b);
rect(0, 0, 40, 40);
popMatrix();
p = pointsP2.get(pointCounter1-1);
pushMatrix();
translate(p.x, p.y);
rotate(-p.angle);
fill(p2.r, p2.g, p2.b);
rect(0, 0, 40, 40);
popMatrix();
fill(0, 0, 0);
textSize(20);
if (!questionSaving)
text(questions.get(QuestionCounter).getQuestion(), 500, (displayHeight/2)+170, 500, displayHeight-100);
rectMode(CORNERS);
fill(0, 0, 0, 80);
rect(questionBoxX, questionBoxY, mouseX, mouseY);
popMatrix();
}
}
}
public String getType()
{
return "Rectangle" ;
}
@Override
public String toString()
{
return "new RectangleQuestion(" + " ,\"" + this.getQuestion() + "\"," + Recshow1(this.getAnswer())+")" ;
}
public Rectangle getAnswer()
{
return answer;
}
}
\ No newline at end of file
class TrailQuestion extends Question {
ArrayList<Coordinate> points;
public TrailQuestion(String question)
{
super(question);
points = new ArrayList<Coordinate>();
}
public String getType()
{
return "Trail" ;
}
public void presentQuestion()
{
int size = 8 ; // increase size to increase perfection
text(questions.get(QuestionCounter).getQuestion(), 500, (displayHeight/2)+170, 500, displayHeight-100);
if (mousePressed)
{
points.add( new Coordinate(mouseX, mouseY));
ellipse(mouseX, mouseY, 10, 10);
}
if ( !trailAnswerSaving)
{
pushMatrix();
noFill();
beginShape();
if (this.points.size() >=1)
{
for ( int i=0; i < size; i++)
vertex(getXfromPoints(i*( points.size()/size)), getYfromPoints(i*( points.size()/size)));
}
endShape(CLOSE);
popMatrix();
trailAnswerSaving = true;
((TrailQuestion) questions.get(QuestionCounter)).points.clear();
}
// store the trail in an array( no need of box 2d just store the coordinates divide the coordinates into four parts and make a polyogon out of it.
// convert that polygon to the best possible rectangle possible
// use rectangel approach
}
int getXfromPoints(int index)
{
return this.points.get(index).x;
}
int getYfromPoints(int index)
{
return this.points.get(index).y;
}
}
class Coordinate {
int x;
int y;
public Coordinate(int x, int y)
{
this.x = x;
this.y = y;
}
}
\ No newline at end of file
class TextQuestion extends Question implements Serializable {
String answer ;
public TextQuestion(String question, String answer)
{
super(question);
this.answer = answer;
}
public void presentQuestion()
{
text(questions.get(QuestionCounter).getQuestion(), 500, (displayHeight/2)+170, 500, displayHeight-100);
if (questions.get(QuestionCounter).getType().equals("Text"))
{
textfield3.setVisible(true);
if (tempAnswer!="")
{
String rightorwrong;
double tempScore = similarity(tempAnswer, this.getSAnswer())*100;
if (tempScore>70)
rightorwrong = "yes";
else if (tempScore>40)
rightorwrong = "maybe";
else
rightorwrong = "no";
writer.println("Date " + date.toString() + " Timestamp: " + millis() + " Partipation ID: " + participationID +" Trial number: " + tempFiler + (QuestionCounter+1) + " Correct Answer: " + this.getSAnswer() + " Answer Given: " + tempAnswer + "Answer Percent: " + tempScore + " Comment: " + rightorwrong );
pushMatrix();
textSize(20);
fill(0, 0, 0);
text( "participationID: " + participationID, 200, 200);
popMatrix();
text(tempAnswer, 400, 400);
save(folderName + "/" + day()+"-"+month()+"-"+year()+"-"+ hour()+"-"+minute() +"-"+second()+ "-" +millis() +"-"+ participationID +"-" + tempFiler + (QuestionCounter+1)+ ".png");
question = false;
questionMouse = false;
timer = 0;
Stime = pointCounter;
tempAnswer = "";
textfield3.setVisible(false);
textfield3.setText("");
QuestionCounter++;
if (QuestionCounter>=questions.size())
{
pushMatrix();
background(255, 255, 255);
textSize(20);
text("Thanks", 200, 200);
popMatrix();
// createGUI1();
button1.setVisible(true);
changingFile = true;
// noLoop();
}
}
}
}
@Override
public String toString()
{
return "new TextQuestion(" + " ,\"" + this.getQuestion() + "\",\"" + this.getSAnswer()+"\")" ;
}
public String getType()
{
return "Text" ;
}
public String getSAnswer()
{
return answer;
}
}
\ No newline at end of file