Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
825d27b
chore: pull main
benaspinall1 Nov 17, 2024
4045b82
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Nov 23, 2024
7450bab
bugfix: fix paramvalidator import bug
benaspinall1 Nov 23, 2024
8fcbb49
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Nov 26, 2024
06dea94
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Nov 29, 2024
70ac046
chore: build
benaspinall1 Dec 3, 2024
f092622
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Jan 25, 2025
5b0ab8a
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Jan 28, 2025
6536a11
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 2, 2025
6b27737
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 4, 2025
8e104e9
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 5, 2025
5e0fd4f
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 9, 2025
ab7c6f5
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 13, 2025
30724df
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 17, 2025
869aa92
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 22, 2025
3833613
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 25, 2025
d902f52
feature: create group feedback section
benaspinall1 Feb 25, 2025
b23570a
feature: add criterion comment, indiv&group fb sec
benaspinall1 Feb 25, 2025
2954c5a
refactor: update pencil to brush
benaspinall1 Feb 26, 2025
4912601
hotfix: fix palette brush export in barrel file
benaspinall1 Feb 26, 2025
5e35e35
feature: connect criterion comments to canvas api
benaspinall1 Feb 26, 2025
6b8ef1f
feature: implement individual comments.
benaspinall1 Feb 26, 2025
b475979
docs: add docs for comments api usage
jwsmith24 Feb 26, 2025
e09e84b
chore: update CanvasGradedSubmissions type to support comments
jwsmith24 Feb 26, 2025
97e06a4
docs: fix individual comment json to reflect full structure
jwsmith24 Feb 26, 2025
58732a0
Merge branch 'feature/grading-comments' into docs/comments-api
benaspinall1 Feb 27, 2025
f2cfa34
feature:(last commit) group&indiv comments togther
benaspinall1 Feb 27, 2025
c54352f
hotfix: palette pencil to brush
benaspinall1 Feb 27, 2025
a006fe7
feature: add existing comment visualization
benaspinall1 Feb 27, 2025
34c4bf6
feature: setup base for updating existinf comments
benaspinall1 Feb 27, 2025
1a6f5a4
feature: implement base for criteria comment edit
benaspinall1 Feb 27, 2025
c0b939e
feature: implement comment handling
benaspinall1 Feb 28, 2025
3ac86dd
chore: prettier/lint
benaspinall1 Feb 28, 2025
c6b8f32
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 28, 2025
3f22cce
hotfix: clean up old routes
benaspinall1 Feb 28, 2025
8b7ef47
feature: implement basic ui for course filter
benaspinall1 Feb 28, 2025
9bd706c
chore:prettier
benaspinall1 Feb 28, 2025
65ee9ca
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Feb 28, 2025
0e102f6
Merge branch 'main' into docs/comments-api
benaspinall1 Feb 28, 2025
63df779
chore:prettier
benaspinall1 Feb 28, 2025
513d103
feature: implement basic filter switching ui
benaspinall1 Feb 28, 2025
718f81e
feature: add course filters to setting.json
benaspinall1 Mar 3, 2025
3c88d57
feature: update course request to parse filters.
benaspinall1 Mar 3, 2025
a346b8a
feature: add default filter and ui utils
benaspinall1 Mar 4, 2025
95e2efc
feature: implement filter preset creating.
benaspinall1 Mar 6, 2025
e147ac8
chore: prettier
benaspinall1 Mar 6, 2025
917a544
feature: implement course filter
benaspinall1 Mar 7, 2025
b3336d9
bugfix: fix data and course type
benaspinall1 Mar 7, 2025
969faac
chore: add loggers back
benaspinall1 Mar 7, 2025
3f52260
chore: add strict mode back
benaspinall1 Mar 7, 2025
3bb3fdc
chore: prettier
benaspinall1 Mar 7, 2025
38490b3
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Mar 7, 2025
724045a
Merge branch 'main' into feature/custom-course-filter
benaspinall1 Mar 7, 2025
4eb5a16
chore:prettier
benaspinall1 Mar 7, 2025
9f1fcef
Merge branch 'feature/custom-course-filter' into docs/comments-api
benaspinall1 Mar 7, 2025
82083c2
chore: prettier
benaspinall1 Mar 7, 2025
95c326d
hotfix: restore lost project grading view features
benaspinall1 Mar 8, 2025
adcf830
hotfix: truncate average points to 2 decimals
benaspinall1 Mar 8, 2025
31d1bcb
hotfix: add back group feedback
benaspinall1 Mar 8, 2025
0671122
hotfix: fix comment funtionality
benaspinall1 Mar 8, 2025
69c2453
chore: es lint
benaspinall1 Mar 8, 2025
16618dc
chore: prettier
benaspinall1 Mar 8, 2025
3d231e6
feature: implement brush and eye focus
benaspinall1 Mar 8, 2025
d613306
chore: prettier
benaspinall1 Mar 8, 2025
db6f987
hotfix: send filter id to backend w/o updating
benaspinall1 Mar 8, 2025
08a1fae
feature: change cog icon to table
benaspinall1 Mar 8, 2025
f0fe84a
feature: implement assignment filter ui
benaspinall1 Mar 8, 2025
b9b6543
hotfix: implement sending correct month to backend
benaspinall1 Mar 16, 2025
2f6b789
feature: implement month comparision in backend
benaspinall1 Mar 16, 2025
4186d09
Mhttps://github.com/orgs/PaletteProject/projects/1/views/1?pane=issue…
benaspinall1 Mar 19, 2025
03d7b06
Merge branch 'main' into feature/custom-assignment-filter
benaspinall1 Mar 19, 2025
3be7751
bugfix: fix course filter preset persistence
benaspinall1 Mar 19, 2025
47df7bb
feature: update preset section ui
benaspinall1 Mar 19, 2025
aac7ceb
feature: implement assignment filter persistence
benaspinall1 Mar 19, 2025
c38ff71
feature: add filter ui enhancements
benaspinall1 Mar 19, 2025
18c0872
chore: prettier and lint
benaspinall1 Mar 19, 2025
7acac73
feature: update time file to get full date
benaspinall1 Mar 20, 2025
0146876
hotfix: update assignment type
benaspinall1 Mar 20, 2025
f68f87b
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Mar 21, 2025
d90221f
Merge branch 'main' into feature/custom-assignment-filter
benaspinall1 Mar 21, 2025
5ff2fba
chore: fix logical merge error
benaspinall1 Mar 21, 2025
0d6e236
feature: add assignment filters
benaspinall1 Mar 21, 2025
498754c
chore: prettier/lint
benaspinall1 Mar 21, 2025
e275d06
chore: add strict mode back
benaspinall1 Mar 21, 2025
ddd9646
chore: prettier + lint + due date test
benaspinall1 Mar 21, 2025
8d50b70
metric: clean up canvas api token logging
benaspinall1 Mar 24, 2025
0cb3352
chore: prettier
benaspinall1 Mar 24, 2025
462fed9
metric: set up endpoint testing for courses
benaspinall1 Mar 25, 2025
0d492f2
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Mar 27, 2025
e045732
metric: implement working put and get testing
benaspinall1 Mar 29, 2025
7883a65
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Mar 29, 2025
b7c2dd0
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Apr 1, 2025
fcd5d12
Merge branch 'main' into metric/data-transfer-reliability
benaspinall1 Apr 1, 2025
cd843e3
refactor: rebuild submission object for testing
benaspinall1 Apr 1, 2025
0a809f4
refactor: fix rubric assessment pattern
benaspinall1 Apr 4, 2025
f514908
chore: npm update
benaspinall1 Apr 4, 2025
2805a5d
feature: implement subission reliability
benaspinall1 Apr 4, 2025
6b26344
feature: add comment deleting for test
benaspinall1 Apr 4, 2025
d7e5fde
feature: add test stub for rubric tests
benaspinall1 Apr 6, 2025
454090c
feature: set up rubric requwst object for test
benaspinall1 Apr 8, 2025
1e8ae6d
feature: implement rubric data metric
benaspinall1 Apr 9, 2025
f25e0ef
chore: prettier & lint clean up
benaspinall1 Apr 9, 2025
5a4dab1
bugfix: fix separation of concerns bug
benaspinall1 Apr 10, 2025
9bacea1
chore: fix verbose variable names
benaspinall1 Apr 10, 2025
e2b7bc5
feature: add data randomization to rubric sending
benaspinall1 Apr 11, 2025
f646263
feature: implements better randomization
benaspinall1 Apr 11, 2025
f585c15
feature: implement submission randomization
benaspinall1 Apr 11, 2025
b153e82
chore: prettier/lint
benaspinall1 Apr 11, 2025
9c8470f
hotfix: fix palette-types build
benaspinall1 Apr 11, 2025
d014637
chore: prettier
benaspinall1 Apr 11, 2025
be8eac0
hotfix: fix build
benaspinall1 Apr 11, 2025
8715926
feature: exclude metrics from ci
benaspinall1 Apr 12, 2025
c4e4a96
feature: exclude metrics from ci
benaspinall1 Apr 12, 2025
4e22df1
feature: exclude metrics from ci
benaspinall1 Apr 12, 2025
022933b
chore: prettier
benaspinall1 Apr 12, 2025
62d95e8
feature: implement base for performance analysis
benaspinall1 Apr 15, 2025
c793f77
feature: add mock submission generator
benaspinall1 Apr 18, 2025
ab748e3
Merge branch 'main' of https://github.com/jwsmith24/palette
benaspinall1 Apr 18, 2025
d7d9eb8
feature: simplify logger
benaspinall1 Apr 22, 2025
bc1d515
feature: obscate token in palette response logger
benaspinall1 Apr 23, 2025
2182989
feature: obfuscate canvas api request in log.
benaspinall1 Apr 24, 2025
7957304
Merge branch 'main' into metric/student-performance
benaspinall1 Apr 26, 2025
8c0943c
chore: merge conflicts
benaspinall1 Apr 26, 2025
dd186ab
feature: safety metric implemented
benaspinall1 Apr 26, 2025
bff7e81
chore: prettier and lint
benaspinall1 Apr 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["/dist/", "/node_modules/"], // Don't run tests in these directories
testPathIgnorePatterns: [
"/dist/",
"/node_modules/",
"rubrics.test.ts",
"submissions.test.ts",
], // Don't run tests in these directories
// tell jest to interpret .js-ending files as .ts files during testing
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
Expand Down
278 changes: 278 additions & 0 deletions backend/src/__tests__/routes/rubrics.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
import express from "express";
import supertest from "supertest";
import { Server } from "http";
import { calcMaxPoints } from "../../../../frontend/src/utils/calculateMaxPoints";
import courseRouter from "../../routes/courseRouter.js";
import {
CanvasRubric,
Rubric,
CanvasCriterion,
CanvasRating,
} from "palette-types";
const COURSE_ROUTE = "/api/courses";
const COURSE_ID = 15760;
const ASSIGNMENT_ID = 6171684;
const RUBRIC_ID = 1034872;
const TEST_COUNT = 10; // Change this to fully test the metric. Planning to config this number the be reduced when doing GitHub Actions CI.

