UNPKG

@instructure/quiz-interactions

Version:

A React UI component Library for quiz interaction types.

80 lines (78 loc) 2.93 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 ChoiceBody from '../components/ChoiceBody'; /** --- category: TrueFalse --- True False Show component ```jsx_example <SettingsSwitcher locales={LOCALES}> <TrueFalseShow itemBody="The sun is a star" itemId="12" interactionData={{ trueChoice: 'True', falseChoice: 'False' }} scoringData={{ value: false }} /> </SettingsSwitcher> ``` **/ var TrueFalseShow = /*#__PURE__*/function (_Component) { function TrueFalseShow() { _classCallCheck(this, TrueFalseShow); return _callSuper(this, TrueFalseShow, arguments); } _inherits(TrueFalseShow, _Component); return _createClass(TrueFalseShow, [{ key: "render", value: function render() { var _this$props$interacti = this.props.interactionData, falseChoice = _this$props$interacti.falseChoice, trueChoice = _this$props$interacti.trueChoice; return /*#__PURE__*/React.createElement(ItemBodyWrapper, null, /*#__PURE__*/React.createElement(ChoiceBody, { selectedValue: this.props.scoringData.value ? 'trueChoice' : 'falseChoice', name: "".concat(this.props.itemId, "_show"), falseChoiceLabel: falseChoice, trueChoiceLabel: trueChoice, itemBody: this.props.itemBody, readOnly: true })); } }]); }(Component); _defineProperty(TrueFalseShow, "propTypes", { itemBody: PropTypes.string.isRequired, itemId: PropTypes.string, interactionData: PropTypes.shape({ trueChoice: PropTypes.string, falseChoice: PropTypes.string }).isRequired, scoringData: PropTypes.shape({ value: PropTypes.bool }).isRequired }); _defineProperty(TrueFalseShow, "defaultProps", { itemId: void 0 }); export { TrueFalseShow as default };