@1ry/silly-grade-calc 0.1.0 → 0.1.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/build/release.d.ts +11 -0
- package/build/release.js +42 -0
- package/build/release.wasm +0 -0
- package/build/release.wat +1985 -0
- package/package.json +4 -1
- package/.github/workflows/release.yml +0 -31
- package/asconfig.json +0 -22
- package/assembly/calculateGrade.ts +0 -55
- package/assembly/clampWert.ts +0 -3
- package/assembly/formatPunkt.ts +0 -5
- package/assembly/formel.ts +0 -18
- package/assembly/index.ts +0 -1
- package/assembly/tsconfig.json +0 -17
- package/build/.gitignore +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1ry/silly-grade-calc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "a silly grade calculator, mostly for fun, but also to learn AssemblyScript",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:debug": "asc assembly/index.ts --target debug",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"assemblyscript": "^0.28.19"
|
|
16
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"build"
|
|
19
|
+
],
|
|
17
20
|
"exports": {
|
|
18
21
|
".": {
|
|
19
22
|
"import": "./build/release.js",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
name: release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
id-token: write
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build-test-release:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v6
|
|
16
|
-
|
|
17
|
-
- uses: pnpm/action-setup@v4
|
|
18
|
-
with:
|
|
19
|
-
version: 10
|
|
20
|
-
|
|
21
|
-
- uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: 20
|
|
24
|
-
cache: pnpm
|
|
25
|
-
registry-url: https://registry.npmjs.org
|
|
26
|
-
|
|
27
|
-
- run: pnpm install --frozen-lockfile
|
|
28
|
-
- run: pnpm build:release
|
|
29
|
-
- run: npm publish --access public --no-git-checks --provenance
|
|
30
|
-
env:
|
|
31
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/asconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": {
|
|
3
|
-
"debug": {
|
|
4
|
-
"outFile": "build/debug.wasm",
|
|
5
|
-
"textFile": "build/debug.wat",
|
|
6
|
-
"sourceMap": true,
|
|
7
|
-
"debug": true
|
|
8
|
-
},
|
|
9
|
-
"release": {
|
|
10
|
-
"outFile": "build/release.wasm",
|
|
11
|
-
"textFile": "build/release.wat",
|
|
12
|
-
"sourceMap": false,
|
|
13
|
-
"optimizeLevel": 3,
|
|
14
|
-
"shrinkLevel": 3,
|
|
15
|
-
"converge": false,
|
|
16
|
-
"noAssert": false
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"options": {
|
|
20
|
-
"bindings": "esm"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { bayerischeFormel, FormelSelecion, lineareFormel } from "./formel";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param totalOfPoints the maximum of points you could possibly get
|
|
6
|
-
* @param reachedPoints the amount of points you really got
|
|
7
|
-
* @param pointsNeededToPass amount of points needed to pass
|
|
8
|
-
* @param selectedFormel the formel you selected
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export function calculateGrade(
|
|
12
|
-
totalOfPoints: i32,
|
|
13
|
-
reachedPoints: i32,
|
|
14
|
-
pointsNeededToPass: i32 = totalOfPoints / 2,
|
|
15
|
-
selectedFormel: FormelSelecion = FormelSelecion.LINEAR,
|
|
16
|
-
): f32 {
|
|
17
|
-
const lineareSkala = selectedFormel === FormelSelecion.LINEAR;
|
|
18
|
-
if (totalOfPoints <= 0 || reachedPoints < 0) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
"invalid attributes: totalPoints and reached points need to be positive",
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
if (pointsNeededToPass >= totalOfPoints) {
|
|
24
|
-
throw new Error(
|
|
25
|
-
"invalid attributes: points needed to pass can't be more than total points",
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (reachedPoints < pointsNeededToPass) {
|
|
30
|
-
return 5;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const berechneteNote: f32 = (
|
|
34
|
-
lineareSkala
|
|
35
|
-
? lineareFormel(reachedPoints, totalOfPoints)
|
|
36
|
-
: bayerischeFormel(reachedPoints, totalOfPoints, pointsNeededToPass)
|
|
37
|
-
) as f32;
|
|
38
|
-
const gueltigeNoten: f32[] = [1, 1.3, 1.7, 2, 2.3, 2.7, 3, 3.3, 3.7, 4];
|
|
39
|
-
|
|
40
|
-
if (berechneteNote > 4) {
|
|
41
|
-
return 5;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let finaleNote: f32 = gueltigeNoten[0];
|
|
45
|
-
let minDiff: f32 = Math.abs(gueltigeNoten[0] - berechneteNote) as f32;
|
|
46
|
-
for (let index = 1; index < gueltigeNoten.length; index++) {
|
|
47
|
-
const diff: f32 = Math.abs(gueltigeNoten[index] - berechneteNote) as f32;
|
|
48
|
-
if (diff < minDiff) {
|
|
49
|
-
minDiff = diff;
|
|
50
|
-
finaleNote = gueltigeNoten[index];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return finaleNote as f32;
|
|
55
|
-
}
|
package/assembly/clampWert.ts
DELETED
package/assembly/formatPunkt.ts
DELETED
package/assembly/formel.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export enum FormelSelecion {
|
|
2
|
-
LINEAR,
|
|
3
|
-
BAYERISCH,
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export const lineareFormel = (
|
|
7
|
-
erreichtePunkte: f64,
|
|
8
|
-
gesamtPunktzahl: f64,
|
|
9
|
-
): f64 => 6 - 5 * (erreichtePunkte / gesamtPunktzahl);
|
|
10
|
-
export const bayerischeFormel = (
|
|
11
|
-
erreichtePunkte: f64,
|
|
12
|
-
gesamtPunktzahl: f64,
|
|
13
|
-
minimalePunkteZumBestehen: f64,
|
|
14
|
-
): f64 =>
|
|
15
|
-
1 +
|
|
16
|
-
3 *
|
|
17
|
-
((gesamtPunktzahl - erreichtePunkte) /
|
|
18
|
-
(gesamtPunktzahl - minimalePunkteZumBestehen));
|
package/assembly/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {calculateGrade} from "./calculateGrade";
|
package/assembly/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../node_modules/.pnpm/assemblyscript@0.28.19/node_modules/assemblyscript/std/assembly.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"./**/*.ts"
|
|
5
|
-
],
|
|
6
|
-
"compilerOptions": {
|
|
7
|
-
"noEmit": false,
|
|
8
|
-
"noImplicitAny": false,
|
|
9
|
-
"noUnusedLocals": false,
|
|
10
|
-
"noUnusedParameters": false,
|
|
11
|
-
"strictNullChecks": true,
|
|
12
|
-
"target": "es2020",
|
|
13
|
-
"noLib": false,
|
|
14
|
-
"lib": ["es2020", "DOM"],
|
|
15
|
-
"sourceMap": true
|
|
16
|
-
}
|
|
17
|
-
}
|
package/build/.gitignore
DELETED