UNPKG

@instructure/quiz-interactions

Version:

A React UI component Library for quiz interaction types.

89 lines (88 loc) 2.4 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _reactDnd = require("react-dnd"); var _reactDndHtml5Backend = _interopRequireDefault(require("react-dnd-html5-backend")); var _index = _interopRequireDefault(require("./index")); var userResponseFromBlank = function userResponseFromBlank(blank) { if (blank.answerType == 'openEntry') { return 'freeform answer ʃ̬'; } else { return blank.choices[0].id; } }; var _default = exports["default"] = { component: (0, _reactDnd.DragDropContext)(_reactDndHtml5Backend["default"])(_index["default"]), propValues: { blank: [{ id: 'fitb_uuid1', answerType: 'openEntry' }, { id: 'fitb_uuid1', answerType: 'wordbank', choices: [{ id: 'choice_uuid1', position: 1, itemBody: 'one' }, { id: 'choice_uuid2', position: 2, itemBody: 'two' }, { id: 'choice_uuid3', position: 3, itemBody: 'three' }] }, { id: 'fitb_uuid1', answerType: 'dropdown', choices: [{ id: 'choice_uuid1', position: 1, itemBody: 'one' }, { id: 'choice_uuid2', position: 2, itemBody: 'two' }, { id: 'choice_uuid3', position: 3, itemBody: 'three' }] }], showResponse: [true, false], // Normal 'readOnly' doesn't work for some reason? readOnly: [true, false] }, getComponentProps: function getComponentProps(props) { return { interactionData: { // HTML added for effect prompt: "\u0283\u032C <strong>Fill in the Blank </strong> (<em>readOnly=".concat(props.readOnly, "</em>)"), stemItems: [{ id: 'stem_uuid0', position: 1, type: 'text', value: 'Write a number word here: ' }, { id: 'stem_uuid1', position: 2, type: 'blank', blankId: 'fitb_uuid1' }], blanks: [props.blank] }, userResponse: { value: [{ id: 'fitb_uuid1', type: 'Text', value: props.showResponse ? userResponseFromBlank(props.blank) : '' }] }, handleResponseUpdate: Function.prototype }; } };