Skip to content

Commit

Permalink
Merge pull request #57 from rabia93/CompositCommands
Browse files Browse the repository at this point in the history
New Question display changed + Edit partially works
  • Loading branch information
biltzerpos authored Jun 21, 2018
2 parents 643394f + 25e3186 commit a2dfe8f
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 35 deletions.
55 changes: 54 additions & 1 deletion Authoring App/src/authoring/QuestionWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,56 @@ public QuestionWindow(GUI gui){
*/
public QuestionWindow(QuestionCommand a){
this.introField.setText(a.getIntroField());
if(a.getIntroField().length()>0 && a.getIntroField() != "none")
{
text.setText("Edit Text");
text.setForeground(Color.magenta);
}
else if(a.getIntroAudio()!= "none")
{
record.setText("Rerecord Audio");
record.setForeground(Color.magenta);
}
else if(a.getIntroSound()!="none")
{
play.setText("Reselect Audio");
play.setForeground(Color.magenta);
}

if(a.getRepeatField().length()>0 && a.getRepeatField() != "none")
{
textIncorrect.setText("Edit Text");
textIncorrect.setForeground(Color.magenta);
}
else if(a.getIncorrectAudio()!= "none")
{
recordIncorrect.setText("Rerecord Audio");
recordIncorrect.setForeground(Color.magenta);
}
else if(a.getIncorrectSound()!="none")
{
playIncorrect.setText("Reselect Audio");
playIncorrect.setForeground(Color.magenta);
}
if(a.getCorrectField().length()>0 && a.getCorrectField() != "none")
{
textCorrect.setText("Edit Text");
textCorrect.setForeground(Color.magenta);
}
else if(a.getCorrectAudio()!= "none")
{
recordCorrect.setText("Rerecord Audio");
recordCorrect.setForeground(Color.magenta);
}
else if(a.getCorrectSound()!="none")
{
playCorrect.setText("Reselect Audio");
playCorrect.setForeground(Color.magenta);
}




this.brailleField.setText(a.getBrailleField());
this.repeatField.setText(a.getRepeatField());
this.correctField.setText(a.getCorrectField());
Expand Down Expand Up @@ -273,7 +323,8 @@ public void actionPerformed(ActionEvent arg0) {
introAudio= file.toString();
String basename = FilenameUtils.getBaseName(introAudio);
record.setText(basename+".wav");
introField.setText("none");
introField.setText("");
introSound="none";
text.setEnabled(false);
play.setEnabled(false);
// gui.getLeftPanel().addItem(new SoundCommand(file.toString()));
Expand Down Expand Up @@ -305,6 +356,8 @@ public void actionPerformed(ActionEvent arg0) {
introSound = file.toString();
String basename = FilenameUtils.getBaseName(introSound);
play.setText(basename+".wav");
introField.setText("");
introAudio="none";
text.setEnabled(false);
record.setEnabled(false);
// gui.getLeftPanel().addItem(new SoundCommand(file.toString()));
Expand Down
139 changes: 125 additions & 14 deletions Authoring App/src/commands/QuestionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class QuestionCommand implements PlayerCommand{

// private GUI gui = new GUI();

public QuestionCommand(String question,String introAudio, String introSound, String display, String wrongText, String incorrectAudio, String incorrectSound, String rightText, String correctAudio, String correctSound, int correctButton, String button, GUI gui) {
/*public QuestionCommand(String question,String introAudio, String introSound, String display, String wrongText, String incorrectAudio, String incorrectSound, String rightText, String correctAudio, String correctSound, int correctButton, String button, GUI gui) {
this.question = question;
this.display = display;
this.introAudio= introAudio;
Expand All @@ -62,16 +62,78 @@ public QuestionCommand(String question,String introAudio, String introSound, Str
this.correctButton= correctButton+1;
this.noButton= button;
this.gui= gui;
}*/
public QuestionCommand(QuestionWindow ques, GUI gui)
{

if(ques.getIntroField().getText().length()>0)
{
this.question =ques.getIntroField().getText();
}
if(ques.getRepeatField().getText().length()>0)
{
this.wrongText = ques.getRepeatField().getText();
}
if(ques.getCorrectField().getText().length()>0)
{
this.rightText= ques.getCorrectField().getText();
}
this.display = ques.getBrailleField().getText();

this.introAudio= ques.getIntroAudio();
this.introSound= ques.getIntroSound();

this.incorrectAudio = ques.getIncorrectAudio();
this.correctAudio = ques.getCorrectAudio();

this.incorrectSound = ques.getIncorrectSound();
this.correctSound= ques.getCorrectSound();

this.correctButton = ques.getButton().getSelectedIndex()+1;
this.gui=gui;
this.noButton = gui.getSettingsPanel().getButtonField();


}


public void addCommand(PlayerCommand q) // add commands in list
{
questionCommands.add(q);
}
@Override
public String toString() { // this will be printed on Left Panel at one index

String result;
result = "<html>"+ "<html><font color=\"green\">"+ "Question to Ask" +"</font>";
if(question!="none" && question.length()>0)

result=result + "<br>" + "Text: " +"<html><font color=\"red\">"+ question + "</font>";
else if (introAudio != "none")
result= result + "<br>" + "Recorded Audio: "+ "<html><font color=\"red\">"+ introAudio+ "</font>";
else if(introSound != "none")
result= result+ "<br>" + "Selected Audio: "+ "<html><font color=\"red\">"+ introSound+ "</font>";

result = result + "<br>"+ "<html><font color=\"blue\">" + "Display on Braille cells: " + "</font>" + "<html><font color=\"red\">"+ display + "</font>" +
"<br>" + "<html><font color=\"blue\">"+ "Correct button: " + "</font>"+"<html><font color=\"red\">"+ correctButton + "</font>" +
"<br>"+"<html><font color=\"green\">"+ "Wrong Answer" + "</font>";


if(wrongText!="none" && wrongText.length()>0)
result=result + "<br>"+ "Text: " + "<html><font color=\"red\">"+ wrongText + "</font>";
else if (incorrectAudio != "none")
result= result + "<br>" + "Recorded Audio: "+ "<html><font color=\"red\">"+ incorrectAudio+ "</font>";
else if(incorrectSound != "none")
result= result+ "<br>" + "Selected Audio: "+ "<html><font color=\"red\">"+ incorrectSound+ "</font>";


result = result + "<br>"+"<html><font color=\"green\">"+ "Right Answer" + "</font>" ;
if(rightText!="none" && rightText.length()>0)
result=result + "<br>" + "Text: "+ "<html><font color=\"red\">"+ rightText +"</font>";
else if (correctAudio != "none")
result= result + "<br>" + "Recorded Audio: "+ "<html><font color=\"red\">"+ correctAudio+ "</font>";
else if(correctSound != "none")
result= result+ "<br>" + "Selected Audio: "+ "<html><font color=\"red\">"+ correctSound+ "</font>";
/*
return "<html>"+ "<html><font color=\"blue\">" + "Display on Braille cells: " + "</font>" + "<html><font color=\"red\">"+ display + "</font>"+
"<br>" + "<html><font color=\"blue\">"+ "Correct button: " + "</font>"+"<html><font color=\"red\">"+ correctButton + "</font>"+
"<br>"+ "<html><font color=\"green\">"+ "____Question to Ask____" +"</font>"+
Expand All @@ -87,7 +149,8 @@ public String toString() { // this will be printed on Left Panel at one index
"<br>"+"<html><font color=\"green\">"+ "___On Right Answer____" + "</font>" +
"<br>" + "Text: "+ "<html><font color=\"red\">"+ rightText +"</font>"+
"<br>" + "Recorded Audio: "+ "<html><font color=\"red\">"+ correctAudio+ "</font>"+
"<br>" + "Selected Audio: "+ "<html><font color=\"red\">"+ correctSound+ "</font>";
"<br>" + "Selected Audio: "+ "<html><font color=\"red\">"+ correctSound+ "</font>";*/
return result;
}

@Override
Expand Down Expand Up @@ -138,7 +201,7 @@ public void editCommand() {
public void windowClosed(WindowEvent e)
{

setAll(ques.getIntroField().getText(), ques.getIntroAudio(), ques.getIntroSound(), ques.getBrailleField().getText(),ques.getCorrectField().getText(), ques.getRepeatField().getText(), ques.getButton().getSelectedIndex());
setAll(ques.getIntroField().getText(), ques.getIntroAudio(), ques.getIntroSound(), ques.getBrailleField().getText(),ques.getCorrectField().getText(), ques.getCorrectAudio(), ques.getCorrectSound(), ques.getRepeatField().getText(), ques.getIncorrectAudio(), ques.getIncorrectSound(),ques.getButton().getSelectedIndex());
}
});

Expand Down Expand Up @@ -174,33 +237,81 @@ public String getTotalButtons()
{
return this.noButton;
}
public String getIntroAudio()
{
return this.introAudio;
}
public String getIntroSound()
{
return this.introAudio;
}




public String getIncorrectAudio()
{
return this.incorrectAudio;
}
public String getIncorrectSound()
{
return this.incorrectSound;
}

public String getCorrectAudio()
{
return this.correctAudio;
}
public String getCorrectSound()
{
return this.correctSound;
}

public GUI getGUI()
{
return this.gui;
}
public void setAll(String question,String introAudio, String introSound, String display, String rightText, String wrongText, int correctButton)
public void setAll(String question,String introAudio, String introSound, String display, String rightText,String correctAudio, String correctSound, String wrongText, String incorrectAudio, String incorrectSound, int correctButton)
{
System.out.println(question);
if(!(question.equals("none")))
{questionCommands.set(1, new TTSCommand(question));
System.out.println("here");
}

else if(introAudio!="none")
questionCommands.set(1, new SoundCommand(introAudio));
else if(introSound!="none")
questionCommands.set(1, new SoundCommand(introSound));
if(!(question.equals("none")) && question.length()>0)
questionCommands.set(1, new TTSCommand(question));
else if(!(introAudio.equals("none")) && introAudio.length()>0)
questionCommands.set(1, new SoundCommand(introAudio));
else if(!(introSound.equals("none")) && introSound.length()>0)
questionCommands.set(1, new SoundCommand(introSound));


if(display != this.display)
questionCommands.set(3, new SetStringCommand(display));


if(!(wrongText.equals("none")) && wrongText.length()>0)
questionCommands.set(8, new TTSCommand(wrongText));
else if(!(incorrectAudio.equals("none")) && incorrectAudio.length()>0)
questionCommands.set(8, new SoundCommand(incorrectAudio));
else if(!(incorrectSound.equals("none")) && incorrectSound.length()>0)
questionCommands.set(8, new SoundCommand(incorrectSound));



if(!(rightText.equals("none")) && rightText.length()>0)
questionCommands.set(11, new TTSCommand(rightText));
else if(!(correctAudio.equals("none")) && correctAudio.length()>0)
questionCommands.set(11, new SoundCommand(correctAudio));
else if(!(correctSound.equals("none")) && correctSound.length()>0)
questionCommands.set(11, new SoundCommand(correctSound));


for (PlayerCommand pc : questionCommands) {
System.out.println(pc);
}
this.introAudio= introAudio;
this.introSound= introSound;
this.incorrectAudio= incorrectAudio;
this.incorrectSound= incorrectSound;
this.correctAudio= correctAudio;
this.correctSound= correctSound;
this.question= question;
this.display= display;
this.rightText= rightText;
Expand Down
28 changes: 8 additions & 20 deletions Authoring App/src/listeners/NewQuestionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,40 +109,28 @@ public void windowClosed(WindowEvent e)

ArrayList<PlayerCommand> questionCommands = new ArrayList<>();


if(ques.getIntroField().getText().length()>0)
{
introText=ques.getIntroField().getText();
}
if(ques.getRepeatField().getText().length()>0)
{
incorrectText=ques.getRepeatField().getText();
}
if(ques.getCorrectField().getText().length()>0)
{
correctText=ques.getCorrectField().getText();
}




// qc is object of QuestionCommand class
QuestionCommand qc= new QuestionCommand(introText, ques.getIntroAudio(), ques.getIntroSound(), ques.getBrailleField().getText(),incorrectText, ques.getIncorrectAudio(), ques.getIncorrectSound(), correctText, ques.getCorrectAudio(), ques.getCorrectSound(), ques.getButton().getSelectedIndex(), gui.getSettingsPanel().getButtonField(), gui);
QuestionCommand qc = new QuestionCommand(ques, gui);
//QuestionCommand qc= new QuestionCommand(introText, ques.getIntroAudio(), ques.getIntroSound(), ques.getBrailleField().getText(),incorrectText, ques.getIncorrectAudio(), ques.getIncorrectSound(), correctText, ques.getCorrectAudio(), ques.getCorrectSound(), ques.getButton().getSelectedIndex(), gui.getSettingsPanel().getButtonField(), gui);


qc.addCommand(new ResetButtonCommand(""));
if(ques.getIntroField().getText().length()>0)
if(ques.getIntroField().getText().length()>0 && ques.getIntroField().getText()!="none")
{qc.addCommand(new TTSCommand(ques.getIntroField().getText()));
gui.counterMap.put("Text-to-speech", gui.counterMap.get("Text-to-speech") + 1);

}
else if(ques.getIntroAudio()!="none")
{
qc.addCommand(new SoundCommand(ques.getIntroAudio()));
gui.counterMap.put("Record Audio", gui.counterMap.get("Record Audio") + 1);

}
else if(ques.getIntroSound()!="none")
{
qc.addCommand(new SoundCommand(ques.getIntroSound()));
gui.counterMap.put("Sound", gui.counterMap.get("Sound") + 1);

}
qc.addCommand(new PauseCommand("1"));
qc.addCommand(new SetStringCommand(ques.getBrailleField().getText()));
Expand All @@ -169,7 +157,7 @@ else if(ques.getIntroSound()!="none")
qc.addCommand(new UserInputCommand());
// Labels for bad
qc.addCommand(new GoHereCommand("" + randomLabel + "-bad"));
if(ques.getRepeatField().getText().length()>0)
if(ques.getRepeatField().getText().length()>0 && ques.getIntroField().getText()!="none")
qc.addCommand(new TTSCommand(ques.getRepeatField().getText()));
else if(ques.getIncorrectAudio()!="none")
qc.addCommand(new SoundCommand(ques.getIncorrectAudio()));
Expand Down

0 comments on commit a2dfe8f

Please sign in to comment.