cmu.survey.objects
Class QuestionChoicesSQL
java.lang.Object
cmu.survey.objects.QuestionChoicesSQL
- All Implemented Interfaces:
- QuestionChoices, QuestionChoicesWithIDField
public class QuestionChoicesSQL
- extends java.lang.Object
- implements QuestionChoicesWithIDField
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
QuestionChoicesSQL
public QuestionChoicesSQL(DataStorageSQL theDataStorage)
getAnswer
public Answer getAnswer()
- Returns:
isCacheRandomizeAnswerOrder
public boolean isCacheRandomizeAnswerOrder()
- Returns:
getChoicesField
public java.lang.String getChoicesField()
- Returns:
getChoicesIDFieldName
public java.lang.String getChoicesIDFieldName()
- Specified by:
getChoicesIDFieldName
in interface QuestionChoicesWithIDField
- Returns:
getChoicesQuestionID
public java.lang.Integer getChoicesQuestionID()
- Returns:
getChoicesTable
public java.lang.String getChoicesTable()
- Returns:
isChoicesTableStandardFormat
public boolean isChoicesTableStandardFormat()
- Returns:
isRandomizeAnswerOrder
public boolean isRandomizeAnswerOrder()
- Returns:
setAnswer
public void setAnswer(Answer answer)
- Parameters:
answer
-
setCacheRandomizeAnswerOrder
public void setCacheRandomizeAnswerOrder(boolean b)
- Parameters:
b
-
setChoicesField
public void setChoicesField(java.lang.String string)
- Parameters:
string
-
setChoicesIDFieldName
public void setChoicesIDFieldName(java.lang.String string)
- Parameters:
string
-
setChoicesQuestionID
public void setChoicesQuestionID(java.lang.Integer i)
- Parameters:
i
-
setChoicesTable
public void setChoicesTable(java.lang.String string)
- Parameters:
string
-
setRandomizeAnswerOrder
public void setRandomizeAnswerOrder(boolean b)
- Parameters:
b
-
randomizeVectorPair
public QuestionChoices.VectorPair randomizeVectorPair(java.util.Vector choicesIDs,
java.util.Vector<java.lang.String> choicesNames)
- Randomize the orders of the items in a pair of vectors -- both vectors should be the same size. This randomizes the orders of the items in parallel -- i.e. if there's a mapping between one vector to another, it is preserved in the randomization, for example:
Before:
Vector 1 |
Vector 2 |
1 |
a |
2 |
b |
3 |
c |
4 |
d |
After (for example):
Vector 1 |
Vector 2 |
4 |
d |
2 |
b |
1 |
a |
3 |
c |
Returns a vector with two elements: vector1 randomized, and vector2 randomized.
- Returns:
- Vector
setCachedAnswerPair
protected void setCachedAnswerPair(QuestionChoices.VectorPair tuple)
getCachedAnswerPair
protected QuestionChoices.VectorPair getCachedAnswerPair()
setChoicesTableUsingStandardFormat
public void setChoicesTableUsingStandardFormat(java.lang.String theChoicesTable,
java.lang.Integer theChoicesQuestionID)
- The standard format is a specific format for the database table for these answers.
(This feature is related to the tag QuestionsFromDatabase, which is not completely implemented yet)
getPairOfChoicesAndIDs
public QuestionChoices.VectorPair getPairOfChoicesAndIDs()
- Specified by:
getPairOfChoicesAndIDs
in interface QuestionChoices
- Returns:
- a Vector of two Vectors (each of the two vectors will have the same number of elements):
vector.get(0)=is the IDs that should be saved in the database (sometimes a number, sometimes a String).
vector.get(1)=a vector of Strings of the choices that the user sees (in the order they should be used)
or Returns null if there was an error.
setChoicesTableStandardFormat
public void setChoicesTableStandardFormat(boolean b)
- Parameters:
b
-