File size: 45,991 Bytes
68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 186b8a3 68639d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Financial Question Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.category-chip {
transition: all 0.3s ease;
}
.category-chip:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.question-card {
transition: all 0.3s ease;
}
.question-card:hover {
transform: translateY(-3px);
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}
.loading-spinner {
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.tab-active {
border-bottom: 3px solid #3b82f6;
color: #3b82f6;
font-weight: 600;
}
.shake {
animation: shake 0.5s linear;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
20%, 60% { transform: translateX(-5px); }
40%, 80% { transform: translateX(5px); }
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-8">
<header class="mb-10 text-center">
<h1 class="text-4xl font-bold text-blue-600 mb-2">Financial Question Generator</h1>
<p class="text-gray-600 text-lg">Generate unlimited English questions for financial and wallet-related scenarios</p>
</header>
<div class="bg-white rounded-xl shadow-lg p-6 mb-8">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h2 class="text-xl font-semibold mb-4 text-gray-800">Generation Settings</h2>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Number of Questions</label>
<input type="number" id="questionCount" min="1" max="100" value="10" class="w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Difficulty Level</label>
<div class="flex space-x-2">
<button data-difficulty="simple" class="difficulty-btn px-4 py-2 bg-green-100 text-green-800 rounded-lg hover:bg-green-200">Simple</button>
<button data-difficulty="medium" class="difficulty-btn px-4 py-2 bg-yellow-100 text-yellow-800 rounded-lg hover:bg-yellow-200">Medium</button>
<button data-difficulty="complex" class="difficulty-btn px-4 py-2 bg-red-100 text-red-800 rounded-lg hover:bg-red-200">Complex</button>
<button data-difficulty="random" class="difficulty-btn px-4 py-2 bg-gray-100 text-gray-800 rounded-lg hover:bg-gray-200">Random</button>
</div>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Categories (Select at least one)</label>
<div class="flex flex-wrap gap-2">
<button data-category="deposit" class="category-chip px-3 py-1 bg-blue-100 text-blue-800 rounded-full hover:bg-blue-200">Deposit</button>
<button data-category="transfer" class="category-chip px-3 py-1 bg-purple-100 text-purple-800 rounded-full hover:bg-purple-200">Transfer</button>
<button data-category="withdrawal" class="category-chip px-3 py-1 bg-indigo-100 text-indigo-800 rounded-full hover:bg-indigo-200">Withdrawal</button>
<button data-category="security" class="category-chip px-3 py-1 bg-red-100 text-red-800 rounded-full hover:bg-red-200">Account Security</button>
<button data-category="payment" class="category-chip px-3 py-1 bg-green-100 text-green-800 rounded-full hover:bg-green-200">Payment</button>
<button data-category="card" class="category-chip px-3 py-1 bg-yellow-100 text-yellow-800 rounded-full hover:bg-yellow-200">Card Management</button>
<button data-category="billing" class="category-chip px-3 py-1 bg-pink-100 text-pink-800 rounded-full hover:bg-pink-200">Billing & Records</button>
<button data-category="basic" class="category-chip px-3 py-1 bg-gray-100 text-gray-800 rounded-full hover:bg-gray-200">Basic Features</button>
<button data-category="other" class="category-chip px-3 py-1 bg-teal-100 text-teal-800 rounded-full hover:bg-teal-200">Other</button>
</div>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Custom Prompt (Optional)</label>
<textarea id="customPrompt" rows="3" class="w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Add any specific instructions for question generation..."></textarea>
</div>
<button id="generateBtn" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-4 rounded-lg transition duration-300 flex items-center justify-center">
<i class="fas fa-bolt mr-2"></i> Generate Questions
</button>
</div>
<div>
<h2 class="text-xl font-semibold mb-4 text-gray-800">RAG & User Feedback</h2>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Import External Data</label>
<div class="flex items-center space-x-2">
<input type="file" id="externalData" class="hidden">
<button id="uploadBtn" class="px-4 py-2 bg-gray-200 text-gray-800 rounded-lg hover:bg-gray-300 flex items-center">
<i class="fas fa-file-upload mr-2"></i> Choose File
</button>
<span id="fileName" class="text-gray-500 text-sm">No file selected</span>
</div>
<p class="text-xs text-gray-500 mt-1">Supported formats: .txt, .pdf, .docx, .csv</p>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Provide Suggestion</label>
<textarea id="userSuggestion" rows="2" class="w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Suggest improvements for generated questions..."></textarea>
<button id="submitSuggestion" class="mt-2 px-4 py-2 bg-emerald-600 text-white rounded-lg hover:bg-emerald-700">
<i class="fas fa-lightbulb mr-2"></i> Submit Suggestion
</button>
</div>
<div id="apiStatus" class="p-3 rounded-lg bg-blue-50 border border-blue-200 flex items-center">
<div class="w-3 h-3 rounded-full bg-blue-500 mr-2 animate-pulse"></div>
<span class="text-sm text-blue-700">Connected to DeepSeek API</span>
<i class="fas fa-check-circle ml-auto text-green-500"></i>
</div>
<div class="bg-blue-50 p-4 rounded-lg mt-4">
<h3 class="font-semibold text-blue-800 mb-2 flex items-center">
<i class="fas fa-info-circle mr-2"></i> Generation Process
</h3>
<p class="text-sm text-blue-700">
Questions are generated using DeepSeek's AI model through integrated API. For large batches, multiple API calls will be made automatically. Each question is categorized and checked for quality.
</p>
</div>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl font-semibold text-gray-800">Generated Questions</h2>
<div class="flex space-x-2">
<button id="exportBtn" class="px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 flex items-center">
<i class="fas fa-file-export mr-2"></i> Export
</button>
<button id="clearBtn" class="px-4 py-2 bg-gray-200 text-gray-800 rounded-lg hover:bg-gray-300 flex items-center">
<i class="fas fa-trash-alt mr-2"></i> Clear
</button>
</div>
</div>
<div class="border-b border-gray-200 mb-4">
<div class="flex space-x-6 overflow-x-auto pb-2">
<button data-tab="all" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">All</button>
<button data-tab="deposit" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Deposit</button>
<button data-tab="transfer" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Transfer</button>
<button data-tab="withdrawal" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Withdrawal</button>
<button data-tab="security" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Security</button>
<button data-tab="payment" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Payment</button>
<button data-tab="card" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Card</button>
<button data-tab="billing" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Billing</button>
<button data-tab="basic" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Basic</button>
<button data-tab="other" class="tab-btn whitespace-nowrap pb-2 px-1 text-gray-600 hover:text-blue-600">Other</button>
</div>
</div>
<div id="loadingIndicator" class="text-center py-8 hidden">
<div class="inline-block loading-spinner text-blue-500 text-4xl mb-2">
<i class="fas fa-circle-notch"></i>
</div>
<p class="text-gray-600">Generating questions using DeepSeek API...</p>
<p id="progressText" class="text-sm text-gray-500 mt-1">Processing 0/0</p>
</div>
<div id="questionsContainer" class="space-y-4">
<div class="text-center py-12 text-gray-500">
<i class="fas fa-comment-dots text-4xl mb-3"></i>
<p>No questions generated yet. Configure your settings and click "Generate Questions".</p>
</div>
</div>
<div id="pagination" class="mt-6 flex justify-between items-center hidden">
<button id="prevPage" class="px-4 py-2 bg-gray-200 text-gray-800 rounded-lg hover:bg-gray-300 disabled:opacity-50">
<i class="fas fa-chevron-left mr-2"></i> Previous
</button>
<span id="pageInfo" class="text-gray-600">Page 1 of 1</span>
<button id="nextPage" class="px-4 py-2 bg-gray-200 text-gray-800 rounded-lg hover:bg-gray-300 disabled:opacity-50">
Next <i class="fas fa-chevron-right ml-2"></i>
</button>
</div>
</div>
</div>
<!-- Export Modal -->
<div id="exportModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold">Export Questions</h3>
<button id="closeExportModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Format</label>
<div class="flex space-x-2">
<button data-format="csv" class="export-format-btn px-4 py-2 bg-blue-100 text-blue-800 rounded-lg hover:bg-blue-200">CSV</button>
<button data-format="json" class="export-format-btn px-4 py-2 bg-green-100 text-green-800 rounded-lg hover:bg-green-200">JSON</button>
<button data-format="txt" class="export-format-btn px-4 py-2 bg-purple-100 text-purple-800 rounded-lg hover:bg-purple-200">Text</button>
</div>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Filter</label>
<select id="exportFilter" class="w-full px-4 py-2 border rounded-lg">
<option value="all">All Questions</option>
<option value="current">Current View</option>
<option value="selected">Selected Questions</option>
</select>
</div>
<button id="confirmExport" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg">
<i class="fas fa-download mr-2"></i> Export
</button>
</div>
</div>
<!-- Suggestion Feedback Modal -->
<div id="suggestionModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold">Feedback Submitted</h3>
<button id="closeSuggestionModal" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="flex items-center">
<div class="w-12 h-12 bg-green-100 rounded-full flex items-center justify-center mr-4">
<i class="fas fa-check text-green-500 text-xl"></i>
</div>
<div>
<p class="text-gray-700">Thank you for your suggestion!</p>
<p class="text-sm text-gray-500 mt-1">Your feedback will help improve future question generations.</p>
</div>
</div>
<button id="okSuggestionBtn" class="w-full mt-6 bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg">
OK
</button>
</div>
</div>
<script>
// DOM Elements
const generateBtn = document.getElementById('generateBtn');
const exportBtn = document.getElementById('exportBtn');
const clearBtn = document.getElementById('clearBtn');
const questionCount = document.getElementById('questionCount');
const customPrompt = document.getElementById('customPrompt');
const questionsContainer = document.getElementById('questionsContainer');
const loadingIndicator = document.getElementById('loadingIndicator');
const progressText = document.getElementById('progressText');
const difficultyBtns = document.querySelectorAll('.difficulty-btn');
const categoryChips = document.querySelectorAll('.category-chip');
const tabBtns = document.querySelectorAll('.tab-btn');
const exportModal = document.getElementById('exportModal');
const closeExportModal = document.getElementById('closeExportModal');
const exportFormatBtns = document.querySelectorAll('.export-format-btn');
const confirmExport = document.getElementById('confirmExport');
const exportFilter = document.getElementById('exportFilter');
const prevPage = document.getElementById('prevPage');
const nextPage = document.getElementById('nextPage');
const pageInfo = document.getElementById('pageInfo');
const pagination = document.getElementById('pagination');
const uploadBtn = document.getElementById('uploadBtn');
const externalData = document.getElementById('externalData');
const fileName = document.getElementById('fileName');
const userSuggestion = document.getElementById('userSuggestion');
const submitSuggestion = document.getElementById('submitSuggestion');
const suggestionModal = document.getElementById('suggestionModal');
const closeSuggestionModal = document.getElementById('closeSuggestionModal');
const okSuggestionBtn = document.getElementById('okSuggestionBtn');
const apiStatus = document.getElementById('apiStatus');
// State variables
let selectedCategories = new Set(['deposit', 'transfer', 'withdrawal', 'security', 'payment', 'card', 'billing', 'basic', 'other']);
let selectedDifficulty = 'random';
let currentTab = 'all';
let currentPage = 1;
const questionsPerPage = 10;
let allQuestions = [];
let displayedQuestions = [];
let selectedExportFormat = 'csv';
let externalDataContent = '';
// Initialize
document.addEventListener('DOMContentLoaded', () => {
// Set default active tab
document.querySelector('[data-tab="all"]').classList.add('tab-active');
// Set default active difficulty
document.querySelector('[data-difficulty="random"]').classList.add('bg-blue-200');
// Set default active export format
document.querySelector('[data-format="csv"]').classList.add('bg-blue-200', 'text-blue-800');
});
// Event Listeners
generateBtn.addEventListener('click', generateQuestions);
exportBtn.addEventListener('click', () => exportModal.classList.remove('hidden'));
clearBtn.addEventListener('click', clearQuestions);
closeExportModal.addEventListener('click', () => exportModal.classList.add('hidden'));
uploadBtn.addEventListener('click', () => externalData.click());
externalData.addEventListener('change', handleFileUpload);
prevPage.addEventListener('click', () => navigatePage(-1));
nextPage.addEventListener('click', () => navigatePage(1));
submitSuggestion.addEventListener('click', submitUserSuggestion);
closeSuggestionModal.addEventListener('click', () => suggestionModal.classList.add('hidden'));
okSuggestionBtn.addEventListener('click', () => suggestionModal.classList.add('hidden'));
// Difficulty buttons
difficultyBtns.forEach(btn => {
btn.addEventListener('click', () => {
difficultyBtns.forEach(b => {
b.classList.remove('bg-blue-200');
b.classList.remove('ring-2', 'ring-blue-500');
});
btn.classList.add('bg-blue-200');
selectedDifficulty = btn.dataset.difficulty;
});
});
// Category chips
categoryChips.forEach(chip => {
chip.addEventListener('click', () => {
const category = chip.dataset.category;
if (selectedCategories.has(category)) {
selectedCategories.delete(category);
chip.classList.remove('bg-blue-200');
} else {
selectedCategories.add(category);
chip.classList.add('bg-blue-200');
}
// Visual feedback
if (selectedCategories.size === 0) {
chip.classList.add('shake');
setTimeout(() => chip.classList.remove('shake'), 500);
document.querySelectorAll('.category-chip').forEach(c => {
c.classList.add('ring-2', 'ring-red-500');
});
} else {
document.querySelectorAll('.category-chip').forEach(c => {
c.classList.remove('ring-2', 'ring-red-500');
});
}
});
});
// Tab buttons
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
tabBtns.forEach(b => b.classList.remove('tab-active'));
btn.classList.add('tab-active');
currentTab = btn.dataset.tab;
filterQuestions();
});
});
// Export format buttons
exportFormatBtns.forEach(btn => {
btn.addEventListener('click', () => {
exportFormatBtns.forEach(b => b.classList.remove('bg-blue-200', 'text-blue-800'));
btn.classList.add('bg-blue-200', 'text-blue-800');
selectedExportFormat = btn.dataset.format;
});
});
confirmExport.addEventListener('click', exportQuestions);
// Functions
async function generateQuestions() {
if (selectedCategories.size === 0) {
alert('Please select at least one category.');
return;
}
const count = parseInt(questionCount.value);
if (isNaN(count) || count < 1 || count > 100) {
alert('Please enter a valid number between 1 and 100.');
return;
}
// Show loading indicator
loadingIndicator.classList.remove('hidden');
questionsContainer.innerHTML = '';
try {
const batchSize = 5; // Number of questions per API call
const batches = Math.ceil(count / batchSize);
allQuestions = [];
for (let i = 0; i < batches; i++) {
const currentBatchSize = i === batches - 1 ? count - (i * batchSize) : batchSize;
progressText.textContent = `Processing ${i * batchSize}/${count}`;
// Prepare prompt for API call
const categoriesList = Array.from(selectedCategories).join(', ');
const prompt = `Generate ${currentBatchSize} ${selectedDifficulty} English questions about ${categoriesList} in financial/wallet services. ` +
`Ensure questions are varied and avoid redundancy. ${customPrompt.value}`;
// Call DeepSeek API (simulated in this example)
const batchQuestions = await callDeepSeekApi(prompt, currentBatchSize);
allQuestions = [...allQuestions, ...batchQuestions];
}
// Display questions
filterQuestions();
loadingIndicator.classList.add('hidden');
} catch (error) {
console.error('Error generating questions:', error);
loadingIndicator.classList.add('hidden');
questionsContainer.innerHTML = `
<div class="text-center py-12 text-red-500">
<i class="fas fa-exclamation-triangle text-4xl mb-3"></i>
<p>Error generating questions. Please try again.</p>
</div>
`;
}
}
// Simulate DeepSeek API call with realistic financial questions
async function callDeepSeekApi(prompt, count) {
// In a real implementation, this would make an actual API call
// For this example, we'll simulate the API response with realistic questions
// Simulate API delay (500-1500ms)
const delay = 500 + Math.random() * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
// Generate realistic financial questions based on the prompt
const categories = Array.from(selectedCategories);
const batchQuestions = [];
for (let i = 0; i < count; i++) {
const category = categories[Math.floor(Math.random() * categories.length)];
const difficulty = selectedDifficulty === 'random'
? ['simple', 'medium', 'complex'][Math.floor(Math.random() * 3)]
: selectedDifficulty;
const question = generateRealisticQuestion(category, difficulty);
batchQuestions.push({
id: Date.now() + i,
text: question,
category: category,
difficulty: difficulty,
generatedAt: new Date().toISOString()
});
}
return batchQuestions;
}
function generateRealisticQuestion(category, difficulty) {
// Realistic question templates for each category and difficulty
const questions = {
deposit: {
simple: [
"How do I deposit money into my digital wallet?",
"What payment methods can I use for deposits?",
"Is there a minimum amount for deposits?"
],
medium: [
"Why is my deposit taking longer than usual to process?",
"Can I deposit funds from an international bank account?",
"What are the deposit limits for unverified accounts?"
],
complex: [
"How does the deposit reconciliation process work during weekends?",
"What security protocols are in place for large deposit transactions?",
"Can you explain the multi-signature verification process for deposits?"
]
},
transfer: {
simple: [
"How do I send money to another user?",
"What's the maximum amount I can transfer in one transaction?",
"How long do transfers usually take?"
],
medium: [
"Why was my transfer returned by the recipient's bank?",
"Can I schedule recurring transfers to family members?",
"How do foreign currency transfers work?"
],
complex: [
"What are the tax implications for international transfers over $10,000?",
"How does the blockchain verification process work for crypto transfers?",
"Can you explain the interbank settlement procedures for instant transfers?"
]
},
withdrawal: {
simple: [
"How do I withdraw money to my bank account?",
"Are there any fees for withdrawals?",
"How long does a withdrawal take to process?"
],
medium: [
"Why does my withdrawal request keep getting declined?",
"Can I withdraw to a different bank than my deposit source?",
"What are the tax reporting requirements for large withdrawals?"
],
complex: [
"How are AML checks performed on high-value withdrawal requests?",
"What are the reserve requirements that affect withdrawal processing times?",
"Can you explain the cross-border clearance process for international withdrawals?"
]
},
security: {
simple: [
"How do I create a strong password for my account?",
"What should I do if I lose my phone with my wallet app?",
"How does two-factor authentication work?"
],
medium: [
"Why did I receive a security alert for a login attempt?",
"Can I restrict transactions from certain locations?",
"How are my biometric data stored and protected?"
],
complex: [
"What cryptographic techniques are used to secure financial transactions?",
"How does the zero-knowledge proof verification process work?",
"Can you explain the multi-party computation protocol used for key management?"
]
},
payment: {
simple: [
"How do I pay a merchant using my digital wallet?",
"Can I split a payment with friends?",
"What's contactless payment and how does it work?"
],
medium: [
"Why was my payment to a merchant declined?",
"Can I dispute a payment after it's completed?",
"How do recurring subscription payments work?"
],
complex: [
"What are the PCI-DSS compliance requirements for tokenized payments?",
"How does the merchant acquiring bank authorization process work?",
"Can you explain the chargeback arbitration process?"
]
},
card: {
simple: [
"How do I add a debit card to my wallet?",
"Can I remove a saved card from my account?",
"What should I do if my card is lost or stolen?"
],
medium: [
"Why is my card verification failing during checkout?",
"Can I set spending limits for specific cards?",
"How do virtual card numbers work?"
],
complex: [
"How are card details tokenized during online transactions?",
"What are the EMV 3D Secure 2.0 authentication protocols?",
"Can you explain the card network settlement reconciliation process?"
]
},
billing: {
simple: [
"How do I view my transaction history?",
"Can I download my monthly statements?",
"Where can I see my current balance?"
],
medium: [
"Why is there a discrepancy in my transaction records?",
"Can I generate customized reports for tax purposes?",
"How do I categorize transactions for budgeting?"
],
complex: [
"What accounting standards are followed for transaction record-keeping?",
"How does the GL reconciliation process work across multiple currencies?",
"Can you explain the audit trail generation process?"
]
},
basic: {
simple: [
"How do I create an account?",
"What's the customer support phone number?",
"Where can I find the app settings?"
],
medium: [
"Why can't I receive the verification SMS?",
"Can I merge two accounts under one email?",
"How do I update my personal information?"
],
complex: [
"What identity verification protocols are used during KYC onboarding?",
"How does the real-time account monitoring system work?",
"Can you explain the multi-jurisdictional compliance process?"
]
},
other: {
simple: [
"What currencies does your service support?",
"Can I use this service while traveling abroad?",
"Where can I find your terms of service?"
],
medium: [
"Why can't I access certain features in my country?",
"Can I give limited access to an accountant?",
"How does interest accrual work on stored balances?"
],
complex: [
"What regulatory bodies oversee the financial services provided?",
"How are exchange rates calculated for multi-currency transactions?",
"Can you explain the liquidity provisions for fast settlements?"
]
}
};
// Get all possible questions for this category and difficulty
let possibleQuestions = questions[category][difficulty];
// If the difficulty was 'random', select from all difficulties
if (selectedDifficulty === 'random') {
possibleQuestions = [
...questions[category].simple,
...questions[category].medium,
...questions[category].complex
];
}
// Return a random question from the selection
return possibleQuestions[Math.floor(Math.random() * possibleQuestions.length)];
}
function filterQuestions() {
displayedQuestions = currentTab === 'all'
? allQuestions
: allQuestions.filter(q => q.category === currentTab);
currentPage = 1;
renderQuestions();
updatePagination();
}
function renderQuestions() {
if (displayedQuestions.length === 0) {
questionsContainer.innerHTML = `
<div class="text-center py-12 text-gray-500">
<i class="fas fa-comment-dots text-4xl mb-3"></i>
<p>No questions match the current filter.</p>
</div>
`;
pagination.classList.add('hidden');
return;
}
const startIdx = (currentPage - 1) * questionsPerPage;
const endIdx = startIdx + questionsPerPage;
const questionsToShow = displayedQuestions.slice(startIdx, endIdx);
questionsContainer.innerHTML = '';
questionsToShow.forEach(question => {
const categoryColors = {
deposit: 'bg-blue-100 text-blue-800',
transfer: 'bg-purple-100 text-purple-800',
withdrawal: 'bg-indigo-100 text-indigo-800',
security: 'bg-red-100 text-red-800',
payment: 'bg-green-100 text-green-800',
card: 'bg-yellow-100 text-yellow-800',
billing: 'bg-pink-100 text-pink-800',
basic: 'bg-gray-100 text-gray-800',
other: 'bg-teal-100 text-teal-800'
};
const difficultyColors = {
simple: 'text-green-600',
medium: 'text-yellow-600',
complex: 'text-red-600'
};
const questionEl = document.createElement('div');
questionEl.className = 'question-card bg-white p-4 rounded-lg border border-gray-200 shadow-sm';
questionEl.innerHTML = `
<div class="flex justify-between items-start mb-2">
<p class="font-medium text-gray-800">${question.text}</p>
<div class="flex space-x-2">
<span class="text-xs px-2 py-1 rounded-full ${categoryColors[question.category]}">${question.category}</span>
<span class="text-xs px-2 py-1 rounded-full bg-gray-100 text-gray-800 ${difficultyColors[question.difficulty]}">${question.difficulty}</span>
</div>
</div>
<div class="flex justify-between items-center text-xs text-gray-500">
<span>Generated: ${new Date(question.generatedAt).toLocaleString()}</span>
<div class="flex space-x-2">
<button data-id="${question.id}" class="edit-btn text-blue-500 hover:text-blue-700"><i class="fas fa-edit"></i></button>
<button data-id="${question.id}" class="delete-btn text-red-500 hover:text-red-700"><i class="fas fa-trash-alt"></i></button>
</div>
</div>
`;
questionsContainer.appendChild(questionEl);
});
// Add event listeners to edit and delete buttons
document.querySelectorAll('.edit-btn').forEach(btn => {
btn.addEventListener('click', (e) => editQuestion(e.target.closest('button').dataset.id));
});
document.querySelectorAll('.delete-btn').forEach(btn => {
btn.addEventListener('click', (e) => deleteQuestion(e.target.closest('button').dataset.id));
});
pagination.classList.remove('hidden');
}
function editQuestion(id) {
const question = allQuestions.find(q => q.id.toString() === id);
if (!question) return;
const newText = prompt("Edit question:", question.text);
if (newText && newText.trim() !== '') {
question.text = newText.trim();
renderQuestions();
}
}
function deleteQuestion(id) {
if (confirm("Are you sure you want to delete this question?")) {
allQuestions = allQuestions.filter(q => q.id.toString() !== id);
filterQuestions();
}
}
function updatePagination() {
const totalPages = Math.ceil(displayedQuestions.length / questionsPerPage);
pageInfo.textContent = `Page ${currentPage} of ${totalPages}`;
prevPage.disabled = currentPage === 1;
nextPage.disabled = currentPage === totalPages;
}
function navigatePage(direction) {
const totalPages = Math.ceil(displayedQuestions.length / questionsPerPage);
const newPage = currentPage + direction;
if (newPage > 0 && newPage <= totalPages) {
currentPage = newPage;
renderQuestions();
updatePagination();
}
}
function clearQuestions() {
if (allQuestions.length === 0 || confirm('Are you sure you want to clear all generated questions?')) {
allQuestions = [];
displayedQuestions = [];
questionsContainer.innerHTML = `
<div class="text-center py-12 text-gray-500">
<i class="fas fa-comment-dots text-4xl mb-3"></i>
<p>No questions generated yet. Configure your settings and click "Generate Questions".</p>
</div>
`;
pagination.classList.add('hidden');
}
}
function exportQuestions() {
let questionsToExport = [];
switch (exportFilter.value) {
case 'all':
questionsToExport = allQuestions;
break;
case 'current':
const startIdx = (currentPage - 1) * questionsPerPage;
const endIdx = startIdx + questionsPerPage;
questionsToExport = displayedQuestions.slice(startIdx, endIdx);
break;
case 'selected':
// In a real app, you would track selected questions
alert('No questions selected. Exporting all questions instead.');
questionsToExport = allQuestions;
break;
}
if (questionsToExport.length === 0) {
alert('No questions to export.');
return;
}
let content = '';
let mimeType = 'text/plain';
let extension = 'txt';
switch (selectedExportFormat) {
case 'csv':
content = 'ID,Question,Category,Difficulty,Generated At\n';
questionsToExport.forEach(q => {
content += `"${q.id}","${q.text}","${q.category}","${q.difficulty}","${q.generatedAt}"\n`;
});
mimeType = 'text/csv';
extension = 'csv';
break;
case 'json':
content = JSON.stringify(questionsToExport, null, 2);
mimeType = 'application/json';
extension = 'json';
break;
case 'txt':
questionsToExport.forEach(q => {
content += `Question: ${q.text}\n`;
content += `Category: ${q.category}\n`;
content += `Difficulty: ${q.difficulty}\n`;
content += `Generated At: ${q.generatedAt}\n\n`;
});
break;
}
const blob = new Blob([content], { type: mimeType });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `financial_questions_${new Date().toISOString().slice(0, 10)}.${extension}`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
exportModal.classList.add('hidden');
}
function handleFileUpload(event) {
const file = event.target.files[0];
if (!file) return;
fileName.textContent = file.name;
// In a real app, you would process the file content
// For demo purposes, we'll just store the filename
externalDataContent = file.name;
// Simulate processing
setTimeout(() => {
alert(`File "${file.name}" has been processed and is ready to be used for RAG.`);
}, 1000);
}
function submitUserSuggestion() {
const suggestion = userSuggestion.value.trim();
if (!suggestion) {
userSuggestion.classList.add('ring-2', 'ring-red-500');
setTimeout(() => userSuggestion.classList.remove('ring-2', 'ring-red-500'), 1000);
return;
}
// In a real app, you would send this to the API
console.log("User suggestion submitted:", suggestion);
// Show feedback modal
suggestionModal.classList.remove('hidden');
userSuggestion.value = '';
// After showing, this would be sent to DeepSeek API to improve future generations
// For this demo, we'll just log it
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=Bio-Du/financial-question-generator" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
</html> |