-
Notifications
You must be signed in to change notification settings - Fork 588
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/microsoft/pxt into thspar…
…ks/teachertool/update_catalog
- Loading branch information
Showing
60 changed files
with
538 additions
and
487 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/// <reference path="../../localtypings/pxtpackage.d.ts" /> | ||
import * as Blockly from "blockly"; | ||
|
||
// Validates that variables are created and used within the workspace. | ||
// Name is optional. If undefined or empty, all variable names are permitted. | ||
// Returns the definition blocks for variables that passed the check. | ||
export function validateVariableUsage({ | ||
usedBlocks, | ||
count, | ||
name, | ||
}: { | ||
usedBlocks: Blockly.Block[]; | ||
count: number; | ||
name?: String; | ||
}): { | ||
passingVarDefinitions: Map<string, Blockly.Block[]>; | ||
passed: boolean; | ||
} { | ||
const varDefinitionBlocks: Map<string, Blockly.Block[]> = new Map(); | ||
const usedVars: Set<string> = new Set(); | ||
|
||
for (const block of usedBlocks) { | ||
if (!block.isEnabled()) { | ||
continue; | ||
} | ||
|
||
const varsUsed = block.getVarModels(); | ||
for (const varModel of varsUsed ?? []) { | ||
const varName = varModel.name; | ||
if (!name || varName === name) { | ||
if (block.type === "variables_set" || block.type === "variables_change") { | ||
// Variable created | ||
if (!varDefinitionBlocks.has(varName)) { | ||
varDefinitionBlocks.set(varName, []); | ||
} | ||
varDefinitionBlocks.get(varName).push(block); | ||
} else { | ||
// Variable used | ||
usedVars.add(varName); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Var passes check if it is both used and defined. | ||
// We return the definition blocks to allow for recursively checking how the var was set. | ||
const passingVarDefinitions = new Map<string, Blockly.Block[]>(); | ||
for (const [varName, definitionBlocks] of varDefinitionBlocks) { | ||
if (usedVars.has(varName)) { | ||
passingVarDefinitions.set(varName, definitionBlocks); | ||
} | ||
} | ||
|
||
return { passingVarDefinitions, passed: passingVarDefinitions.size >= count }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
...ol/src/components/ActiveRubricDisplay.tsx → ...src/components/ActiveChecklistDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { getCatalogCriteriaWithId } from "../state/helpers"; | ||
import { Checklist } from "../types/checklist"; | ||
import css from "./styling/ChecklistPreview.module.scss"; | ||
|
||
export interface IChecklistPreviewProps { | ||
checklist: Checklist; | ||
} | ||
|
||
export const ChecklistPreview: React.FC<IChecklistPreviewProps> = ({ checklist }) => { | ||
return ( | ||
<div className={css["container"]}> | ||
<div className={css["checklist-header"]}>{checklist.name}</div> | ||
{checklist.criteria.map((c, i) => { | ||
const template = getCatalogCriteriaWithId(c.catalogCriteriaId)?.template; | ||
return template ? ( | ||
<div key={i} className={css["checklist-criteria"]}> | ||
{template} | ||
</div> | ||
) : null; | ||
})} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.