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

PropertyReturnsDescription
createdDateDateWhen the answers were submitted. For a reward quiz this is the submission date of the reward quiz submission. Required.
idlongThe database identifier of this attempt. Attempts are ordered by it, so a higher id is a later attempt.
ignoredByProfileThe 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.
ignoredDateDateWhen this attempt was set aside so the user could sit the quiz again. Null for a live attempt.
moduleStatusModuleStatusThe course module progress record this attempt belongs to, when the quiz sits inside a course. Null for a quiz attached to a reward.
passedbooleanWhether 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.
profileProfileThe 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.
quizAnswersList<QuizAnswer>The answers given in this attempt, one row per answer selected or entered. Null on a new attempt until answers are added.
quizNameStringWhich 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.
rewardQuizSubmissionRewardQuizSubmissionThe reward quiz submission this attempt belongs to, when the quiz is attached to a reward. Null for a quiz inside a course.
scorePercIntegerThe 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.

ParameterDescription
moduleStatusthe 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.

ParameterDescription
rewardQuizSubmissionthe 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.

ParameterDescription
quizNamethe 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.

ParameterDescription
createdDatethe 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.

ParameterDescription
passedtrue 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.

ParameterDescription
quizAnswersthe 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.

ParameterDescription
scorePercthe 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.

ParameterDescription
ignoredBythe 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.

ParameterDescription
ignoredDatethe 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.

ParameterDescription
answerKeythe 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.

ParameterDescription
answerKeythe key identifying the question or option
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.