mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
testing negative rubric things
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { LocalAssignment } from "../localAssignment";
|
import { RubricItem } from "../rubricItem";
|
||||||
|
|
||||||
export const assignmentPoints = (assignment: LocalAssignment) => {
|
export const assignmentPoints = (rubric: RubricItem[]) => {
|
||||||
const basePoints = assignment.rubric
|
const basePoints = rubric
|
||||||
.map((r) =>
|
.map((r) =>
|
||||||
r.label.toLowerCase().includes("(extra credit)") ? 0 : r.points
|
r.label.toLowerCase().includes("(extra credit)") ? 0 : r.points
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export const canvasAssignmentService = {
|
|||||||
lock_at:
|
lock_at:
|
||||||
localAssignment.lockAt &&
|
localAssignment.lockAt &&
|
||||||
getDateFromString(localAssignment.lockAt)?.toISOString(),
|
getDateFromString(localAssignment.lockAt)?.toISOString(),
|
||||||
points_possible: assignmentPoints(localAssignment),
|
points_possible: assignmentPoints(localAssignment.rubric),
|
||||||
assignment_group_id: canvasAssignmentGroupId,
|
assignment_group_id: canvasAssignmentGroupId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -78,7 +78,7 @@ export const canvasAssignmentService = {
|
|||||||
lock_at:
|
lock_at:
|
||||||
localAssignment.lockAt &&
|
localAssignment.lockAt &&
|
||||||
getDateFromString(localAssignment.lockAt)?.toISOString(),
|
getDateFromString(localAssignment.lockAt)?.toISOString(),
|
||||||
points_possible: assignmentPoints(localAssignment),
|
points_possible: assignmentPoints(localAssignment.rubric),
|
||||||
assignment_group_id: canvasAssignmentGroupId,
|
assignment_group_id: canvasAssignmentGroupId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -109,7 +109,7 @@ const createRubric = async (
|
|||||||
localAssignment: LocalAssignment
|
localAssignment: LocalAssignment
|
||||||
) => {
|
) => {
|
||||||
const criterion = getRubricCriterion(localAssignment.rubric);
|
const criterion = getRubricCriterion(localAssignment.rubric);
|
||||||
|
|
||||||
const rubricBody = {
|
const rubricBody = {
|
||||||
rubric_association_id: assignmentCanvasId,
|
rubric_association_id: assignmentCanvasId,
|
||||||
rubric: {
|
rubric: {
|
||||||
@@ -137,7 +137,7 @@ const createRubric = async (
|
|||||||
|
|
||||||
const assignmentPointAdjustmentUrl = `${canvasApi}/courses/${courseId}/assignments/${assignmentCanvasId}`;
|
const assignmentPointAdjustmentUrl = `${canvasApi}/courses/${courseId}/assignments/${assignmentCanvasId}`;
|
||||||
const assignmentPointAdjustmentBody = {
|
const assignmentPointAdjustmentBody = {
|
||||||
assignment: { points_possible: assignmentPoints(localAssignment) },
|
assignment: { points_possible: assignmentPoints(localAssignment.rubric) },
|
||||||
};
|
};
|
||||||
|
|
||||||
await axiosClient.put(
|
await axiosClient.put(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { RubricItem } from "@/models/local/assignment/rubricItem";
|
import { RubricItem } from "@/models/local/assignment/rubricItem";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import { getRubricCriterion } from "./canvasRubricUtils";
|
import { getRubricCriterion } from "./canvasRubricUtils";
|
||||||
|
import { assignmentPoints } from "@/models/local/assignment/utils/assignmentPointsUtils";
|
||||||
|
|
||||||
describe("can prepare rubric for canvas", () =>{
|
describe("can prepare rubric for canvas", () =>{
|
||||||
it("can parse normal rubric into criterion", () =>{
|
it("can parse normal rubric into criterion", () =>{
|
||||||
@@ -69,4 +70,24 @@ describe("can prepare rubric for canvas", () =>{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it("negative rubric items do not contribute to the total", () =>{
|
||||||
|
const rubric: RubricItem[] = [
|
||||||
|
{
|
||||||
|
label: "first",
|
||||||
|
points: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "second",
|
||||||
|
points: -2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "second",
|
||||||
|
points: 3
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const points = assignmentPoints(rubric)
|
||||||
|
expect(points).toBe(4)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user