@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
120 lines (114 loc) • 3.83 kB
JavaScript
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import RichFillInTheBlankTake from '../Take'
const noop = () => {}
/**
category: RichFillInTheBlank
Rich Fill in the Blank Show component
```jsx_example
<SettingsSwitcher locales={LOCALES}>
<DndProvider backend={HTML5Backend}>
<FillBlankShow
itemBody={`<p><span id="blank_fitb_uuid1"></span> Columbus sailed in
<span id="blank_fitb_uuid2"></span> from the country of
<span id="blank_fitb_uuid3"></span> on the continent of
<span id="blank_fitb_uuid4"></span> across the
<span id="blank_fitb_uuid5"></span> and found...
<span id="blank_fitb_uuid6"></span>!!! Where the people were "
<span id="blank_fitb_uuid7"></span>"</p>`}
interactionData={{
blanks: [{
id: 'fitb_uuid1',
answerType: 'openEntry'
}, {
id: 'fitb_uuid2',
answerType: 'openEntry'
}, {
id: 'fitb_uuid3',
answerType: 'openEntry'
}, {
id: 'fitb_uuid4',
answerType: 'openEntry'
}, {
id: 'fitb_uuid5',
answerType: 'openEntry'
}, {
id: 'fitb_uuid6',
answerType: 'wordbank',
choices: [
{ id: 'choice_uuid11_brazil', position: 1, itemBody: 'Brazil' },
{ id: 'choice_uuid12_austria', position: 2, itemBody: 'Austria' },
{ id: 'choice_uuid13_america', position: 3, itemBody: 'America' }
]
}, {
id: 'fitb_uuid7',
answerType: 'dropdown',
choices: [
{ id: 'choice_uuid11_peaceful', position: 1, itemBody: 'peaceful' },
{ id: 'choice_uuid12_war-torn', position: 2, itemBody: 'war-torn' },
{ id: 'choice_uuid13_confused', position: 3, itemBody: 'confused' }
]
}]
}}
scoringData={{
value: [{
id: 'fitb_uuid1',
scoringAlgorithm: 'TextRegex',
scoringData: { value: '.*Christopher', blankText: 'Christopher' }
}, {
id: 'fitb_uuid2',
scoringAlgorithm: 'TextCloseEnough',
scoringData: { value: '1492', editDistance: 1, blankText: '1492' }
}, {
id: 'fitb_uuid3',
scoringAlgorithm: 'TextInChoices',
scoringData: { value: ['Spain', 'Espana', 'Kingdom of Spain'], blankText: 'Spain' }
}, {
id: 'fitb_uuid4',
scoringAlgorithm: 'TextEquivalence',
scoringData: { value: 'Europe', blankText: 'Europe' }
}, {
id: 'fitb_uuid5',
scoringAlgorithm: 'TextContainsAnswer',
scoringData: { value: 'Atlantic', blankText: 'Atlantic' }
}, {
id: 'fitb_uuid6',
scoringAlgorithm: 'Equivalence',
scoringData: { value: 'choice_uuid13_america', blankText: 'America' }
}, {
id: 'fitb_uuid7',
scoringAlgorithm: 'Equivalence',
scoringData: { value: 'choice_uuid13_confused', blankText: 'Confused' }
}]
}}
/>
</DndProvider>
</SettingsSwitcher>
```
**/
export default class RichFillBlankShow extends Component {
static propTypes = {
interactionData: PropTypes.object.isRequired,
itemBody: PropTypes.string.isRequired,
scoringData: PropTypes.object.isRequired,
}
render() {
return (
<RichFillInTheBlankTake
userResponse={{
value: this.props.scoringData.value.map(({id, scoringData: {value}}) => ({
id,
value: Array.isArray(value) ? value[0] : value,
type: 'Text',
})),
}}
interactionData={this.props.interactionData}
itemBody={this.props.itemBody}
handleResponseUpdate={noop}
readOnly
/>
)
}
}