Methods
# arraysEqual(a, b)
Check whether all elements of two arrays are equal.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
* | |
b |
* |
bool
# CheckOption(props)
Child component used to create the a multiple choice question with multiple correct answer using MCQMulti. The only props needed to create the question are children, one or more correct answers, and (optionally) feedback.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
children |
string | Answer text |
|
correct |
bool | false | Specify correct answer |
feedback |
string | Feedback displayed when this answer is selected. |
|
ind |
number | string | Answer index (provided by MCQMulti) |
|
name |
string | Question name (provided by MCQMulti) |
|
checked |
bool | Whether element is selected (provided by MCQMulti) |
|
onClick |
function | Event handler (provided by MCQMulti) |
|
disabledGuesses |
bool | false | Disable radio if true. |
# DispP(props)
Helper component to control whether a paragraph (
element) is displayed.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
display |
bool | false | Hide the element unless true. |
# FeedbackP(props)
Control whether a feedback paragraph is displayed.
The feedback can be specified
- directly through a
displayprop (true if displayed) - through an ans prop (displayed if
value===ans) - through the min and/or max props (displayed if value in range)
- the relError property can be given to allow equality within a given percentage error, to account for student rounding error.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | The properties |
|
ans |
number | The correct answer |
|
display |
bool | false | Control whether the component is displayed. |
value |
number | 0 | The value that will activate the component |
min |
number | The minimum value the |
|
max |
number | The maximum value |
|
relErr |
number | The relative error tolerance. The paragraph will display if |ans - value| / value < relErr |
Example
(
<FeedbackP value={2} ans={3}/>
Here is the feedback!
</FeedbackP>
)
# IncorrectFeedback(props)
This provides default feedback that will reveal the correct answer after a certain maximum number of guesses.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
guesses |
number | Number of guesses used. |
|
maxGuesses |
number | Maximum guesses allowed. |
|
answer |
number | The correct answer. |
|
digits |
number | 2 | Number of digits after the decimal point to include in the answer. |
inputLabel |
string | The label (unit) that should be attached to the correct answer. |
# IncorrectFeedbackText(props)
This provides default feedback that will reveal the correct answer after a certain maximum number of guesses.
Parameters:
| Name | Type | Description |
|---|---|---|
props |
Object | |
guesses |
number | Number of guesses used. |
maxGuesses |
number | Maximum guesses allowed. |
answer |
string | The correct answer. |
# MCQ(props)
Create a multiple choice question.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
name |
string | A unique name for this question. |
|
options |
Array.<object> | Array of props used to create RadioOptions (children, correct, and feedback) |
|
defaultFeedback |
string | The default incorrect answer feedback |
|
correctFeedback |
string | "Correct!" | The default correct feedback |
guesses |
number | 3 | Maximum guesses allowed |
disabled |
bool | false | Disable input if true |
update |
function | ()=>null |
# MCQMulti(props)
Create a multiple choice question with multiple correct answers.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
name |
string | A unique name for this question. |
|
options |
Array.<object> | Array of props used to create CheckOptions (children, correct, and feedback) |
|
defaultFeedback |
string | The default incorrect answer feedback |
|
correctFeedback |
string | "Correct!" | The default correct feedback |
guesses |
number | 3 | Maximum guesses allowed |
disabled |
bool | false | Disable input if true |
update |
function | ()=>null |
# QuestionF(props)
This component represents a question with feedback; with no way to limit the number of allowed attempts.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
answer |
number | The correct answer to the question |
|
correctFeedback |
string | 'Correct!' | The feedback given when the user answers correctly. |
incorrectFeedbackDigits |
number | 2 | The number of digits after the decimal point that are displayed. |
relErr |
number | 0.015 | The relative error tolerance; defaults to 1.5% to allow for rounding errors in user calculations. |
absErr |
number | 1e-12 | The absolute error tolerance (to account for small floating point errors). |
hidden |
bool | If true, hide the element. |
|
condIncorrectFeedback |
Array.<Object> | A list of FeedbackP props objects used to generate feedback elements. |
# QuestionLimF(props)
A numerical answer question with a limited number of guesses (default 3) built-in and feedback.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
answer |
number | The correct answer to the question |
|
correctFeedback |
string | 'Correct!' | The feedback given when the user answers correctly. |
incorrectFeedbackDigits |
number | 2 | The number of digits after the decimal point that are displayed. |
guesses |
number | 3 | The number of guesses the user gets before the correct answer is revealed. |
relErr |
number | 0.015 | The relative error tolerance; defaults to 1.5% to allow for rounding errors in user calculations. |
absErr |
number | 1e-12 | The absolute error tolerance (to account for small floating point errors). |
hidden |
bool | If true, hide the element. |
|
condIncorrectFeedback |
Array.<Object> | A list of FeedbackP props objects used to generate feedback elements. |
Example
(
<QuestionLimF answer={42}/>
What is the meaning of life?
</QuestionLimF>
)
# RadioOption(props)
Child component used to create the a multiple choice question with a single correct answer using MCQ. The only props needed to create the question are children, one correct answer, and (optionally) feedback.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
props |
Object | ||
children |
string | Answer text |
|
correct |
bool | false | Specify correct answer |
feedback |
string | Feedback displayed when this answer is selected. |
|
ind |
number | string | Answer index (provided by MCQ) |
|
name |
string | Question name (provided by MCQ) |
|
checked |
bool | Whether element is selected (provided by MCQ) |
|
onClick |
function | Event handler (provided by MCQ) |
|
disabledGuesses |
bool | false | Disable radio if true. |