One submission of a set of answers to a quiz. The outcome is recorded in the passed and score properties, and the answers themselves are held as QuizAnswer rows. An attempt hangs off either a module status, for a quiz inside a course, or a reward quiz submission, for a quiz attached to a reward. To let someone sit a quiz again the existing attempts are marked as ignored rather than deleted, so any counting of attempts should skip rows that have an ignored by value.
Group: Database Entities
Implements: Serializable, Relational
Properties
| Property | Returns | Description |
|---|---|---|
| createdDate | Date | When the answers were submitted. For a reward quiz this is the submission date of the reward quiz submission. Required. |
| id | long | The database identifier of this attempt. Attempts are ordered by it, so a higher id is a later attempt. |
| ignoredBy | Profile | The administrator who set this attempt aside so the user could sit the quiz again. Null for a live attempt, and the finders on this class skip attempts that have a value here. |
| ignoredDate | Date | When this attempt was set aside so the user could sit the quiz again. Null for a live attempt. |
| moduleStatus | ModuleStatus | The course module progress record this attempt belongs to, when the quiz sits inside a course. Null for a quiz attached to a reward. |
| passed | boolean | Whether this attempt met the pass mark for the quiz. False for an attempt that has not been marked as well as for one that failed. |
| profile | Profile | The user who made this attempt, taken from the module status or, failing that, the reward quiz submission. Null if the attempt is attached to neither. |
| quizAnswers | List<QuizAnswer> | The answers given in this attempt, one row per answer selected or entered. Null on a new attempt until answers are added. |
| quizName | String | Which quiz was attempted. For a course quiz this is the name of the quiz page, and for a reward quiz it is the name of the reward. Required. |
| rewardQuizSubmission | RewardQuizSubmission | The reward quiz submission this attempt belongs to, when the quiz is attached to a reward. Null for a quiz inside a course. |
| scorePerc | Integer | The score for this attempt as a percentage from 0 to 100. Null when the quiz was not scored, for example a survey style quiz or an attempt recorded before scoring was in use. |
Methods
getId() · getModuleStatus() · setModuleStatus(ModuleStatus moduleStatus) · getRewardQuizSubmission() · setRewardQuizSubmission(RewardQuizSubmission rewardQuizSubmission) · getQuizName() · setQuizName(String quizName) · getCreatedDate() · setCreatedDate(Date createdDate) · isPassed() · setPassed(boolean passed) · getQuizAnswers() · setQuizAnswers(List<QuizAnswer> quizAnswers) · getScorePerc() · setScorePerc(Integer scorePerc) · getIgnoredBy() · setIgnoredBy(Profile ignoredBy) · getIgnoredDate() · setIgnoredDate(Date ignoredDate) · getProfile() · createAnswer(String answerKey) · answer(String answerKey)
getId()
Returns: long
The database identifier of this attempt. Attempts are ordered by it, so a higher id is a later attempt.
getModuleStatus()
Returns: ModuleStatus
The course module progress record this attempt belongs to, when the quiz sits inside a course. Null for a quiz attached to a reward.
setModuleStatus(ModuleStatus moduleStatus)
Returns: void
Sets the course module progress record this attempt belongs to.
| Parameter | Description |
|---|---|
moduleStatus | the module status this attempt belongs to, or null |
getRewardQuizSubmission()
Returns: RewardQuizSubmission
The reward quiz submission this attempt belongs to, when the quiz is attached to a reward. Null for a quiz inside a course.
setRewardQuizSubmission(RewardQuizSubmission rewardQuizSubmission)
Returns: void
Sets the reward quiz submission this attempt belongs to.
| Parameter | Description |
|---|---|
rewardQuizSubmission | the reward quiz submission this attempt belongs to, or null |
getQuizName()
Returns: String
Which quiz was attempted. For a course quiz this is the name of the quiz page, and for a reward quiz it is the name of the reward. Required.
setQuizName(String quizName)
Returns: void
Sets which quiz was attempted.
| Parameter | Description |
|---|---|
quizName | the name identifying the quiz attempted |
getCreatedDate()
Returns: Date
When the answers were submitted. For a reward quiz this is the submission date of the reward quiz submission. Required.
setCreatedDate(Date createdDate)
Returns: void
Sets when the answers were submitted.
| Parameter | Description |
|---|---|
createdDate | the date this attempt was made |
isPassed()
Returns: boolean
Whether this attempt met the pass mark for the quiz. False for an attempt that has not been marked as well as for one that failed.
setPassed(boolean passed)
Returns: void
Sets whether this attempt met the pass mark for the quiz.
| Parameter | Description |
|---|---|
passed | true if this attempt passed |
getQuizAnswers()
Returns: List<QuizAnswer>
The answers given in this attempt, one row per answer selected or entered. Null on a new attempt until answers are added.
setQuizAnswers(List<QuizAnswer> quizAnswers)
Returns: void
Replaces the answers given in this attempt.
| Parameter | Description |
|---|---|
quizAnswers | the answers making up this attempt |
getScorePerc()
Returns: Integer
The score for this attempt as a percentage from 0 to 100. Null when the quiz was not scored, for example a survey style quiz or an attempt recorded before scoring was in use.
setScorePerc(Integer scorePerc)
Returns: void
Sets the score for this attempt as a percentage.
| Parameter | Description |
|---|---|
scorePerc | the score as a percentage from 0 to 100, or null if not scored |
getIgnoredBy()
Returns: Profile
The administrator who set this attempt aside so the user could sit the quiz again. Null for a live attempt, and the finders on this class skip attempts that have a value here.
setIgnoredBy(Profile ignoredBy)
Returns: void
Sets the administrator who set this attempt aside so the user could sit the quiz again.
| Parameter | Description |
|---|---|
ignoredBy | the profile that ignored this attempt, or null to make it live again |
getIgnoredDate()
Returns: Date
When this attempt was set aside so the user could sit the quiz again. Null for a live attempt.
setIgnoredDate(Date ignoredDate)
Returns: void
Sets when this attempt was set aside so the user could sit the quiz again.
| Parameter | Description |
|---|---|
ignoredDate | the date this attempt was ignored |
getProfile()
Returns: Profile
The user who made this attempt, taken from the module status or, failing that, the reward quiz submission. Null if the attempt is attached to neither.
createAnswer(String answerKey)
Returns: QuizAnswer
Adds an answer to this attempt and links it back to the attempt. The new answer is only held in memory, so save it yourself once its value has been filled in.
| Parameter | Description |
|---|---|
answerKey | the key identifying the question or option being answered |
answer(String answerKey)
Returns: QuizAnswer
Finds the answer in this attempt with the given key. The already loaded answers are scanned rather than the database, and matching is exact.
| Parameter | Description |
|---|---|
answerKey | the key identifying the question or option |