UNPKG

@instructure/quiz-interactions

Version:

A React UI component Library for quiz interaction types.

100 lines (98 loc) 3.64 kB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; 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 = _getPrototypeOf(derived); return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); } import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { ItemBodyWrapper } from '@instructure/quiz-rce'; import OrderGroup from '../common/OrderGroup'; /** --- category: Ordering --- Ordering Show component ```jsx_example <SettingsSwitcher locales={LOCALES}> <OrderingShow itemBody="Order these characters from tallest to shortest:" interactionData={{ choices: { uuid6: { id: 'uuid6', itemBody: 'Gandalf' }, uuid5: { id: 'uuid5', itemBody: 'Legolas' }, uuid4: { id: 'uuid4', itemBody: 'Aragorn' }, uuid3: { id: 'uuid3', itemBody: 'Gimli' }, uuid2: { id: 'uuid2', itemBody: 'Frodo' }, uuid1: { id: 'uuid1', itemBody: 'Gollum' } } }} properties={{ displayAnswersParagraph: false, includeLabels: true, topLabel: 'Taller', bottomLabel: 'Shorter' }} scoringData={{ value: ['uuid6','uuid5','uuid4','uuid3','uuid2','uuid1'] }} /> </SettingsSwitcher> ``` **/ var OrderingShow = /*#__PURE__*/function (_Component) { function OrderingShow() { _classCallCheck(this, OrderingShow); return _callSuper(this, OrderingShow, arguments); } _inherits(OrderingShow, _Component); return _createClass(OrderingShow, [{ key: "render", value: function render() { return /*#__PURE__*/React.createElement(ItemBodyWrapper, { itemBody: this.props.itemBody }, /*#__PURE__*/React.createElement(OrderGroup, { bottomLabel: this.props.properties.bottomLabel, choiceOrder: this.props.scoringData.value, choices: this.props.interactionData.choices, displayAnswersParagraph: this.props.properties.displayAnswersParagraph, includeLabels: this.props.properties.includeLabels, topLabel: this.props.properties.topLabel, readOnly: true })); } }]); }(Component); _defineProperty(OrderingShow, "propTypes", { itemBody: PropTypes.string.isRequired, interactionData: PropTypes.shape({ choices: PropTypes.objectOf(PropTypes.shape({ id: PropTypes.string.isRequired, itemBody: PropTypes.string.isRequired })).isRequired }).isRequired, scoringData: PropTypes.shape({ value: PropTypes.arrayOf(PropTypes.string).isRequired }).isRequired, properties: PropTypes.shape({ displayAnswersParagraph: PropTypes.bool, includeLabels: PropTypes.bool, topLabel: PropTypes.string, bottomLabel: PropTypes.string }).isRequired }); export { OrderingShow as default };