@khanacademy/perseus-editor 2.14.2 → 2.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n$1);
64
64
 
65
65
  // This file is processed by a Rollup plugin (replace) to inject the production
66
66
  const libName = "@khanacademy/perseus-editor";
67
- const libVersion = "2.14.2";
67
+ const libVersion = "2.15.1";
68
68
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
69
69
 
70
70
  function _extends() {
@@ -23837,36 +23837,99 @@ class ItemExtrasEditor extends React__namespace.Component {
23837
23837
  static defaultProps = {
23838
23838
  calculator: false,
23839
23839
  chi2Table: false,
23840
+ financialCalculatorMonthlyPayment: false,
23841
+ financialCalculatorTotalAmount: false,
23842
+ financialCalculatorTimeToPayOff: false,
23840
23843
  periodicTable: false,
23841
23844
  periodicTableWithKey: false,
23842
23845
  tTable: false,
23843
23846
  zTable: false
23844
23847
  };
23848
+ state = {
23849
+ financialCalculatorOptionsExpanded: false
23850
+ };
23851
+ componentDidUpdate(prevProps) {
23852
+ // If no financial calculator options are checked, uncheck the
23853
+ // financial calculator option.
23854
+ if (this.state.financialCalculatorOptionsExpanded && !this.props.financialCalculatorMonthlyPayment && !this.props.financialCalculatorTotalAmount && !this.props.financialCalculatorTimeToPayOff) {
23855
+ this.setState({
23856
+ financialCalculatorOptionsExpanded: false
23857
+ });
23858
+ }
23859
+ }
23845
23860
  serialize = () => {
23846
- return {
23847
- calculator: this.props.calculator,
23848
- chi2Table: this.props.chi2Table,
23849
- periodicTable: this.props.periodicTable,
23850
- periodicTableWithKey: this.props.periodicTableWithKey,
23851
- tTable: this.props.tTable,
23852
- zTable: this.props.zTable
23861
+ const data = {
23862
+ ...ItemExtrasEditor.defaultProps
23853
23863
  };
23864
+ for (const key of perseus.ItemExtras) {
23865
+ data[key] = !!this.props[key];
23866
+ }
23867
+ return data;
23854
23868
  };
23855
23869
  render() {
23856
23870
  return /*#__PURE__*/React__namespace.createElement("div", {
23857
23871
  className: "perseus-answer-editor"
23858
23872
  }, /*#__PURE__*/React__namespace.createElement("div", {
23859
23873
  className: "perseus-answer-options"
23860
- }, /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Show calculator:", " ", /*#__PURE__*/React__namespace.createElement("input", {
23861
- type: "checkbox",
23874
+ }, /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23875
+ label: "Show calculator:",
23876
+ infoTip: "Use the calculator when completing difficult calculations is NOT the intent of the question. DON\u2019T use the calculator when testing the student\u2019s ability to complete different types of computations.",
23862
23877
  checked: this.props.calculator,
23863
23878
  onChange: e => {
23864
23879
  this.props.onChange({
23865
23880
  calculator: e.target.checked
23866
23881
  });
23867
23882
  }
23868
- })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "Use the calculator when completing difficult calculations is NOT the intent of the question. DON\u2019T use the calculator when testing the student\u2019s ability to complete different types of computations.")), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Show periodic table:", " ", /*#__PURE__*/React__namespace.createElement("input", {
23869
- type: "checkbox",
23883
+ }), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23884
+ label: "Show financial calculator:",
23885
+ infoTip: "This provides the student with the ability to view a financial calculator, e.g., for answering financial questions. Once checked, requires at least one of the three options below to be checked.",
23886
+ checked: this.state.financialCalculatorOptionsExpanded,
23887
+ onChange: e => {
23888
+ this.setState({
23889
+ financialCalculatorOptionsExpanded: e.target.checked
23890
+ });
23891
+ // If the financial calculator is unchecked,
23892
+ // this needs to be reset. All checked by
23893
+ // default.
23894
+ this.props.onChange({
23895
+ financialCalculatorMonthlyPayment: e.target.checked,
23896
+ financialCalculatorTotalAmount: e.target.checked,
23897
+ financialCalculatorTimeToPayOff: e.target.checked
23898
+ });
23899
+ }
23900
+ }), this.state.financialCalculatorOptionsExpanded && /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23901
+ label: "Include monthly payment:",
23902
+ infoTip: "This provides the student with the ability to view a monthly payment calculator; e.g., given a loan amount, interest rate, and term, what is the monthly payment?",
23903
+ checked: this.props.financialCalculatorMonthlyPayment,
23904
+ onChange: e => {
23905
+ this.props.onChange({
23906
+ financialCalculatorMonthlyPayment: e.target.checked
23907
+ });
23908
+ },
23909
+ indent: true
23910
+ }), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23911
+ label: "Include total amount:",
23912
+ infoTip: "This provides the student with the ability to view a total amount calculator; e.g., given a monthly payment, interest rate, and term, what is the total amount to be paid?",
23913
+ checked: this.props.financialCalculatorTotalAmount,
23914
+ onChange: e => {
23915
+ this.props.onChange({
23916
+ financialCalculatorTotalAmount: e.target.checked
23917
+ });
23918
+ },
23919
+ indent: true
23920
+ }), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23921
+ label: "Include time-to-pay-off:",
23922
+ infoTip: "This provides the student with the ability to view a time to pay off calculator; e.g., given a loan amount, interest rate, and monthly payment, how long will it take to pay off the loan?",
23923
+ checked: this.props.financialCalculatorTimeToPayOff,
23924
+ onChange: e => {
23925
+ this.props.onChange({
23926
+ financialCalculatorTimeToPayOff: e.target.checked
23927
+ });
23928
+ },
23929
+ indent: true
23930
+ })), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23931
+ label: "Show periodic table:",
23932
+ infoTip: "This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions.",
23870
23933
  checked: this.props.periodicTable,
23871
23934
  onChange: e => {
23872
23935
  this.props.onChange({
@@ -23877,41 +23940,55 @@ class ItemExtrasEditor extends React__namespace.Component {
23877
23940
  periodicTableWithKey: false
23878
23941
  });
23879
23942
  }
23880
- })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions.")), this.props.periodicTable && /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Include key/legend with periodic table:", " ", /*#__PURE__*/React__namespace.createElement("input", {
23881
- type: "checkbox",
23943
+ }), this.props.periodicTable && /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23944
+ label: "Include key/legend with periodic table:",
23945
+ infoTip: "Include a key for HS courses; omit for AP chemistry.",
23882
23946
  checked: this.props.periodicTableWithKey,
23883
23947
  onChange: e => {
23884
23948
  this.props.onChange({
23885
23949
  periodicTableWithKey: e.target.checked
23886
23950
  });
23887
- }
23888
- })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "Include a key for HS courses, omit for AP chemistry.")), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Show z table (statistics):", " ", /*#__PURE__*/React__namespace.createElement("input", {
23889
- type: "checkbox",
23951
+ },
23952
+ indent: true
23953
+ }), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23954
+ label: "Show z table (statistics):",
23955
+ infoTip: "This provides the student with the ability to view a table of critical values for the z distribution, e.g. for answering statistics questions.",
23890
23956
  checked: this.props.zTable,
23891
23957
  onChange: e => {
23892
23958
  this.props.onChange({
23893
23959
  zTable: e.target.checked
23894
23960
  });
23895
23961
  }
23896
- })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "This provides the student with the ability to view a table of critical values for the z distribution, e.g. for answering statistics questions.")), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Show t table (statistics):", " ", /*#__PURE__*/React__namespace.createElement("input", {
23897
- type: "checkbox",
23962
+ }), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23963
+ label: "Show t table (statistics):",
23964
+ infoTip: "This provides the student with the ability to view a table of critical values for the Student's t distribution, e.g. for answering statistics questions.",
23898
23965
  checked: this.props.tTable,
23899
23966
  onChange: e => {
23900
23967
  this.props.onChange({
23901
23968
  tTable: e.target.checked
23902
23969
  });
23903
23970
  }
23904
- })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "This provides the student with the ability to view a table of critical values for the Student's t distribution, e.g. for answering statistics questions.")), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("label", null, "Show chi-squared table (statistics):", " ", /*#__PURE__*/React__namespace.createElement("input", {
23905
- type: "checkbox",
23971
+ }), /*#__PURE__*/React__namespace.createElement(ItemExtraCheckbox, {
23972
+ label: "Show chi-squared table (statistics):",
23973
+ infoTip: "This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions.",
23906
23974
  checked: this.props.chi2Table,
23907
23975
  onChange: e => {
23908
23976
  this.props.onChange({
23909
23977
  chi2Table: e.target.checked
23910
23978
  });
23911
23979
  }
23912
- })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, "This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions."))));
23980
+ })));
23913
23981
  }
23914
23982
  }
23983
+ const ItemExtraCheckbox = props => /*#__PURE__*/React__namespace.createElement("div", {
23984
+ style: {
23985
+ marginLeft: props.indent ? "10px" : "0px"
23986
+ }
23987
+ }, /*#__PURE__*/React__namespace.createElement("label", null, props.label, /*#__PURE__*/React__namespace.createElement("input", {
23988
+ type: "checkbox",
23989
+ checked: props.checked,
23990
+ onChange: props.onChange
23991
+ })), /*#__PURE__*/React__namespace.createElement(InfoTip$m, null, props.infoTip));
23915
23992
 
23916
23993
  const ITEM_DATA_VERSION = perseus.itemDataVersion;
23917
23994
  class ItemEditor extends React__namespace.Component {