Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/microsoft/pxt into thspar…
Browse files Browse the repository at this point in the history
…ks/teachertool/clean_catalog
  • Loading branch information
thsparks committed Apr 12, 2024
2 parents 54ee5a4 + 61c7a6c commit 7f0f196
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 11 deletions.
5 changes: 3 additions & 2 deletions teachertool/src/services/loggingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export const logInfo = (message: any) => {
console.log(timestamp(), message);
};

export const logDebug = (message: any) => {
export const logDebug = (message: any, data?: any) => {
if (pxt.BrowserUtils.isLocalHost() || pxt.options.debug) {
console.log(timestamp(), message);
console.log(timestamp(), message, data);
}
};

4 changes: 2 additions & 2 deletions teachertool/src/services/makecodeEditorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function setEditorRef(ref: HTMLIFrameElement | undefined) {
driver = new EditorDriver(ref);

driver.addEventListener("message", ev => {
logDebug(`Message received from iframe: ${JSON.stringify(ev)}`);
logDebug(`Message received from iframe. ID: ${ev?.id}`, ev);
});
driver.addEventListener("sent", ev => {
logDebug(`Sent message to iframe: ${JSON.stringify(ev)}`);
logDebug(`Sent message to iframe. ID: ${ev?.id}`, ev);
});
driver.addEventListener("editorcontentloaded", ev => {
AutorunService.poke();
Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/getRubricFromFileAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function getRubricFromFileAsync(file: File, allowPartial: boolean):
let rubric = await loadRubricFromFileAsync(file);

if (rubric) {
logDebug(`Loading rubric '${rubric.name}' from file...`);
logDebug("Loading rubric from file...", {file, rubric});

const rubricVerificationResult = verifyRubricIntegrity(rubric);

Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/loadProjectMetadataAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export async function loadProjectMetadataAsync(inputText: string, shareLink: str
};
dispatch(Actions.setProjectMetadata(projectData));
initNewProjectResults();
logDebug(`Loaded project metadata: ${JSON.stringify(projMeta)}`);
logDebug("Loaded project metadata", projMeta);
}
11 changes: 8 additions & 3 deletions teachertool/src/transforms/runEvaluateAsync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logError } from "../services/loggingService";
import { logDebug, logError } from "../services/loggingService";
import { runValidatorPlanAsync } from "../services/makecodeEditorService";
import { stateAndDispatch } from "../state";
import * as Actions from "../state/actions";
Expand Down Expand Up @@ -28,14 +28,17 @@ function generateValidatorPlan(
return undefined;
}

const plan = teacherTool.validatorPlans?.find(plan => plan.name === catalogCriteria.use);
if (!plan) {
const planTemplate = teacherTool.validatorPlans?.find(plan => plan.name === catalogCriteria.use);
if (!planTemplate) {
logError(ErrorCode.evalMissingPlan, "Attempting to evaluate criteria with unrecognized plan", {
plan: catalogCriteria.use,
});
return undefined;
}

// Create a copy we can modify without affecting other uses of this template.
const plan = pxt.Util.deepCopy(planTemplate);

// Fill in parameters.
for (const param of criteriaInstance.params ?? []) {
const catalogParam = catalogCriteria.params?.find(p => p.name === param.name);
Expand Down Expand Up @@ -109,6 +112,8 @@ export async function runEvaluateAsync(fromUserInteraction: boolean) {

const plan = generateValidatorPlan(criteriaInstance, fromUserInteraction);

logDebug(`${criteriaInstance.instanceId}: Generated Plan`, plan)

if (!plan) {
dispatch(Actions.clearEvalResult(criteriaInstance.instanceId));
return resolve(false);
Expand Down
1 change: 0 additions & 1 deletion teachertool/src/transforms/setActiveTab.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { logDebug } from "../services/loggingService";
import { stateAndDispatch } from "../state";
import * as Actions from "../state/actions";
import { TabName } from "../types";
Expand Down
2 changes: 1 addition & 1 deletion teachertool/src/transforms/tryLoadLastActiveRubricAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function tryLoadLastActiveRubricAsync() {
const lastActiveRubric = await getLastActiveRubricAsync();

if (lastActiveRubric) {
logDebug(`Loading last active rubric '${lastActiveRubric.name}'...`);
logDebug("Loading last active rubric...", lastActiveRubric);

const rubricVerificationResult = verifyRubricIntegrity(lastActiveRubric);

Expand Down

0 comments on commit 7f0f196

Please sign in to comment.