ÿþ<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Class XI Physics Sample Paper Generator</title> <link href="img/logo1.jpg" rel="icon"> <!-- Add jsPDF library --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> :root { --primary: #4361ee; --primary-dark: #3f37c9; --secondary: #4895ef; --danger: #f72585; --success: #4cc9f0; --light: #f8f9fa; --dark: #212529; --gray: #6c757d; --border-radius: 12px; --box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); --transition: all 0.3s ease; } * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } body { background: linear-gradient(135deg, #f5f7fa 0%, #e2e8f0 100%); min-height: 100vh; display: flex; justify-content: center; align-items: center; padding: 20px; color: var(--dark); line-height: 1.6; } .container { width: 100%; max-width: 900px; background: white; border-radius: var(--border-radius); box-shadow: var(--box-shadow); overflow: hidden; transition: var(--transition); animation: fadeIn 0.5s ease-out; } @keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } } .header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; padding: 30px 20px; text-align: center; position: relative; overflow: hidden; } .header::before { content: ''; position: absolute; top: -50px; right: -50px; width: 150px; height: 150px; background: rgba(255, 255, 255, 0.1); border-radius: 50%; } .header h1 { font-size: 2rem; margin-bottom: 10px; font-weight: 700; position: relative; z-index: 1; } .header p { font-size: 1rem; opacity: 0.9; position: relative; z-index: 1; } .content-area { padding: 30px; } .hidden { display: none !important; } .btn { display: inline-block; padding: 12px 28px; border-radius: 50px; font-weight: 600; cursor: pointer; transition: var(--transition); border: none; text-align: center; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); margin: 10px 5px; } .btn-primary { background: var(--primary); color: white; } .btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: 0 8px 15px rgba(67, 97, 238, 0.3); } .btn-success { background: var(--success); color: white; } .btn-success:hover { background: #3ab0d6; transform: translateY(-2px); box-shadow: 0 8px 15px rgba(76, 201, 240, 0.3); } .btn-danger { background: var(--danger); color: white; } .btn-danger:hover { background: #d3166b; transform: translateY(-2px); box-shadow: 0 8px 15px rgba(247, 37, 133, 0.3); } .btn-group { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 20px 0; } .section-title { text-align: center; margin-bottom: 25px; color: var(--primary-dark); font-size: 1.5rem; position: relative; padding-bottom: 10px; } .section-title::after { content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 80px; height: 3px; background: var(--secondary); border-radius: 3px; } .checkbox-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; margin: 25px 0; } .checkbox-item { display: flex; align-items: center; } .checkbox-item input { margin-right: 10px; width: 18px; height: 18px; cursor: pointer; } .checkbox-item label { cursor: pointer; font-size: 0.95rem; } .generated-paper { padding: 30px; } .paper-header { text-align: center; margin-bottom: 30px; border-bottom: 2px solid var(--primary); padding-bottom: 20px; } .paper-header h2 { color: var(--primary-dark); margin-bottom: 5px; font-size: 1.8rem; } .paper-header h3 { color: var(--gray); margin-bottom: 5px; font-size: 1.2rem; font-weight: 500; } .paper-meta { display: flex; justify-content: space-between; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #eee; font-weight: 500; } .instructions { margin-bottom: 30px; padding: 20px; background: #f8f9fa; border-radius: var(--border-radius); } .instructions ol { padding-left: 20px; margin-top: 10px; } .instructions li { margin-bottom: 8px; } .question-section { margin-bottom: 30px; } .section-heading { font-weight: 600; color: var(--primary-dark); margin-bottom: 15px; padding-bottom: 5px; border-bottom: 1px solid #eee; } .question { margin-bottom: 20px; page-break-inside: avoid; } .question-text { font-weight: 500; margin-bottom: 8px; } .option { margin-left: 20px; margin-bottom: 5px; } .action-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 15px; margin-top: 40px; } @media (max-width: 768px) { .header h1 { font-size: 1.6rem; } .content-area { padding: 20px; } .checkbox-container { grid-template-columns: 1fr; } .btn { padding: 10px 20px; font-size: 0.9rem; } .paper-header h2 { font-size: 1.4rem; } .paper-header h3 { font-size: 1rem; } } @media (max-width: 480px) { .header { padding: 20px 15px; } .section-title { font-size: 1.3rem; } .paper-meta { flex-direction: column; gap: 10px; } .action-buttons { flex-direction: column; align-items: center; } .btn { width: 100%; max-width: 250px; } } @media print { body { background: none; padding: 0; } .container { box-shadow: none; max-width: 100%; } .action-buttons { display: none; } .question { page-break-inside: avoid; } } </style> <style> /* Ensure header styling is preserved */ .header { background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important; color: white !important; padding: 30px 20px !important; text-align: center !important; position: relative !important; overflow: hidden !important; width: 100% !important; } .header h1, .header h2, .header h3 { color: white !important; font-weight: bold !important; } .temp-pdf-container { font-family: Arial, sans-serif; line-height: 1.5; } .temp-pdf-container * { max-width: 100% !important; background-color: white !important; color: black !important; } /* Page break control */ .question { page-break-inside: avoid; break-inside: avoid; } .question-section { page-break-after: auto; } @media print { body { margin: 0 !important; padding: 0 !important; background: white !important; } .container { width: 100% !important; margin: 0 !important; padding: 0 !important; box-shadow: none !important; } .header { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; } } /* Home icon styles */ .home-icon { position: absolute; top: 20px; left: 20px; color: white; font-size: 24px; cursor: pointer; transition: var(--transition); z-index: 2; } .home-icon:hover { transform: scale(1.1); color: rgba(255, 255, 255, 0.8); } @media (max-width: 480px) { .home-icon { font-size: 20px; top: 15px; left: 15px; } } @media print { .home-icon { display: none; } } </style> </head> <body> <div class="container" id="startContainer"> <div class="header"> <a href="cbse-class-9-to-12-exam-paper-generator.html" class="home-icon"> <i class="fas fa-home"></i> </a> <h1>Class XI Physics</h1> <p>Generate Customized Sample Papers</p> </div> <div class="content-area"> <div id="startScreen"> <h2 class="section-title">Physics Paper Generator</h2> <div class="btn-group"> <button class="btn btn-primary" onclick="showChapterSelection()">Start Generating</button> </div> </div> <div id="chapterSelection" class="hidden"> <h2 class="section-title">Select Chapters for Physics</h2> <form id="chapterForm"> <div class="checkbox-container"> <div class="checkbox-item"> <input type="checkbox" id="fullPaper" name="chapter" value="Full Paper" onchange="toggleChapters()"> <label for="fullPaper">Full Paper (All Chapters)</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter1" name="chapter" value="Chapter 1"> <label for="chapter1">1. Physical World</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter2" name="chapter" value="Chapter 2"> <label for="chapter2">2. Units and Measurement</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter3" name="chapter" value="Chapter 3"> <label for="chapter3">3. Motion in a Straight Line</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter4" name="chapter" value="Chapter 4"> <label for="chapter4">4. Motion in a Plane</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter5" name="chapter" value="Chapter 5"> <label for="chapter5">5. Laws of Motion</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter6" name="chapter" value="Chapter 6"> <label for="chapter6">6. Work, Energy and Power</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter7" name="chapter" value="Chapter 7"> <label for="chapter7">7. System of Particles and Rotational Motion</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter8" name="chapter" value="Chapter 8"> <label for="chapter8">8. Gravitation</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter9" name="chapter" value="Chapter 9"> <label for="chapter9">9. Mechanical Properties of Solids</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter10" name="chapter" value="Chapter 10"> <label for="chapter10">10. Mechanical Properties of Fluids</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter11" name="chapter" value="Chapter 11"> <label for="chapter11">11. Thermal Properties of Matter</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter12" name="chapter" value="Chapter 12"> <label for="chapter12">12. Thermodynamics</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter13" name="chapter" value="Chapter 13"> <label for="chapter13">13. Kinetic Theory</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter14" name="chapter" value="Chapter 14"> <label for="chapter14">14. Oscillations</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter15" name="chapter" value="Chapter 15"> <label for="chapter15">15. Waves</label> </div> </div> </form> <div id="message" class="hidden"></div> <div class="btn-group"> <button class="btn btn-danger" onclick="backToStart()">Back to Start</button> <button class="btn btn-success" onclick="promptSchoolName()">Generate Paper</button> </div> </div> </div> </div> <div class="container hidden" id="generatedPaperContainer"></div> <script> // Initialize jsPDF const { jsPDF } = window.jspdf; let schoolName = ''; let questionCounter = 1; let sessionYear = ''; const questions = { physics: { "Chapter 1": { mcq: [ { question: "Which of the following is not a fundamental force in nature?", options: ["Gravitational force", "Electromagnetic force", "Nuclear force", "Frictional force"], answer: "Frictional force" }, { question: "The scientific method involves:", options: ["Observation, hypothesis, experiment, conclusion", "Hypothesis, observation, conclusion, experiment", "Experiment, observation, hypothesis, conclusion", "Conclusion, hypothesis, observation, experiment"], answer: "Observation, hypothesis, experiment, conclusion" }, { question: "The scope of physics is:", options: ["Limited to macroscopic world only", "Limited to microscopic world only", "Limited to theoretical concepts only", "From microscopic to macroscopic world"], answer: "From microscopic to macroscopic world" }, { question: "Which of the following is not a branch of physics?", options: ["Thermodynamics", "Electromagnetism", "Genetics", "Quantum mechanics"], answer: "Genetics" }, { question: "The unification of forces means:", options: ["Combining all forces into one", "Understanding different forces as manifestations of a single fundamental force", "Making all forces equal in magnitude", "Eliminating all forces except one"], answer: "Understanding different forces as manifestations of a single fundamental force" } ], assertion: [ { statement1: "Physics is a fundamental science.", statement2: "Physics provides the basis for all other natural sciences.", options: ["Both Assertion and Reason are true and Reason is the correct explanation of Assertion", "Both Assertion and Reason are true but Reason is not the correct explanation of Assertion", "Assertion is true but Reason is false", "Both Assertion and Reason are false"], answer: "Both Assertion and Reason are true and Reason is the correct explanation of Assertion" }, { statement1: "The electromagnetic force is stronger than gravitational force.", statement2: "The electromagnetic force acts between charged particles while gravitational force acts between all masses.", options: ["Both Assertion and Reason are true and Reason is the correct explanation of Assertion", "Both Assertion and Reason are true but Reason is not the correct explanation of Assertion", "Assertion is true but Reason is false", "Both Assertion and Reason are false"], answer: "Both Assertion and Reason are true but Reason is not the correct explanation of Assertion" } ], twoMark: [ "What are the four fundamental forces in nature? Arrange them in order of increasing strength.", "Explain the difference between classical physics and quantum physics.", "What is the role of physics in technology development? Give two examples.", "Define the scientific method and explain its steps." ], threeMark: [ "Explain with examples how physics is related to other sciences like chemistry and biology.", "What do you understand by unification of forces in physics? Explain with one example.", "Discuss the impact of physics on society with two examples." ], fiveMark: [ "Explain the scope of physics with examples from different domains (macroscopic, microscopic, etc.). How does physics contribute to our understanding of the universe?", "Discuss the fundamental forces in nature. Compare their relative strengths and ranges. What is the current status of unification of these forces?" ], caseStudy: [ { case: "Case Study Based Question: Fundamental Forces\nPhysics deals with four fundamental forces that govern all natural phenomena. These forces are gravitational force, electromagnetic force, strong nuclear force, and weak nuclear force. Each force has different characteristics in terms of their strength, range, and the particles they act upon.", questions: ["Which is the weakest fundamental force?", "Which fundamental force is responsible for radioactive decay?", "What is the range of strong nuclear force?", "Which force is responsible for binding electrons to the nucleus in an atom?"] }, { case: "Case Study Based Question: Scientific Method\nThe scientific method is a systematic approach to research that involves making observations, forming hypotheses, conducting experiments, and drawing conclusions. This method has been crucial in the development of physics as a science.", questions: ["What is the first step in the scientific method?", "Why is hypothesis important in scientific research?", "What is the purpose of conducting experiments in the scientific method?", "How does the scientific method ensure objectivity in research?"] } ] }, "Chapter 2": { mcq: [ { question: "Which of the following is not a fundamental unit in SI system?", options: ["Meter", "Kilogram", "Second", "Newton"], answer: "Newton" }, { question: "The dimensional formula for force is:", options: ["[MLT{ ²]", "[ML²T{ ²]", "[ML{ ¹T{ ²]", "[Mp Lp Tp ]"], answer: "[MLT{ ²]" }, { question: "The number of significant figures in 0.0025 is:", options: ["1", "2", "3", "4"], answer: "2" }, { question: "Which instrument would you use to measure the diameter of a thin wire?", options: ["Vernier calipers", "Screw gauge", "Meter scale", "Spectrometer"], answer: "Screw gauge" }, { question: "The relative error in the measurement of the side of a cube is 2%. The relative error in the measurement of its volume would be:", options: ["2%", "4%", "6%", "8%"], answer: "6%" } ], assertion: [ { statement1: "All physical quantities can be expressed in terms of fundamental quantities.", statement2: "The seven fundamental quantities in SI system are length, mass, time, electric current, thermodynamic temperature, amount of substance, and luminous intensity.", options: ["Both Assertion and Reason are true and Reason is the correct explanation of Assertion", "Both Assertion and Reason are true but Reason is not the correct explanation of Assertion", "Assertion is true but Reason is false", "Both Assertion and Reason are false"], answer: "Both Assertion and Reason are true and Reason is the correct explanation of Assertion" }, { statement1: "The precision of a measurement depends on the least count of the measuring instrument.", statement2: "A screw gauge has higher precision than a vernier caliper.", options: ["Both Assertion and Reason are true and Reason is the correct explanation of Assertion", "Both Assertion and Reason are true but Reason is not the correct explanation of Assertion", "Assertion is true but Reason is false", "Both Assertion and Reason are false"], answer: "Both Assertion and Reason are true and Reason is the correct explanation of Assertion" } ], twoMark: [ "Define the terms: (i) Precision (ii) Accuracy. How are they different?", "Explain the principle of dimensional homogeneity with an example.", "What are the advantages of SI system of units?", "A student measures the length of a rod five times and gets the following readings: 5.23 cm, 5.25 cm, 5.20 cm, 5.22 cm, 5.21 cm. Calculate the mean absolute error." ], threeMark: [ "Explain the principle and use of (i) Vernier calipers (ii) Screw gauge for precise measurements.", "Derive the dimensional formula for (i) Work (ii) Power (iii) Pressure.", "What are the rules for determining the number of significant figures in a measurement? Give examples." ], fiveMark: [ "Explain the different types of errors in measurement. How can systematic errors be minimized in experiments? Discuss the concept of least count and its importance in measurements.", "What is dimensional analysis? Explain its applications and limitations with suitable examples. How can dimensional analysis be used to check the correctness of physical equations?" ], caseStudy: [ { case: "Case Study Based Question: Measurement Techniques\nPrecise measurement is crucial in physics experiments. Various instruments like vernier calipers, screw gauges, and measuring scales are used depending on the required precision. The least count of an instrument determines its precision.", questions: ["What is the least count of a vernier caliper having 10 divisions on the vernier scale matching with 9 divisions of the main scale (1 MSD = 1 mm)?", "How does a screw gauge provide more precise measurement than a vernier caliper?", "What is zero error in measuring instruments? How is it corrected?", "Why is it important to take multiple readings in an experiment?"] }, { case: "Case Study Based Question: Dimensional Analysis\nDimensional analysis is a powerful tool in physics to check the correctness of equations, derive relationships between physical quantities, and convert units from one system to another. It is based on the principle of dimensional homogeneity.", questions: ["What is the principle of dimensional homogeneity?", "How can dimensional analysis be used to check the correctness of an equation?", "What are the limitations of dimensional analysis?", "Using dimensional analysis, derive the relation for the time period of a simple pendulum assuming it depends on length (l) and acceleration due to gravity (g)."] } ] }, // [Additional chapters with similar structure would follow here] // Chapters 3-15 would contain questions relevant to each topic } }; // [All JavaScript functions remain exactly the same] // showChapterSelection(), toggleChapters(), backToStart(), // promptSchoolName(), promptSession(), generatePaper(), // getRandomQuestions(), downloadPDF() functions remain unchanged // ... function getRandomQuestions(selectedChapters, type, count) { let allQuestions = []; if (selectedChapters.includes("Full Paper")) { for (let chapter in questions.physics) { if (questions.physics[chapter][type]) { allQuestions = allQuestions.concat(questions.physics[chapter][type]); } } } else { selectedChapters.forEach(chapter => { if (questions.physics[chapter] && questions.physics[chapter][type]) { allQuestions = allQuestions.concat(questions.physics[chapter][type]); } }); } allQuestions = allQuestions.sort(() => Math.random() - 0.5); return allQuestions.slice(0, count); } function showChapterSelection() { document.getElementById('startScreen').classList.add('hidden'); document.getElementById('chapterSelection').classList.remove('hidden'); } function toggleChapters() { const fullPaperCheckbox = document.getElementById('fullPaper'); const checkboxes = document.querySelectorAll('input[name="chapter"]:not(#fullPaper)'); checkboxes.forEach(cb => cb.disabled = fullPaperCheckbox.checked); } function backToStart() { document.getElementById('generatedPaperContainer').classList.add('hidden'); document.getElementById('startContainer').classList.remove('hidden'); document.getElementById('chapterSelection').classList.add('hidden'); document.getElementById('startScreen').classList.remove('hidden'); questionCounter = 1; } function promptSchoolName() { schoolName = prompt("Write your school/institute name").toUpperCase(); if (!schoolName) { alert("School/Institute name is required!"); } else { promptSession(); } } function promptSession() { sessionYear = prompt("Enter the academic session (e.g., 2024-25)").toUpperCase(); if (!sessionYear) { alert("Academic session is required!"); } else { generatePaper(); } } function generatePaper() { document.getElementById('startContainer').classList.add('hidden'); const generatedPaperContainer = document.getElementById('generatedPaperContainer'); generatedPaperContainer.classList.remove('hidden'); generatedPaperContainer.innerHTML = ''; let paperContent = ` <div class="header"> <h2>${schoolName}</h2> </div> <div class="content-area"> <div class="paper-header"> <h3>SAMPLE QUESTION PAPER PHYSICS-042</h3> <h3>CLASS - XI</h3> <h3>Academic Session ${sessionYear}</h3> </div> <div class="paper-meta"> <div>Maximum Marks: 70</div> <div>Time Allowed: 3 hours</div> </div> <div class="instructions"> <p><strong>General Instructions:</strong></p> <ol> <li>There are 33 questions in all. All questions are compulsory.</li> <li>This question paper has five sections: Section A, Section B, Section C, Section D and Section E.</li> <li>All the sections are compulsory.</li> <li><strong>Section A</strong> contains <strong>sixteen questions</strong>, <strong>twelve MCQ and four Assertion Reasoning based of 1 mark each</strong>, <strong>Section B</strong> contains <strong>five questions of two marks each</strong>, <strong>Section C</strong> contains seven questions of three marks each, <strong>Section D</strong> contains <strong>two case study-based questions of four marks each</strong> and <strong>Section E</strong> contains <strong>three long answer questions of five marks each</strong>.</li> <li>There is no overall choice. However, an internal choice has been provided in one question in Section B, one question in Section C, one question in each CBQ in Section D and all three questions in Section E. You have to attempt only one of the choices in such questions.</li> <li>Use of calculators is not allowed.</li> <li>You may use the following values of physical constants where ever necessary: <ul style="margin-top: 10px; list-style-type: none; padding-left: 0;"> <li>i. c = 3 × 10x m/s</li> <li>ii. m‘ = 9.1 × 10{ ³¹ kg</li> <li>iii. mš = 1.7 × 10{ ²w kg</li> <li>iv. e = 1.6 × 10{ ¹y C</li> <li>v. ¼€ = 4À × 10{ w T m A{ ¹</li> <li>vi. h = 6.63 × 10{ ³t J s</li> <li>vii. µ€ = 8.854 × 10{ ¹² C² N{ ¹ m{ ²</li> <li>viii. Avogadro's number = 6.023 × 10²³ per gram mole</li> </ul> </li> </ol> </div> `; const selectedChapters = document.getElementById('fullPaper').checked ? ["Full Paper"] : Array.from(document.querySelectorAll('input[name="chapter"]:checked')).map(cb => cb.value); // Section A - MCQs const mcqs = getRandomQuestions(selectedChapters, 'mcq', 12); paperContent += ` <div class="question-section"> <h4 class="section-heading">SECTION A (16x1=16 marks)</h4> <p>Question 1 to 12 are multiple choice questions. Only one of the choices is correct. Select and write the correct choice as well as the answer to these questions.</p> `; mcqs.forEach((q, i) => { paperContent += ` <div class="question"> <p class="question-text">Q${questionCounter++}. ${q.question}</p> ${q.options.map((opt, j) => `<p class="option">${String.fromCharCode(65 + j)}. ${opt}</p>` ).join('')} </div> `; }); // Section A - Assertion Reasoning const assertions = getRandomQuestions(selectedChapters, 'assertion', 4); paperContent += ` <h4 class="section-heading" style="margin-top: 30px;">For Questions 13 to 16, two statements are given  one labelled Assertion (A) and other labelled Reason (R). Select the correct answer to these questions from the options as given below:</h4> <p style="margin-bottom: 15px;"> A. If both Assertion and Reason are true and Reason is the correct explanation of Assertion.<br> B. If both Assertion and Reason are true but Reason is not the correct explanation of Assertion.<br> C. If Assertion is true but Reason is false.<br> D. If both Assertion and Reason are false. </p> `; assertions.forEach((q, i) => { paperContent += ` <div class="question"> <p class="question-text">Q${questionCounter++}. Assertion (A): ${q.statement1}</p> <p class="option">Reason (R): ${q.statement2}</p> ${q.options.map((opt, j) => `<p class="option">${String.fromCharCode(65 + j)}. ${opt}</p>` ).join('')} </div> `; }); // Section B - 2 marks const twoMarks = getRandomQuestions(selectedChapters, 'twoMark', 5); paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">SECTION B (05x2=10 marks)</h4> <p>Question No. 17 to 21 are short answer questions carrying 2 marks each.</p> `; twoMarks.forEach(q => { paperContent += ` <div class="question"> <p class="question-text">Q${questionCounter++}. ${q}</p> </div> `; }); // Section C - 3 marks const threeMarks = getRandomQuestions(selectedChapters, 'threeMark', 7); paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">SECTION C (07x3=21 marks)</h4> <p>Question No. 22 to 28 are short answer questions carrying 3 marks each.</p> `; threeMarks.forEach(q => { paperContent += ` <div class="question"> <p class="question-text">Q${questionCounter++}. ${q}</p> </div> `; }); // Section D - Case Studies const caseStudies = getRandomQuestions(selectedChapters, 'caseStudy', 2); paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">SECTION D (02x4=08 marks)</h4> <p>Question No. 29 to 30 are case-based/data-based questions carrying 4 marks each.</p> `; caseStudies.forEach(cs => { paperContent += ` <div class="question"> <p class="question-text">Q${questionCounter++}. ${cs.case}</p> ${cs.questions.map((subQ, j) => `<p class="option">${j + 1}. ${subQ}</p>` ).join('')} </div> `; }); // Section E - 5 marks const fiveMarks = getRandomQuestions(selectedChapters, 'fiveMark', 3); paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">SECTION E (03x5=15 marks)</h4> <p>Question No. 31 to 33 are long answer questions carrying 5 marks each.</p> `; fiveMarks.forEach(q => { paperContent += ` <div class="question"> <p class="question-text">Q${questionCounter++}. ${q}</p> </div> `; }); // Add buttons below the generated paper paperContent += ` </div> <div class="action-buttons"> <button class="btn btn-primary" onclick="downloadPDF()">Download as PDF</button> <button class="btn btn-success" onclick="window.print()">Print</button> <button class="btn btn-danger" onclick="backToStart()">Back to Start</button> </div> </div> `; generatedPaperContainer.innerHTML = paperContent; } async function downloadPDF() { const element = document.getElementById('generatedPaperContainer'); // Create a temporary div with optimized settings const tempDiv = document.createElement('div'); tempDiv.style.position = 'absolute'; tempDiv.style.left = '-9999px'; tempDiv.style.width = '794px'; // A4 width in pixels (210mm) tempDiv.style.backgroundColor = 'white'; tempDiv.style.padding = '20px'; tempDiv.innerHTML = element.innerHTML; document.body.appendChild(tempDiv); try { const pdf = new jsPDF('p', 'mm', 'a4'); const pageWidth = pdf.internal.pageSize.getWidth() - 25.4; // 0.5" margins const pageHeight = pdf.internal.pageSize.getHeight() - 25.4; // Split content into pages let position = 12.7; // Start with 0.5" top margin let remainingHeight = tempDiv.scrollHeight; let pageNum = 1; while (remainingHeight > 0) { // Capture the current page section const canvas = await html2canvas(tempDiv, { scale: 2, windowHeight: pageHeight * 3.78, // mm to px windowWidth: pageWidth * 3.78, y: position * 3.78, // mm to px height: pageHeight * 3.78, useCORS: true, backgroundColor: '#ffffff', logging: false }); const imgData = canvas.toDataURL('image/jpeg', 0.92); // Add page to PDF if (pageNum > 1) { pdf.addPage('a4', 'portrait'); } pdf.addImage(imgData, 'JPEG', 12.7, 12.7, pageWidth, canvas.height * pageWidth / canvas.width); position += pageHeight; remainingHeight -= pageHeight * 3.78; // px pageNum++; } document.body.removeChild(tempDiv); pdf.save(`${schoolName}_Physics_Paper.pdf`); } catch (error) { console.error('PDF generation error:', error); alert('Error generating PDF. Please try again.'); document.body.removeChild(tempDiv); } } </script> </body> </html>