Nuzwa commited on
Commit
684978f
Β·
verified Β·
1 Parent(s): a6c9f20

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +102 -21
index.html CHANGED
@@ -166,9 +166,56 @@
166
  <option>30 minutes</option><option selected>45 minutes</option><option>60 minutes</option>
167
  </select>
168
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  <div style="grid-column:1/-1">
170
  <label for="topic">Topic (optional)</label>
171
- <input id="topic" class="field" type="text" placeholder="Unit 2 (Dynamics)" />
172
  </div>
173
  </div>
174
 
@@ -192,7 +239,12 @@
192
  const CUSTOM_GPT_URL = "https://chatgpt.com/g/g-68697e4c49508191b175d86830b34d85-eduassess-pro-smart-exam-paper-designer";
193
  const $ = (s)=>document.querySelector(s);
194
 
195
- // Build plain-text prompt (NO stray code outside this function)
 
 
 
 
 
196
  function buildPrompt(){
197
  const grade = $('#grade').value;
198
  const subject = $('#subject').value;
@@ -201,9 +253,22 @@
201
  const questionType = $('#questionType').value;
202
  const duration = $('#duration').value;
203
  const topic = ($('#topic').value || '').trim();
 
 
 
 
 
 
 
204
 
205
  let p = `I need a ${testType} paper for ${grade} - ${subject}, Board: ${board}.`;
206
- p += ` Question Type: ${questionType}. Duration: ${duration}.`;
 
 
 
 
 
 
207
  if(topic) p += ` Topic: ${topic}.`;
208
  return p;
209
  }
@@ -223,7 +288,7 @@
223
 
224
  $('#copy').addEventListener('click', async ()=>{
225
  const prompt = $('#output').textContent || buildPrompt();
226
- // Try to open immediately (user gesture) β€” may be blocked by popup rules
227
  const popup = window.open(CUSTOM_GPT_URL, '_blank', 'noopener,noreferrer');
228
  try{ await navigator.clipboard.writeText(prompt); }catch(e){}
229
  showToast(popup ? 'Copied & Opening GPT...' : 'Copied! Tap Open GPT');
@@ -231,7 +296,7 @@
231
  if(link){ link.style.display = 'inline-flex'; link.focus(); }
232
  });
233
 
234
- // ===== Minimal tests (run once) =====
235
  (function runTests(){
236
  const log = [];
237
  const save = {
@@ -241,10 +306,16 @@
241
  testType: $('#testType').value,
242
  questionType: $('#questionType').value,
243
  duration: $('#duration').value,
244
- topic: $('#topic').value
 
 
 
 
 
 
245
  };
246
 
247
- // Test 1: Default selections, no topic
248
  $('#grade').value = 'Grade 9';
249
  $('#subject').value = 'Physics';
250
  $('#board').value = 'FBISE (Federal)';
@@ -252,30 +323,35 @@
252
  $('#questionType').value = 'MCQs';
253
  $('#duration').value = '45 minutes';
254
  $('#topic').value = '';
 
 
 
 
 
 
 
255
  let out = buildPrompt();
256
  const expected1 = 'I need a Formative paper for Grade 9 - Physics, Board: FBISE (Federal). Question Type: MCQs. Duration: 45 minutes.';
257
  console.assert(out === expected1, 'Test 1 failed', {out, expected1});
258
- log.push((out === expected1 ? 'βœ…' : '❌') + ' Test 1');
259
 
260
- // Test 2: With topic
261
  $('#topic').value = 'Unit 2 (Dynamics)';
262
  out = buildPrompt();
263
  const expected2 = expected1 + ' Topic: Unit 2 (Dynamics).';
264
  console.assert(out === expected2, 'Test 2 failed', {out, expected2});
265
- log.push((out === expected2 ? 'βœ…' : '❌') + ' Test 2');
266
 
267
- // Test 3: Different selections
268
- $('#grade').value = 'Grade 1';
269
- $('#subject').value = 'Mathematics';
270
- $('#board').value = 'PCTB (Punjab)';
271
- $('#testType').value = 'Diagnostic';
272
- $('#questionType').value = 'Short Questions';
273
- $('#duration').value = '30 minutes';
274
- $('#topic').value = 'Numbers';
275
  out = buildPrompt();
276
- const expected3 = 'I need a Diagnostic paper for Grade 1 - Mathematics, Board: PCTB (Punjab). Question Type: Short Questions. Duration: 30 minutes. Topic: Numbers.';
277
  console.assert(out === expected3, 'Test 3 failed', {out, expected3});
278
- log.push((out === expected3 ? 'βœ…' : '❌') + ' Test 3');
279
 
280
  // Restore original values
281
  $('#grade').value = save.grade;
@@ -285,8 +361,13 @@
285
  $('#questionType').value = save.questionType;
286
  $('#duration').value = save.duration;
287
  $('#topic').value = save.topic;
 
 
 
 
 
 
288
 
289
- // Optionally expose results (hidden element)
290
  const tl = document.getElementById('testlog');
291
  if(tl){ tl.textContent = log.join('\n'); }
292
  })();
 
