@thanh01.pmt/interactive-quiz-kit 1.0.32 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.cjs +124 -65
- package/dist/ai.mjs +124 -65
- package/dist/authoring.cjs +143 -81
- package/dist/authoring.d.cts +1 -1
- package/dist/authoring.d.ts +1 -1
- package/dist/authoring.mjs +143 -81
- package/dist/index.cjs +13 -8
- package/dist/index.mjs +13 -8
- package/dist/player.cjs +13 -8
- package/dist/player.mjs +13 -8
- package/dist/react-ui.cjs +140 -184
- package/dist/react-ui.d.cts +1 -1
- package/dist/react-ui.d.ts +1 -1
- package/dist/react-ui.mjs +140 -184
- package/dist/{toaster-Blf5k3DP.d.cts → toaster-D1bLqmd_.d.cts} +1 -1
- package/dist/{toaster-BrChkQ23.d.ts → toaster-eWZIxSVc.d.ts} +1 -1
- package/package.json +1 -1
package/dist/react-ui.cjs
CHANGED
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var React162 = require('react');
|
|
4
4
|
var zod = require('zod');
|
|
5
|
-
var
|
|
6
|
-
var googleai = require('@genkit-ai/googleai');
|
|
5
|
+
var genai = require('@google/genai');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
var ReactDOM4 = require('react-dom');
|
|
9
8
|
var default2 = require('path');
|
|
10
9
|
var default3 = require('process');
|
|
11
10
|
var url = require('url');
|
|
12
|
-
var genai = require('@google/genai');
|
|
13
11
|
var JSZip = require('jszip');
|
|
14
12
|
var navigation = require('next/navigation');
|
|
15
13
|
|
|
@@ -7862,10 +7860,7 @@ var EvaluateUserCodeOutputSchema = AIEvaluationOutputSchema;
|
|
|
7862
7860
|
// src/ai/flows/evaluate-user-code.ts
|
|
7863
7861
|
async function evaluateUserCode(clientInput, apiKey) {
|
|
7864
7862
|
try {
|
|
7865
|
-
const
|
|
7866
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
7867
|
-
model: googleai.gemini20Flash
|
|
7868
|
-
});
|
|
7863
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
7869
7864
|
const { language: language3, problemPrompt, userCode, testCase } = clientInput;
|
|
7870
7865
|
const promptText = `
|
|
7871
7866
|
You are an expert Code Judge and Teaching Assistant for a ${language3} programming course.
|
|
@@ -7902,8 +7897,17 @@ Return ONLY the JSON object with this EXACT structure.
|
|
|
7902
7897
|
\`\`\`
|
|
7903
7898
|
|
|
7904
7899
|
Return only the JSON response.`;
|
|
7905
|
-
const
|
|
7906
|
-
const
|
|
7900
|
+
const modelName = "gemini-1.5-flash";
|
|
7901
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
7902
|
+
const result = await genAI.models.generateContent({
|
|
7903
|
+
model: modelName,
|
|
7904
|
+
contents
|
|
7905
|
+
});
|
|
7906
|
+
const response = result;
|
|
7907
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
7908
|
+
if (!rawText) {
|
|
7909
|
+
throw new Error("AI returned an empty response.");
|
|
7910
|
+
}
|
|
7907
7911
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
7908
7912
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
7909
7913
|
return EvaluateUserCodeOutputSchema.parse(aiGeneratedContent);
|
|
@@ -128447,109 +128451,6 @@ function QuestionFilters({
|
|
|
128447
128451
|
}
|
|
128448
128452
|
), /* @__PURE__ */ React162__namespace.default.createElement(Select2, { value: subjectCode || ALL_ITEMS_VALUE, onValueChange: createSelectHandler(setSubjectCode) }, /* @__PURE__ */ React162__namespace.default.createElement(SelectTrigger2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectValue2, { placeholder: "Subject" })), /* @__PURE__ */ React162__namespace.default.createElement(SelectContent2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: ALL_ITEMS_VALUE }, "All Subjects"), subjects.map((s4) => /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { key: s4.code, value: s4.code }, s4.name)))), /* @__PURE__ */ React162__namespace.default.createElement(Select2, { value: topicCode || ALL_ITEMS_VALUE, onValueChange: createSelectHandler(setTopicCode), disabled: !subjectCode || filteredTopics.length === 0 }, /* @__PURE__ */ React162__namespace.default.createElement(SelectTrigger2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectValue2, { placeholder: "Topic" })), /* @__PURE__ */ React162__namespace.default.createElement(SelectContent2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: ALL_ITEMS_VALUE }, "All Topics"), filteredTopics.map((t4) => /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { key: t4.code, value: t4.code }, t4.name)))), /* @__PURE__ */ React162__namespace.default.createElement(Select2, { value: gradeLevelCode || ALL_ITEMS_VALUE, onValueChange: createSelectHandler(setGradeLevelCode) }, /* @__PURE__ */ React162__namespace.default.createElement(SelectTrigger2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectValue2, { placeholder: "Grade Level" })), /* @__PURE__ */ React162__namespace.default.createElement(SelectContent2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: ALL_ITEMS_VALUE }, "All Grade Levels"), gradeLevels.map((gl) => /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { key: gl.code, value: gl.code }, gl.name)))), /* @__PURE__ */ React162__namespace.default.createElement(Select2, { value: bloomLevelCode || ALL_ITEMS_VALUE, onValueChange: createSelectHandler(setBloomLevelCode) }, /* @__PURE__ */ React162__namespace.default.createElement(SelectTrigger2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectValue2, { placeholder: "Bloom's Level" })), /* @__PURE__ */ React162__namespace.default.createElement(SelectContent2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: ALL_ITEMS_VALUE }, "All Levels"), bloomLevels.map((bl) => /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { key: bl.code, value: bl.code }, bl.name)))), /* @__PURE__ */ React162__namespace.default.createElement(Select2, { value: questionTypeCode || ALL_ITEMS_VALUE, onValueChange: createSelectHandler(setQuestionTypeCode) }, /* @__PURE__ */ React162__namespace.default.createElement(SelectTrigger2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectValue2, { placeholder: "Question Type" })), /* @__PURE__ */ React162__namespace.default.createElement(SelectContent2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: ALL_ITEMS_VALUE }, "All Types"), questionTypes.map((qt) => /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { key: qt.code, value: qt.code }, qt.name)))), /* @__PURE__ */ React162__namespace.default.createElement(Select2, { value: difficulty || ALL_ITEMS_VALUE, onValueChange: createSelectHandler(setDifficulty) }, /* @__PURE__ */ React162__namespace.default.createElement(SelectTrigger2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectValue2, { placeholder: "Difficulty" })), /* @__PURE__ */ React162__namespace.default.createElement(SelectContent2, null, /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: ALL_ITEMS_VALUE }, "All Difficulties"), /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: "easy" }, "Easy"), /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: "medium" }, "Medium"), /* @__PURE__ */ React162__namespace.default.createElement(SelectItem2, { value: "hard" }, "Hard"))), /* @__PURE__ */ React162__namespace.default.createElement("div", { className: "flex gap-2 col-span-full sm:col-span-1 xl:col-span-2 xl:col-start-6" }, /* @__PURE__ */ React162__namespace.default.createElement(Button, { onClick: handleApplyFilters, className: "w-full sm:w-auto flex-grow" }, /* @__PURE__ */ React162__namespace.default.createElement(Search, { className: "mr-2 h-4 w-4" }), " Apply"), /* @__PURE__ */ React162__namespace.default.createElement(Button, { onClick: handleClearFilters, variant: "outline", className: "w-full sm:w-auto flex-grow" }, /* @__PURE__ */ React162__namespace.default.createElement(CircleX, { className: "mr-2 h-4 w-4" }), " Clear"))));
|
|
128449
128453
|
}
|
|
128450
|
-
|
|
128451
|
-
// src/services/questionBankService.ts
|
|
128452
|
-
var LocalStorageManager2 = class {
|
|
128453
|
-
constructor(key) {
|
|
128454
|
-
this.key = key;
|
|
128455
|
-
}
|
|
128456
|
-
getAll() {
|
|
128457
|
-
if (typeof window === "undefined") return [];
|
|
128458
|
-
try {
|
|
128459
|
-
const stored = localStorage.getItem(this.key);
|
|
128460
|
-
return stored ? JSON.parse(stored) : [];
|
|
128461
|
-
} catch (e3) {
|
|
128462
|
-
console.error(`Error reading from localStorage key ${this.key}:`, e3);
|
|
128463
|
-
return [];
|
|
128464
|
-
}
|
|
128465
|
-
}
|
|
128466
|
-
saveAll(items) {
|
|
128467
|
-
if (typeof window === "undefined") return;
|
|
128468
|
-
try {
|
|
128469
|
-
localStorage.setItem(this.key, JSON.stringify(items));
|
|
128470
|
-
} catch (e3) {
|
|
128471
|
-
console.error(`Error writing to localStorage key ${this.key}:`, e3);
|
|
128472
|
-
}
|
|
128473
|
-
}
|
|
128474
|
-
};
|
|
128475
|
-
var questionBankManager = new LocalStorageManager2("iqk_question_bank");
|
|
128476
|
-
var QuestionBankService = class {
|
|
128477
|
-
static getQuestions(filters) {
|
|
128478
|
-
let questions = questionBankManager.getAll();
|
|
128479
|
-
if (filters) {
|
|
128480
|
-
if (filters.subjectCode) {
|
|
128481
|
-
questions = questions.filter((q2) => q2.subjectCode === filters.subjectCode);
|
|
128482
|
-
}
|
|
128483
|
-
if (filters.topicCode) {
|
|
128484
|
-
questions = questions.filter((q2) => q2.topicCode === filters.topicCode);
|
|
128485
|
-
}
|
|
128486
|
-
if (filters.gradeLevelCode) {
|
|
128487
|
-
questions = questions.filter((q2) => q2.gradeLevelCode === filters.gradeLevelCode);
|
|
128488
|
-
}
|
|
128489
|
-
if (filters.bloomLevelCode) {
|
|
128490
|
-
questions = questions.filter((q2) => q2.bloomLevelCode === filters.bloomLevelCode);
|
|
128491
|
-
}
|
|
128492
|
-
if (filters.questionTypeCode) {
|
|
128493
|
-
questions = questions.filter((q2) => q2.questionTypeCode === filters.questionTypeCode);
|
|
128494
|
-
}
|
|
128495
|
-
if (filters.difficulty) {
|
|
128496
|
-
questions = questions.filter((q2) => q2.difficulty === filters.difficulty);
|
|
128497
|
-
}
|
|
128498
|
-
if (filters.searchTerm) {
|
|
128499
|
-
const lowercasedTerm = filters.searchTerm.toLowerCase();
|
|
128500
|
-
questions = questions.filter(
|
|
128501
|
-
(q2) => q2.text.toLowerCase().includes(lowercasedTerm) || q2.code.toLowerCase().includes(lowercasedTerm)
|
|
128502
|
-
);
|
|
128503
|
-
}
|
|
128504
|
-
}
|
|
128505
|
-
return questions.sort((a4, b2) => new Date(b2.lastModified).getTime() - new Date(a4.lastModified).getTime());
|
|
128506
|
-
}
|
|
128507
|
-
static getQuestionByCode(code4) {
|
|
128508
|
-
return questionBankManager.getAll().find((q2) => q2.code === code4);
|
|
128509
|
-
}
|
|
128510
|
-
// CHANGE 2: Simplified function signature. It now takes the full object to be added.
|
|
128511
|
-
static addQuestion(questionData) {
|
|
128512
|
-
const allQuestions = questionBankManager.getAll();
|
|
128513
|
-
if (allQuestions.some((q2) => q2.code === questionData.code)) {
|
|
128514
|
-
throw new Error(`A question with code "${questionData.code}" already exists.`);
|
|
128515
|
-
}
|
|
128516
|
-
const newQuestion = {
|
|
128517
|
-
...questionData,
|
|
128518
|
-
id: generateUniqueId("qb_"),
|
|
128519
|
-
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
128520
|
-
};
|
|
128521
|
-
questionBankManager.saveAll([...allQuestions, newQuestion]);
|
|
128522
|
-
return newQuestion;
|
|
128523
|
-
}
|
|
128524
|
-
// CHANGE 2: Simplified function signature.
|
|
128525
|
-
static updateQuestion(id3, updates) {
|
|
128526
|
-
const allQuestions = questionBankManager.getAll();
|
|
128527
|
-
const index3 = allQuestions.findIndex((q2) => q2.id === id3);
|
|
128528
|
-
if (index3 === -1) {
|
|
128529
|
-
console.warn(`Question with id "${id3}" not found for update.`);
|
|
128530
|
-
return null;
|
|
128531
|
-
}
|
|
128532
|
-
const updatedQuestion = {
|
|
128533
|
-
...allQuestions[index3],
|
|
128534
|
-
...updates,
|
|
128535
|
-
lastModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
128536
|
-
};
|
|
128537
|
-
allQuestions[index3] = updatedQuestion;
|
|
128538
|
-
questionBankManager.saveAll(allQuestions);
|
|
128539
|
-
return updatedQuestion;
|
|
128540
|
-
}
|
|
128541
|
-
static deleteQuestionByCode(code4) {
|
|
128542
|
-
const allQuestions = questionBankManager.getAll();
|
|
128543
|
-
const newQuestions = allQuestions.filter((q2) => q2.code !== code4);
|
|
128544
|
-
if (allQuestions.length === newQuestions.length) {
|
|
128545
|
-
return false;
|
|
128546
|
-
}
|
|
128547
|
-
questionBankManager.saveAll(newQuestions);
|
|
128548
|
-
return true;
|
|
128549
|
-
}
|
|
128550
|
-
};
|
|
128551
|
-
|
|
128552
|
-
// src/react-ui/components/authoring/QuestionFormDialog.tsx
|
|
128553
128454
|
function QuestionFormDialog({
|
|
128554
128455
|
isOpen,
|
|
128555
128456
|
onOpenChange,
|
|
@@ -128634,9 +128535,11 @@ function QuestionFormDialog({
|
|
|
128634
128535
|
toast2({ title: "Validation Error", description: "Question content is missing. Please create or edit the question details.", variant: "destructive" });
|
|
128635
128536
|
return;
|
|
128636
128537
|
}
|
|
128637
|
-
startTransition(() => {
|
|
128538
|
+
startTransition(async () => {
|
|
128638
128539
|
try {
|
|
128639
128540
|
const finalDataPayload = {
|
|
128541
|
+
id: questionToEdit?.id || "",
|
|
128542
|
+
// Will be ignored for new items, used for updates
|
|
128640
128543
|
code: code4,
|
|
128641
128544
|
text: questionConfig.prompt.replace(/<[^>]*>?/gm, "").substring(0, 200),
|
|
128642
128545
|
subjectCode,
|
|
@@ -128645,6 +128548,8 @@ function QuestionFormDialog({
|
|
|
128645
128548
|
bloomLevelCode,
|
|
128646
128549
|
questionTypeCode: questionConfig.questionType,
|
|
128647
128550
|
difficulty: questionConfig.difficulty,
|
|
128551
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
128552
|
+
// This will be set by the saving service
|
|
128648
128553
|
questionConfig: {
|
|
128649
128554
|
...questionConfig,
|
|
128650
128555
|
subject: subjectCode,
|
|
@@ -128653,14 +128558,7 @@ function QuestionFormDialog({
|
|
|
128653
128558
|
bloomLevel: bloomLevelCode
|
|
128654
128559
|
}
|
|
128655
128560
|
};
|
|
128656
|
-
|
|
128657
|
-
QuestionBankService.updateQuestion(questionToEdit.id, finalDataPayload);
|
|
128658
|
-
toast2({ title: "Success", description: "Question updated." });
|
|
128659
|
-
} else {
|
|
128660
|
-
QuestionBankService.addQuestion(finalDataPayload);
|
|
128661
|
-
toast2({ title: "Success", description: "Question added." });
|
|
128662
|
-
}
|
|
128663
|
-
onSave();
|
|
128561
|
+
await onSave(finalDataPayload);
|
|
128664
128562
|
onOpenChange(false);
|
|
128665
128563
|
} catch (error) {
|
|
128666
128564
|
toast2({ title: "Error", description: error.message || "Failed to save question.", variant: "destructive" });
|
|
@@ -133501,10 +133399,7 @@ var AIQuizReviewOutputSchema = zod.z.object({
|
|
|
133501
133399
|
// src/ai/flows/generate-quiz-review.ts
|
|
133502
133400
|
async function generateQuizReview(clientInput, apiKey) {
|
|
133503
133401
|
try {
|
|
133504
|
-
const
|
|
133505
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
133506
|
-
model: googleai.gemini20Flash
|
|
133507
|
-
});
|
|
133402
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
133508
133403
|
const resultsString = JSON.stringify(clientInput.questionResults, null, 2);
|
|
133509
133404
|
const promptText = `
|
|
133510
133405
|
You are an expert educational tutor. Your task is to analyze a student's quiz results and provide a detailed, helpful review in ${clientInput.language}.
|
|
@@ -133541,8 +133436,17 @@ Return a single, valid JSON object with this EXACT format.
|
|
|
133541
133436
|
\`\`\`
|
|
133542
133437
|
|
|
133543
133438
|
Return only the valid JSON response.`;
|
|
133544
|
-
const
|
|
133545
|
-
const
|
|
133439
|
+
const modelName = "gemini-1.5-flash";
|
|
133440
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
133441
|
+
const result = await genAI.models.generateContent({
|
|
133442
|
+
model: modelName,
|
|
133443
|
+
contents
|
|
133444
|
+
});
|
|
133445
|
+
const response = result;
|
|
133446
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
133447
|
+
if (!rawText) {
|
|
133448
|
+
throw new Error("AI returned an empty response.");
|
|
133449
|
+
}
|
|
133546
133450
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
133547
133451
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
133548
133452
|
const validatedOutput = AIQuizReviewOutputSchema.parse(aiGeneratedContent);
|
|
@@ -133607,10 +133511,7 @@ var LearningAnalysisOutputSchema = zod.z.object({
|
|
|
133607
133511
|
// src/ai/flows/generate-learning-analysis.ts
|
|
133608
133512
|
async function generateLearningAnalysis(clientInput, apiKey) {
|
|
133609
133513
|
try {
|
|
133610
|
-
const
|
|
133611
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
133612
|
-
model: googleai.gemini20Flash
|
|
133613
|
-
});
|
|
133514
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
133614
133515
|
const {
|
|
133615
133516
|
language: language3,
|
|
133616
133517
|
userName = "learner",
|
|
@@ -133698,8 +133599,17 @@ The 'suggestedDifficulty' field MUST ALWAYS be one of these exact English string
|
|
|
133698
133599
|
}
|
|
133699
133600
|
\`\`\`
|
|
133700
133601
|
`;
|
|
133701
|
-
const
|
|
133702
|
-
const
|
|
133602
|
+
const modelName = "gemini-1.5-flash";
|
|
133603
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
133604
|
+
const result = await genAI.models.generateContent({
|
|
133605
|
+
model: modelName,
|
|
133606
|
+
contents
|
|
133607
|
+
});
|
|
133608
|
+
const response = result;
|
|
133609
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
133610
|
+
if (!rawText) {
|
|
133611
|
+
throw new Error("AI returned an empty response.");
|
|
133612
|
+
}
|
|
133703
133613
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
133704
133614
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
133705
133615
|
const validatedOutput = LearningAnalysisOutputSchema.parse(aiGeneratedContent);
|
|
@@ -133730,10 +133640,7 @@ var GenerateMotivationalQuoteOutputSchema = zod.z.object({
|
|
|
133730
133640
|
// src/ai/flows/generate-motivational-quote.ts
|
|
133731
133641
|
async function generateMotivationalQuote(clientInput, apiKey) {
|
|
133732
133642
|
try {
|
|
133733
|
-
const
|
|
133734
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
133735
|
-
model: googleai.gemini20Flash
|
|
133736
|
-
});
|
|
133643
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
133737
133644
|
const { language: language3, userName, currentStreak, weakestTopic } = clientInput;
|
|
133738
133645
|
let contextPrompt = "";
|
|
133739
133646
|
if (userName) {
|
|
@@ -133766,8 +133673,17 @@ Return the response as a single, valid JSON object with this EXACT format:
|
|
|
133766
133673
|
|
|
133767
133674
|
Return only the JSON response.`;
|
|
133768
133675
|
try {
|
|
133769
|
-
const
|
|
133770
|
-
const
|
|
133676
|
+
const modelName = "gemini-1.5-flash";
|
|
133677
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
133678
|
+
const result = await genAI.models.generateContent({
|
|
133679
|
+
model: modelName,
|
|
133680
|
+
contents
|
|
133681
|
+
});
|
|
133682
|
+
const response = result;
|
|
133683
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
133684
|
+
if (!rawText) {
|
|
133685
|
+
throw new Error("AI returned an empty response.");
|
|
133686
|
+
}
|
|
133771
133687
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
133772
133688
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
133773
133689
|
const validatedOutput = GenerateMotivationalQuoteOutputSchema.parse(aiGeneratedContent);
|
|
@@ -133793,10 +133709,7 @@ var PlanKnowledgeCardsOutputSchema = zod.z.object({
|
|
|
133793
133709
|
// src/ai/flows/plan-knowledge-cards.ts
|
|
133794
133710
|
async function planKnowledgeCards(clientInput, apiKey) {
|
|
133795
133711
|
try {
|
|
133796
|
-
const
|
|
133797
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
133798
|
-
model: googleai.gemini20Flash
|
|
133799
|
-
});
|
|
133712
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
133800
133713
|
const { language: language3, learningObjectivesContent, overallSubject } = clientInput;
|
|
133801
133714
|
const promptText = `
|
|
133802
133715
|
You are an expert curriculum designer specializing in the subject of "${overallSubject}".
|
|
@@ -133816,18 +133729,28 @@ ${learningObjectivesContent}
|
|
|
133816
133729
|
|
|
133817
133730
|
**JSON OUTPUT FORMAT:**
|
|
133818
133731
|
Return a single, valid JSON object with this EXACT format:
|
|
133732
|
+
\`\`\`json
|
|
133819
133733
|
{
|
|
133820
133734
|
"concepts": [
|
|
133821
133735
|
"First Concept",
|
|
133822
133736
|
"Second Concept",
|
|
133823
|
-
"Third Concept"
|
|
133824
|
-
...
|
|
133737
|
+
"Third Concept"
|
|
133825
133738
|
]
|
|
133826
133739
|
}
|
|
133740
|
+
\`\`\`
|
|
133827
133741
|
|
|
133828
133742
|
Return only the JSON response.`;
|
|
133829
|
-
const
|
|
133830
|
-
const
|
|
133743
|
+
const modelName = "gemini-1.5-flash";
|
|
133744
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
133745
|
+
const result = await genAI.models.generateContent({
|
|
133746
|
+
model: modelName,
|
|
133747
|
+
contents
|
|
133748
|
+
});
|
|
133749
|
+
const response = result;
|
|
133750
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
133751
|
+
if (!rawText) {
|
|
133752
|
+
throw new Error("AI returned an empty response.");
|
|
133753
|
+
}
|
|
133831
133754
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
133832
133755
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
133833
133756
|
const validatedOutput = PlanKnowledgeCardsOutputSchema.parse(aiGeneratedContent);
|
|
@@ -133854,30 +133777,48 @@ var GenerateSingleKnowledgeCardOutputSchema = zod.z.object({
|
|
|
133854
133777
|
|
|
133855
133778
|
// src/ai/flows/generate-single-knowledge-card.ts
|
|
133856
133779
|
async function generateSingleKnowledgeCard(clientInput, apiKey) {
|
|
133857
|
-
const ai = genkit.genkit({
|
|
133858
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
133859
|
-
model: googleai.gemini20Flash
|
|
133860
|
-
});
|
|
133861
133780
|
try {
|
|
133862
|
-
const
|
|
133781
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
133782
|
+
const { language: language3, concept, overallSubject } = clientInput;
|
|
133863
133783
|
const promptText = `
|
|
133864
|
-
You are an expert educator for "${overallSubject}".
|
|
133865
|
-
|
|
133866
|
-
|
|
133867
|
-
|
|
133868
|
-
|
|
133869
|
-
|
|
133870
|
-
|
|
133871
|
-
|
|
133872
|
-
|
|
133873
|
-
|
|
133874
|
-
|
|
133875
|
-
|
|
133784
|
+
You are an expert educator for "${overallSubject}". Your task is to create content for a single knowledge card based on the provided concept.
|
|
133785
|
+
|
|
133786
|
+
**Target Concept:**
|
|
133787
|
+
${concept}
|
|
133788
|
+
|
|
133789
|
+
**Instructions:**
|
|
133790
|
+
1. **Definition:** Write a concise definition for the concept (under 40 words).
|
|
133791
|
+
2. **Example:** Provide a practical example (code or real-world scenario) relevant to "${overallSubject}".
|
|
133792
|
+
3. **Language:** All content must be in ${language3}.
|
|
133793
|
+
4. **Format:** You MUST return ONLY a single, valid JSON object that strictly follows the provided schema. Do not include any extra text, comments, or markdown formatting.
|
|
133794
|
+
|
|
133795
|
+
**Required JSON Output Format:**
|
|
133796
|
+
Your response must be ONLY the JSON object, matching this exact structure. The 'concept' field must exactly match the Target Concept provided above.
|
|
133797
|
+
|
|
133798
|
+
{
|
|
133799
|
+
"concept": "${concept}",
|
|
133800
|
+
"definition": "A concise explanation of the concept goes here, in ${language3}.",
|
|
133801
|
+
"example": "A practical code snippet or real-world example goes here, in ${language3}."
|
|
133802
|
+
}
|
|
133803
|
+
|
|
133804
|
+
Now, generate the JSON for the requested knowledge card.`;
|
|
133805
|
+
const modelName = "gemini-1.5-flash";
|
|
133806
|
+
const config3 = {
|
|
133807
|
+
responseMimeType: "application/json"
|
|
133808
|
+
};
|
|
133809
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
133810
|
+
const result = await genAI.models.generateContent({
|
|
133811
|
+
model: modelName,
|
|
133812
|
+
contents,
|
|
133813
|
+
config: config3
|
|
133876
133814
|
});
|
|
133877
|
-
const
|
|
133878
|
-
|
|
133815
|
+
const response = result;
|
|
133816
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
133817
|
+
if (!rawText) {
|
|
133879
133818
|
throw new Error("AI did not return a valid structured output.");
|
|
133880
133819
|
}
|
|
133820
|
+
const aiGeneratedContent = JSON.parse(rawText);
|
|
133821
|
+
const validatedOutput = GenerateSingleKnowledgeCardOutputSchema.parse(aiGeneratedContent);
|
|
133881
133822
|
return validatedOutput;
|
|
133882
133823
|
} catch (error) {
|
|
133883
133824
|
console.error(`Error generating knowledge card for concept "${clientInput.concept}":`, error);
|
|
@@ -133913,10 +133854,7 @@ var AssessAndMapDocumentOutputSchema = zod.z.object({
|
|
|
133913
133854
|
// src/ai/flows/assess-and-map-document.ts
|
|
133914
133855
|
async function assessAndMapDocument(clientInput, apiKey) {
|
|
133915
133856
|
try {
|
|
133916
|
-
const
|
|
133917
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
133918
|
-
model: googleai.gemini20Flash
|
|
133919
|
-
});
|
|
133857
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
133920
133858
|
const { language: language3, documentContent, learningObjectives } = clientInput;
|
|
133921
133859
|
const relevanceThreshold = 40;
|
|
133922
133860
|
const promptText = `
|
|
@@ -133964,8 +133902,17 @@ Return a single, valid JSON object in this EXACT format. Do not include any othe
|
|
|
133964
133902
|
|
|
133965
133903
|
If the document is not relevant at all, the "mappedLOs" array should be empty, and the "relevanceScore" should be low.
|
|
133966
133904
|
`;
|
|
133967
|
-
const
|
|
133968
|
-
const
|
|
133905
|
+
const modelName = "gemini-1.5-flash";
|
|
133906
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
133907
|
+
const result = await genAI.models.generateContent({
|
|
133908
|
+
model: modelName,
|
|
133909
|
+
contents
|
|
133910
|
+
});
|
|
133911
|
+
const response = result;
|
|
133912
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
133913
|
+
if (!rawText) {
|
|
133914
|
+
throw new Error("AI returned an empty response.");
|
|
133915
|
+
}
|
|
133969
133916
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
133970
133917
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
133971
133918
|
const validatedOutput = AssessAndMapDocumentOutputSchema.parse(aiGeneratedContent);
|
|
@@ -133997,10 +133944,7 @@ var GenerateQuizFromTextOutputSchema = zod.z.object({
|
|
|
133997
133944
|
var AnyGeneratedQuestionSchema2 = GenerateQuizFromTextOutputSchema.shape.generatedQuestions.element;
|
|
133998
133945
|
async function generateQuizFromText(clientInput, apiKey) {
|
|
133999
133946
|
try {
|
|
134000
|
-
const
|
|
134001
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
134002
|
-
model: googleai.gemini20Flash
|
|
134003
|
-
});
|
|
133947
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
134004
133948
|
const { language: language3, documentContent, numQuestions, questionTypes } = clientInput;
|
|
134005
133949
|
const allowedTypes = questionTypes || ["multiple_choice", "true_false"];
|
|
134006
133950
|
const promptText = `
|
|
@@ -134054,8 +133998,17 @@ Return the response as a single JSON object with a key "generatedQuestions" cont
|
|
|
134054
133998
|
\`\`\`
|
|
134055
133999
|
|
|
134056
134000
|
Now, generate the JSON response.`;
|
|
134057
|
-
const
|
|
134058
|
-
const
|
|
134001
|
+
const modelName = "gemini-1.5-flash";
|
|
134002
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
134003
|
+
const result = await genAI.models.generateContent({
|
|
134004
|
+
model: modelName,
|
|
134005
|
+
contents
|
|
134006
|
+
});
|
|
134007
|
+
const response = result;
|
|
134008
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
134009
|
+
if (!rawText) {
|
|
134010
|
+
throw new Error("AI returned an empty response.");
|
|
134011
|
+
}
|
|
134059
134012
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
134060
134013
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
134061
134014
|
if (!aiGeneratedContent.generatedQuestions || !Array.isArray(aiGeneratedContent.generatedQuestions)) {
|
|
@@ -162973,10 +162926,7 @@ var AskTutorChatOutputSchema = zod.z.object({
|
|
|
162973
162926
|
// src/ai/flows/ask-tutor-chat.ts
|
|
162974
162927
|
async function askTutorChat(clientInput, apiKey) {
|
|
162975
162928
|
try {
|
|
162976
|
-
const
|
|
162977
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
162978
|
-
model: googleai.gemini20Flash
|
|
162979
|
-
});
|
|
162929
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
162980
162930
|
const { language: language3, currentQuestion, chatHistory, knowledgeContext } = clientInput;
|
|
162981
162931
|
const historyString = chatHistory.map((msg) => `${msg.role}: ${msg.content}`).join("\n");
|
|
162982
162932
|
const contextString = knowledgeContext && knowledgeContext.length > 0 ? `--- KNOWLEDGE CONTEXT ---
|
|
@@ -163003,8 +162953,14 @@ user: ${currentQuestion}
|
|
|
163003
162953
|
|
|
163004
162954
|
**Your Response (as 'assistant'):**
|
|
163005
162955
|
`;
|
|
163006
|
-
const
|
|
163007
|
-
const
|
|
162956
|
+
const modelName = "gemini-1.5-flash";
|
|
162957
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
162958
|
+
const result = await genAI.models.generateContent({
|
|
162959
|
+
model: modelName,
|
|
162960
|
+
contents
|
|
162961
|
+
});
|
|
162962
|
+
const response = result;
|
|
162963
|
+
const aiResponseText = response.candidates?.[0]?.content?.parts?.[0]?.text?.trim() || "";
|
|
163008
162964
|
if (!aiResponseText) {
|
|
163009
162965
|
throw new Error("AI returned an empty response.");
|
|
163010
162966
|
}
|
package/dist/react-ui.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { Q as QuizResultType, U as UserAnswerType, m as PracticeSuggestion, l as
|
|
|
5
5
|
export { j as AchievementDefinition, r as ActivityCalendarData, u as AnalysisReport, A as AnswerDetail, x as ChatContext, C as ChatMessage, v as DashboardCardConfig, D as DashboardCardId, w as DashboardLayout, y as Goal, G as GoalType, t as ImageContextItem, I as ImportError, K as KnowledgeCard, L as LearningAnalysis, e as PerformanceByBloomLevel, b as PerformanceByCategory, d as PerformanceByDifficulty, P as PerformanceByLearningObjective, c as PerformanceByTopic, f as PerformanceMetric, s as PerformanceSummary, k as PracticeDifficulty, n as PracticeSession, q as PracticeTopicSummary, g as QuestionReview, R as RoadmapItem, T as TestCaseResult, a as UserAnswers, W as WeeklyRoadmap } from './ai-ecosystem-DCPvHU4-.cjs';
|
|
6
6
|
import * as React$1 from 'react';
|
|
7
7
|
import React__default from 'react';
|
|
8
|
-
export { a as AIFullQuizGeneratorModal, A as AIQuestionGeneratorModal, b as APIKeyManagerModal, i as ApproachManager, B as BloomLevelManager, C as CategoryManager, h as ContextManager, E as EditQuestionModal, G as GradeLevelManager, I as ImportQuestionsModal, L as LearningObjectiveManager, M as MetadataTabs, d as QuestionFilters, e as QuestionFormDialog, c as QuestionList, g as QuestionTypeManager, Q as QuizAuthoringTool, S as SCORMExportModal, f as SubjectManager, j as Toaster, T as TopicManager, t as toast, u as useToast } from './toaster-
|
|
8
|
+
export { a as AIFullQuizGeneratorModal, A as AIQuestionGeneratorModal, b as APIKeyManagerModal, i as ApproachManager, B as BloomLevelManager, C as CategoryManager, h as ContextManager, E as EditQuestionModal, G as GradeLevelManager, I as ImportQuestionsModal, L as LearningObjectiveManager, M as MetadataTabs, d as QuestionFilters, e as QuestionFormDialog, c as QuestionList, g as QuestionTypeManager, Q as QuizAuthoringTool, S as SCORMExportModal, f as SubjectManager, j as Toaster, T as TopicManager, t as toast, u as useToast } from './toaster-D1bLqmd_.cjs';
|
|
9
9
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
10
10
|
import { VariantProps } from 'class-variance-authority';
|
|
11
11
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
package/dist/react-ui.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Q as QuizResultType, U as UserAnswerType, m as PracticeSuggestion, l as
|
|
|
5
5
|
export { j as AchievementDefinition, r as ActivityCalendarData, u as AnalysisReport, A as AnswerDetail, x as ChatContext, C as ChatMessage, v as DashboardCardConfig, D as DashboardCardId, w as DashboardLayout, y as Goal, G as GoalType, t as ImageContextItem, I as ImportError, K as KnowledgeCard, L as LearningAnalysis, e as PerformanceByBloomLevel, b as PerformanceByCategory, d as PerformanceByDifficulty, P as PerformanceByLearningObjective, c as PerformanceByTopic, f as PerformanceMetric, s as PerformanceSummary, k as PracticeDifficulty, n as PracticeSession, q as PracticeTopicSummary, g as QuestionReview, R as RoadmapItem, T as TestCaseResult, a as UserAnswers, W as WeeklyRoadmap } from './ai-ecosystem-D6vuLxnS.js';
|
|
6
6
|
import * as React$1 from 'react';
|
|
7
7
|
import React__default from 'react';
|
|
8
|
-
export { a as AIFullQuizGeneratorModal, A as AIQuestionGeneratorModal, b as APIKeyManagerModal, i as ApproachManager, B as BloomLevelManager, C as CategoryManager, h as ContextManager, E as EditQuestionModal, G as GradeLevelManager, I as ImportQuestionsModal, L as LearningObjectiveManager, M as MetadataTabs, d as QuestionFilters, e as QuestionFormDialog, c as QuestionList, g as QuestionTypeManager, Q as QuizAuthoringTool, S as SCORMExportModal, f as SubjectManager, j as Toaster, T as TopicManager, t as toast, u as useToast } from './toaster-
|
|
8
|
+
export { a as AIFullQuizGeneratorModal, A as AIQuestionGeneratorModal, b as APIKeyManagerModal, i as ApproachManager, B as BloomLevelManager, C as CategoryManager, h as ContextManager, E as EditQuestionModal, G as GradeLevelManager, I as ImportQuestionsModal, L as LearningObjectiveManager, M as MetadataTabs, d as QuestionFilters, e as QuestionFormDialog, c as QuestionList, g as QuestionTypeManager, Q as QuizAuthoringTool, S as SCORMExportModal, f as SubjectManager, j as Toaster, T as TopicManager, t as toast, u as useToast } from './toaster-eWZIxSVc.js';
|
|
9
9
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
10
10
|
import { VariantProps } from 'class-variance-authority';
|
|
11
11
|
import * as LabelPrimitive from '@radix-ui/react-label';
|