1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-02 13:52:46 +02:00
This commit is contained in:
Arik Chakma
2025-07-01 14:40:57 +06:00
parent 399ce72650
commit abf58dabcd
5 changed files with 57 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ import {
BookOpenIcon, BookOpenIcon,
FileTextIcon, FileTextIcon,
ListCheckIcon, ListCheckIcon,
ListIcon,
ListTodoIcon, ListTodoIcon,
MapIcon, MapIcon,
SparklesIcon, SparklesIcon,
@@ -25,6 +26,7 @@ import { cn } from '../../lib/classname';
import { getUrlParams } from '../../lib/browser'; import { getUrlParams } from '../../lib/browser';
import { useParams } from '../../hooks/use-params'; import { useParams } from '../../hooks/use-params';
import { FormatItem } from '../ContentGenerator/FormatItem'; import { FormatItem } from '../ContentGenerator/FormatItem';
import { AIQuizLayout } from './AIQuizLayout';
const allowedFormats = ['mcq', 'open-ended', 'mixed'] as const; const allowedFormats = ['mcq', 'open-ended', 'mixed'] as const;
export type AllowedFormat = (typeof allowedFormats)[number]; export type AllowedFormat = (typeof allowedFormats)[number];
@@ -56,22 +58,26 @@ export function AIQuizGenerator() {
const allowedFormats: { const allowedFormats: {
label: string; label: string;
formatTitle: string;
icon: LucideIcon; icon: LucideIcon;
value: AllowedFormat; value: AllowedFormat;
}[] = [ }[] = [
{ {
label: 'MCQ', label: 'MCQ',
formatTitle: 'Multiple Choice Question',
icon: ListTodoIcon, icon: ListTodoIcon,
value: 'mcq', value: 'mcq',
}, },
{ {
label: 'Open-Ended', label: 'Open-Ended',
formatTitle: 'Open-Ended Question',
icon: FileTextIcon, icon: FileTextIcon,
value: 'open-ended', value: 'open-ended',
}, },
{ {
label: 'Mixed', label: 'Mixed',
icon: MapIcon, formatTitle: 'Mixed Question (MCQ + Open-Ended)',
icon: ListIcon,
value: 'mixed', value: 'mixed',
}, },
]; ];
@@ -99,6 +105,9 @@ export function AIQuizGenerator() {
const trimmedTitle = title.trim(); const trimmedTitle = title.trim();
const canGenerate = trimmedTitle && trimmedTitle.length >= 3; const canGenerate = trimmedTitle && trimmedTitle.length >= 3;
const selectedFormatTitle = allowedFormats.find(
(f) => f.value === selectedFormat,
)?.formatTitle;
return ( return (
<div className="mx-auto flex w-full max-w-2xl flex-grow flex-col pt-4 md:justify-center md:pt-10 lg:pt-28 lg:pb-24"> <div className="mx-auto flex w-full max-w-2xl flex-grow flex-col pt-4 md:justify-center md:pt-10 lg:pt-28 lg:pb-24">
@@ -118,10 +127,10 @@ export function AIQuizGenerator() {
</div> </div>
)} )}
<h1 className="mb-0.5 text-center text-4xl font-semibold max-md:text-left max-md:text-xl lg:mb-3"> <h1 className="mb-0.5 text-center text-4xl font-semibold max-md:text-left max-md:text-xl lg:mb-3">
What can I help you learn? Test your Knowledge
</h1> </h1>
<p className="text-center text-lg text-balance text-gray-600 max-md:text-left max-md:text-sm"> <p className="text-center text-lg text-balance text-gray-600 max-md:text-left max-md:text-sm">
Enter a topic below to generate a personalized course for it Create a personalized quiz to test your understanding of any topic
</p> </p>
</div> </div>
@@ -134,12 +143,12 @@ export function AIQuizGenerator() {
> >
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<label htmlFor={titleFieldId} className="inline-block text-gray-500"> <label htmlFor={titleFieldId} className="inline-block text-gray-500">
What can I help you learn? What topic would you like to quiz yourself on?
</label> </label>
<input <input
type="text" type="text"
id={titleFieldId} id={titleFieldId}
placeholder="Enter a topic" placeholder="e.g., JavaScript fundamentals, Machine Learning basics"
value={title} value={title}
onChange={(e) => { onChange={(e) => {
setTitle(e.target.value); setTitle(e.target.value);
@@ -196,22 +205,22 @@ export function AIQuizGenerator() {
}} }}
/> />
<span className="max-sm:hidden"> <span className="max-sm:hidden">
Answer the following questions for a better {selectedFormat} Answer the following questions for a better result
</span> </span>
<span className="sm:hidden">Customize your {selectedFormat}</span> <span className="sm:hidden">Customize your quiz</span>
</label> </label>
{/* {showFineTuneOptions && ( {showFineTuneOptions && (
<QuestionAnswerChat <QuestionAnswerChat
term={title} term={title}
format={selectedFormat} format={selectedFormatTitle || selectedFormat}
questionAnswerChatMessages={questionAnswerChatMessages} questionAnswerChatMessages={questionAnswerChatMessages}
setQuestionAnswerChatMessages={setQuestionAnswerChatMessages} setQuestionAnswerChatMessages={setQuestionAnswerChatMessages}
onGenerateNow={() => { onGenerateNow={() => {
handleSubmit(); handleSubmit();
}} }}
/> />
)} */} )}
<button <button
type="submit" type="submit"
@@ -219,7 +228,7 @@ export function AIQuizGenerator() {
disabled={!canGenerate} disabled={!canGenerate}
> >
<SparklesIcon className="size-4" /> <SparklesIcon className="size-4" />
Generate Generate Quiz
</button> </button>
</form> </form>
</div> </div>

View File

@@ -0,0 +1,17 @@
import { AITutorLayout } from '../AITutor/AITutorLayout';
type AIQuizLayoutProps = {
children: React.ReactNode;
};
export function AIQuizLayout(props: AIQuizLayoutProps) {
const { children } = props;
return (
<AITutorLayout
wrapperClassName="flex-row p-0 lg:p-0 relative overflow-hidden bg-white"
containerClassName="h-[calc(100vh-49px)] overflow-hidden relative"
>
{children}
</AITutorLayout>
);
}

View File

@@ -1,6 +1,7 @@
import { import {
BookOpen, BookOpen,
Compass, Compass,
ListTodoIcon,
MessageCircle, MessageCircle,
Plus, Plus,
Star, Star,
@@ -39,6 +40,12 @@ const sidebarItems = [
href: '/ai/chat', href: '/ai/chat',
icon: MessageCircle, icon: MessageCircle,
}, },
{
key: 'quiz',
label: 'Test my Knowledge',
href: '/ai/quiz',
icon: ListTodoIcon,
},
{ {
key: 'library', key: 'library',
label: 'My Learning', label: 'My Learning',

View File

@@ -5,11 +5,7 @@ import {
type AIQuestionSuggestionsResponse, type AIQuestionSuggestionsResponse,
} from '../../queries/user-ai-session'; } from '../../queries/user-ai-session';
import type { AllowedFormat } from './ContentGenerator'; import type { AllowedFormat } from './ContentGenerator';
import { import { Loader2Icon, RefreshCcwIcon, SendIcon, Trash2 } from 'lucide-react';
Loader2Icon,
RefreshCcwIcon,
SendIcon, Trash2
} from 'lucide-react';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { cn } from '../../lib/classname'; import { cn } from '../../lib/classname';
import { flushSync } from 'react-dom'; import { flushSync } from 'react-dom';
@@ -26,7 +22,7 @@ export type QuestionAnswerChatMessage =
type QuestionAnswerChatProps = { type QuestionAnswerChatProps = {
term: string; term: string;
format: AllowedFormat; format: AllowedFormat | (string & {});
questionAnswerChatMessages: QuestionAnswerChatMessage[]; questionAnswerChatMessages: QuestionAnswerChatMessage[];
setQuestionAnswerChatMessages: ( setQuestionAnswerChatMessages: (
messages: QuestionAnswerChatMessage[], messages: QuestionAnswerChatMessage[],
@@ -259,7 +255,11 @@ export function QuestionAnswerChat(props: QuestionAnswerChatProps) {
value={message} value={message}
onChange={(e) => setMessage(e.target.value)} onChange={(e) => setMessage(e.target.value)}
className="w-full bg-transparent text-sm focus:outline-none" className="w-full bg-transparent text-sm focus:outline-none"
placeholder={activeMessage.possibleAnswers ? "Type your answer..." : "Or type your own answer..."} placeholder={
activeMessage.possibleAnswers
? 'Type your answer...'
: 'Or type your own answer...'
}
autoFocus autoFocus
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey) { if (e.key === 'Enter' && !e.shiftKey) {
@@ -346,7 +346,7 @@ function QuestionAnswerChatMessage(props: QuestionAnswerChatMessageProps) {
<div className="group relative"> <div className="group relative">
<button <button
type="button" type="button"
className="flex size-6 shrink-0 items-center justify-center rounded-md opacity-70 hover:bg-gray-100 hover:opacity-100 focus:outline-none text-gray-500" className="flex size-6 shrink-0 items-center justify-center rounded-md text-gray-500 opacity-70 hover:bg-gray-100 hover:opacity-100 focus:outline-none"
onClick={onEdit} onClick={onEdit}
> >
<Trash2 className="size-4" /> <Trash2 className="size-4" />

View File

@@ -1,5 +1,6 @@
--- ---
import { AIQuiz } from '../../../components/AIQuiz/AIQuiz'; import { AIQuizGenerator } from '../../../components/AIQuiz/AIQuizGenerator';
import { AITutorLayout } from '../../../components/AITutor/AITutorLayout';
import SkeletonLayout from '../../../layouts/SkeletonLayout.astro'; import SkeletonLayout from '../../../layouts/SkeletonLayout.astro';
--- ---
@@ -11,5 +12,7 @@ import SkeletonLayout from '../../../layouts/SkeletonLayout.astro';
canonicalUrl='/ai/quiz' canonicalUrl='/ai/quiz'
noIndex={true} noIndex={true}
> >
<AIQuiz client:load /> <AITutorLayout activeTab='quiz' client:load>
<AIQuizGenerator client:load />
</AITutorLayout>
</SkeletonLayout> </SkeletonLayout>