const app = express();
app.use(express.json());
app.use("/api/courses", courseRouter);

let server: Server | null = null;

beforeAll(() => {
server = app.listen();
});

afterAll((done) => {
if (server) {
server.close(done);
} else {
done();
}
});

function getPointsForAdjective(adjective: string): number {
const pointMap: Record<string, number> = {
Excellent: 15,
Outstanding: 15,
Good: 10,
Satisfactory: 8,
Fair: 5,
Poor: 3,
Inadequate: 0,
};

return pointMap[adjective] || 5; // Default to middle value if adjective not found
}

function extractAdjectiveFromDescription(description: string): string {
const words = description.split(" ");
return words[0]; // The first word is the adjective
}

function generateRandomDescription(): string {
const adjectives = [
"Excellent",
"Good",
"Fair",
"Poor",
"Outstanding",
"Satisfactory",
"Inadequate",
];
const nouns = [
"work",
"performance",
"effort",
"submission",
"deliverable",
"project",
"assignment",
];

const randomAdjective =
adjectives[Math.floor(Math.random() * adjectives.length)];
const randomNoun = nouns[Math.floor(Math.random() * nouns.length)];

return `${randomAdjective} ${randomNoun}.`;
}

function generateRandomCriteriaDescription(): string {
const descriptions = [
"Sprint planning",
"Code review",
"Unit testing",
"Documentation",
"Bug fixing",
"Feature implementation",
"Refactoring",
"API design",
"Database schema",
"UI/UX design",
"Deployment process",
"Version control",
"Code quality",
"Performance optimization",
"Security practices",
"Agile methodology",
"Continuous integration",
"Error handling",
"Logging implementation",
"Accessibility compliance",
];

return descriptions[Math.floor(Math.random() * descriptions.length)];
}