166
  <option>30 minutes</option><option selected>45 minutes</option><option>60 minutes</option>
167
  </select>
168
  </div>
169
+ <div>
170
+ <label for="language">Language of Paper</label>
171
+ <select id="language" class="field">
172
+ <option value="">β€” Select β€”</option>
173
+ <option>English</option>
174
+ <option>Urdu</option>
175
+ <option>Bilingual</option>
176
+ </select>
177
+ </div>
178
+ <div>
179
+ <label for="bloom">Bloom's Taxonomy</label>
180
+ <select id="bloom" class="field">
181
+ <option value="no" selected>No</option>
182
+ <option value="yes">Yes (Varied Levels)</option>
183
+ </select>
184
+ </div>
185
+ <div>
186
+ <label for="bloomLevel">Bloom Level Emphasis (optional)</label>
187
+ <select id="bloomLevel" class="field">
188
+ <option value="">β€” Not specified β€”</option>
189
+ <option>Knowledge</option>
190
+ <option>Comprehension</option>
191
+ <option>Application</option>
192
+ <option>Analysis</option>
193
+ <option>Synthesis</option>
194
+ <option>Evaluation</option>
195
+ <option>Mixed/Varied</option>
196
+ </select>
197
+ </div>
198
+ <div>
199
+ <label for="mcqSelect">How many MCQs?</label>
200
+ <select id="mcqSelect" class="field">
201
+ <option value="">β€” Select β€”</option>
202
+ <option>10</option><option>15</option><option>20</option><option>25</option><option>30</option>
203
+ </select>
204
+ </div>
205
+ <div>
206
+ <label for="mcqCustom">Custom MCQs (optional)</label>
207
+ <input id="mcqCustom" class="field" type="number" min="1" step="1" placeholder="e.g., 18" />
208
+ </div>
209
+ <div>
210
+ <label for="difficulty">Difficulty (optional)</label>
211
+ <select id="difficulty" class="field">
212
+ <option value="">β€” Not specified β€”</option>
213
+ <option>Easy</option><option>Moderate</option><option>Hard</option><option>Mixed</option>
214
+ </select>
215
+ </div>
216
  <div style="grid-column:1/-1">
217
  <label for="topic">Topic (optional)</label>
218
+ <input id="topic" class="field" type="text" placeholder="Units 3–4" />
219
  </div>
220
  </div>
221
 
 
239
  const CUSTOM_GPT_URL = "https://chatgpt.com/g/g-68697e4c49508191b175d86830b34d85-eduassess-pro-smart-exam-paper-designer";
240
  const $ = (s)=>document.querySelector(s);
241
 
242
+ function normalizeInt(v){
243
+ const n = parseInt(v, 10);
244
+ return Number.isFinite(n) && n > 0 ? n : null;
245
+ }
246
+
247
+ // Build plain-text prompt
248
  function buildPrompt(){
249
  const grade = $('#grade').value;
250
  const subject = $('#subject').value;
 
253
  const questionType = $('#questionType').value;
254
  const duration = $('#duration').value;
255
  const topic = ($('#topic').value || '').trim();
256
+ const language = $('#language').value; // may be '' (not specified)
257
+ const bloom = $('#bloom').value; // 'yes' | 'no'
258
+ const bloomLevel = $('#bloomLevel').value; // '' or specific
259
+ const mcqSel = normalizeInt($('#mcqSelect').value);
260
+ const mcqCustom = normalizeInt($('#mcqCustom').value);
261
+ const mcqs = mcqCustom ?? mcqSel; // custom overrides select
262
+ const difficulty = $('#difficulty').value; // may be ''
263
 
264
  let p = `I need a ${testType} paper for ${grade} - ${subject}, Board: ${board}.`;
265
+ p += ` Question Type: ${questionType}.`;
266
+ if(duration) p += ` Duration: ${duration}.`;
267
+ if(typeof mcqs === 'number') p += ` MCQs: ${mcqs}.`;
268
+ if(language) p += ` Language: ${language}.`;
269
+ if(bloom === 'yes') p += ` Include Bloom's taxonomy: Yes.`;
270
+ if(bloomLevel) p += ` Bloom emphasis: ${bloomLevel}.`;
271
+ if(difficulty) p += ` Difficulty: ${difficulty}.`;
272
  if(topic) p += ` Topic: ${topic}.`;
273
  return p;
274
  }
 
