Commit ·
8ec90be
1
Parent(s): c5b3050
Duplicate the question
Browse files- src/app/page.tsx +19 -4
src/app/page.tsx
CHANGED
|
@@ -115,6 +115,24 @@ export default function QuestionBuilder() {
|
|
| 115 |
setIsEditModalOpen(false);
|
| 116 |
};
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
return (
|
| 119 |
<div className="min-h-screen bg-gray-50 dark:bg-[#212529]">
|
| 120 |
{/* Header */}
|
|
@@ -308,10 +326,7 @@ export default function QuestionBuilder() {
|
|
| 308 |
onQuestionReorder={reorderQuestions}
|
| 309 |
onQuestionEdit={handleEditQuestion}
|
| 310 |
editingQuestionId={editingQuestion?.id || null}
|
| 311 |
-
onQuestionDuplicate={
|
| 312 |
-
// TODO: Implement duplicate functionality
|
| 313 |
-
console.log('Duplicate question:', question);
|
| 314 |
-
}}
|
| 315 |
onQuestionPreview={(question) => {
|
| 316 |
// TODO: Implement preview functionality
|
| 317 |
console.log('Preview question:', question);
|
|
|
|
| 115 |
setIsEditModalOpen(false);
|
| 116 |
};
|
| 117 |
|
| 118 |
+
const handleDuplicateQuestion = (question: GeneratedQuestion) => {
|
| 119 |
+
const duplicatedQuestion: GeneratedQuestion = {
|
| 120 |
+
...question,
|
| 121 |
+
id: Date.now().toString(), // Generate new ID
|
| 122 |
+
stem: `${question.stem} (Copy)`, // Add "(Copy)" to distinguish
|
| 123 |
+
content: {
|
| 124 |
+
...question.content,
|
| 125 |
+
Question: `${question.content.Question} (Copy)`, // Also update the content.Question
|
| 126 |
+
},
|
| 127 |
+
createdAt: new Date(), // Update creation date
|
| 128 |
+
};
|
| 129 |
+
|
| 130 |
+
setQuestions(prev => [...prev, duplicatedQuestion]);
|
| 131 |
+
|
| 132 |
+
// Simple feedback - you could replace this with a proper toast notification
|
| 133 |
+
console.log('Question duplicated successfully!');
|
| 134 |
+
};
|
| 135 |
+
|
| 136 |
return (
|
| 137 |
<div className="min-h-screen bg-gray-50 dark:bg-[#212529]">
|
| 138 |
{/* Header */}
|
|
|
|
| 326 |
onQuestionReorder={reorderQuestions}
|
| 327 |
onQuestionEdit={handleEditQuestion}
|
| 328 |
editingQuestionId={editingQuestion?.id || null}
|
| 329 |
+
onQuestionDuplicate={handleDuplicateQuestion}
|
|
|
|
|
|
|
|
|
|
| 330 |
onQuestionPreview={(question) => {
|
| 331 |
// TODO: Implement preview functionality
|
| 332 |
console.log('Preview question:', question);
|