Skip to content

Commit

Permalink
Teacher Tool: Only Auto-Run Modified Criteria (#9958)
Browse files Browse the repository at this point in the history
With this change, auto-run will only evaluate criteria that have been modified. It will not re-evaluate everything unless the share link changes. If the user presses the run button directly, everything will re-run.

I also changed Pending to NotStarted because I kept confusing Pending with InProgress.
  • Loading branch information
thsparks authored Apr 11, 2024
1 parent e7602f2 commit f9e3edc
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 11 deletions.
6 changes: 3 additions & 3 deletions teachertool/src/components/CriteriaEvalResultDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ const itemIdToCriteriaResult: pxt.Map<EvaluationStatus> = {
notevaluated: EvaluationStatus.CompleteWithNoResult,
fail: EvaluationStatus.Fail,
pass: EvaluationStatus.Pass,
pending: EvaluationStatus.Pending,
notstarted: EvaluationStatus.NotStarted,
};

const criteriaResultToItemId: pxt.Map<string> = {
[EvaluationStatus.CompleteWithNoResult]: "notevaluated",
[EvaluationStatus.Fail]: "fail",
[EvaluationStatus.Pass]: "pass",
[EvaluationStatus.Pending]: "pending",
[EvaluationStatus.NotStarted]: "notstarted",
};

const dropdownItems: DropdownItem[] = [
Expand All @@ -42,7 +42,7 @@ const dropdownItems: DropdownItem[] = [
label: lf("Looks good!"),
},
{
id: "pending",
id: "notstarted",
title: lf("not started"),
label: lf("Not started"),
},
Expand Down
4 changes: 2 additions & 2 deletions teachertool/src/transforms/initNewProjectResults.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { stateAndDispatch } from "../state";
import { setEvalResultsPending } from "./setEvalResultsPending";
import { setEvalResultsToNotStarted } from "./setEvalResultsToNotStarted";
import * as Actions from "../state/actions";

export function initNewProjectResults() {
const { dispatch } = stateAndDispatch();
setEvalResultsPending({ overwriteExistingEntries: true });
setEvalResultsToNotStarted({ overwriteExistingEntries: true });
dispatch(Actions.clearAllEvalResultNotes());
}
1 change: 0 additions & 1 deletion teachertool/src/transforms/loadProjectMetadataAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { getProjectMetaAsync } from "../services/backendRequests";
import { logDebug } from "../services/loggingService";
import { showToast } from "./showToast";
import { makeToast } from "../utils";
import { setEvalResultsPending } from "./setEvalResultsPending";
import { initNewProjectResults } from "./initNewProjectResults";

export async function loadProjectMetadataAsync(inputText: string, shareLink: string) {
Expand Down
10 changes: 10 additions & 0 deletions teachertool/src/transforms/runEvaluateAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ export async function runEvaluateAsync(fromUserInteraction: boolean) {
const evalRequests = teacherTool.rubric.criteria.map(
criteriaInstance =>
new Promise(async resolve => {
const existingOutcome = teacherTool.evalResults[criteriaInstance.instanceId]?.result;
if (
!fromUserInteraction &&
existingOutcome !== undefined &&
existingOutcome !== EvaluationStatus.NotStarted
) {
// The criteria has not changed since it was last evaluated, so we can skip it (unless user specifically clicked run).
return resolve(true);
}

setEvalResultOutcome(criteriaInstance.instanceId, EvaluationStatus.InProgress);

const loadedValidatorPlans = teacherTool.validatorPlans;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EvaluationStatus, CriteriaResult } from "../types/criteria";
import { Rubric } from "../types/rubric";
import * as Actions from "../state/actions";

export function setEvalResultsPending({
export function setEvalResultsToNotStarted({
overwriteExistingEntries,
rubric,
}: {
Expand All @@ -16,7 +16,7 @@ export function setEvalResultsPending({
for (const criteria of usedRubric.criteria) {
const instanceId = criteria.instanceId;
if (!teachertool.evalResults[instanceId] || overwriteExistingEntries) {
allEvalResults[instanceId] = { result: EvaluationStatus.Pending };
allEvalResults[instanceId] = { result: EvaluationStatus.NotStarted };
}
}
if (!overwriteExistingEntries) {
Expand Down
3 changes: 3 additions & 0 deletions teachertool/src/transforms/setParameterValue.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { logDebug, logError } from "../services/loggingService";
import { stateAndDispatch } from "../state";
import { getCriteriaInstanceWithId } from "../state/helpers";
import { EvaluationStatus } from "../types/criteria";
import { ErrorCode } from "../types/errorCode";
import { setEvalResultOutcome } from "./setEvalResultOutcome";
import { setRubric } from "./setRubric";

export function setParameterValue(instanceId: string, paramName: string, newValue: any) {
Expand Down Expand Up @@ -34,4 +36,5 @@ export function setParameterValue(instanceId: string, paramName: string, newValu
const newRubric = { ...teacherTool.rubric, criteria: newInstanceSet };

setRubric(newRubric);
setEvalResultOutcome(instanceId, EvaluationStatus.NotStarted);
}
4 changes: 2 additions & 2 deletions teachertool/src/transforms/setRubric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { stateAndDispatch } from "../state";
import { Rubric } from "../types/rubric";
import * as Actions from "../state/actions";
import * as AutorunService from "../services/autorunService";
import { setEvalResultsPending } from "./setEvalResultsPending";
import { setEvalResultsToNotStarted } from "./setEvalResultsToNotStarted";

export function setRubric(rubric: Rubric) {
const { dispatch } = stateAndDispatch();
dispatch(Actions.setRubric(rubric));
setEvalResultsPending({ rubric });
setEvalResultsToNotStarted({ rubric });
AutorunService.poke();
}
2 changes: 1 addition & 1 deletion teachertool/src/types/criteria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export enum EvaluationStatus {
Fail,
CompleteWithNoResult,
InProgress,
Pending,
NotStarted,
}

export interface CriteriaResult {
Expand Down

0 comments on commit f9e3edc

Please sign in to comment.