From e7602f27c56cb6af943969abc3a9f82978c6c96b Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 11 Apr 2024 11:17:55 -0700 Subject: [PATCH 1/2] Remove all traces of crowdin branch support (#9964) --- cli/cli.ts | 16 +-------------- localtypings/pxtarget.d.ts | 1 - localtypings/pxtpackage.d.ts | 2 -- pxtlib/browserutils.ts | 40 ++++++++++++++++++------------------ pxtlib/emitter/cloud.ts | 5 ++--- pxtlib/package.ts | 2 +- pxtlib/util.ts | 39 +++++++++++++++-------------------- pxtrunner/runner.ts | 6 +----- skillmap/src/App.tsx | 10 --------- webapp/src/app.tsx | 7 +------ 10 files changed, 42 insertions(+), 86 deletions(-) diff --git a/cli/cli.ts b/cli/cli.ts index f2b5022bda2e..c305d8b7c10a 100644 --- a/cli/cli.ts +++ b/cli/cli.ts @@ -2539,9 +2539,7 @@ async function buildTargetCoreAsync(options: BuildTargetOptions = {}) { tag: info.tag, commits: info.commitUrl, target: readJson("package.json")["version"], - pxt: pxtVersion(), - pxtCrowdinBranch: pxtCrowdinBranch(), - targetCrowdinBranch: targetCrowdinBranch() + pxt: pxtVersion() } saveThemeJson(cfg, options.localDir, options.packaged) fillInCompilerExtension(cfg); @@ -2610,18 +2608,6 @@ function pxtVersion(): string { readJson("node_modules/pxt-core/package.json")["version"]; } -function pxtCrowdinBranch(): string { - const theme = pxt.appTarget.id == "core" ? - readJson("pxtarget.json").appTheme : - readJson("node_modules/pxt-core/pxtarget.json").appTheme; - return theme ? theme.crowdinBranch : undefined; -} - -function targetCrowdinBranch(): string { - const theme = readJson("pxtarget.json").appTheme; - return theme ? theme.crowdinBranch : undefined; -} - function buildAndWatchAsync(f: () => Promise, maxDepth: number): Promise { let currMtime = Date.now() return f() diff --git a/localtypings/pxtarget.d.ts b/localtypings/pxtarget.d.ts index e1c77ff8e936..f8603a5244b8 100644 --- a/localtypings/pxtarget.d.ts +++ b/localtypings/pxtarget.d.ts @@ -374,7 +374,6 @@ declare namespace pxt { hasAudio?: boolean; // target uses the Audio manager. if true: a mute button is added to the simulator toolbar. crowdinProject?: string; crowdinProjectId?: number; // Crowdin project id. Can be found by going to the project page in Crowdin and selecting Tools > API - crowdinBranch?: string; // optional branch specification for localization files monacoToolbox?: boolean; // if true: show the monaco toolbox when in the monaco editor blockHats?: boolean; // if true, event blocks have hats allowParentController?: boolean; // allow parent iframe to control editor diff --git a/localtypings/pxtpackage.d.ts b/localtypings/pxtpackage.d.ts index 16d9ad7fe718..de6db9f51133 100644 --- a/localtypings/pxtpackage.d.ts +++ b/localtypings/pxtpackage.d.ts @@ -12,8 +12,6 @@ declare namespace pxt { targetId?: string; targetWebsite?: string; pxt?: string; - pxtCrowdinBranch?: string; - targetCrowdinBranch?: string; tag?: string; branch?: string; commits?: string; // URL diff --git a/pxtlib/browserutils.ts b/pxtlib/browserutils.ts index 9201b6f0c84c..443197601718 100644 --- a/pxtlib/browserutils.ts +++ b/pxtlib/browserutils.ts @@ -773,7 +773,7 @@ namespace pxt.BrowserUtils { console.log(`adding entry ${md.length * 2} bytes`); return U.delay(1) .then(() => translationDbAsync()) - .then(db => db.setAsync("foobar", Math.random().toString(), "", null, undefined, md)) + .then(db => db.setAsync("foobar", Math.random().toString(), null, undefined, md)) .then(() => pxt.BrowserUtils.storageEstimateAsync()) .then(estimate => !estimate.quota || estimate.usage / estimate.quota < 0.8 ? stressTranslationsAsync() : Promise.resolve()); } @@ -787,33 +787,33 @@ namespace pxt.BrowserUtils { } export interface ITranslationDb { - getAsync(lang: string, filename: string, branch: string): Promise; - setAsync(lang: string, filename: string, branch: string, etag: string, strings?: pxt.Map, md?: string): Promise; + getAsync(lang: string, filename: string): Promise; + setAsync(lang: string, filename: string, etag: string, strings?: pxt.Map, md?: string): Promise; // delete all clearAsync(): Promise; } class MemTranslationDb implements ITranslationDb { translations: pxt.Map = {}; - key(lang: string, filename: string, branch: string) { - return `${lang}|${filename}|${branch || "master"}`; + key(lang: string, filename: string) { + return `${lang}|${filename}|master`; } - get(lang: string, filename: string, branch: string): ITranslationDbEntry { - return this.translations[this.key(lang, filename, branch)]; + get(lang: string, filename: string): ITranslationDbEntry { + return this.translations[this.key(lang, filename)]; } - getAsync(lang: string, filename: string, branch: string): Promise { - return Promise.resolve(this.get(lang, filename, branch)); + getAsync(lang: string, filename: string): Promise { + return Promise.resolve(this.get(lang, filename)); } - set(lang: string, filename: string, branch: string, etag: string, time: number, strings?: pxt.Map, md?: string) { - this.translations[this.key(lang, filename, branch)] = { + set(lang: string, filename: string, etag: string, time: number, strings?: pxt.Map, md?: string) { + this.translations[this.key(lang, filename)] = { etag, time, strings, md } } - setAsync(lang: string, filename: string, branch: string, etag: string, strings?: pxt.Map, md?: string): Promise { - this.set(lang, filename, branch, etag, Util.now(), strings); + setAsync(lang: string, filename: string, etag: string, strings?: pxt.Map, md?: string): Promise { + this.set(lang, filename, etag, Util.now(), strings); return Promise.resolve(); } clearAsync() { @@ -1011,17 +1011,17 @@ namespace pxt.BrowserUtils { this.db = db; this.mem = new MemTranslationDb(); } - getAsync(lang: string, filename: string, branch: string): Promise { + getAsync(lang: string, filename: string): Promise { lang = (lang || "en-US").toLowerCase(); // normalize locale - const id = this.mem.key(lang, filename, branch); - const r = this.mem.get(lang, filename, branch); + const id = this.mem.key(lang, filename); + const r = this.mem.get(lang, filename); if (r) return Promise.resolve(r); return this.db.getAsync(IndexedDbTranslationDb.TABLE, id) .then((res) => { if (res) { // store in-memory so that we don't try to download again - this.mem.set(lang, filename, branch, res.etag, res.time, res.strings); + this.mem.set(lang, filename, res.etag, res.time, res.strings); return Promise.resolve(res); } return Promise.resolve(undefined); @@ -1030,11 +1030,11 @@ namespace pxt.BrowserUtils { return Promise.resolve(undefined); }); } - setAsync(lang: string, filename: string, branch: string, etag: string, strings?: pxt.Map, md?: string): Promise { + setAsync(lang: string, filename: string, etag: string, strings?: pxt.Map, md?: string): Promise { lang = (lang || "en-US").toLowerCase(); // normalize locale - const id = this.mem.key(lang, filename, branch); + const id = this.mem.key(lang, filename); let time = Util.now(); - this.mem.set(lang, filename, branch, etag, time, strings, md); + this.mem.set(lang, filename, etag, time, strings, md); if (strings) { Object.keys(strings).filter(k => !strings[k]).forEach(k => delete strings[k]); diff --git a/pxtlib/emitter/cloud.ts b/pxtlib/emitter/cloud.ts index 4d1280ef7548..a75812ab0c41 100644 --- a/pxtlib/emitter/cloud.ts +++ b/pxtlib/emitter/cloud.ts @@ -142,17 +142,16 @@ namespace pxt.Cloud { const FORCE_MARKDOWN_UPDATE = MARKDOWN_EXPIRATION * 24 * 7; locale = locale || pxt.Util.userLanguage(); - const branch = ""; const db = await pxt.BrowserUtils.translationDbAsync(); - const entry = await db.getAsync(locale, docid, branch); + const entry = await db.getAsync(locale, docid); const downloadAndSetMarkdownAsync = async () => { try { const r = await downloadMarkdownAsync(docid, locale, entry?.etag); // TODO directly compare the entry/response etags after backend change if (!entry || (r.md && entry.md !== r.md)) { - await db.setAsync(locale, docid, branch, r.etag, undefined, r.md); + await db.setAsync(locale, docid, r.etag, undefined, r.md); return r.md; } return entry.md; diff --git a/pxtlib/package.ts b/pxtlib/package.ts index 0b3639e5b171..e4ba5a1c35c3 100644 --- a/pxtlib/package.ts +++ b/pxtlib/package.ts @@ -936,7 +936,7 @@ namespace pxt { if (pxt.Util.liveLocalizationEnabled() && this.id != "this" && pxt.appTarget.bundledpkgs[this.id]) { pxt.debug(`loading live translations for ${this.id}`) return Promise.all(filenames.map( - fn => pxt.Util.downloadLiveTranslationsAsync(lang, `${targetId}/${fn}-strings.json`, theme.crowdinBranch) + fn => pxt.Util.downloadLiveTranslationsAsync(lang, `${targetId}/${fn}-strings.json`) .then(tr => { if (tr && Object.keys(tr).length) { Util.jsonMergeFrom(r, tr); diff --git a/pxtlib/util.ts b/pxtlib/util.ts index 543ace5b8ddd..af1f25b431a9 100644 --- a/pxtlib/util.ts +++ b/pxtlib/util.ts @@ -1120,14 +1120,13 @@ namespace ts.pxtc.Util { return f() + f() + "-" + f() + "-4" + f().slice(-3) + "-" + f() + "-" + f() + f() + f(); } - export function downloadLiveTranslationsAsync(lang: string, filename: string, branch?: string, etag?: string): Promise> { + export function downloadLiveTranslationsAsync(lang: string, filename: string, etag?: string): Promise> { // hitting the cloud function downloadFromCloudAsync(strings?: pxt.Map) { - pxt.debug(`downloading translations for ${lang} ${filename} ${branch || ""}`); + pxt.debug(`downloading translations for ${lang} ${filename}`); let host = pxt.BrowserUtils.isLocalHost() || pxt.webConfig.isStatic ? "https://makecode.com/api/" : "" - // https://pxt.io/api/translations?filename=strings.json&lang=pl&approved=true&branch=v0 + // https://pxt.io/api/translations?filename=strings.json&lang=pl&approved=true let url = `${host}translations?lang=${encodeURIComponent(lang)}&filename=${encodeURIComponent(filename)}&approved=true`; - if (branch) url += '&branch=' + encodeURIComponent(branch); const headers: pxt.Map = {}; if (etag && !pxt.Cloud.useCdnApi()) headers["If-None-Match"] = etag; return (host ? requestAsync : pxt.Cloud.apiRequestWithCdnAsync)({ url, headers }).then(resp => { @@ -1136,7 +1135,7 @@ namespace ts.pxtc.Util { // store etag and translations etag = resp.headers["etag"] as string || ""; return pxt.BrowserUtils.translationDbAsync() - .then(db => db.setAsync(lang, filename, branch, etag, resp.json || strings)) + .then(db => db.setAsync(lang, filename, etag, resp.json || strings)) .then(() => resp.json || strings); } @@ -1149,7 +1148,7 @@ namespace ts.pxtc.Util { // check for cache return pxt.BrowserUtils.translationDbAsync() - .then(db => db.getAsync(lang, filename, branch)) + .then(db => db.getAsync(lang, filename)) .then((entry: pxt.BrowserUtils.ITranslationDbEntry) => { // if cached, return immediately if (entry) { @@ -1278,8 +1277,6 @@ namespace ts.pxtc.Util { targetId: string; baseUrl: string; code: string; - pxtBranch: string; - targetBranch: string; force?: boolean; } @@ -1287,8 +1284,6 @@ namespace ts.pxtc.Util { const { targetId, baseUrl, - pxtBranch, - targetBranch, force, } = opts; let { code } = opts; @@ -1303,8 +1298,7 @@ namespace ts.pxtc.Util { pxt.debug(`loc: ${code}`); const liveUpdateStrings = pxt.Util.liveLocalizationEnabled() - return downloadTranslationsAsync(targetId, baseUrl, code, - pxtBranch, targetBranch, liveUpdateStrings, + return downloadTranslationsAsync(targetId, baseUrl, code, liveUpdateStrings, ts.pxtc.Util.TranslationsKind.Editor) .then((translations) => { if (translations) { @@ -1315,8 +1309,7 @@ namespace ts.pxtc.Util { // Download api translations return ts.pxtc.Util.downloadTranslationsAsync( - targetId, baseUrl, code, - pxtBranch, targetBranch, liveUpdateStrings, + targetId, baseUrl, code, liveUpdateStrings, ts.pxtc.Util.TranslationsKind.Apis) .then(trs => { if (trs) @@ -1332,7 +1325,7 @@ namespace ts.pxtc.Util { SkillMap } - export function downloadTranslationsAsync(targetId: string, baseUrl: string, code: string, pxtBranch: string, targetBranch: string, live: boolean, translationKind?: TranslationsKind): Promise> { + export function downloadTranslationsAsync(targetId: string, baseUrl: string, code: string, live: boolean, translationKind?: TranslationsKind): Promise> { translationKind = translationKind || TranslationsKind.Editor; code = normalizeLanguageCode(code)[0]; if (code === "en-US" || code === "en") // shortcut @@ -1343,22 +1336,22 @@ namespace ts.pxtc.Util { return Promise.resolve(translationsCache()[translationsCacheId]); } - let stringFiles: { branch: string, staticName: string, path: string }[]; + let stringFiles: { staticName: string, path: string }[]; switch (translationKind) { case TranslationsKind.Editor: stringFiles = [ - { branch: pxtBranch, staticName: "strings.json", path: "strings.json" }, - { branch: targetBranch, staticName: "target-strings.json", path: targetId + "/target-strings.json" }, + { staticName: "strings.json", path: "strings.json" }, + { staticName: "target-strings.json", path: targetId + "/target-strings.json" }, ]; break; case TranslationsKind.Sim: - stringFiles = [{ branch: targetBranch, staticName: "sim-strings.json", path: targetId + "/sim-strings.json" }]; + stringFiles = [{ staticName: "sim-strings.json", path: targetId + "/sim-strings.json" }]; break; case TranslationsKind.Apis: - stringFiles = [{ branch: targetBranch, staticName: "bundled-strings.json", path: targetId + "/bundled-strings.json" }]; + stringFiles = [{ staticName: "bundled-strings.json", path: targetId + "/bundled-strings.json" }]; break; case TranslationsKind.SkillMap: - stringFiles = [{ branch: targetBranch, staticName: "skillmap-strings.json", path: "/skillmap-strings.json" }]; + stringFiles = [{ staticName: "skillmap-strings.json", path: "/skillmap-strings.json" }]; break; } let translations: pxt.Map; @@ -1375,7 +1368,7 @@ namespace ts.pxtc.Util { if (live) { let errorCount = 0; - const pAll = U.promiseMapAllSeries(stringFiles, (file) => downloadLiveTranslationsAsync(code, file.path, file.branch) + const pAll = U.promiseMapAllSeries(stringFiles, (file) => downloadLiveTranslationsAsync(code, file.path) .then(mergeTranslations, e => { console.log(e.message); ++errorCount; @@ -1391,7 +1384,7 @@ namespace ts.pxtc.Util { if (errorCount === stringFiles.length || !translations) { // Retry with non-live translations by setting live to false pxt.tickEvent("translations.livetranslationsfailed"); - return downloadTranslationsAsync(targetId, baseUrl, code, pxtBranch, targetBranch, false, translationKind); + return downloadTranslationsAsync(targetId, baseUrl, code, false, translationKind); } return Promise.resolve(translations); diff --git a/pxtrunner/runner.ts b/pxtrunner/runner.ts index 772b7ab603d6..a04aa6010c22 100644 --- a/pxtrunner/runner.ts +++ b/pxtrunner/runner.ts @@ -253,8 +253,6 @@ function initInnerAsync() { targetId: pxt.appTarget.id, baseUrl: cfg.commitCdnUrl, code: lang, - pxtBranch: versions ? versions.pxtCrowdinBranch : "", - targetBranch: versions ? versions.targetCrowdinBranch : "", force: force, }) .then(() => initHost()) @@ -605,9 +603,7 @@ export function setEditorContextAsync(mode: LanguageMode, localeInfo: string) { return pxt.Util.updateLocalizationAsync({ targetId: pxt.appTarget.id, baseUrl: pxt.webConfig.commitCdnUrl, - code: localeInfo.replace(localeLiveRx, ''), - pxtBranch: pxt.appTarget.versions.pxtCrowdinBranch, - targetBranch: pxt.appTarget.versions.targetCrowdinBranch, + code: localeInfo.replace(localeLiveRx, '') }); } diff --git a/skillmap/src/App.tsx b/skillmap/src/App.tsx index 6f9b262762fd..de20daea983f 100644 --- a/skillmap/src/App.tsx +++ b/skillmap/src/App.tsx @@ -158,8 +158,6 @@ class AppImpl extends React.Component { // TODO: include the pxt webconfig so that we can get the commitcdnurl (and not always pass live=true) const baseUrl = ""; const targetId = pxt.appTarget.id; - const pxtBranch = pxt.appTarget.versions.pxtCrowdinBranch; - const targetBranch = pxt.appTarget.versions.targetCrowdinBranch; const langLowerCase = useLang?.toLocaleLowerCase(); const localDevServe = pxt.BrowserUtils.isLocalHostDev() @@ -175,8 +173,6 @@ class AppImpl extends React.Component { targetId: targetId, baseUrl: baseUrl, code: useLang!, - pxtBranch: pxtBranch!, - targetBranch: targetBranch!, force: force, }); @@ -544,8 +540,6 @@ interface LocalizationUpdateOptions { targetId: string; baseUrl: string; code: string; - pxtBranch: string; - targetBranch: string; force?: boolean; } @@ -553,8 +547,6 @@ async function updateLocalizationAsync(opts: LocalizationUpdateOptions): Promise const { targetId, baseUrl, - pxtBranch, - targetBranch, force, } = opts; let { code } = opts; @@ -563,8 +555,6 @@ async function updateLocalizationAsync(opts: LocalizationUpdateOptions): Promise targetId, baseUrl, code, - pxtBranch, - targetBranch, pxt.Util.liveLocalizationEnabled(), ts.pxtc.Util.TranslationsKind.SkillMap ); diff --git a/webapp/src/app.tsx b/webapp/src/app.tsx index e2063bb4adbb..d5ee67200499 100644 --- a/webapp/src/app.tsx +++ b/webapp/src/app.tsx @@ -5979,14 +5979,10 @@ document.addEventListener("DOMContentLoaded", async () => { } const targetId = pxt.appTarget.id; const baseUrl = config.commitCdnUrl; - const pxtBranch = pxt.appTarget.versions.pxtCrowdinBranch; - const targetBranch = pxt.appTarget.versions.targetCrowdinBranch; return Util.updateLocalizationAsync({ targetId: targetId, baseUrl: baseUrl, code: useLang, - pxtBranch: pxtBranch, - targetBranch: targetBranch, force: force, }).then(() => { if (pxt.Util.isLocaleEnabled(useLang)) { @@ -5999,8 +5995,7 @@ document.addEventListener("DOMContentLoaded", async () => { // Download sim translations and save them in the sim // don't wait! Util.downloadTranslationsAsync( - targetId, baseUrl, useLang, - pxtBranch, targetBranch, pxt.Util.liveLocalizationEnabled(), Util.TranslationsKind.Sim) + targetId, baseUrl, useLang, pxt.Util.liveLocalizationEnabled(), Util.TranslationsKind.Sim) .then(simStrings => simStrings && simulator.setTranslations(simStrings)) }); }) From f9e3edc400daf0402df110bd4b1572148751ddda Mon Sep 17 00:00:00 2001 From: Thomas Sparks <69657545+thsparks@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:19:00 -0700 Subject: [PATCH 2/2] Teacher Tool: Only Auto-Run Modified Criteria (#9958) 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. --- .../src/components/CriteriaEvalResultDropdown.tsx | 6 +++--- teachertool/src/transforms/initNewProjectResults.ts | 4 ++-- teachertool/src/transforms/loadProjectMetadataAsync.ts | 1 - teachertool/src/transforms/runEvaluateAsync.ts | 10 ++++++++++ ...ResultsPending.ts => setEvalResultsToNotStarted.ts} | 4 ++-- teachertool/src/transforms/setParameterValue.ts | 3 +++ teachertool/src/transforms/setRubric.ts | 4 ++-- teachertool/src/types/criteria.ts | 2 +- 8 files changed, 23 insertions(+), 11 deletions(-) rename teachertool/src/transforms/{setEvalResultsPending.ts => setEvalResultsToNotStarted.ts} (93%) diff --git a/teachertool/src/components/CriteriaEvalResultDropdown.tsx b/teachertool/src/components/CriteriaEvalResultDropdown.tsx index 87e0c9ec70d0..641f0c08409c 100644 --- a/teachertool/src/components/CriteriaEvalResultDropdown.tsx +++ b/teachertool/src/components/CriteriaEvalResultDropdown.tsx @@ -15,14 +15,14 @@ const itemIdToCriteriaResult: pxt.Map = { notevaluated: EvaluationStatus.CompleteWithNoResult, fail: EvaluationStatus.Fail, pass: EvaluationStatus.Pass, - pending: EvaluationStatus.Pending, + notstarted: EvaluationStatus.NotStarted, }; const criteriaResultToItemId: pxt.Map = { [EvaluationStatus.CompleteWithNoResult]: "notevaluated", [EvaluationStatus.Fail]: "fail", [EvaluationStatus.Pass]: "pass", - [EvaluationStatus.Pending]: "pending", + [EvaluationStatus.NotStarted]: "notstarted", }; const dropdownItems: DropdownItem[] = [ @@ -42,7 +42,7 @@ const dropdownItems: DropdownItem[] = [ label: lf("Looks good!"), }, { - id: "pending", + id: "notstarted", title: lf("not started"), label: lf("Not started"), }, diff --git a/teachertool/src/transforms/initNewProjectResults.ts b/teachertool/src/transforms/initNewProjectResults.ts index f27356c4ece1..363f497c32af 100644 --- a/teachertool/src/transforms/initNewProjectResults.ts +++ b/teachertool/src/transforms/initNewProjectResults.ts @@ -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()); } diff --git a/teachertool/src/transforms/loadProjectMetadataAsync.ts b/teachertool/src/transforms/loadProjectMetadataAsync.ts index 1bd1dba9e0c5..847b81bcd1c2 100644 --- a/teachertool/src/transforms/loadProjectMetadataAsync.ts +++ b/teachertool/src/transforms/loadProjectMetadataAsync.ts @@ -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) { diff --git a/teachertool/src/transforms/runEvaluateAsync.ts b/teachertool/src/transforms/runEvaluateAsync.ts index 64076bd67c59..6bc99d05226a 100644 --- a/teachertool/src/transforms/runEvaluateAsync.ts +++ b/teachertool/src/transforms/runEvaluateAsync.ts @@ -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; diff --git a/teachertool/src/transforms/setEvalResultsPending.ts b/teachertool/src/transforms/setEvalResultsToNotStarted.ts similarity index 93% rename from teachertool/src/transforms/setEvalResultsPending.ts rename to teachertool/src/transforms/setEvalResultsToNotStarted.ts index d78898b57790..fd982aeea8fe 100644 --- a/teachertool/src/transforms/setEvalResultsPending.ts +++ b/teachertool/src/transforms/setEvalResultsToNotStarted.ts @@ -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, }: { @@ -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) { diff --git a/teachertool/src/transforms/setParameterValue.ts b/teachertool/src/transforms/setParameterValue.ts index 67d62ff27382..2fa79ecd9b38 100644 --- a/teachertool/src/transforms/setParameterValue.ts +++ b/teachertool/src/transforms/setParameterValue.ts @@ -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) { @@ -34,4 +36,5 @@ export function setParameterValue(instanceId: string, paramName: string, newValu const newRubric = { ...teacherTool.rubric, criteria: newInstanceSet }; setRubric(newRubric); + setEvalResultOutcome(instanceId, EvaluationStatus.NotStarted); } diff --git a/teachertool/src/transforms/setRubric.ts b/teachertool/src/transforms/setRubric.ts index 72631b0e6666..347dbf2e10a9 100644 --- a/teachertool/src/transforms/setRubric.ts +++ b/teachertool/src/transforms/setRubric.ts @@ -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(); } diff --git a/teachertool/src/types/criteria.ts b/teachertool/src/types/criteria.ts index 1d014f0acd0c..a44b339a0e35 100644 --- a/teachertool/src/types/criteria.ts +++ b/teachertool/src/types/criteria.ts @@ -38,7 +38,7 @@ export enum EvaluationStatus { Fail, CompleteWithNoResult, InProgress, - Pending, + NotStarted, } export interface CriteriaResult {