-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1172afd
Showing
14 changed files
with
495 additions
and
0 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,88 @@ | ||
name: Exercise Feedback | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- src/exercises/** | ||
|
||
jobs: | ||
grading-feedback: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
path: main | ||
|
||
- name: Checkout exercise feedback | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: riehlegroup/adap-exercise-feedback | ||
path: main/src/tests | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "lts/*" | ||
|
||
# Run grading feedback | ||
- name: Exercise feedback | ||
id: ex_feedback | ||
run: | | ||
main/src/tests/ci/run_grading.sh | ||
# Create badges | ||
- name: Create badges ex1 | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: score_ex1 | ||
LABEL: "Ex1" | ||
STATUS: ${{ steps.ex_feedback.outputs.score_ex1 }} | ||
COLOR: 00EEFF | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Create badges ex2 | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: score_ex2 | ||
LABEL: "Ex2" | ||
STATUS: ${{ steps.ex_feedback.outputs.score_ex2 }} | ||
COLOR: 00EEFF | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create badges ex3 | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: score_ex3 | ||
LABEL: "Ex3" | ||
STATUS: ${{ steps.ex_feedback.outputs.score_ex3 }} | ||
COLOR: 00EEFF | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create badges ex4 | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: score_ex4 | ||
LABEL: "Ex4" | ||
STATUS: ${{ steps.ex_feedback.outputs.score_ex4 }} | ||
COLOR: 00EEFF | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create badges ex5 | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: score_ex5 | ||
LABEL: "Ex5" | ||
STATUS: ${{ steps.ex_feedback.outputs.score_ex5 }} | ||
COLOR: 00EEFF | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create badges ex6 | ||
uses: RubbaBoy/[email protected] | ||
with: | ||
NAME: score_ex6 | ||
LABEL: "Ex6" | ||
STATUS: ${{ steps.ex_feedback.outputs.score_ex6 }} | ||
COLOR: 00EEFF | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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,79 @@ | ||
##### | ||
# Own | ||
#### | ||
|
||
src/results/ | ||
|
||
|
||
|
||
################## | ||
# Provided by microsoft | ||
##################### | ||
dist | ||
diagnosticInformationMap | ||
node_modules/ | ||
.node_modules/ | ||
built/* | ||
tests/cases/rwc/* | ||
tests/cases/perf/* | ||
!tests/cases/webharness/compilerToString.js | ||
test-args.txt | ||
~*.docx | ||
\#*\# | ||
.\#* | ||
tests/baselines/local/* | ||
tests/baselines/local.old/* | ||
tests/services/baselines/local/* | ||
tests/baselines/prototyping/local/* | ||
tests/baselines/rwc/* | ||
tests/baselines/reference/projectOutput/* | ||
tests/baselines/local/projectOutput/* | ||
tests/baselines/reference/testresults.tap | ||
tests/baselines/symlinks/* | ||
tests/services/baselines/prototyping/local/* | ||
tests/services/browser/typescriptServices.js | ||
src/harness/*.js | ||
src/compiler/diagnosticInformationMap.generated.ts | ||
src/compiler/diagnosticMessages.generated.json | ||
src/parser/diagnosticInformationMap.generated.ts | ||
src/parser/diagnosticMessages.generated.json | ||
rwc-report.html | ||
*.swp | ||
build.json | ||
*.actual | ||
tests/webTestServer.js | ||
tests/webTestServer.js.map | ||
tests/webhost/*.d.ts | ||
tests/webhost/webtsc.js | ||
tests/cases/**/*.js | ||
tests/cases/**/*.js.map | ||
*.config | ||
scripts/eslint/built/ | ||
scripts/debug.bat | ||
scripts/run.bat | ||
scripts/**/*.js | ||
scripts/**/*.js.map | ||
coverage/ | ||
internal/ | ||
**/.DS_Store | ||
.settings | ||
**/.vs | ||
**/.vscode/* | ||
!**/.vscode/tasks.json | ||
!**/.vscode/settings.template.json | ||
!**/.vscode/launch.template.json | ||
!**/.vscode/extensions.json | ||
!tests/cases/projects/projectOption/**/node_modules | ||
!tests/cases/projects/NodeModulesSearch/**/* | ||
!tests/baselines/reference/project/nodeModules*/**/* | ||
.idea | ||
yarn.lock | ||
yarn-error.log | ||
.parallelperf.* | ||
tests/baselines/reference/dt | ||
.failed-tests | ||
TEST-results.xml | ||
package-lock.json | ||
.eslintcache | ||
*v8.log | ||
/lib/ |
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,9 @@ | ||
# Exercise Badges | ||
|
||
      | ||
