Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2017 09:22
Show Gist options
  • Save anonymous/e7dbd438d3680044a1f42f5113e338e5 to your computer and use it in GitHub Desktop.
Save anonymous/e7dbd438d3680044a1f42f5113e338e5 to your computer and use it in GitHub Desktop.
public class quizSceneController{
private Flow flow;
public void setMain(Flow flow){ this.flow = flow;}
@FXML Button answerbutton;
@FXML Text timeField, scoreField;
@FXML public Label question, showQuestionCounter, answer, questionId, questionType, questionSpeed;
NextQuestion nextQuestion;
public String temp, temp2;
public GridPane takingTestPane = new GridPane();
public void chooseNextQuestion(Flow flow){
try {
this.flow.nextQ = false;
this.flow.startTime = System.currentTimeMillis();
//Choosing the next question
String sql = "select * from Questions where Subject = ? and Level = ? and questionId = ?";
PreparedStatement pst = this.flow.connectionQuestions.prepareStatement(sql);
pst.setString(1, this.flow.textSubjectQTest);
pst.setString(2, this.flow.user_course_level);
pst.setString(3, this.flow.list.get(counter));
ResultSet rs = pst.executeQuery();
if (rs.next()) {
temp = rs.getString("Question");
temp2 = rs.getString("Answer");
pst.execute();
pst.close();
} else {
System.out.println("No data for this subject");
}
} catch (Exception a) {
System.out.println(a);
}
}
@FXML private void myButton(ActionEvent event){
chooseNextQuestion(this.flow);
this.question.setText(temp);
}
@FXML public void initialize(){
chooseNextQuestion(this.flow);
this.question.setText(temp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment