@khanacademy/perseus 27.1.0 → 27.2.0

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.d.ts CHANGED
@@ -71,7 +71,7 @@ export { generateTestPerseusItem, genericPerseusItemData, generateTestRadioWidge
71
71
  export { getWidgetTypeByWidgetId, contentHasWidgetType, getWidgetIdsFromContent, getWidgetIdsFromContentByType, getWidgetsMapFromItemData, getWidgetFromWidgetMap, getWidgetsFromWidgetMap, } from "./widget-type-utils";
72
72
  export { convertWidgetNameToEnum } from "./util/widget-enum-utils";
73
73
  export { addWidget, QUESTION_WIDGETS } from "./util/snowman-utils";
74
- export { getCircleCoords, getLineCoords, getLinearSystemCoords, getSegmentCoords, } from "./widgets/interactive-graphs/reducer/initialize-graph-state";
74
+ export { getCircleCoords, getLineCoords, getLinearSystemCoords, getSegmentCoords, getSinusoidCoords, getQuadraticCoords, } from "./widgets/interactive-graphs/reducer/initialize-graph-state";
75
75
  /**
76
76
  * Mixins
77
77
  */
package/dist/index.js CHANGED
@@ -31650,9 +31650,17 @@ function getGradableGraph(state, initialGraph) {
31650
31650
  };
31651
31651
  }
31652
31652
  if (state.type === "angle" && initialGraph.type === "angle") {
31653
+ // We're going to reverse the coords for scoring if the angle is clockwise and
31654
+ // we don't allow reflex angles. This is because the angle is largely defined
31655
+ // by the order of the points in the coords array, and we want to maintain
31656
+ // the same angle scoring with the legacy graph (which had a bug).
31657
+ // (LEMS-2190): When we remove the legacy graph, move this logic to the scoring function.
31658
+ const areClockwise = clockwise$1([state.coords[0], state.coords[2], state.coords[1]]);
31659
+ const shouldReverseCoords = areClockwise && !state.allowReflexAngles;
31660
+ const coords = shouldReverseCoords ? state.coords.slice().reverse() : state.coords;
31653
31661
  return {
31654
31662
  ...initialGraph,
31655
- coords: state.coords,
31663
+ coords,
31656
31664
  allowReflexAngles: state.allowReflexAngles
31657
31665
  };
31658
31666
  }
@@ -33353,6 +33361,10 @@ const makeInvalidTypeError = (functionName, graphType) => {
33353
33361
 
33354
33362
  // There's no transform function in exports
33355
33363
 
33364
+ // (LEMS-2190): Move the Mafs Angle Graph coordinate reversal logic in interactive-graph-state.ts
33365
+ // to this file when we remove the legacy graph. This logic allows us to support bi-directional angles
33366
+ // for the new (non-reflexive) Mafs graphs, while maintaining the same scoring behaviour as the legacy graph.
33367
+ // Once the legacy graph is removed, we should move this logic directly into the validate function below.
33356
33368
  class LegacyInteractiveGraph extends React__namespace.Component {
33357
33369
  static contextType = PerseusI18nContext;
33358
33370
  angle;
@@ -44512,7 +44524,7 @@ const init = function (options) {
44512
44524
 
44513
44525
  // This file is processed by a Rollup plugin (replace) to inject the production
44514
44526
  const libName = "@khanacademy/perseus";
44515
- const libVersion = "27.1.0";
44527
+ const libVersion = "27.2.0";
44516
44528
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
44517
44529
 
44518
44530
  const apiVersion = {
@@ -48172,7 +48184,9 @@ exports.getCircleCoords = getCircleCoords;
48172
48184
  exports.getCorrectAnswerForWidgetId = getCorrectAnswerForWidgetId;
48173
48185
  exports.getLineCoords = getLineCoords;
48174
48186
  exports.getLinearSystemCoords = getLinearSystemCoords;
48187
+ exports.getQuadraticCoords = getQuadraticCoords;
48175
48188
  exports.getSegmentCoords = getSegmentCoords;
48189
+ exports.getSinusoidCoords = getSinusoidCoords;
48176
48190
  exports.getValidWidgetIds = getValidWidgetIds;
48177
48191
  exports.getWidgetFromWidgetMap = getWidgetFromWidgetMap;
48178
48192
  exports.getWidgetIdsFromContent = getWidgetIdsFromContent;