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

Made Question Editing Easy

parents 6d774465 759d8c16
......@@ -15,7 +15,7 @@ import com.sun.jna.platform.win32.WinUser.WINDOWINFO;
private static final int WS_ICONIC = 0x20000000; //for check minimized
import java.util.ArrayList;
import java.util.Scanner;
import static javax.swing.JOptionPane.*;
import shiffman.box2d.*;
import org.jbox2d.common.*;
import org.jbox2d.dynamics.joints.*;
......@@ -29,9 +29,7 @@ import java.util.Date;
Box2DProcessing box2d;
boolean question;
String user = "gaa721";
float afterAttentionTime;
String participationID;
Capture video;
......@@ -56,7 +54,7 @@ boolean obscured;
boolean attention;
int k;
boolean moving;
boolean saveornot=true;
boolean saveornot=false;
boolean attentHere;
//int mover=10;
Person p;
......@@ -86,9 +84,10 @@ Date date = new Date();
PrintWriter writer;
FileWriter fw ;
BufferedWriter bw;
String folderName ;
String tempQuestion,tempType="";
boolean tempQAnswered = false;
boolean tempTAnswered = false;
// D)
//String[] Questions = {
// "Select the most recent portion","was line drawn first or circle was moved first? Select that ", "Select the most recent portion", "Select the new portion drawn after the black screen "
......@@ -119,14 +118,18 @@ Rectangle[] r = {
float totalShapesandTrailCount = 0;
boolean questionSaving;
ArrayList<Question> questions ;
char tempFiler = 'E';
char tempFiler = 'F';
void setup()
{
createGUI();
startMenu = true;
setupInside();
createGUI();
startMenu = true;
tempQAnswered = false;
tempTAnswered = false;
questionToBeSaved.setVisible(false);
QuestionType.setVisible(false);
textfield2.setVisible(false);
setupInside();
}
......@@ -284,39 +287,63 @@ void setupInside()
return;
}
}
eof = false;
if (!questionSaving)
{
try {
while (!eof)
{
Question tempQuest = (Question) inQ.readObject();
questions.add(tempQuest);
}
}
catch(ClassNotFoundException 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]);
catch(java.io.EOFException ex1)
{
eof=true;
}
catch(IOException i)
{
i.printStackTrace();
return;
}
}
}
//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() +")";
}
String QuestiontoString(Question q )
{
return "new Question(" + " \"" + q.type + "\",\"" + q.question + "," + Recshow1(q.answer) ;
}
void draw()
{
if (!changingFile)
{
......@@ -339,9 +366,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;
......@@ -349,22 +379,33 @@ void draw()
{
timer = 0;
Stime = (int)totalShapesandTrailCount;
question = true;
drawing();
question = true;
textSize(20);
fill(0, 0, 0);
if (!questionSaving)
text(questions.get(QuestionCounter).getQuestion(), 600, 600);
else
text(Questions[QuestionCounter], 600, 600);
{
tempType = showInputDialog("Please enter the type");
tempQuestion = showInputDialog("Please enter the Question");
if(tempType.equals("Text" ))
{
//questionToBeSaved.setVisible(true);
}
}
}
}
}
if (question)
{
if (!questionMouse)
{
if (mousePressed)
......@@ -380,8 +421,7 @@ void draw()
popMatrix();
if (!questionSaving)
text(questions.get(QuestionCounter).getQuestion(), 600, 600);
else
text(Questions[QuestionCounter], 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)));
......@@ -395,6 +435,7 @@ void draw()
else
drawing();
}
}
......@@ -425,8 +466,7 @@ void mousePressed()
{
if (!questionSaving)
text(questions.get(QuestionCounter).getQuestion(), 600, 600);
else
text(Questions[QuestionCounter], 600, 600);
questionBoxX=mouseX;
questionBoxY=mouseY;
// ellipse(questionBoxX, questionBoxY, 10, 10);
......@@ -436,6 +476,8 @@ void mousePressed()
void mouseReleased()
{
Rectangle r1=null;
if (mp && !question)
{
......@@ -450,18 +492,48 @@ 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);
//
//
//}
Rectangle r1 = new Rectangle(questionBoxX, questionBoxY, mouseX, mouseY);
// print(questionBoxX + " " +questionBoxY + " " +mouseX + " " +mouseY);
r1.show();
if (!questionSaving)
{
if(questions.get(QuestionCounter).type.equals( "Rectangle"))
{
questions.get(QuestionCounter).answer.show();
double intersection = r1.getIntersectionPercent(questions.get(QuestionCounter).answer, r1);
double intersection = r1.getIntersectionPercent(r1,questions.get(QuestionCounter).answer );
double bigRecRatio = (r1.getArea()/questions.get(QuestionCounter).answer.getArea());
print(intersection);
String rightorwronng = "";
......@@ -499,13 +571,17 @@ void mouseReleased()
changingFile = true;
// noLoop();
}
}
}
else
{
if(tempType.equals( "Rectangle"))
try {
outQ.writeObject(new Question(Questions[QuestionCounter++], r1));
outQ.writeObject(new Question(tempType,tempQuestion,r1));
}
catch(IOException i) {
}
......@@ -606,8 +682,10 @@ void drawing()
timer = (int)totalShapesandTrailCount - Stime;
// print(timer + " ") ;
if (timer<=100 )
if (timer<=100 )
{
}
else if (timer>=200 )
......@@ -767,6 +845,8 @@ void drawing()
p.drawAll();
}
......@@ -783,4 +863,16 @@ public String RectoString(Rectangle r)
return "Point 1: " + PointtoString(r.p1) + " Point 2: " + PointtoString(r.p2) ;
}
......@@ -3,18 +3,21 @@ import java.util.ArrayList;
class Question implements Serializable
{
String type;
String question;
Rectangle answer;
public Question( String quest, Rectangle ans)
public Question(String type ,String quest, Rectangle ans)
{
this.type = type;
this.question = quest;
this.answer = ans;
}
public Question( String quest)
public Question( String type,String quest)
{
this.type = type;
this.question = quest;
}
//
......
Question [][] questionandanswers = {
{
new Question( "Rectangle", "When you were not attentive something was drawn. Mark that portion.", new Rectangle(245.0, 245.0, 359.0, 330.0)),
new Question( "Rectangle", "When you were not attentive so many lines were drawn mark the most recently drawn line. ", new Rectangle(365.0, 609.0, 398.0, 655.0)),
new Question( "Rectangle", "When you were not attentive circle was moved. mark the initial position of the circle. ", new Rectangle(1033.0, 179.0, 1138.0, 275.0)),
new Question( "Rectangle", "When you were not attentive two lines were drawn. Mark the line which was drawn first.", new Rectangle(1124.0, 419.0, 1237.0, 348.0)),
new Question( "Rectangle", "when you were not attentive one the circles was deleted. mark the position where was the circle and how big was it? ", new Rectangle(179.0, 684.0, 266.0, 761.0))
}
,
{
new Question( "Rectangle", "When you were not attentive one the Rectangles was deleted. Mark the position where was the Rectangle and how big was it?", new Rectangle(652.0, 514.0, 687.0, 547.0)),
new Question( "Rectangle", "When you were not attentive something was drawn. Mark that Portion.", new Rectangle(552.0, 160.0, 666.0, 55.0)),
new Question( "Rectangle", "When you were not attentive Rectangle was moved. Mark the initial position and size of the Rectangle.", new Rectangle(690.0, 423.0, 630.0, 368.0)),
new Question( "Rectangle", "When you were not attentive so many lines were drawn. Mark the line which was drawn last.", new Rectangle(518.0, 400.0, 570.0, 475.0)),
new Question( "Rectangle", "When you were not attentive two lines were drawn. Mark the line which was drawn first. ", new Rectangle(29.0, 196.0, 107.0, 123.0))
}
,
{
new Question( "Rectangle", "When you were not attentive two lines were drawn. Mark the line which was drawn first.", new Rectangle(365.0, 300.0, 499.0, 336.0)),
new Question( "Rectangle", "When you were not attentive circle was moved. Mark the initial position and size of the Circle.", new Rectangle(382.0, 173.0, 482.0, 272.0)),
new Question( "Rectangle", "when you were not attentive one the circles was deleted. mark the position where was the circle and how big was it?", new Rectangle(868.0, 289.0, 848.0, 266.0)),
new Question( "Rectangle", "When you were not attentive something was drawn. Mark the bigger portion.", new Rectangle(137.0, 696.0, 50.0, 586.0)),
new Question( "Rectangle", "When you were not attentive some lines were drawn. Mark the line drawn last.", new Rectangle(1434.0, 146.0, 1490.0, 222.0))
}
,
{
new Question( "Rectangle", "When you were not attentive something was drawn. Mark that portion. ", new Rectangle(293.0, 286.0, 455.0, 392.0)),
new Question( "Rectangle", "When you were not attentive circle was moved. Mark the initial position and size of the Circle. ", new Rectangle(41.0, 91.0, 156.0, 192.0)),
new Question( "Rectangle", "When you were not attentive one the circles was deleted. mark the position where was the circle and how big was it?", new Rectangle(515.0, 319.0, 570.0, 367.0)),
new Question( "Rectangle", "When you were not attentive some lines were drawn. Mark the line drawn first.", new Rectangle(1470.0, 378.0, 1509.0, 430.0)),
new Question( "Rectangle", "When you were not attentive a big line was drawn. Mark the starting point of the line.", new Rectangle(1044.0, 62.0, 1103.0, 98.0))
}
,
};
......@@ -20,7 +20,7 @@ public class Rectangle implements Serializable {
}
public String show() {
return "( " + x + " , " + y + " )";
return x + " , " + y ;
}
public boolean isEqual(Point p) {
......@@ -53,6 +53,9 @@ public class Rectangle implements Serializable {
System.out.println("---------- " + this + " ------------");
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() {
......
......@@ -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!
......@@ -62,28 +62,66 @@ public void textfield1_change1(GTextField source, GEvent event) { //_CODE_:textf
}
} //_CODE_:textfield1:215102:
public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:983045:
println("button1 - GButton >> GEvent." + event + " @ " + millis());
// tempFiler = (char)((int)(tempFiler-1);
tempFiler--;
tempFiler++;
if((int)tempFiler > 73)
{
noLoop();
background(255);
text("Thanks",200,200);
source.setVisible(false);
}
else
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();
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:
println("textfield2 - GTextField >> GEvent." + event + " @ " + millis());
} //_CODE_:textfield2:870671:
// 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:");
......@@ -94,6 +132,15 @@ public void createGUI() {
button1 = new GButton(this, 298, 285, 122, 30);
button1.setText("Click for next drawing");
button1.addEventHandler(this, "button1_click1");
questionToBeSaved = new GTextField(this, 300, 493, 638, 72, G4P.SCROLLBARS_NONE);
questionToBeSaved.setOpaque(true);
questionToBeSaved.addEventHandler(this, "textfield2_change1");
QuestionType = new GTextField(this, 98, 502, 174, 56, G4P.SCROLLBARS_NONE);
QuestionType.setOpaque(true);
QuestionType.addEventHandler(this, "textfield2_change2");
textfield2 = new GTextField(this, 354, 637, 311, 29, G4P.SCROLLBARS_NONE);
textfield2.setOpaque(true);
textfield2.addEventHandler(this, "textfield2_change3");
}
// Variable declarations
......@@ -101,4 +148,7 @@ public void createGUI() {
GLabel label1;
GTextField textfield1;
GButton button1;
GTextField questionToBeSaved;
GTextField QuestionType;
GTextField textfield2;
......@@ -15,7 +15,7 @@ import com.sun.jna.platform.win32.WinUser.WINDOWINFO;
private static final int WS_ICONIC = 0x20000000; //for check minimized
import java.util.ArrayList;
import java.util.Scanner;
import static javax.swing.JOptionPane.*;
import shiffman.box2d.*;
import org.jbox2d.common.*;
import org.jbox2d.dynamics.joints.*;
......@@ -29,9 +29,7 @@ import java.util.Date;
Box2DProcessing box2d;
boolean question;
String user = "gaa721";
float afterAttentionTime;
String participationID;
Capture video;
......@@ -56,7 +54,7 @@ boolean obscured;
boolean attention;
int k;
boolean moving;
boolean saveornot=true;
boolean saveornot=false;
boolean attentHere;
//int mover=10;
Person p;
......@@ -86,9 +84,10 @@ Date date = new Date();
PrintWriter writer;
FileWriter fw ;
BufferedWriter bw;
String folderName ;
String tempQuestion,tempType="";
boolean tempQAnswered = false;
boolean tempTAnswered = false;
// D)
//String[] Questions = {
// "Select the most recent portion","was line drawn first or circle was moved first? Select that ", "Select the most recent portion", "Select the new portion drawn after the black screen "
......@@ -119,14 +118,18 @@ Rectangle[] r = {
float totalShapesandTrailCount = 0;
boolean questionSaving;
ArrayList<Question> questions ;
char tempFiler = 'E';
char tempFiler = 'F';
void setup()
{
createGUI();
startMenu = true;
setupInside();
createGUI();
startMenu = true;
tempQAnswered = false;
tempTAnswered = false;
questionToBeSaved.setVisible(false);
QuestionType.setVisible(false);
textfield2.setVisible(false);
setupInside();
}
......@@ -284,39 +287,63 @@ void setupInside()
return;
}
}
eof = false;
if (!questionSaving)
{
try {
while (!eof)