-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create validation plans from instanced criteria, send to editor for e…
…valuation, get results. Needs clean up.
- Loading branch information
Showing
16 changed files
with
302 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,16 @@ | ||
{ | ||
"criteria": [ | ||
{ | ||
"id": "A7C78825-51B5-45B0-9E42-2AAC767D4E02", | ||
"use": "processes_and_displays_array_in_loop", | ||
"template": "One kind of loop to process/display the information in an array", | ||
"id": "B3FD8B3D-61B4-42F4-B0EF-64BD7D62CDAB", | ||
"use": "two_different_loops", | ||
"template": "Two different kinds of loops used.", | ||
"docPath": "/teachertool" | ||
}, | ||
{ | ||
"id": "59AAC5BA-B0B3-4389-AA90-1E767EFA8563", | ||
"use": "block_used_n_times", | ||
"template": "${block_id} used ${count} times", | ||
"description": "This block was used the specified number of times in your project.", | ||
"docPath": "/teachertool", | ||
"params": [ | ||
{ | ||
"name": "block_id", | ||
"type": "string", | ||
"picker": "blockSelector", | ||
"path": "checks[0].blocks[:clear&:append]" | ||
}, | ||
{ | ||
"name": "count", | ||
"type": "number", | ||
"default": 1, | ||
"path": "checks[0].count" | ||
} | ||
] | ||
"id": "49262A2B-C02A-43A2-BAD5-FCAC6AE9D464", | ||
"use": "custom_function_called", | ||
"template": "A custom function exists and gets called.", | ||
"docPath": "/teachertool" | ||
} | ||
] | ||
} |
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,17 @@ | ||
{ | ||
"validatorPlans": [ | ||
{ | ||
".desc": "Block used n times (to be filled in by the user)", | ||
"name": "block_used_n_times", | ||
"threshold": 1, | ||
"checks": [ | ||
{ | ||
"validator": "blocksExist", | ||
"blockCounts": { | ||
"": 0 | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
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,35 @@ | ||
{ | ||
"validatorPlans": [ | ||
{ | ||
".desc": "Two different kinds of loops used", | ||
"name": "two_different_loops", | ||
"threshold": 2, | ||
"checks": [ | ||
{ | ||
"validator": "blocksExist", | ||
"blockCounts": { | ||
"controls_repeat_ext": 1 | ||
} | ||
}, | ||
{ | ||
"validator": "blocksExist", | ||
"blockCounts": { | ||
"device_while": 1 | ||
} | ||
}, | ||
{ | ||
"validator": "blocksExist", | ||
"blockCounts": { | ||
"pxt_controls_for": 1 | ||
} | ||
}, | ||
{ | ||
"validator": "blocksExist", | ||
"blockCounts": { | ||
"pxt_controls_for_of": 1 | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
namespace pxt.blocks { | ||
export interface EvaluationResult { | ||
blockIdResults: pxt.Map<boolean>; | ||
results: pxt.Map<boolean>; | ||
} | ||
} |
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,63 @@ | ||
namespace pxt.blocks { | ||
// A set of validation checks (with inputs) to run for a given criteria. | ||
export interface ValidatorPlan { | ||
name: string; | ||
threshold: number; | ||
checks: ValidatorCheckBase[]; | ||
} | ||
|
||
// Used so a specific plan can be identified when sending results. | ||
export interface ValidatorPlanWithId extends ValidatorPlan { | ||
id: string; | ||
} | ||
|
||
// Base class to describes a single validation check to run (with inputs). | ||
// Each type of validation will need to implement its own ValidatorCheck based on this. | ||
export interface ValidatorCheckBase { | ||
validator: string; | ||
} | ||
|
||
// Inputs for "Blocks Exist" validation. | ||
export interface BlocksExistValidatorCheck extends ValidatorCheckBase { | ||
validator: "blocksExist"; | ||
blockCounts: pxt.Map<number>; | ||
} | ||
|
||
function isBlocksExistValidatorCheck(check: ValidatorCheckBase): check is BlocksExistValidatorCheck { | ||
return check.validator === "blocksExist"; | ||
} | ||
|
||
// export function getValidatorCheck(check: ValidatorCheckBase): ValidatorCheckBase { | ||
// switch (check.validator) { | ||
// case "blocksExist": | ||
// return ; | ||
// default: | ||
// console.error(`Unrecognized validator: ${check.validator}`); | ||
// return undefined; | ||
// } | ||
// } | ||
|
||
// export function parseValidatorPlans(plans: string): ValidatorPlan[] { | ||
// let plansObj; | ||
// try { | ||
// plansObj = JSON.parse(plans); | ||
// } catch (e) { | ||
// console.error(`Error parsing validator plans. ${e}`); | ||
// return undefined; | ||
// } | ||
|
||
// const finalPlans = plansObj.map(plan => { | ||
// const checks: ValidatorCheckBase[] = plan.checks.map((c: ValidatorCheckBase) => { | ||
// return getValidatorCheck(c); | ||
// }).filter((r: ValidatorCheckBase) => !!r); | ||
|
||
// return { | ||
// name: plan.name, | ||
// threshold: plan.threshold, | ||
// checks: checks | ||
// } as ValidatorPlan; | ||
// }); | ||
|
||
// return finalPlans; | ||
// } | ||
} |
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
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
Oops, something went wrong.