diff --git a/common-docs/teachertool/catalog-shared.json b/common-docs/teachertool/catalog-shared.json index 2768e7c8422..0b33bb96a1d 100644 --- a/common-docs/teachertool/catalog-shared.json +++ b/common-docs/teachertool/catalog-shared.json @@ -1,25 +1,20 @@ { "criteria": [ - { - "id": "8F97C9A6-CF16-48B4-A84F-3105C24B20DE", - "use": "functions_have_comments", - "template": "All function definitions have comments", - "docPath": "/teachertool", - "description": "All user-defined functions in the program have comments attached to them." - }, { "id": "D21D76A2-D9FD-4F9B-B0AC-973CB870EA78", "use": "variable_set", "template": "At least one custom variable is set", "docPath": "/teachertool", - "description": "At least one user-defined variable is set to a value." + "description": "At least one user-defined variable is set to a value.", + "maxCount": 1 }, { "id": "0173898D-8A48-4266-AAB9-CE934471A734", "use": "variable_accessed", "template": "At least one variable is accessed", "docPath": "/teachertool", - "description": "At least one variable's value is read." + "description": "At least one variable's value is read.", + "maxCount": 1 }, { "id": "7AE7EA2A-3AC8-42DC-89DB-65E3AE157156", @@ -27,6 +22,7 @@ "template": "At least ${count} comments", "description": "The project contains at least the specified number of comments.", "docPath": "/teachertool", + "maxCount": 1, "params": [ { "name": "count", @@ -62,6 +58,7 @@ "template": "At least ${count} loops used", "docPath": "/teachertool", "description": "The program uses at least this many loops of any kind (for, repeat, while, or for-of).", + "maxCount": 1, "params": [ { "name": "count", @@ -77,6 +74,7 @@ "template": "At least ${count} custom functions exist and get called", "docPath": "/teachertool", "description": "At least this many user-defined functions are created and called.", + "maxCount": 1, "params": [ { "name": "count", diff --git a/common-docs/teachertool/test/catalog-shared.json b/common-docs/teachertool/test/catalog-shared.json index b9e60b6d4d8..73e98c28ce4 100644 --- a/common-docs/teachertool/test/catalog-shared.json +++ b/common-docs/teachertool/test/catalog-shared.json @@ -6,6 +6,7 @@ "template": "Ask Copilot: ${question}", "description": "Experimental: AI outputs may not be accurate. Use with caution and always review responses.", "docPath": "/teachertool", + "maxCount": 10, "params": [ { "name": "question", diff --git a/teachertool/src/components/CatalogOverlay.tsx b/teachertool/src/components/CatalogOverlay.tsx index 42ddb777be6..d3eeb93afc2 100644 --- a/teachertool/src/components/CatalogOverlay.tsx +++ b/teachertool/src/components/CatalogOverlay.tsx @@ -32,22 +32,17 @@ const CatalogHeader: React.FC = ({ onClose }) => { interface CatalogItemLabelProps { catalogCriteria: CatalogCriteria; - allowsMultiple: boolean; - existingInstanceCount: number; + isMaxed: boolean; recentlyAdded: boolean; } -const CatalogItemLabel: React.FC = ({ - catalogCriteria, - allowsMultiple, - existingInstanceCount, - recentlyAdded, -}) => { - const canAddMore = allowsMultiple || existingInstanceCount === 0; - const showRecentlyAddedIndicator = recentlyAdded && canAddMore; +const CatalogItemLabel: React.FC = ({ catalogCriteria, isMaxed, recentlyAdded }) => { + const showRecentlyAddedIndicator = recentlyAdded && !isMaxed; return (
- {canAddMore ? ( + {isMaxed ? ( + {Strings.Max} + ) : ( <> = ({ title={Strings.AddToChecklist} /> - ) : ( - {Strings.Max} )}
@@ -116,10 +109,10 @@ const CatalogList: React.FC = () => { return (
{criteria.map(c => { - const allowsMultiple = c.params !== undefined && c.params.length !== 0; // TODO add a json flag for this (MaxCount or AllowMultiple) const existingInstanceCount = teacherTool.rubric.criteria.filter( i => i.catalogCriteriaId === c.id ).length; + const isMaxed = c.maxCount !== undefined && existingInstanceCount >= c.maxCount; return ( c.template && (