@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
155 lines (151 loc) • 7.09 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _Take = _interopRequireDefault(require("../Take"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _callSuper(_this, derived, args) {
function isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch (e) {
return false;
}
}
derived = (0, _getPrototypeOf2["default"])(derived);
return (0, _possibleConstructorReturn2["default"])(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], (0, _getPrototypeOf2["default"])(_this).constructor) : derived.apply(_this, args));
}
var noop = function noop() {};
/**
---
category: RichFillInTheBlank
---
Rich Fill in the Blank Show component
```jsx_example
const WrappedExample = DragDropContext(HTML5Backend)(FillBlankShow);
<SettingsSwitcher locales={LOCALES}>
<WrappedExample
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' }
}]
}}
/>
</SettingsSwitcher>
```
**/
var RichFillBlankShow = exports["default"] = /*#__PURE__*/function (_Component) {
function RichFillBlankShow() {
(0, _classCallCheck2["default"])(this, RichFillBlankShow);
return _callSuper(this, RichFillBlankShow, arguments);
}
(0, _inherits2["default"])(RichFillBlankShow, _Component);
return (0, _createClass2["default"])(RichFillBlankShow, [{
key: "render",
value: function render() {
return /*#__PURE__*/_react["default"].createElement(_Take["default"], {
userResponse: {
value: this.props.scoringData.value.map(function (_ref) {
var id = _ref.id,
value = _ref.scoringData.value;
return {
id: id,
value: Array.isArray(value) ? value[0] : value,
type: 'Text'
};
})
},
interactionData: this.props.interactionData,
itemBody: this.props.itemBody,
handleResponseUpdate: noop,
readOnly: true
});
}
}]);
}(_react.Component);
(0, _defineProperty2["default"])(RichFillBlankShow, "propTypes", {
interactionData: _propTypes["default"].object.isRequired,
itemBody: _propTypes["default"].string.isRequired,
scoringData: _propTypes["default"].object.isRequired
});