@thanh01.pmt/interactive-quiz-kit 1.0.31 → 1.0.33
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/authoring.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { genkit } from 'genkit';
|
|
3
|
-
import { gemini20Flash, googleAI } from '@genkit-ai/googleai';
|
|
4
|
-
import JSZip from 'jszip';
|
|
5
2
|
import { GoogleGenAI } from '@google/genai';
|
|
3
|
+
import JSZip from 'jszip';
|
|
6
4
|
import * as React96 from 'react';
|
|
7
5
|
import React96__default, { createContext, forwardRef, createElement, useRef, useState, useImperativeHandle, useCallback, useEffect, useLayoutEffect, useContext, useTransition, Suspense } from 'react';
|
|
8
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -2763,10 +2761,7 @@ var EvaluateUserCodeOutputSchema = AIEvaluationOutputSchema;
|
|
|
2763
2761
|
// src/ai/flows/evaluate-user-code.ts
|
|
2764
2762
|
async function evaluateUserCode(clientInput, apiKey) {
|
|
2765
2763
|
try {
|
|
2766
|
-
const
|
|
2767
|
-
plugins: [googleAI({ apiKey })],
|
|
2768
|
-
model: gemini20Flash
|
|
2769
|
-
});
|
|
2764
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
2770
2765
|
const { language: language3, problemPrompt, userCode, testCase } = clientInput;
|
|
2771
2766
|
const promptText = `
|
|
2772
2767
|
You are an expert Code Judge and Teaching Assistant for a ${language3} programming course.
|
|
@@ -2803,8 +2798,17 @@ Return ONLY the JSON object with this EXACT structure.
|
|
|
2803
2798
|
\`\`\`
|
|
2804
2799
|
|
|
2805
2800
|
Return only the JSON response.`;
|
|
2806
|
-
const
|
|
2807
|
-
const
|
|
2801
|
+
const modelName = "gemini-1.5-flash";
|
|
2802
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
2803
|
+
const result = await genAI.models.generateContent({
|
|
2804
|
+
model: modelName,
|
|
2805
|
+
contents
|
|
2806
|
+
});
|
|
2807
|
+
const response = result;
|
|
2808
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
2809
|
+
if (!rawText) {
|
|
2810
|
+
throw new Error("AI returned an empty response.");
|
|
2811
|
+
}
|
|
2808
2812
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
2809
2813
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
2810
2814
|
return EvaluateUserCodeOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10410,10 +10414,7 @@ var AIQuizReviewOutputSchema = z.object({
|
|
|
10410
10414
|
// src/ai/flows/generate-quiz-review.ts
|
|
10411
10415
|
async function generateQuizReview(clientInput, apiKey) {
|
|
10412
10416
|
try {
|
|
10413
|
-
const
|
|
10414
|
-
plugins: [googleAI({ apiKey })],
|
|
10415
|
-
model: gemini20Flash
|
|
10416
|
-
});
|
|
10417
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10417
10418
|
const resultsString = JSON.stringify(clientInput.questionResults, null, 2);
|
|
10418
10419
|
const promptText = `
|
|
10419
10420
|
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}.
|
|
@@ -10450,8 +10451,17 @@ Return a single, valid JSON object with this EXACT format.
|
|
|
10450
10451
|
\`\`\`
|
|
10451
10452
|
|
|
10452
10453
|
Return only the valid JSON response.`;
|
|
10453
|
-
const
|
|
10454
|
-
const
|
|
10454
|
+
const modelName = "gemini-1.5-flash";
|
|
10455
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
10456
|
+
const result = await genAI.models.generateContent({
|
|
10457
|
+
model: modelName,
|
|
10458
|
+
contents
|
|
10459
|
+
});
|
|
10460
|
+
const response = result;
|
|
10461
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
10462
|
+
if (!rawText) {
|
|
10463
|
+
throw new Error("AI returned an empty response.");
|
|
10464
|
+
}
|
|
10455
10465
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
10456
10466
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
10457
10467
|
const validatedOutput = AIQuizReviewOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10498,10 +10508,7 @@ var PracticeSuggestionOutputSchema = z.object({
|
|
|
10498
10508
|
});
|
|
10499
10509
|
async function generatePracticeSuggestion(clientInput, apiKey) {
|
|
10500
10510
|
try {
|
|
10501
|
-
const
|
|
10502
|
-
plugins: [googleAI({ apiKey })],
|
|
10503
|
-
model: gemini20Flash
|
|
10504
|
-
});
|
|
10511
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10505
10512
|
const { language: language3, userName, performanceByTopic, recentHistory, allAvailableTopics } = clientInput;
|
|
10506
10513
|
const promptText = `
|
|
10507
10514
|
You are a friendly and insightful AI Learning Coach. Your goal is to provide a personalized practice suggestion for a student named ${userName || "there"}.
|
|
@@ -10540,8 +10547,17 @@ Return a single, valid JSON object in this exact format. All text must be in ${l
|
|
|
10540
10547
|
}
|
|
10541
10548
|
|
|
10542
10549
|
Return only the JSON response.`;
|
|
10543
|
-
const
|
|
10544
|
-
const
|
|
10550
|
+
const modelName = "gemini-1.5-flash";
|
|
10551
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
10552
|
+
const result = await genAI.models.generateContent({
|
|
10553
|
+
model: modelName,
|
|
10554
|
+
contents
|
|
10555
|
+
});
|
|
10556
|
+
const response = result;
|
|
10557
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
10558
|
+
if (!rawText) {
|
|
10559
|
+
throw new Error("AI returned an empty response.");
|
|
10560
|
+
}
|
|
10545
10561
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
10546
10562
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
10547
10563
|
const validatedOutput = PracticeSuggestionOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10606,10 +10622,7 @@ var LearningAnalysisOutputSchema = z.object({
|
|
|
10606
10622
|
// src/ai/flows/generate-learning-analysis.ts
|
|
10607
10623
|
async function generateLearningAnalysis(clientInput, apiKey) {
|
|
10608
10624
|
try {
|
|
10609
|
-
const
|
|
10610
|
-
plugins: [googleAI({ apiKey })],
|
|
10611
|
-
model: gemini20Flash
|
|
10612
|
-
});
|
|
10625
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10613
10626
|
const {
|
|
10614
10627
|
language: language3,
|
|
10615
10628
|
userName = "learner",
|
|
@@ -10697,8 +10710,17 @@ The 'suggestedDifficulty' field MUST ALWAYS be one of these exact English string
|
|
|
10697
10710
|
}
|
|
10698
10711
|
\`\`\`
|
|
10699
10712
|
`;
|
|
10700
|
-
const
|
|
10701
|
-
const
|
|
10713
|
+
const modelName = "gemini-1.5-flash";
|
|
10714
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
10715
|
+
const result = await genAI.models.generateContent({
|
|
10716
|
+
model: modelName,
|
|
10717
|
+
contents
|
|
10718
|
+
});
|
|
10719
|
+
const response = result;
|
|
10720
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
10721
|
+
if (!rawText) {
|
|
10722
|
+
throw new Error("AI returned an empty response.");
|
|
10723
|
+
}
|
|
10702
10724
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
10703
10725
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
10704
10726
|
const validatedOutput = LearningAnalysisOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10729,10 +10751,7 @@ var GenerateMotivationalQuoteOutputSchema = z.object({
|
|
|
10729
10751
|
// src/ai/flows/generate-motivational-quote.ts
|
|
10730
10752
|
async function generateMotivationalQuote(clientInput, apiKey) {
|
|
10731
10753
|
try {
|
|
10732
|
-
const
|
|
10733
|
-
plugins: [googleAI({ apiKey })],
|
|
10734
|
-
model: gemini20Flash
|
|
10735
|
-
});
|
|
10754
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10736
10755
|
const { language: language3, userName, currentStreak, weakestTopic } = clientInput;
|
|
10737
10756
|
let contextPrompt = "";
|
|
10738
10757
|
if (userName) {
|
|
@@ -10765,8 +10784,17 @@ Return the response as a single, valid JSON object with this EXACT format:
|
|
|
10765
10784
|
|
|
10766
10785
|
Return only the JSON response.`;
|
|
10767
10786
|
try {
|
|
10768
|
-
const
|
|
10769
|
-
const
|
|
10787
|
+
const modelName = "gemini-1.5-flash";
|
|
10788
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
10789
|
+
const result = await genAI.models.generateContent({
|
|
10790
|
+
model: modelName,
|
|
10791
|
+
contents
|
|
10792
|
+
});
|
|
10793
|
+
const response = result;
|
|
10794
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
10795
|
+
if (!rawText) {
|
|
10796
|
+
throw new Error("AI returned an empty response.");
|
|
10797
|
+
}
|
|
10770
10798
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
10771
10799
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
10772
10800
|
const validatedOutput = GenerateMotivationalQuoteOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10792,10 +10820,7 @@ var PlanKnowledgeCardsOutputSchema = z.object({
|
|
|
10792
10820
|
// src/ai/flows/plan-knowledge-cards.ts
|
|
10793
10821
|
async function planKnowledgeCards(clientInput, apiKey) {
|
|
10794
10822
|
try {
|
|
10795
|
-
const
|
|
10796
|
-
plugins: [googleAI({ apiKey })],
|
|
10797
|
-
model: gemini20Flash
|
|
10798
|
-
});
|
|
10823
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10799
10824
|
const { language: language3, learningObjectivesContent, overallSubject } = clientInput;
|
|
10800
10825
|
const promptText = `
|
|
10801
10826
|
You are an expert curriculum designer specializing in the subject of "${overallSubject}".
|
|
@@ -10815,18 +10840,28 @@ ${learningObjectivesContent}
|
|
|
10815
10840
|
|
|
10816
10841
|
**JSON OUTPUT FORMAT:**
|
|
10817
10842
|
Return a single, valid JSON object with this EXACT format:
|
|
10843
|
+
\`\`\`json
|
|
10818
10844
|
{
|
|
10819
10845
|
"concepts": [
|
|
10820
10846
|
"First Concept",
|
|
10821
10847
|
"Second Concept",
|
|
10822
|
-
"Third Concept"
|
|
10823
|
-
...
|
|
10848
|
+
"Third Concept"
|
|
10824
10849
|
]
|
|
10825
10850
|
}
|
|
10851
|
+
\`\`\`
|
|
10826
10852
|
|
|
10827
10853
|
Return only the JSON response.`;
|
|
10828
|
-
const
|
|
10829
|
-
const
|
|
10854
|
+
const modelName = "gemini-1.5-flash";
|
|
10855
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
10856
|
+
const result = await genAI.models.generateContent({
|
|
10857
|
+
model: modelName,
|
|
10858
|
+
contents
|
|
10859
|
+
});
|
|
10860
|
+
const response = result;
|
|
10861
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
10862
|
+
if (!rawText) {
|
|
10863
|
+
throw new Error("AI returned an empty response.");
|
|
10864
|
+
}
|
|
10830
10865
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
10831
10866
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
10832
10867
|
const validatedOutput = PlanKnowledgeCardsOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10853,30 +10888,48 @@ var GenerateSingleKnowledgeCardOutputSchema = z.object({
|
|
|
10853
10888
|
|
|
10854
10889
|
// src/ai/flows/generate-single-knowledge-card.ts
|
|
10855
10890
|
async function generateSingleKnowledgeCard(clientInput, apiKey) {
|
|
10856
|
-
const ai = genkit({
|
|
10857
|
-
plugins: [googleAI({ apiKey })],
|
|
10858
|
-
model: gemini20Flash
|
|
10859
|
-
});
|
|
10860
10891
|
try {
|
|
10861
|
-
const
|
|
10892
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10893
|
+
const { language: language3, concept, overallSubject } = clientInput;
|
|
10862
10894
|
const promptText = `
|
|
10863
|
-
You are an expert educator for "${overallSubject}".
|
|
10864
|
-
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10868
|
-
|
|
10869
|
-
|
|
10870
|
-
|
|
10871
|
-
|
|
10872
|
-
|
|
10873
|
-
|
|
10874
|
-
|
|
10895
|
+
You are an expert educator for "${overallSubject}". Your task is to create content for a single knowledge card based on the provided concept.
|
|
10896
|
+
|
|
10897
|
+
**Target Concept:**
|
|
10898
|
+
${concept}
|
|
10899
|
+
|
|
10900
|
+
**Instructions:**
|
|
10901
|
+
1. **Definition:** Write a concise definition for the concept (under 40 words).
|
|
10902
|
+
2. **Example:** Provide a practical example (code or real-world scenario) relevant to "${overallSubject}".
|
|
10903
|
+
3. **Language:** All content must be in ${language3}.
|
|
10904
|
+
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.
|
|
10905
|
+
|
|
10906
|
+
**Required JSON Output Format:**
|
|
10907
|
+
Your response must be ONLY the JSON object, matching this exact structure. The 'concept' field must exactly match the Target Concept provided above.
|
|
10908
|
+
|
|
10909
|
+
{
|
|
10910
|
+
"concept": "${concept}",
|
|
10911
|
+
"definition": "A concise explanation of the concept goes here, in ${language3}.",
|
|
10912
|
+
"example": "A practical code snippet or real-world example goes here, in ${language3}."
|
|
10913
|
+
}
|
|
10914
|
+
|
|
10915
|
+
Now, generate the JSON for the requested knowledge card.`;
|
|
10916
|
+
const modelName = "gemini-1.5-flash";
|
|
10917
|
+
const config2 = {
|
|
10918
|
+
responseMimeType: "application/json"
|
|
10919
|
+
};
|
|
10920
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
10921
|
+
const result = await genAI.models.generateContent({
|
|
10922
|
+
model: modelName,
|
|
10923
|
+
contents,
|
|
10924
|
+
config: config2
|
|
10875
10925
|
});
|
|
10876
|
-
const
|
|
10877
|
-
|
|
10926
|
+
const response = result;
|
|
10927
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
10928
|
+
if (!rawText) {
|
|
10878
10929
|
throw new Error("AI did not return a valid structured output.");
|
|
10879
10930
|
}
|
|
10931
|
+
const aiGeneratedContent = JSON.parse(rawText);
|
|
10932
|
+
const validatedOutput = GenerateSingleKnowledgeCardOutputSchema.parse(aiGeneratedContent);
|
|
10880
10933
|
return validatedOutput;
|
|
10881
10934
|
} catch (error) {
|
|
10882
10935
|
console.error(`Error generating knowledge card for concept "${clientInput.concept}":`, error);
|
|
@@ -10912,10 +10965,7 @@ var AssessAndMapDocumentOutputSchema = z.object({
|
|
|
10912
10965
|
// src/ai/flows/assess-and-map-document.ts
|
|
10913
10966
|
async function assessAndMapDocument(clientInput, apiKey) {
|
|
10914
10967
|
try {
|
|
10915
|
-
const
|
|
10916
|
-
plugins: [googleAI({ apiKey })],
|
|
10917
|
-
model: gemini20Flash
|
|
10918
|
-
});
|
|
10968
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
10919
10969
|
const { language: language3, documentContent, learningObjectives } = clientInput;
|
|
10920
10970
|
const relevanceThreshold = 40;
|
|
10921
10971
|
const promptText = `
|
|
@@ -10963,8 +11013,17 @@ Return a single, valid JSON object in this EXACT format. Do not include any othe
|
|
|
10963
11013
|
|
|
10964
11014
|
If the document is not relevant at all, the "mappedLOs" array should be empty, and the "relevanceScore" should be low.
|
|
10965
11015
|
`;
|
|
10966
|
-
const
|
|
10967
|
-
const
|
|
11016
|
+
const modelName = "gemini-1.5-flash";
|
|
11017
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
11018
|
+
const result = await genAI.models.generateContent({
|
|
11019
|
+
model: modelName,
|
|
11020
|
+
contents
|
|
11021
|
+
});
|
|
11022
|
+
const response = result;
|
|
11023
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
11024
|
+
if (!rawText) {
|
|
11025
|
+
throw new Error("AI returned an empty response.");
|
|
11026
|
+
}
|
|
10968
11027
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
10969
11028
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
10970
11029
|
const validatedOutput = AssessAndMapDocumentOutputSchema.parse(aiGeneratedContent);
|
|
@@ -10996,10 +11055,7 @@ var GenerateQuizFromTextOutputSchema = z.object({
|
|
|
10996
11055
|
var AnyGeneratedQuestionSchema2 = GenerateQuizFromTextOutputSchema.shape.generatedQuestions.element;
|
|
10997
11056
|
async function generateQuizFromText(clientInput, apiKey) {
|
|
10998
11057
|
try {
|
|
10999
|
-
const
|
|
11000
|
-
plugins: [googleAI({ apiKey })],
|
|
11001
|
-
model: gemini20Flash
|
|
11002
|
-
});
|
|
11058
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
11003
11059
|
const { language: language3, documentContent, numQuestions, questionTypes } = clientInput;
|
|
11004
11060
|
const allowedTypes = questionTypes || ["multiple_choice", "true_false"];
|
|
11005
11061
|
const promptText = `
|
|
@@ -11053,8 +11109,17 @@ Return the response as a single JSON object with a key "generatedQuestions" cont
|
|
|
11053
11109
|
\`\`\`
|
|
11054
11110
|
|
|
11055
11111
|
Now, generate the JSON response.`;
|
|
11056
|
-
const
|
|
11057
|
-
const
|
|
11112
|
+
const modelName = "gemini-1.5-flash";
|
|
11113
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
11114
|
+
const result = await genAI.models.generateContent({
|
|
11115
|
+
model: modelName,
|
|
11116
|
+
contents
|
|
11117
|
+
});
|
|
11118
|
+
const response = result;
|
|
11119
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
11120
|
+
if (!rawText) {
|
|
11121
|
+
throw new Error("AI returned an empty response.");
|
|
11122
|
+
}
|
|
11058
11123
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
11059
11124
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
11060
11125
|
if (!aiGeneratedContent.generatedQuestions || !Array.isArray(aiGeneratedContent.generatedQuestions)) {
|
|
@@ -103599,9 +103664,11 @@ function QuestionFormDialog({
|
|
|
103599
103664
|
toast2({ title: "Validation Error", description: "Question content is missing. Please create or edit the question details.", variant: "destructive" });
|
|
103600
103665
|
return;
|
|
103601
103666
|
}
|
|
103602
|
-
startTransition(() => {
|
|
103667
|
+
startTransition(async () => {
|
|
103603
103668
|
try {
|
|
103604
103669
|
const finalDataPayload = {
|
|
103670
|
+
id: questionToEdit?.id || "",
|
|
103671
|
+
// Will be ignored for new items, used for updates
|
|
103605
103672
|
code: code4,
|
|
103606
103673
|
text: questionConfig.prompt.replace(/<[^>]*>?/gm, "").substring(0, 200),
|
|
103607
103674
|
subjectCode,
|
|
@@ -103610,6 +103677,8 @@ function QuestionFormDialog({
|
|
|
103610
103677
|
bloomLevelCode,
|
|
103611
103678
|
questionTypeCode: questionConfig.questionType,
|
|
103612
103679
|
difficulty: questionConfig.difficulty,
|
|
103680
|
+
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
103681
|
+
// This will be set by the saving service
|
|
103613
103682
|
questionConfig: {
|
|
103614
103683
|
...questionConfig,
|
|
103615
103684
|
subject: subjectCode,
|
|
@@ -103618,14 +103687,7 @@ function QuestionFormDialog({
|
|
|
103618
103687
|
bloomLevel: bloomLevelCode
|
|
103619
103688
|
}
|
|
103620
103689
|
};
|
|
103621
|
-
|
|
103622
|
-
QuestionBankService.updateQuestion(questionToEdit.id, finalDataPayload);
|
|
103623
|
-
toast2({ title: "Success", description: "Question updated." });
|
|
103624
|
-
} else {
|
|
103625
|
-
QuestionBankService.addQuestion(finalDataPayload);
|
|
103626
|
-
toast2({ title: "Success", description: "Question added." });
|
|
103627
|
-
}
|
|
103628
|
-
onSave();
|
|
103690
|
+
await onSave(finalDataPayload);
|
|
103629
103691
|
onOpenChange(false);
|
|
103630
103692
|
} catch (error) {
|
|
103631
103693
|
toast2({ title: "Error", description: error.message || "Failed to save question.", variant: "destructive" });
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
|
-
var
|
|
5
|
-
var googleai = require('@genkit-ai/googleai');
|
|
4
|
+
var genai = require('@google/genai');
|
|
6
5
|
var JSZip = require('jszip');
|
|
7
6
|
|
|
8
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -814,10 +813,7 @@ var EvaluateUserCodeOutputSchema = AIEvaluationOutputSchema;
|
|
|
814
813
|
// src/ai/flows/evaluate-user-code.ts
|
|
815
814
|
async function evaluateUserCode(clientInput, apiKey) {
|
|
816
815
|
try {
|
|
817
|
-
const
|
|
818
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
819
|
-
model: googleai.gemini20Flash
|
|
820
|
-
});
|
|
816
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
821
817
|
const { language, problemPrompt, userCode, testCase } = clientInput;
|
|
822
818
|
const promptText = `
|
|
823
819
|
You are an expert Code Judge and Teaching Assistant for a ${language} programming course.
|
|
@@ -854,8 +850,17 @@ Return ONLY the JSON object with this EXACT structure.
|
|
|
854
850
|
\`\`\`
|
|
855
851
|
|
|
856
852
|
Return only the JSON response.`;
|
|
857
|
-
const
|
|
858
|
-
const
|
|
853
|
+
const modelName = "gemini-1.5-flash";
|
|
854
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
855
|
+
const result = await genAI.models.generateContent({
|
|
856
|
+
model: modelName,
|
|
857
|
+
contents
|
|
858
|
+
});
|
|
859
|
+
const response = result;
|
|
860
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
861
|
+
if (!rawText) {
|
|
862
|
+
throw new Error("AI returned an empty response.");
|
|
863
|
+
}
|
|
859
864
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
860
865
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
861
866
|
return EvaluateUserCodeOutputSchema.parse(aiGeneratedContent);
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import { gemini20Flash, googleAI } from '@genkit-ai/googleai';
|
|
2
|
+
import { GoogleGenAI } from '@google/genai';
|
|
4
3
|
import JSZip from 'jszip';
|
|
5
4
|
|
|
6
5
|
// src/services/SCORMService.ts
|
|
@@ -808,10 +807,7 @@ var EvaluateUserCodeOutputSchema = AIEvaluationOutputSchema;
|
|
|
808
807
|
// src/ai/flows/evaluate-user-code.ts
|
|
809
808
|
async function evaluateUserCode(clientInput, apiKey) {
|
|
810
809
|
try {
|
|
811
|
-
const
|
|
812
|
-
plugins: [googleAI({ apiKey })],
|
|
813
|
-
model: gemini20Flash
|
|
814
|
-
});
|
|
810
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
815
811
|
const { language, problemPrompt, userCode, testCase } = clientInput;
|
|
816
812
|
const promptText = `
|
|
817
813
|
You are an expert Code Judge and Teaching Assistant for a ${language} programming course.
|
|
@@ -848,8 +844,17 @@ Return ONLY the JSON object with this EXACT structure.
|
|
|
848
844
|
\`\`\`
|
|
849
845
|
|
|
850
846
|
Return only the JSON response.`;
|
|
851
|
-
const
|
|
852
|
-
const
|
|
847
|
+
const modelName = "gemini-1.5-flash";
|
|
848
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
849
|
+
const result = await genAI.models.generateContent({
|
|
850
|
+
model: modelName,
|
|
851
|
+
contents
|
|
852
|
+
});
|
|
853
|
+
const response = result;
|
|
854
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
855
|
+
if (!rawText) {
|
|
856
|
+
throw new Error("AI returned an empty response.");
|
|
857
|
+
}
|
|
853
858
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
854
859
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
855
860
|
return EvaluateUserCodeOutputSchema.parse(aiGeneratedContent);
|
package/dist/player.cjs
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
var React72 = require('react');
|
|
4
4
|
var ReactDOM5 = require('react-dom/client');
|
|
5
5
|
var zod = require('zod');
|
|
6
|
-
var
|
|
7
|
-
var googleai = require('@genkit-ai/googleai');
|
|
6
|
+
var genai = require('@google/genai');
|
|
8
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
8
|
var ReactDOM4 = require('react-dom');
|
|
10
9
|
var default2 = require('path');
|
|
@@ -3030,10 +3029,7 @@ var EvaluateUserCodeOutputSchema = AIEvaluationOutputSchema;
|
|
|
3030
3029
|
// src/ai/flows/evaluate-user-code.ts
|
|
3031
3030
|
async function evaluateUserCode(clientInput, apiKey) {
|
|
3032
3031
|
try {
|
|
3033
|
-
const
|
|
3034
|
-
plugins: [googleai.googleAI({ apiKey })],
|
|
3035
|
-
model: googleai.gemini20Flash
|
|
3036
|
-
});
|
|
3032
|
+
const genAI = new genai.GoogleGenAI({ apiKey });
|
|
3037
3033
|
const { language: language3, problemPrompt, userCode, testCase } = clientInput;
|
|
3038
3034
|
const promptText = `
|
|
3039
3035
|
You are an expert Code Judge and Teaching Assistant for a ${language3} programming course.
|
|
@@ -3070,8 +3066,17 @@ Return ONLY the JSON object with this EXACT structure.
|
|
|
3070
3066
|
\`\`\`
|
|
3071
3067
|
|
|
3072
3068
|
Return only the JSON response.`;
|
|
3073
|
-
const
|
|
3074
|
-
const
|
|
3069
|
+
const modelName = "gemini-1.5-flash";
|
|
3070
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
3071
|
+
const result = await genAI.models.generateContent({
|
|
3072
|
+
model: modelName,
|
|
3073
|
+
contents
|
|
3074
|
+
});
|
|
3075
|
+
const response = result;
|
|
3076
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
3077
|
+
if (!rawText) {
|
|
3078
|
+
throw new Error("AI returned an empty response.");
|
|
3079
|
+
}
|
|
3075
3080
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
3076
3081
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
3077
3082
|
return EvaluateUserCodeOutputSchema.parse(aiGeneratedContent);
|
package/dist/player.mjs
CHANGED
|
@@ -2,8 +2,7 @@ import * as React72 from 'react';
|
|
|
2
2
|
import React72__default, { createContext, forwardRef, createElement, useRef, useState, useImperativeHandle, useCallback, useEffect, useLayoutEffect, useContext, useMemo } from 'react';
|
|
3
3
|
import ReactDOM5 from 'react-dom/client';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import {
|
|
6
|
-
import { gemini20Flash, googleAI } from '@genkit-ai/googleai';
|
|
5
|
+
import { GoogleGenAI } from '@google/genai';
|
|
7
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
7
|
import * as ReactDOM4 from 'react-dom';
|
|
9
8
|
import ReactDOM4__default from 'react-dom';
|
|
@@ -3004,10 +3003,7 @@ var EvaluateUserCodeOutputSchema = AIEvaluationOutputSchema;
|
|
|
3004
3003
|
// src/ai/flows/evaluate-user-code.ts
|
|
3005
3004
|
async function evaluateUserCode(clientInput, apiKey) {
|
|
3006
3005
|
try {
|
|
3007
|
-
const
|
|
3008
|
-
plugins: [googleAI({ apiKey })],
|
|
3009
|
-
model: gemini20Flash
|
|
3010
|
-
});
|
|
3006
|
+
const genAI = new GoogleGenAI({ apiKey });
|
|
3011
3007
|
const { language: language3, problemPrompt, userCode, testCase } = clientInput;
|
|
3012
3008
|
const promptText = `
|
|
3013
3009
|
You are an expert Code Judge and Teaching Assistant for a ${language3} programming course.
|
|
@@ -3044,8 +3040,17 @@ Return ONLY the JSON object with this EXACT structure.
|
|
|
3044
3040
|
\`\`\`
|
|
3045
3041
|
|
|
3046
3042
|
Return only the JSON response.`;
|
|
3047
|
-
const
|
|
3048
|
-
const
|
|
3043
|
+
const modelName = "gemini-1.5-flash";
|
|
3044
|
+
const contents = [{ role: "user", parts: [{ text: promptText }] }];
|
|
3045
|
+
const result = await genAI.models.generateContent({
|
|
3046
|
+
model: modelName,
|
|
3047
|
+
contents
|
|
3048
|
+
});
|
|
3049
|
+
const response = result;
|
|
3050
|
+
const rawText = response.candidates?.[0]?.content?.parts?.[0]?.text || "";
|
|
3051
|
+
if (!rawText) {
|
|
3052
|
+
throw new Error("AI returned an empty response.");
|
|
3053
|
+
}
|
|
3049
3054
|
const jsonText = extractJsonFromMarkdown(rawText);
|
|
3050
3055
|
const aiGeneratedContent = JSON.parse(jsonText);
|
|
3051
3056
|
return EvaluateUserCodeOutputSchema.parse(aiGeneratedContent);
|