UNPKG

@instructure/quiz-interactions

Version:

A React UI component Library for quiz interaction types.

87 lines (86 loc) 2.26 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 scoringDataFromBlank = function scoringDataFromBlank(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' }] }], showScored: [true, false] }, getComponentProps: function getComponentProps(props) { return { interactionData: { // HTML added for effect prompt: "<p><strong>Please</strong> fill in all the blanks (".concat(props.blank.answerType, ")</p>"), 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] }, scoringData: { value: [{ id: props.blank.id, scoringData: { value: props.showScored ? scoringDataFromBlank(props.blank) : '' } }] } }; } };