function generateDescriptionPair(): { short: string; long: string } {
const shortDescription = generateRandomCriteriaDescription();
const longDescription = `${shortDescription} long version`;

return {
short: shortDescription,
long: longDescription,
};
}

function generateMockRubricSubmission() {
// Generate descriptions for criteria
const criteria1Descriptions = generateDescriptionPair();
const criteria2Descriptions = generateDescriptionPair();

// Generate a random description to use for both comment and points
const rating1Description = generateRandomDescription();
const rating1Adjective = extractAdjectiveFromDescription(rating1Description);
const rating1Points = getPointsForAdjective(rating1Adjective);

const rating2Description = generateRandomDescription();
const rating2Adjective = extractAdjectiveFromDescription(rating2Description);
const rating2Points = getPointsForAdjective(rating2Adjective);

const rating3Description = generateRandomDescription();
const rating3Adjective = extractAdjectiveFromDescription(rating3Description);
const rating3Points = getPointsForAdjective(rating3Adjective);

const rating4Description = generateRandomDescription();
const rating4Adjective = extractAdjectiveFromDescription(rating4Description);
const rating4Points = getPointsForAdjective(rating4Adjective);

return {
id: RUBRIC_ID,
title: "Rubric Data Reliability Metric",
pointsPossible: 10,
key: "1a26e0ba-5fef-4959-8303-933196bc5795",
criteria: [
{
id: "_7158",
description: criteria1Descriptions.short,
longDescription: criteria1Descriptions.long,
ratings: [
{
id: "blank",
description: "Rating 1",
longDescription: rating1Description,
points: rating1Points,
key: "a86e75cb-5532-4435-b40c-1647a1a338db",
},
{
id: "blank2",
description: "Rating 2",
longDescription: rating2Description,
points: rating2Points,
key: "43cdfd36-248e-4515-9c6b-d92f5cea8f27",
},
],
pointsPossible: 999,
template: "",
updatePoints() {
this.pointsPossible = Number(calcMaxPoints(this.ratings));
},
scores: [],
isGroupCriterion: true,
},
{
id: "_9287",
description: criteria2Descriptions.short,
longDescription: criteria2Descriptions.long,
ratings: [
{
id: "_791",
description: "Rating 3",
longDescription: rating3Description,
points: rating3Points,
key: "976aea74-241b-4428-9eff-d4f305948174",
},
{
id: "_8542",
description: "Rating 4",
longDescription: rating4Description,
points: rating4Points,
key: "c29a2932-fbfc-48c3-93b9-720f97850046",
},
],
pointsPossible: 999,
template: "",
updatePoints() {
this.pointsPossible = Number(calcMaxPoints(this.ratings));
},
scores: [],
isGroupCriterion: true,
},
],
};
}

