-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fine-tuned the comment validator, split out the logic for comments on…
… specific blocks
- Loading branch information
Showing
5 changed files
with
44 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
|
||
namespace pxt.blocks { | ||
export function validateCommentsExist(usedBlocks: Blockly.Block[]): boolean { | ||
const commentBlocks = usedBlocks.filter((block) => !!block.comment); | ||
return commentBlocks.length > 0; | ||
// validates that one or more blocks comments are in the project | ||
// returns the blocks that have comments for teacher tool scenario | ||
export function validateBlockCommentsExist({ usedBlocks }: { usedBlocks: Blockly.Block[] }): Blockly.Block[] { | ||
const commentBlocks = usedBlocks.filter((block) => !!block.getCommentText()); | ||
return commentBlocks; | ||
} | ||
|
||
// validates that all of a specific block type have comments | ||
// returns the blocks that do not have comments for a tutorial validation scenario | ||
export function validateCommentsOnSpecificBlocksExist({ usedBlocks, blockType }: { | ||
usedBlocks: Blockly.Block[], | ||
blockType: string, | ||
}): Blockly.Block[] { | ||
const allSpecifcBlocks = usedBlocks.filter((block) => block.type === blockType); | ||
const noncommentBlocks = allSpecifcBlocks.filter((block) => !block.getCommentText()); | ||
return noncommentBlocks; | ||
} | ||
} |
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