feat(assessment): grade choice answers with distractors from error models
This commit is contained in:
1 parent
efa41d5967
commit
f1147b1885
22 files changed
+1346
-47
No files matched your search
@@ -16,6 +16,9 @@ const (
|
||||
// AnswerFormatIntegerSequence is decimal integers separated by single
|
||||
// spaces.
|
||||
AnswerFormatIntegerSequence = "integer_sequence"
|
||||
// AnswerFormatChoice is the decimal index of the correct option of a
|
||||
// choice variant. The options and their order are part of the variant.
|
||||
AnswerFormatChoice = "choice"
|
||||
)
|
||||
|
||||
// variantSeedDomain separates the seed derivation of variants from any other
|
||||
@@ -122,7 +125,21 @@ func (generator AssessmentSeedGenerator) instantiate(
|
||||
}
|
||||
values[spec.name] = random.between(parameterRange.Min, parameterRange.Max)
|
||||
}
|
||||
data, answer := algorithm.generate(random, values)
|
||||
var (
|
||||
data map[string]string
|
||||
answer string
|
||||
options []AssessmentChoiceOption
|
||||
)
|
||||
if algorithm.generateChoice != nil {
|
||||
task := algorithm.generateChoice(random, values)
|
||||
built, correct, err := newChoiceOptions(random, task.correct, task.mistakes, task.nearby, choiceOptionCount-1)
|
||||
if err != nil {
|
||||
return variantBody{}, fmt.Errorf("AssessmentSeedGenerator.instantiate - build choice options: %w", err)
|
||||
}
|
||||
data, answer, options = task.data, strconv.Itoa(correct), built
|
||||
} else {
|
||||
data, answer = algorithm.generate(random, values)
|
||||
}
|
||||
for name, value := range values {
|
||||
data[name] = strconv.Itoa(int(value))
|
||||
}
|
||||
@@ -130,27 +147,37 @@ func (generator AssessmentSeedGenerator) instantiate(
|
||||
if err != nil {
|
||||
return variantBody{}, err
|
||||
}
|
||||
return variantBody{parameters: values, statement: rendered, answer: answer}, nil
|
||||
return variantBody{parameters: values, statement: rendered, answer: answer, options: options}, nil
|
||||
}
|
||||
|
||||
type variantBody struct {
|
||||
parameters map[string]int32
|
||||
statement string
|
||||
answer string
|
||||
// answer is the reference answer; for a choice variant it is the decimal
|
||||
// index of the correct option.
|
||||
answer string
|
||||
options []AssessmentChoiceOption
|
||||
}
|
||||
|
||||
// AssessmentVariant is one generated task of a family version. The rubric is
|
||||
// the family's rubric: no seed changes it.
|
||||
type AssessmentVariant struct {
|
||||
FamilyID AssessmentFamilyID
|
||||
FamilyKey AssessmentFamilyKey
|
||||
FamilyVersion int32
|
||||
Seed VariantSeed
|
||||
Parameters map[string]int32
|
||||
Statement string
|
||||
FamilyID AssessmentFamilyID
|
||||
FamilyKey AssessmentFamilyKey
|
||||
FamilyVersion int32
|
||||
Seed VariantSeed
|
||||
Parameters map[string]int32
|
||||
Statement string
|
||||
// ReferenceAnswer is the key. For AnswerFormatChoice it is the decimal
|
||||
// index of the correct entry of Options.
|
||||
ReferenceAnswer string
|
||||
AnswerFormat string
|
||||
Rubric AssessmentRubric
|
||||
// Options are the options of a choice variant in the order that the
|
||||
// candidate sees, with the server-side IDs; empty for other formats. They
|
||||
// are private to the server like the key: a candidate is shown only the
|
||||
// IDs and texts, never the index of the correct one.
|
||||
Options []AssessmentChoiceOption
|
||||
Rubric AssessmentRubric
|
||||
}
|
||||
|
||||
// NewVariant generates the variant of a seed. It is a pure function of the
|
||||
@@ -181,6 +208,7 @@ func (family AssessmentFamily) NewVariant(seed VariantSeed) (AssessmentVariant,
|
||||
Statement: body.statement,
|
||||
ReferenceAnswer: body.answer,
|
||||
AnswerFormat: algorithm.answerFormat,
|
||||
Options: body.options,
|
||||
Rubric: family.core.Rubric.clone(),
|
||||
}, nil
|
||||
}
|
||||
@@ -243,8 +271,13 @@ type assessmentAlgorithm struct {
|
||||
// the candidate would not see the input.
|
||||
requiredNames []string
|
||||
// generate returns the input data for the statement template and the
|
||||
// reference answer.
|
||||
// reference answer. It is set for the algorithms of every answer format
|
||||
// except AnswerFormatChoice.
|
||||
generate func(random *seededRandom, parameters map[string]int32) (data map[string]string, answer string)
|
||||
// generateChoice is set instead of generate exactly for the algorithms
|
||||
// whose answer format is AnswerFormatChoice. It returns the input data, the
|
||||
// correct value, and the wrong values of known error models.
|
||||
generateChoice func(random *seededRandom, parameters map[string]int32) choiceTask
|
||||
}
|
||||
|
||||
// probeSeedCount is the number of seeds that an importer renders at the
|
||||
|
||||
Reference in new issue
Block a user