package cz.muni.fi.bronchus.questions; import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Combined Question derived from MultipleChoice and Fill-In-Blank questions. User has amount of * the answers and the one expecting the Fill-In-Blank input from the student. * @author Tomáš Udržal */ public class CombinedQuestion extends Question { /** * correct answer indexed as the letter 'A'..'Z' */ protected String correctAnswer; /** * Vector of answers */ private Vector answers; /** * Shuffle order of answers */ private boolean shuffle; /** * Answer wording for the FIB input */ private String fIBAnswer; /** * Length in chars of the FIB input */ private int fIBAnswerLength; /** Creates a new instance of CombinedQuestion */ public CombinedQuestion() { super("Combined"); correctAnswer=""; answers=new Vector(); shuffle=false; fIBAnswer=""; fIBAnswerLength=-1; } /** * Setter method for the correct answer * @param x letter 'A'..'Z' */ public void setCorrectAnswer(String x) { correctAnswer=x; } /** * Getter method for the correct answer * @return letter 'A'..'Z' */ public String getCorrectAnswer() { return correctAnswer; } /** * Adds an answer to the end of the Vector * @param x answer to be added */ public void addAnswer(String x) { answers.add(x); } /** * Getter method for the Vector of answers * @return Vector of answers */ public Vector getAnswers() { return answers; } /** * Setter method for the shuffle order of answers * @param x true if shuffle is enabled otherwise false */ public void setShuffle(boolean x) { shuffle=x; } /** * Getter method for the shuffle order of answers * @return true if shuffle is enabled otherwise false */ public boolean isShuffle() { return shuffle; } /** * Setter method for the FIB answer wording * @param x FIB answer wording */ public void setFIBAnswer(String x) { fIBAnswer=x; } /** * Getter method for the FIB answer wording * @return FIB answer wording */ public String getFIBAnswer() { return fIBAnswer; } /** * Setter method for the length of the FIB input * @param x length of the FIB input */ public void setFIBAnswerLength(int x) { fIBAnswerLength=x; } /** * Getter method for the length of the FIB input * @return length of the FIB input */ public int getFIBAnswerLength() { return fIBAnswerLength; } /** * Method for generating a response processing condition from a selected answers. * If the correct answer is FIB answer, returns empty String. * @return response processing condition */ public String generateCondition() { String s=""; s=correctAnswer+"==true"; return s; } }