|
||
|
||
# ADAP Grading | ||
|
||
Install: `npm i` | ||
Test: `npm run test` |
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,9 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
modulePaths: ['<rootDir>/src'], | ||
moduleDirectories: ['node_modules', 'src'], | ||
testEnvironment: "node", | ||
globalSetup: "<rootDir>/src/test-setup.ts", | ||
globalTeardown: "<rootDir>/src/test-teardown.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "adap-grading", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"start": "npm run build && node dist/index.js", | ||
"test": "jest" | ||
}, | ||
"author": "", | ||
"license": "TBD", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.14.11", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.2.2" | ||
} | ||
} |
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,6 @@ | ||
export class HelloWorld { | ||
|
||
hello(other: HelloWorld): string { | ||
return "HelloWorld - Now with CI"; | ||
} | ||
} |
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 @@ | ||
export * from './hello_world' |
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,5 @@ | ||
import { Grader } from "./grader"; | ||
|
||
declare global { | ||
var grader: Grader; | ||
} |
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,98 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
export interface GradingMessage { | ||
name: string; | ||
hint?: string; | ||
success?: boolean; // For public tests | ||
} | ||
|
||
export class Grader { | ||
rubrics: Map<string, GradingMessage[]> = new Map(); | ||
|
||
addEntry(rubricName: string, entry: GradingMessage): void { | ||
if (!this.rubrics.has(rubricName)) { | ||
this.rubrics.set(rubricName, []); | ||
} | ||
this.rubrics.get(rubricName)!.push(entry); | ||
} | ||
|
||
getPerformance(): { percent?: number; success?: number } { | ||
|
||
const successes = [...this.rubrics.values()] | ||
.flatMap(v => v.filter(entry => entry.success === true).length) | ||
.reduce((prev, current) => prev + current, 0); | ||
|
||
const totalTests = [...this.rubrics.values()] | ||
.flatMap(v => v.length) | ||
.reduce((prev, current) => prev + current, 0); | ||
|
||
return { | ||
success: totalTests ? (successes / totalTests) * 100 : undefined, | ||
}; | ||
} | ||
|
||
reset() { | ||
this.rubrics.clear(); | ||
} | ||
} | ||
|
||
export function GradedTest(ctx: { | ||
exerciseNumber: number; | ||
rubricName: string; | ||
testCaseName: string; | ||
hintOnFailure?: string; | ||
testCase: () => void; | ||
resultsFile: string; | ||
}) { | ||
test(ctx.testCaseName, () => { | ||
const grader = new Grader(); // Create a new grader for each test | ||
|
||
try { | ||
ctx.testCase(); | ||
grader.addEntry(ctx.rubricName, { | ||
name: ctx.testCaseName, | ||
success: true, | ||
}); | ||
} catch (error) { | ||
grader.addEntry(ctx.rubricName, { | ||
name: ctx.testCaseName, | ||
hint: ctx.hintOnFailure, | ||
success: false, | ||
}); | ||
throw error; // Rethrow the error to ensure the test fails correctly | ||
} finally { | ||
// Write the results to a file | ||
const results = grader.getPerformance(); | ||
const resultEntry = { | ||
rubric: ctx.rubricName, | ||
test: ctx.testCaseName, | ||
success: results.success, | ||
}; | ||
// Append the result to the results file | ||
appendResultToFile(ctx.resultsFile, resultEntry); | ||
} | ||
}); | ||
} | ||
|
||
function appendResultToFile(filePath: string, result: any) { | ||
let resultsArray = []; | ||
|
||
// Check if the file exists | ||
if (fs.existsSync(filePath)) { | ||
// Read existing results | ||
const data = fs.readFileSync(filePath, 'utf-8'); | ||
try { | ||
resultsArray = JSON.parse(data); | ||
} catch { | ||
// If parsing fails, start with an empty array | ||
resultsArray = []; | ||
} | ||
} | ||
|
||
// Append the new result | ||
resultsArray.push(result); | ||
|
||
// Write the updated array back to the file | ||
fs.writeFileSync(filePath, JSON.stringify(resultsArray, null, 2)); | ||
} |
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 @@ | ||
console.log("Hello world!"); |
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,5 @@ | ||
import { Grader } from "./grader"; | ||
|
||
export default async function globalSetup() { | ||
global.grader = new Grader(); // Ensure this line is reached | ||
} |
Oops, something went wrong.