I have two domain classes as following
class Quiz {
String name
String description
int duration
User user
int points
static hasMany = [questions:Question]
}
and
class Question {
String question
String questionType
int points
String option_1
String option_2
String option_3
String option_4
boolean isOption_1_Correct
boolean isOption_2_Correct
boolean isOption_3_Correct
boolean isOption_4_Correct
User user
static belongsTo = [user:User]
}
static hasMany = [questions:Question] in Quiz class has made my life a lot easier. I also understand it will be able to use convenience methods like addTo and removeFrom. Only query I have is that I want users to be able to define display order for the questions. Is there an easier way to do this or do I have to create a mapping class like following?
class QuestionInQuiz {
Quiz quiz
Question question
int displayOder
static constraints = {
question unique:['quiz']
}
}
It will be great if i can somehow avoid using this mapping class and keep my code simpler!