public static List<Question> getQuizQuestions(int QuizDbId)
    {
        try
        {
            String query = String.format("select qq.QUIZID, q.QUESTIONID, q.QUESTIONTEXT, q.ISVALIDATED, qa.ANSWERID, qa.ANSWERTEXT, qa.ISCORRECT from Question q right join \n" +
"QuestionAnswer qa on Q.QUESTIONID = \n" +
"qa.QUESTIONID\n" +
"join QuizQuestion qq on qq.QUESTIONID = q.QUESTIONID\n" +
"where qq.QUIZID = %d", QuizDbId);
            ResultSet rs = getQueryResults(query);
            List<Question> questions = new ArrayList<Question>();
            Question q = new Question("");
            int lastqid = 0, currqid =0; 
            List<Answer> answers = new ArrayList<Answer>();
            while(rs.next())
            {
                currqid = rs.getInt("QUESTIONID");
                if (lastqid == 0)
                {
                    q = new Question(rs.getString("QuestionText"));
                    q.dbId = rs.getInt("QuestionID");
                    Answer a = new Answer(rs.getString("AnswerText"), rs.getBoolean("IsCorrect"));
                    a.dbId = rs.getInt("AnswerID");
                    q.answers.add(a);
                }
                else if (lastqid == currqid)
                {
                    Answer a = new Answer(rs.getString("AnswerText"), rs.getBoolean("IsCorrect"));
                    a.dbId = rs.getInt("AnswerID");
                    q.answers.add(a);
                }
                else
                {
                    questions.add(q);
                    q = new Question(rs.getString("QuestionText"));
                    q.dbId = rs.getInt("QuestionID");
                    Answer a = new Answer(rs.getString("AnswerText"), rs.getBoolean("IsCorrect"));
                    a.dbId = rs.getInt("AnswerID");
                    q.answers.add(a);
                }
                lastqid = currqid; 
            }
            questions.add(q);
            return questions;
           
        }
        catch(SQLException se)
        {
            return null;
        }
    }