One profile's submission of the quiz attached to a reward, holding every attempt they made at that quiz. A reward can require the participant to answer questions before it is granted, for example a set of qualifying questions on a prize draw. Each pass at those questions is a QuizAttempt hanging off this submission, so the submission is the per profile, per reward container and the attempts are the history. An attempt can be marked ignored, in which case it is skipped when working out the latest attempt.
Group: Database Entities
Implements: Serializable
Properties
| Property | Returns | Description |
|---|---|---|
| id | long | The database-assigned unique identifier for this submission. |
| lastAttempt | QuizAttempt | The most recent attempt by created date, ignoring any attempt that has been marked ignored. This is the attempt the reward should be judged on. |
| profile | Profile | The profile that answered the quiz. Always set. |
| quizAttempts | List<QuizAttempt> | Every attempt this profile made at the reward's quiz, in no guaranteed order. Can be null on a submission that has not been populated yet, so check before iterating. |
| reward | Reward | The reward whose quiz was answered. Always set, and together with the profile it identifies the submission. |
| submittedDate | Date | When the quiz was submitted. Mapped as a date rather than a timestamp, so the time of day is not retained. |
Methods
getId() · getProfile() · getReward() · getSubmittedDate() · getQuizAttempts() · createQuizAttempt(String quizName, Date now) · addQuizAttempt(QuizAttempt attempt) · getLastAttempt() · answersMap()
getId()
Returns: long
The database-assigned unique identifier for this submission.
getProfile()
Returns: Profile
The profile that answered the quiz. Always set.
getReward()
Returns: Reward
The reward whose quiz was answered. Always set, and together with the profile it identifies the submission.
getSubmittedDate()
Returns: Date
When the quiz was submitted. Mapped as a date rather than a timestamp, so the time of day is not retained.
getQuizAttempts()
Returns: List<QuizAttempt>
Every attempt this profile made at the reward's quiz, in no guaranteed order. Can be null on a submission that has not been populated yet, so check before iterating.
createQuizAttempt(String quizName, Date now)
Returns: QuizAttempt
Creates a new QuizAttempt for the named quiz, links it to this submission and adds it to the attempts list. The attempt is only added in memory, so the caller is responsible for saving it.
| Parameter | Description |
|---|---|
quizName | the name of the quiz being attempted |
now | the date and time to record as the attempt's created date |
addQuizAttempt(QuizAttempt attempt)
Returns: void
Adds an already-created attempt to this submission's list of attempts, creating the list if it is null. Note that this does not set the attempt's own reference back to this submission.
| Parameter | Description |
|---|---|
attempt | the quiz attempt to add |
getLastAttempt()
Returns: QuizAttempt
The most recent attempt by created date, ignoring any attempt that has been marked ignored. This is the attempt the reward should be judged on.
answersMap()
Returns: Map<String,String>
Flattens the answers from every attempt into a single map of answer key to given answer. Later attempts overwrite earlier ones for the same key, and ignored attempts are included, so prefer reading the answers off the last attempt when only the final answers matter.