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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Quiz Parser</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
</head>
|
| 9 |
+
<body class="bg-gray-100 min-h-screen p-8">
|
| 10 |
+
<div class="max-w-4xl mx-auto bg-white shadow-lg rounded-lg p-6">
|
| 11 |
+
<h1 class="text-3xl font-bold mb-6 text-center text-gray-800">Quiz Parser</h1>
|
| 12 |
+
|
| 13 |
+
<!-- Quiz Input Section -->
|
| 14 |
+
<div class="mb-6">
|
| 15 |
+
<label for="quizInput" class="block text-sm font-medium text-gray-700 mb-2">Paste your quiz below:</label>
|
| 16 |
+
<textarea id="quizInput" class="w-full h-64 p-3 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500" placeholder="Paste quiz here..."></textarea>
|
| 17 |
+
</div>
|
| 18 |
+
|
| 19 |
+
<!-- Configuration Section -->
|
| 20 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
|
| 21 |
+
<div>
|
| 22 |
+
<label for="testInstruction" class="block text-sm font-medium text-gray-700 mb-1">Test Instruction:</label>
|
| 23 |
+
<input type="text" id="testInstruction" value="General Quiz Test" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
| 24 |
+
</div>
|
| 25 |
+
<div>
|
| 26 |
+
<label for="marks" class="block text-sm font-medium text-gray-700 mb-1">Marks per Question:</label>
|
| 27 |
+
<input type="number" id="marks" value="1" min="0" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
| 28 |
+
</div>
|
| 29 |
+
<div>
|
| 30 |
+
<label for="negativeMarks" class="block text-sm font-medium text-gray-700 mb-1">Negative Marks per Question:</label>
|
| 31 |
+
<input type="number" id="negativeMarks" value="0.25" min="0" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
| 32 |
+
</div>
|
| 33 |
+
<div>
|
| 34 |
+
<label for="tag" class="block text-sm font-medium text-gray-700 mb-1">Tag:</label>
|
| 35 |
+
<input type="text" id="tag" value="General Knowledge" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
| 36 |
+
</div>
|
| 37 |
+
<div>
|
| 38 |
+
<label for="difficulty" class="block text-sm font-medium text-gray-700 mb-1">Difficulty:</label>
|
| 39 |
+
<select id="difficulty" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
| 40 |
+
<option value="Easy">Easy</option>
|
| 41 |
+
<option value="Medium" selected>Medium</option>
|
| 42 |
+
<option value="Hard">Hard</option>
|
| 43 |
+
</select>
|
| 44 |
+
</div>
|
| 45 |
+
<div>
|
| 46 |
+
<label for="answerTime" class="block text-sm font-medium text-gray-700 mb-1">Answer Time (in minutes per question):</label>
|
| 47 |
+
<input type="number" id="answerTime" value="3" min="1" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
<!-- Action Buttons -->
|
| 52 |
+
<div class="flex justify-center space-x-4 mb-6">
|
| 53 |
+
<button onclick="parseQuiz()" class="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">Parse Quiz</button>
|
| 54 |
+
<button onclick="downloadHTML()" class="px-4 py-2 bg-green-500 text-white rounded-md hover:bg-green-600 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2">Download as HTML</button>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<!-- Output Section -->
|
| 58 |
+
<h2 class="text-2xl font-semibold mb-3 text-gray-800">Parsed Quiz Output:</h2>
|
| 59 |
+
<div id="output" class="w-full h-64 p-3 bg-gray-50 border border-gray-300 rounded-md overflow-auto whitespace-pre-wrap"></div>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<script>
|
| 63 |
+
let parsedHTML = '';
|
| 64 |
+
|
| 65 |
+
// Function to parse the quiz content
|
| 66 |
+
function parseQuiz() {
|
| 67 |
+
// Get quiz content and configuration values
|
| 68 |
+
const quizContent = document.getElementById('quizInput').value;
|
| 69 |
+
const testInstruction = document.getElementById('testInstruction').value;
|
| 70 |
+
const marks = parseFloat(document.getElementById('marks').value);
|
| 71 |
+
const negativeMarks = parseFloat(document.getElementById('negativeMarks').value);
|
| 72 |
+
const tag = document.getElementById('tag').value;
|
| 73 |
+
const difficulty = document.getElementById('difficulty').value;
|
| 74 |
+
const answerTime = parseFloat(document.getElementById('answerTime').value);
|
| 75 |
+
|
| 76 |
+
// Split quiz by "---" delimiter
|
| 77 |
+
const questionBlocks = quizContent.split(/\n---\n/);
|
| 78 |
+
const totalQuestions = questionBlocks.length;
|
| 79 |
+
const totalMarks = totalQuestions * marks;
|
| 80 |
+
const totalDuration = totalQuestions * answerTime;
|
| 81 |
+
|
| 82 |
+
let output = '';
|
| 83 |
+
|
| 84 |
+
// Initialize HTML structure for Word-style output
|
| 85 |
+
parsedHTML = `
|
| 86 |
+
<html>
|
| 87 |
+
<head>
|
| 88 |
+
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
|
| 89 |
+
<meta name=Generator content="Microsoft Word 15 (filtered)">
|
| 90 |
+
<style>
|
| 91 |
+
p.MsoNormal, li.MsoNormal, div.MsoNormal {
|
| 92 |
+
margin-top:0cm; margin-right:0cm; margin-bottom:8.0pt; margin-left:0cm;
|
| 93 |
+
line-height:107%; font-size:11.0pt; font-family:"Calibri",sans-serif;
|
| 94 |
+
}
|
| 95 |
+
</style>
|
| 96 |
+
</head>
|
| 97 |
+
<body lang=EN-GB style='word-wrap:break-word'>
|
| 98 |
+
<div class="WordSection1">
|
| 99 |
+
<p class=MsoNormal>[TEST INSTRUCTION] ${testInstruction}</p>
|
| 100 |
+
<p class=MsoNormal>[TEST DURATION] ${totalDuration}</p>
|
| 101 |
+
<p class=MsoNormal>[TEST MAXIMUM MARKS] ${totalMarks}</p>
|
| 102 |
+
<p class=MsoNormal> </p>
|
| 103 |
+
<p class=MsoNormal>[SECTION] Section 1</p>
|
| 104 |
+
<p class=MsoNormal>[SECTION DURATION] ${totalDuration}</p>
|
| 105 |
+
<p class=MsoNormal>[SECTION MARKS] ${totalMarks}</p>
|
| 106 |
+
<p class=MsoNormal> </p>
|
| 107 |
+
`;
|
| 108 |
+
|
| 109 |
+
// Iterate through each question block
|
| 110 |
+
questionBlocks.forEach((block, index) => {
|
| 111 |
+
// Extract Question Text
|
| 112 |
+
const questionTextMatch = block.match(/\*\*\d+\.\s*(.*?)\*\*/);
|
| 113 |
+
const questionText = questionTextMatch ? questionTextMatch[1].trim() : '';
|
| 114 |
+
|
| 115 |
+
// Extract Options
|
| 116 |
+
const options = [];
|
| 117 |
+
const optionMatches = block.matchAll(/([a-d])\)\s*(.*?)\n/g);
|
| 118 |
+
for (const match of optionMatches) {
|
| 119 |
+
options.push({ letter: match[1], text: match[2].trim() });
|
| 120 |
+
}
|
| 121 |
+
options.splice(4);
|
| 122 |
+
|
| 123 |
+
// Extract Correct Answer
|
| 124 |
+
const correctAnswerMatch = block.match(/\*\*Correct Answer:\*\*\s*([a-d])\)/i);
|
| 125 |
+
const correctLetter = correctAnswerMatch ? correctAnswerMatch[1].trim() : '';
|
| 126 |
+
|
| 127 |
+
// Extract Explanation
|
| 128 |
+
const explanationMatch = block.match(/\*\*Explanation:\*\*\s*(.*)/);
|
| 129 |
+
const explanation = explanationMatch ? explanationMatch[1].trim() : '';
|
| 130 |
+
|
| 131 |
+
// Output for Textarea
|
| 132 |
+
output += `Q.${index + 1}) ${questionText}\n`;
|
| 133 |
+
options.forEach((opt, i) => {
|
| 134 |
+
output += `${opt.letter === correctLetter ? '*' : ''}[${i + 1}] ${opt.text}\n`;
|
| 135 |
+
});
|
| 136 |
+
output += `[MARKS] ${marks}\n`;
|
| 137 |
+
output += `[NEGATIVE MARKS] ${negativeMarks}\n`;
|
| 138 |
+
output += `[TAG] ${tag}\n`;
|
| 139 |
+
output += `[DIFFICULTY] ${difficulty}\n`;
|
| 140 |
+
output += `[ANSWER TIME] ${answerTime}\n`;
|
| 141 |
+
output += `[QUESTION TYPE] Multi_choice\n`;
|
| 142 |
+
output += `[SOLUTION] (${correctLetter.toLowerCase()}) Explanation: ${explanation}\n\n`;
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
// HTML output
|
| 146 |
+
parsedHTML += `
|
| 147 |
+
<p class=MsoNormal>Q.${index + 1}) ${questionText}</p>
|
| 148 |
+
${options.map((opt, i) => `
|
| 149 |
+
<p class=MsoNormal>${opt.letter === correctLetter ? '*' : ''}[${i + 1}] ${opt.text}</p>
|
| 150 |
+
`).join('')}
|
| 151 |
+
<p class=MsoNormal>[MARKS] ${marks}</p>
|
| 152 |
+
<p class=MsoNormal>[NEGATIVE MARKS] ${negativeMarks}</p>
|
| 153 |
+
<p class=MsoNormal>[TAG] ${tag}</p>
|
| 154 |
+
<p class=MsoNormal>[DIFFICULTY] ${difficulty}</p>
|
| 155 |
+
<p class=MsoNormal>[ANSWER TIME] ${answerTime}</p>
|
| 156 |
+
<p class=MsoNormal>[QUESTION TYPE] Multi_choice</p>
|
| 157 |
+
<p class=MsoNormal>[SOLUTION] (${correctLetter}) Explanation: ${explanation}</p>
|
| 158 |
+
<p class=MsoNormal> </p>
|
| 159 |
+
`;
|
| 160 |
+
});
|
| 161 |
+
|
| 162 |
+
parsedHTML += `</div></body></html>`;
|
| 163 |
+
document.getElementById('output').textContent = output;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
// Function to download as HTML
|
| 167 |
+
function downloadHTML() {
|
| 168 |
+
const blob = new Blob([parsedHTML], { type: "text/html" });
|
| 169 |
+
const url = URL.createObjectURL(blob);
|
| 170 |
+
const a = document.createElement("a");
|
| 171 |
+
a.href = url;
|
| 172 |
+
a.download = "quiz_export.html";
|
| 173 |
+
a.click();
|
| 174 |
+
URL.revokeObjectURL(url);
|
| 175 |
+
}
|
| 176 |
+
</script>
|
| 177 |
+
</body>
|
| 178 |
+
</html>
|