// /**
// * @route POST /courses/:courseID/rubrics
// * @description Create a new rubric in a specific course.
// */

describe("Rubric Router", () => {
describe("given a course and assignment", () => {
for (let i = 0; i < TEST_COUNT; i++) {
it("should create a new rubric", async () => {
const rubricGetEndpoint = `${COURSE_ROUTE}/${COURSE_ID}/rubrics/${RUBRIC_ID}`;
const rubricUpdateEndpoint = `${COURSE_ROUTE}/${COURSE_ID}/rubrics/${RUBRIC_ID}/${ASSIGNMENT_ID}`;
const mockRubricSubmission = generateMockRubricSubmission();
const putResponse = await supertest(app)
.put(rubricUpdateEndpoint)
.send(mockRubricSubmission)
.expect(200);

const getResponse = await supertest(app)
.get(rubricGetEndpoint)
.expect(200);

// Add type assertions to fix unsafe member access errors
const putResponseBody = putResponse.body as { data: CanvasRubric };
const getResponseBody = getResponse.body as { data: Rubric };

const putRubric = putResponseBody.data;
const getRubric = getResponseBody.data;

console.log("putRubric: ", putRubric);
console.log("getRubric: ", getRubric);

expect(putRubric.id).toEqual(getRubric.id);
expect(putRubric.title).toEqual(getRubric.title);
expect(putRubric.points_possible).toEqual(getRubric.pointsPossible);
const putRubricCriteria = putRubric.data;
const getRubricCriteria = getRubric.criteria;

// Compare all criteria
expect(putRubricCriteria?.length).toEqual(getRubricCriteria.length);

putRubricCriteria?.forEach(
(putCriterion: CanvasCriterion, index: number) => {
const getCriterion = getRubricCriteria[index];

expect(getCriterion.id).toEqual(putCriterion.id);
expect(getCriterion.description).toEqual(putCriterion.description);
expect(getCriterion.longDescription).toEqual(
putCriterion.long_description,
);
expect(getCriterion.pointsPossible).toEqual(putCriterion.points);

// Compare ratings if they exist
if (putCriterion.ratings && getCriterion.ratings) {
expect(putCriterion.ratings.length).toEqual(
getCriterion.ratings.length,
);

putCriterion.ratings.forEach(
(putRating: CanvasRating, ratingIndex: number) => {
const getRating = getCriterion.ratings[ratingIndex];
expect(putRating.id).toEqual(getRating.id);
expect(putRating.description).toEqual(getRating.description);
expect(putRating.points).toEqual(getRating.points);
},
);
}
},
);
});
}
});
});
Loading