288
 
289
  $('#copy').addEventListener('click', async ()=>{
290
  const prompt = $('#output').textContent || buildPrompt();
291
+ // Try to open immediately (user gesture)
292
  const popup = window.open(CUSTOM_GPT_URL, '_blank', 'noopener,noreferrer');
293
  try{ await navigator.clipboard.writeText(prompt); }catch(e){}
294
  showToast(popup ? 'Copied & Opening GPT...' : 'Copied! Tap Open GPT');
 
296
  if(link){ link.style.display = 'inline-flex'; link.focus(); }
297
  });
298
 
299
+ // ===== Minimal tests (keep old behavior intact) =====
300
  (function runTests(){
301
  const log = [];
302
  const save = {
 
306
  testType: $('#testType').value,
307
  questionType: $('#questionType').value,
308
  duration: $('#duration').value,
309
+ topic: $('#topic').value,
310
+ language: $('#language').value,
311
+ bloom: $('#bloom').value,
312
+ bloomLevel: $('#bloomLevel').value,
313
+ mcqSelect: $('#mcqSelect').value,
314
+ mcqCustom: $('#mcqCustom').value,
315
+ difficulty: $('#difficulty').value
316
  };
317
 
318
+ // Ensure new fields do NOT change legacy prompt when left blank/No
319
  $('#grade').value = 'Grade 9';
320
  $('#subject').value = 'Physics';
321
  $('#board').value = 'FBISE (Federal)';
 
323
  $('#questionType').value = 'MCQs';
324
  $('#duration').value = '45 minutes';
325
  $('#topic').value = '';
326
+ $('#language').value = '';
327
+ $('#bloom').value = 'no';
328
+ $('#bloomLevel').value = '';
329
+ $('#mcqSelect').value = '';
330
+ $('#mcqCustom').value = '';
331
+ $('#difficulty').value = '';
332
+
333
  let out = buildPrompt();
334
  const expected1 = 'I need a Formative paper for Grade 9 - Physics, Board: FBISE (Federal). Question Type: MCQs. Duration: 45 minutes.';
335
  console.assert(out === expected1, 'Test 1 failed', {out, expected1});
336
+ log.push((out === expected1 ? 'βœ…' : '❌') + ' Test 1: legacy prompt unchanged');
337
 
338
+ // Test 2: With topic only
339
  $('#topic').value = 'Unit 2 (Dynamics)';
340
  out = buildPrompt();
341
  const expected2 = expected1 + ' Topic: Unit 2 (Dynamics).';
342
  console.assert(out === expected2, 'Test 2 failed', {out, expected2});
343
+ log.push((out === expected2 ? 'βœ…' : '❌') + ' Test 2: topic appends');
344
 
345
+ // Test 3: New fields engaged
346
+ $('#language').value = 'English';
347
+ $('#bloom').value = 'yes';
348
+ $('#bloomLevel').value = 'Application';
349
+ $('#mcqSelect').value = '20';
350
+ $('#difficulty').value = 'Moderate';
 
 
351
  out = buildPrompt();
352
+ const expected3 = expected2 + ' MCQs: 20. Language: English. Include Bloom\'s taxonomy: Yes. Bloom emphasis: Application. Difficulty: Moderate.';
353
  console.assert(out === expected3, 'Test 3 failed', {out, expected3});
354
+ log.push((out === expected3 ? 'βœ…' : '❌') + ' Test 3: new fields appended');
355
 
356
  // Restore original values
357
  $('#grade').value = save.grade;
 
361
  $('#questionType').value = save.questionType;
362
  $('#duration').value = save.duration;
363
  $('#topic').value = save.topic;
364
+ $('#language').value = save.language;
365
+ $('#bloom').value = save.bloom;
366
+ $('#bloomLevel').value = save.bloomLevel;
367
+ $('#mcqSelect').value = save.mcqSelect;
368
+ $('#mcqCustom').value = save.mcqCustom;
369
+ $('#difficulty').value = save.difficulty;
370
 
 
371
  const tl = document.getElementById('testlog');
372
  if(tl){ tl.textContent = log.join('\n'); }
373
  })();