-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary: Part of LEMS-2737 This PR is to initialize a new subpackage: `perseus-score` To prove that the package was working, I decided to move `answer-types.ts` from `perseus` to `perseus-score`. This resulted in a couple of side-effects (as a result of the fact that `perseus-score` cannot import from `perseus`): 1. I needed to move `util/math.ts` from `perseus` to `kmath` 2. `math.ts` needed something from `perseus-types.ts` which means I needed to go ahead and move that from `perseus` to `perseus-core` (and per Jeremy's request I renamed `perseus-types.ts` to `data-schema.ts`) 3. Probably 90%+ of the files changed are because of the `perseus-types.ts` move 4. `answer-types.ts` needed access to `strings.ts` which is a special export from `perseus`, so I had to refactor `answer-types.ts` to use error placeholders that could get mapped to strings when being displayed to learners. Issue: LEMS-2737 ## Test plan: - Make sure widgets that use `answer-types.ts` still work - Expression - InputNumber - Matrix - NumericInput - Table - Make sure user-facing errors in those widgets still work - I dunno, it's a big change; everything should still work Author: handeyeco Reviewers: handeyeco, jeremywiebe Required Reviewers: Approved By: jeremywiebe Checks: ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x) Pull Request URL: #2086
- Loading branch information
Showing
249 changed files
with
557 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@khanacademy/perseus": major | ||
"@khanacademy/perseus-score": major | ||
"@khanacademy/kmath": minor | ||
"@khanacademy/perseus-core": minor | ||
"@khanacademy/perseus-dev-ui": patch | ||
"@khanacademy/perseus-editor": patch | ||
--- | ||
|
||
Init perseus-score, move AnswerTypes from perseus to perseus-score, move perseus-types in perseus to data-schema in perseus-core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
5 changes: 3 additions & 2 deletions
5
packages/perseus/src/util/math.ts → packages/kmath/src/math.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* HACK(somewhatabstract): Due to https://github.com/facebook/jest/issues/11741, | ||
* we need to have this file, or updating inline snapshots can fail rather | ||
* cryptically. | ||
* | ||
* We should remove this when jest is fixed. | ||
*/ | ||
module.exports = require("../../config/build/babel.config"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-require-imports */ | ||
/* eslint-disable import/no-commonjs */ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
rules: { | ||
"import/no-extraneous-dependencies": [ | ||
"error", | ||
{ | ||
packageDir: [__dirname, path.join(__dirname, "../../")], | ||
includeTypes: true, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @khanacademy/perseus-score | ||
|
||
Logic for scoring Perseus exercises. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@khanacademy/perseus-score", | ||
"description": "Perseus score", | ||
"author": "Khan Academy", | ||
"license": "MIT", | ||
"version": "0.0.0", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Khan/perseus.git", | ||
"directory": "packages/perseus-score" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Khan/perseus/issues" | ||
}, | ||
"module": "dist/es/index.js", | ||
"main": "dist/index.js", | ||
"source": "src/index.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"prepublishOnly": "../../utils/package-pre-publish-check.sh", | ||
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'" | ||
}, | ||
"dependencies": { | ||
"@khanacademy/kas": "^0.4.9", | ||
"@khanacademy/kmath": "^0.1.24", | ||
"@khanacademy/perseus-core": "3.0.5" | ||
}, | ||
"devDependencies": {}, | ||
"peerDependencies": {}, | ||
"keywords": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const MISSING_PERCENT_ERROR = "MISSING_PERCENT_ERROR"; | ||
const NEEDS_TO_BE_SIMPLIFIED_ERROR = "NEEDS_TO_BE_SIMPLIFIED_ERROR"; | ||
const APPROXIMATED_PI_ERROR = "APPROXIMATED_PI_ERROR"; | ||
const EXTRA_SYMBOLS_ERROR = "EXTRA_SYMBOLS_ERROR"; | ||
const WRONG_CASE_ERROR = "WRONG_CASE_ERROR"; | ||
const WRONG_LETTER_ERROR = "WRONG_LETTER_ERROR"; | ||
const MULTIPLICATION_SIGN_ERROR = "MULTIPLICATION_SIGN_ERROR"; | ||
|
||
const ErrorCodes = { | ||
MISSING_PERCENT_ERROR, | ||
NEEDS_TO_BE_SIMPLIFIED_ERROR, | ||
APPROXIMATED_PI_ERROR, | ||
EXTRA_SYMBOLS_ERROR, | ||
WRONG_CASE_ERROR, | ||
WRONG_LETTER_ERROR, | ||
MULTIPLICATION_SIGN_ERROR, | ||
}; | ||
|
||
export default ErrorCodes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export {default as KhanAnswerTypes} from "./util/answer-types"; | ||
export type {Score} from "./util/answer-types"; | ||
export {default as ErrorCodes} from "./error-codes"; |
3 changes: 0 additions & 3 deletions
3
...ges/perseus/src/util/answer-types.test.ts → ...rseus-score/src/util/answer-types.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This file is processed by a Rollup plugin (replace) to inject the production | ||
// version number during the release build. | ||
// In dev, you'll never see the version number. | ||
|
||
import {addLibraryVersionToPerseusDebug} from "@khanacademy/perseus-core"; | ||
|
||
const libName = "@khanacademy/perseus-score"; | ||
export const libVersion = "__lib_version__"; | ||
|
||
addLibraryVersionToPerseusDebug(libName, libVersion); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../tsconfig-shared.json", | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"rootDir": "src", | ||
"paths": { | ||
// NOTE(kevinb): We have to repeat this here because TS doesn't do | ||
// intelligent merge of tsconfig.json files when using `extends`. | ||
"@khanacademy/*": [ | ||
"../*/src" | ||
] | ||
} | ||
}, | ||
"references": [ | ||
{"path": "../kas/tsconfig-build.json"}, | ||
{"path": "../kmath/tsconfig-build.json"}, | ||
{"path": "../perseus-core/tsconfig-build.json"}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../types/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.