Grading a solution

First we need to define a new bqTest object in solve mode by doing:

const gradedSolution = solveModeTest.gradeSolution({
    openAnswers,
    multipleChoiceAnswers
})

Where:

  • openAnswers: is an array containing the open answers for each of the questions. This value needs to be provided if the test being solved is either open answer or mixed, and left empty otherwise.

  • multipleChoiceAnswers: is an array containing the answer choices (1 for A, 2 for B, ...) for each of the questions. This value needs to be provided if the test being solved is either multiple choice or mixed, and left empty otherwise.

Calling this method will return an object which will include the following values:

  • grade: the resulting grade out of 100.

  • minimumGrade: the minimum grade required to obtain this credential

  • pass: Whether this solution would obtain this credential.

  • nQuestions: the number of questions that define this test

  • multipleChoiceGrade: the grade obtained in the multiple choice part of the test

  • openAnswerGrade: the grade obtained in the opne answer part of the test

  • multipleChoiceWeigh: the percentage the multiple choice component counts towards the final grade

  • openAnswerResults: list containing the results for each of the answers, that is, whether they were correct or not.

When we call on the deployed contract on testnet:

> console.log(
    solveModeTest.gradeSolution({
        openAnswers: new Array(64).fill("deenz"), 
        multipleChoiceAnswers: Array.from({length: 64}, (_, i) => 1)
    })
)
> {
    grade: 100,
    minimumGrade: 1,
    pass: true,
    nQuestions: 64,
    multipleChoiceGrade: 100,
    openAnswerGrade: 100,
    multipleChoiceWeight: 50,
    openAnswerResults: [
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true, true, true, true, true, true, true,
        true
    ]
}

Last updated