Skip to content

Commit

Permalink
Consolidate calls to set rubric so they go through the transform.
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed Feb 9, 2024
1 parent 3f419e3 commit 202c529
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 2 additions & 4 deletions teachertool/src/transforms/addCriteriaToRubric.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { stateAndDispatch } from "../state";
import * as Actions from "../state/actions";
import { getCatalogCriteriaWithId } from "../state/helpers";
import { logDebug, logError } from "../services/loggingService";
import { CriteriaInstance, CriteriaParameterValue } from "../types/criteria";
import { nanoid } from "nanoid";
import { ErrorCode } from "../types/errorCode";
import * as AutorunService from "../services/autorunService";
import { setRubric } from "./setRubric";

export function addCriteriaToRubric(catalogCriteriaIds: string[]) {
const { state: teacherTool, dispatch } = stateAndDispatch();
Expand Down Expand Up @@ -45,8 +44,7 @@ export function addCriteriaToRubric(catalogCriteriaIds: string[]) {
newRubric.criteria.push(criteriaInstance);
}

dispatch(Actions.setRubric(newRubric));
AutorunService.poke();
setRubric(newRubric);

pxt.tickEvent("teachertool.addcriteria", {
ids: JSON.stringify(catalogCriteriaIds),
Expand Down
6 changes: 2 additions & 4 deletions teachertool/src/transforms/removeCriteriaFromRubric.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { stateAndDispatch } from "../state";
import * as Actions from "../state/actions";
import { logDebug } from "../services/loggingService";
import { CriteriaInstance } from "../types/criteria";
import * as AutorunService from "../services/autorunService";
import { setRubric } from "./setRubric";

export function removeCriteriaFromRubric(instance: CriteriaInstance) {
const { state: teacherTool, dispatch } = stateAndDispatch();
Expand All @@ -14,8 +13,7 @@ export function removeCriteriaFromRubric(instance: CriteriaInstance) {
criteria: teacherTool.rubric.criteria.filter(c => c.instanceId !== instance.instanceId),
};

dispatch(Actions.setRubric(newRubric));
AutorunService.poke();
setRubric(newRubric);

pxt.tickEvent("teachertool.removecriteria", { catalogCriteriaId: instance.catalogCriteriaId });
}
6 changes: 3 additions & 3 deletions teachertool/src/transforms/setRubricName.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { stateAndDispatch } from "../state";
import * as Actions from "../state/actions";
import { setRubric } from "./setRubric";

export function setRubricName(name: string) {
const { state: teacherTool, dispatch } = stateAndDispatch();
const { state: teacherTool } = stateAndDispatch();

const oldName = teacherTool.rubric.name;

Expand All @@ -14,5 +14,5 @@ export function setRubricName(name: string) {
...teacherTool.rubric,
name,
};
dispatch(Actions.setRubric(newRubric));
setRubric(newRubric);
}

0 comments on commit 202c529

Please sign in to comment.