ÿþ<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="img/logo1.jpg" rel="icon"> <title>Class 8 Maths Assignment Generator | Create CBSE PDF</title> <meta name="description" content="Generate free chapter-wise or full Class 8 Maths assignments online. Custom worksheets, solved examples, and PDF downloads for CBSE exam practice."> <meta name="keywords" content="Class 8 Maths Assignment Generator,CBSE Class 8 Maths Assignment Creator,Chapter-wise Class 8 Maths Assignment Generator,Full Class 8 Maths Assignment Maker,Free Class 8 Maths Assignment Creator Online,NCERT Class 8 Maths Assignment Generator,Custom Class 8 Maths Assignment Generator,Class 8 Maths Homework Assignment Maker,CBSE Class 8 Maths Practice Assignment Generator,Class 8 Maths Worksheet Creator,Class 8 Maths Assignment Generator Chapter 1,CBSE Class 8 Chapter 1 Assignment Maker,NCERT Class 8 Maths Chapter 1 Custom Assignment,Class 8 Maths Assignment Generator Chapter 2,CBSE Class 8 Chapter 2 Assignment Creator,NCERT Class 8 Maths Chapter 2 Worksheet Generator,Class 8 Maths Assignment Generator Chapter 3,CBSE Class 8 Chapter 3 Assignment Maker,NCERT Class 8 Maths Chapter 3 Practice Assignment,Class 8 Maths Assignment Generator Chapter 4,CBSE Class 8 Quadrilaterals Assignment Creator,NCERT Class 8 Chapter 4 Custom Assignment,Class 8 Maths Assignment Generator Chapter 5,CBSE Class 8 Number Play Assignment Creator,NCERT Class 8 Chapter 5 Assignment Maker,Class 8 Maths Assignment Generator Chapter 6,CBSE Class 8 Chapter 6 Assignment Creator,NCERT Class 8 Maths Chapter 6 Practice Assignment,Class 8 Maths Assignment Generator Chapter 7,CBSE Class 8 Ratios & Proportions Assignment Creator,NCERT Class 8 Chapter 7 Assignment Maker,Generate Free Class 8 Maths Assignments Online,Create Custom Class 8 Maths Assignments by Chapter,Chapter-wise Class 8 Maths Assignment Maker Tool,Full Syllabus Class 8 Maths Assignment Generator,Free Online CBSE Class 8 Maths Assignment Creator,Class 8 Maths Exam Practice Assignment Generator,Class 8 Maths Assignments with Answers Generator,  M 7 > 8  # ? $  8 >  ( . G    ( 0 G  0 ,  M 7 > 8  # ? $  8 >  ( . G   . G  0  ( 2 >  ( ,  M 7 > 8  # ? $  ' M / > / 5 > 0  8 >  ( . G    M 0 ?   0 ,CBSE   M 7 > 8  # ? $ 9 K . 5 0 M   ( 0 G  0 "> <meta name="robots" content="index, follow"> <meta name="author" content="Routera.in"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Open Graph Tags --> <meta property="og:site_name" content="routera.in"> <meta property="og:title" content="Class 8 Maths Assignment Generator | Create CBSE PDF"> <meta property="og:description" content="Generate free chapter-wise or full Class 8 Maths assignments online. Custom worksheets, solved examples, and PDF downloads for CBSE exam practice."> <meta property="og:image" content="https://www.routera.in/img/cat-2.png"> <!-- Replace with actual image URL --> <meta property="og:image:width" content="600" /> <meta property="og:image:height" content="400" /> <meta property="og:url" content="https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html"> <meta property="og:type" content="website"> <!-- Twitter Card Tags --> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:title" content="Class 8 Maths Assignment Generator | Create CBSE PDF"> <meta name="twitter:description" content="Generate free chapter-wise or full Class 8 Maths assignments online. Custom worksheets, solved examples, and PDF downloads for CBSE exam practice."> <meta name="twitter:image" content="https://www.routera.in/img/cat-2.png"> <!-- Replace with actual image URL --> <!-- Canonical Tag --> <link rel="canonical" href="https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html" /> <script type="application/ld+json"> { "@context": "https://schema.org", "@graph": [ { "@type": "WebPage", "@id": "https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html", "url": "https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html", "name": "Class 8 Maths Assignment Generator | CBSE Chapter-wise", "description": "Generate free chapter-wise or full Class 8 Maths assignments online. Custom worksheets, solved examples, and PDF downloads for CBSE exam practice.", "inLanguage": "en", "isPartOf": { "@id": "https://www.routera.in/#website" }, "breadcrumb": { "@id": "https://www.routera.in/#breadcrumb" } }, { "@type": "WebSite", "@id": "https://www.routera.in/#website", "url": "https://www.routera.in/", "name": "Routera", "publisher": { "@id": "https://www.routera.in/#organization" }, "potentialAction": { "@type": "SearchAction", "target": "https://www.routera.in/search?q={search_term_string}", "query-input": "required name=search_term_string" } }, { "@type": "Organization", "@id": "https://www.routera.in/#organization", "name": "Routera", "url": "https://www.routera.in/", "logo": "https://www.routera.in/img/logo1.jpg", "sameAs": [ "https://www.facebook.com/routera", "https://www.twitter.com/routera", "https://www.instagram.com/routera" ] }, { "@type": "EducationalOrganization", "@id": "https://www.routera.in/#eduorg", "name": "Routera Learning", "url": "https://www.routera.in/", "logo": "https://www.routera.in/img/logo1.jpg", "description": "Routera provides CBSE Class 8 Maths chapter-wise assignment generator, practice worksheets, video lectures, and exam preparation resources.", "address": { "@type": "PostalAddress", "addressCountry": "IN" } }, { "@type": "Review", "itemReviewed": { "@id": "https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html" }, "author": { "@type": "Person", "name": "Students & Teachers" }, "reviewRating": { "@type": "Rating", "ratingValue": "4.9", "bestRating": "5", "worstRating": "1" }, "reviewBody": "The Class 8 Maths Assignment Generator is a highly useful tool for creating chapter-wise and full syllabus assignments with solved examples and PDF downloads." }, { "@type": "BreadcrumbList", "@id": "https://www.routera.in/#breadcrumb", "itemListElement": [ { "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.routera.in/" }, { "@type": "ListItem", "position": 2, "name": "Class 8", "item": "https://www.routera.in/cbse-class-8-study-material.html" }, { "@type": "ListItem", "position": 3, "name": "Class 8 Maths Assignment Generator" } ] }, { "@type": "Article", "headline": "Class 8 Maths Assignment Generator | CBSE Chapter-wise", "author": { "@type": "Organization", "name": "Routera" }, "publisher": { "@id": "https://www.routera.in/#organization" }, "datePublished": "2025-10-03", "dateModified": "2025-10-03", "mainEntityOfPage": "https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html" }, { "@type": "FAQPage", "mainEntity": [ { "@type": "Question", "name": "What is the Class 8 Maths Assignment Generator?", "acceptedAnswer": { "@type": "Answer", "text": "It is an online tool to create chapter-wise or full syllabus Class 8 Maths assignments with PDF download." } }, { "@type": "Question", "name": "Is the Class 8 Maths Assignment Generator free?", "acceptedAnswer": { "@type": "Answer", "text": "Yes, the assignment generator is completely free for all users." } }, { "@type": "Question", "name": "Which chapters are included in the generator?", "acceptedAnswer": { "@type": "Answer", "text": "All 7 chapters from Ganita Prakash book: A Square and A Cube, Power Play, A Story of Numbers, Quadrilaterals, Number Play, We Distribute Yet Things Multiply, and Proportional Reasoning  1." } } ] }, { "@type": "HowTo", "name": "How to Use the Class 8 Maths Assignment Generator?", "step": [ { "@type": "HowToStep", "text": "Open the Class 8 Maths Assignment Generator page on Routera.in." }, { "@type": "HowToStep", "text": "Select the chapter(s) or full syllabus." }, { "@type": "HowToStep", "text": "Choose the number of questions and difficulty level." }, { "@type": "HowToStep", "text": "Click Generate Assignment and download the PDF." } ] }, { "@type": "SiteNavigationElement", "name": "Class 8 Maths Assignment Generator", "url": "https://www.routera.in/cbse-class-8-Mathematics-assignment-generator.html" }, { "@type": "Product", "name": "Class 8 Maths Assignment Generator", "description": "Free chapter-wise and full syllabus Class 8 Maths assignment creator with PDF downloads and solved examples for CBSE exam practice.", "brand": { "@type": "Organization", "name": "Routera" }, "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.9", "reviewCount": "1100" } }, { "@type": "Course", "name": "CBSE Class 8 Mathematics Assignment Program", "description": "Chapter-wise Class 8 Maths assignments including exercises, solved examples, and practice questions for exam preparation.", "provider": { "@id": "https://www.routera.in/#eduorg" } }, { "@type": "ItemList", "name": "Class 8 Maths Chapters Assignments", "itemListElement": [ { "@type": "ListItem", "position": 1, "name": "A Square and A Cube" }, { "@type": "ListItem", "position": 2, "name": "Power Play" }, { "@type": "ListItem", "position": 3, "name": "A Story of Numbers" }, { "@type": "ListItem", "position": 4, "name": "Quadrilaterals" }, { "@type": "ListItem", "position": 5, "name": "Number Play" }, { "@type": "ListItem", "position": 6, "name": "We Distribute, Yet Things Multiply" }, { "@type": "ListItem", "position": 7, "name": "Proportional Reasoning  1" } ] }, { "@type": "EducationalOccupationalProgram", "name": "CBSE Class 8 Mathematics Program", "provider": { "@id": "https://www.routera.in/#eduorg" } } ] } </script> <!-- 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> /* All CSS styles remain the same as before */ :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, #4361ee, #3f37c9) !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; width: 794px; /* A4 width in pixels (210mm) */ background-color: white; color: black; } /* 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> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4930137336556867" crossorigin="anonymous"></script> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-KMZ9RJ62EY"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-KMZ9RJ62EY'); </script> </head> <body> <div class="container" id="startContainer"> <div class="header"> <!-- Home icon added here --> <a href="cbse-class-6-to-8-assignment-generator.html" class="home-icon"> <i class="fas fa-home"></i> </a> <h1>Class VIII Mathematics</h1> <p>Generate Customized Assignments</p> </div> <div class="content-area"> <div id="startScreen"> <h2 class="section-title">Math Assignment Generator</h2> <div class="btn-group"> <button class="btn btn-primary" id="startGeneratingBtn">Start Generating</button> </div> </div> <div id="mathOptions" class="hidden"> <h2 class="section-title">Select Math Course</h2> <div class="btn-group"> <button class="btn btn-primary" id="selectMathBtn">Mathematics</button> </div> </div> <div id="chapterSelection" class="hidden"> <h2 class="section-title">Select Chapters</h2> <form id="chapterForm"> <div class="checkbox-container"> <div class="checkbox-item"> <input type="checkbox" id="fullPaper" name="chapter" value="Full Paper"> <label for="fullPaper">Full Syllabus (All Chapters)</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter1" name="chapter" value="Chapter 1"> <label for="chapter1">1. A Square and A Cube</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter2" name="chapter" value="Chapter 2"> <label for="chapter2">2. Power Play</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter3" name="chapter" value="Chapter 3"> <label for="chapter3">3. A Story of Numbers</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter4" name="chapter" value="Chapter 4"> <label for="chapter4">4. Quadrilaterals</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter5" name="chapter" value="Chapter 5"> <label for="chapter5">5. Number Play</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter6" name="chapter" value="Chapter 6"> <label for="chapter6">6. We Distribute, Yet Things Multiply</label> </div> <div class="checkbox-item"> <input type="checkbox" id="chapter7" name="chapter" value="Chapter 7"> <label for="chapter7">7. Proportional Reasoning-1</label> </div> </div> </form> <div id="message" class="hidden"></div> <div class="btn-group"> <button class="btn btn-danger" id="backToStartBtn">Back to Start</button> <button class="btn btn-success" id="generateAssignmentBtn">Generate Assignment</button> </div> </div> </div> </div> <div class="container hidden" id="generatedPaperContainer"></div> <script> // Initialize jsPDF const { jsPDF } = window.jspdf; // DOM Elements const startContainer = document.getElementById('startContainer'); const startScreen = document.getElementById('startScreen'); const mathOptions = document.getElementById('mathOptions'); const chapterSelection = document.getElementById('chapterSelection'); const generatedPaperContainer = document.getElementById('generatedPaperContainer'); // Buttons const startGeneratingBtn = document.getElementById('startGeneratingBtn'); const selectMathBtn = document.getElementById('selectMathBtn'); const backToStartBtn = document.getElementById('backToStartBtn'); const generateAssignmentBtn = document.getElementById('generateAssignmentBtn'); const fullPaperCheckbox = document.getElementById('fullPaper'); const chapterCheckboxes = document.querySelectorAll('input[name="chapter"]:not(#fullPaper)'); // Event Listeners startGeneratingBtn.addEventListener('click', showMathOptions); selectMathBtn.addEventListener('click', showChapters); backToStartBtn.addEventListener('click', backToStart); generateAssignmentBtn.addEventListener('click', generateAssignment); fullPaperCheckbox.addEventListener('change', toggleChapters); const questions = { "Chapter 1": { mcq: [ { question: "What is the volume of a cube with side length 3 cm?", options: ["9 cm³", "18 cm³", "27 cm³", "36 cm³"], answer: "27 cm³" }, { question: "Which of these is a perfect square?", options: ["24", "36", "50", "63"], answer: "36" }, { question: "What is the surface area of a cube with edge length 4 cm?", options: ["16 cm²", "64 cm²", "96 cm²", "128 cm²"], answer: "96 cm²" } ], fillBlank: [ { question: "The cube of 5 is __________.", answer: "125" }, { question: "A square has __________ sides of equal length.", answer: "four" } ], trueFalse: [ { question: "All cubes are cuboids.", answer: "True" }, { question: "The area of a square is always less than its perimeter.", answer: "False" } ], veryShort: [ "Find the square of 12.", "What is the edge length of a cube with volume 64 cm³?" ], short: [ "Explain the difference between a square and a cube with examples.", "Calculate the total surface area of a cube with side length 5 cm." ], long: [ "Discuss the properties of squares and cubes with diagrams.", "Explain how to find the volume of a cuboid and relate it to the volume of a cube." ] }, "Chapter 2": { mcq: [ { question: "What is 2³ × 2² equal to?", options: ["2u ", "2v ", "4u ", "4v "], answer: "2u " }, { question: "Which of these is equal to 10{ ²?", options: ["0.01", "0.1", "100", "-100"], answer: "0.01" }, { question: "What is the value of (3²)³?", options: ["3u ", "3v ", "9u ", "9v "], answer: "3v " } ], fillBlank: [ { question: "Any number raised to the power 0 is __________.", answer: "1" }, { question: "The expression aP × a = a__________.", answer: "m+n" } ], trueFalse: [ { question: "5p = 0", answer: "False" }, { question: "(2³)² = 2v ", answer: "True" } ], veryShort: [ "Simplify: 7³ ÷ 7²", "Express 0.0001 in power notation" ], short: [ "Explain the laws of exponents with examples.", "Simplify: (3² × 3u ) ÷ 3³" ], long: [ "Discuss the applications of exponents in real-life situations.", "Explain negative exponents and how they relate to fractions." ] }, "Chapter 3": { mcq: [ { question: "Which of these is a rational number?", options: [""2", "À", "0.75", ""5"], answer: "0.75" }, { question: "What is the decimal expansion of 3/8?", options: ["0.375", "0.38", "0.333...", "0.4"], answer: "0.375" }, { question: "Which number is neither prime nor composite?", options: ["0", "1", "2", "4"], answer: "1" } ], fillBlank: [ { question: "The decimal expansion of a rational number is either __________ or __________.", answer: "terminating, repeating" }, { question: "The smallest prime number is __________.", answer: "2" } ], trueFalse: [ { question: "All integers are rational numbers.", answer: "True" }, { question: "The decimal expansion of À is terminating.", answer: "False" } ], veryShort: [ "Is 0.333... a rational number? Why?", "Find two irrational numbers between 2 and 3." ], short: [ "Explain the difference between rational and irrational numbers with examples.", "Represent "5 on the number line." ], long: [ "Discuss the different types of numbers in the number system with examples.", "Explain how to find rational numbers between two given rational numbers." ] }, "Chapter 4": { mcq: [ { question: "How many diagonals does a quadrilateral have?", options: ["1", "2", "3", "4"], answer: "2" }, { question: "Which of these is always true for a parallelogram?", options: ["All sides equal", "All angles equal", "Opposite sides equal", "Diagonals equal"], answer: "Opposite sides equal" }, { question: "What is the sum of interior angles of a quadrilateral?", options: ["180°", "270°", "360°", "540°"], answer: "360°" } ], fillBlank: [ { question: "A quadrilateral with all sides equal is called a __________.", answer: "rhombus" }, { question: "The diagonals of a __________ bisect each other at right angles.", answer: "rhombus (or square)" } ], trueFalse: [ { question: "All rectangles are squares.", answer: "False" }, { question: "A square is both a rectangle and a rhombus.", answer: "True" } ], veryShort: [ "Name two properties of a parallelogram.", "What is the measure of each angle in a square?" ], short: [ "Explain the properties of a rectangle with a diagram.", "Differentiate between a trapezium and a parallelogram." ], long: [ "Discuss the hierarchy of quadrilaterals with their properties.", "Explain how to verify that a quadrilateral is a parallelogram using different methods." ] }, "Chapter 5": { mcq: [ { question: "What is the LCM of 12 and 18?", options: ["6", "18", "36", "72"], answer: "36" }, { question: "Which of these is a perfect cube?", options: ["16", "27", "36", "49"], answer: "27" }, { question: "What is the HCF of 24 and 36?", options: ["6", "8", "12", "24"], answer: "12" } ], fillBlank: [ { question: "The smallest number divisible by both 4 and 6 is __________.", answer: "12" }, { question: "A number that can be expressed as the cube of an integer is called a __________.", answer: "perfect cube" } ], trueFalse: [ { question: "The LCM of two prime numbers is their product.", answer: "True" }, { question: "1 is considered a prime number.", answer: "False" } ], veryShort: [ "Find the prime factors of 28.", "Is 64 a perfect cube? If yes, of what number?" ], short: [ "Explain how to find LCM using prime factorization with an example.", "List all perfect cubes between 20 and 100." ], long: [ "Discuss the applications of LCM and HCF in real-life situations with examples.", "Explain the concept of perfect cubes and their properties with examples." ] }, "Chapter 6": { mcq: [ { question: "What is the distributive property of multiplication over addition?", options: ["a × (b + c) = (a × b) + (a × c)", "a + (b × c) = (a + b) × (a + c)", "(a × b) × c = a × (b × c)", "a + b = b + a"], answer: "a × (b + c) = (a × b) + (a × c)" }, { question: "Which property is demonstrated by: 5 × (3 + 2) = (5 × 3) + (5 × 2)?", options: ["Commutative", "Associative", "Distributive", "Identity"], answer: "Distributive" }, { question: "What is the multiplicative inverse of 1/5?", options: ["-1/5", "-5", "5", "1/5"], answer: "5" } ], fillBlank: [ { question: "The property a + b = b + a is called the __________ property of addition.", answer: "commutative" }, { question: "The __________ property states that a × (b × c) = (a × b) × c.", answer: "associative" } ], trueFalse: [ { question: "Division is commutative for integers.", answer: "False" }, { question: "The distributive property applies to multiplication over subtraction as well.", answer: "True" } ], veryShort: [ "Name the property: 7 + 0 = 7", "What is the additive inverse of -3?" ], short: [ "Explain the distributive property with an example.", "Verify the associative property for multiplication with numbers 2, 3, and 4." ], long: [ "Discuss different properties of numbers (commutative, associative, distributive) with examples.", "Explain how the distributive property helps in simplifying algebraic expressions." ] }, "Chapter 7": { mcq: [ { question: "If 5 pens cost ¹ 75, what is the cost of 8 pens?", options: ["¹ 100", "¹ 120", "¹ 150", "¹ 200"], answer: "¹ 120" }, { question: "Which ratio is equivalent to 3:4?", options: ["6:8", "9:12", "12:16", "All of these"], answer: "All of these" }, { question: "If a:b = 2:3 and b:c = 4:5, what is a:c?", options: ["2:5", "8:15", "3:4", "5:8"], answer: "8:15" } ], fillBlank: [ { question: "If two quantities are in direct proportion, their ratio remains __________.", answer: "constant" }, { question: "The method of solving problems by finding the value of one unit first is called the __________ method.", answer: "unitary" } ], trueFalse: [ { question: "Speed and time are directly proportional when distance is constant.", answer: "False" }, { question: "If x " y, then x/y is constant.", answer: "True" } ], veryShort: [ "If 15 oranges cost ¹ 60, what is the cost of 25 oranges?", "Express the ratio 36:24 in simplest form." ], short: [ "Explain the concept of direct proportion with an example.", "Divide ¹ 1000 in the ratio 3:2 between two people." ], long: [ "Discuss different types of proportion (direct and inverse) with real-life examples.", "Explain how to solve problems involving compound ratios." ] } }; function getRandomQuestions(chapters, type, count) { try { let allQuestions = []; chapters.forEach(chapter => { if (questions[chapter] && questions[chapter][type]) { allQuestions = allQuestions.concat(questions[chapter][type]); } }); allQuestions = allQuestions.sort(() => Math.random() - 0.5); return allQuestions.slice(0, count); } catch (error) { console.error("Error in getRandomQuestions:", error); return []; } } function showMathOptions() { startScreen.classList.add('hidden'); mathOptions.classList.remove('hidden'); } function showChapters() { mathOptions.classList.add('hidden'); chapterSelection.classList.remove('hidden'); } function toggleChapters() { chapterCheckboxes.forEach(cb => cb.disabled = fullPaperCheckbox.checked); } function backToStart() { generatedPaperContainer.classList.add('hidden'); startContainer.classList.remove('hidden'); chapterSelection.classList.add('hidden'); startScreen.classList.remove('hidden'); } function generateAssignment() { try { console.log("Generating assignment..."); // Hide start container and show assignment container startContainer.classList.add('hidden'); generatedPaperContainer.classList.remove('hidden'); generatedPaperContainer.innerHTML = ''; // Get selected chapters const selectedChapters = fullPaperCheckbox.checked ? Object.keys(questions) : Array.from(document.querySelectorAll('input[name="chapter"]:checked')).map(cb => cb.value); if (selectedChapters.length === 0) { alert("Please select at least one chapter!"); startContainer.classList.remove('hidden'); return; } console.log("Selected chapters:", selectedChapters); const chapterNames = selectedChapters.map(ch => { if (ch === "Full Paper") return "Full Syllabus"; const label = document.querySelector(`label[for="${ch.toLowerCase()}"]`); return label ? ch + ". " + label.textContent.split(". ")[1] : ch; }).join(", "); console.log("Chapter names:", chapterNames); // Create assignment content let paperContent = ` <div class="header"> <h2>Class VIII Mathematics Assignment</h2> <h3>${selectedChapters.length === Object.keys(questions).length ? "Full Syllabus" : chapterNames}</h3> </div> <div class="content-area"> <div class="instructions"> <p><strong>General Instructions:</strong></p> <ol> <li>Complete all questions in your math notebook.</li> <li>Show all your workings clearly.</li> <li>Draw diagrams wherever necessary.</li> <li>Submit the assignment by the due date.</li> <li>Use blue or black ink only.</li> </ol> </div> `; // Get random questions const mcqs = getRandomQuestions(selectedChapters, 'mcq', 10); const fillBlanks = getRandomQuestions(selectedChapters, 'fillBlank', 5); const trueFalse = getRandomQuestions(selectedChapters, 'trueFalse', 5); const veryShort = getRandomQuestions(selectedChapters, 'veryShort', 5); const short = getRandomQuestions(selectedChapters, 'short', 5); const long = getRandomQuestions(selectedChapters, 'long', 5); console.log("Questions retrieved:", { mcqs, fillBlanks, trueFalse, veryShort, short, long }); let questionNumber = 1; // Section A - MCQ paperContent += ` <div class="question-section"> <h4 class="section-heading">Section A - Multiple Choice Questions (1 mark each)</h4> <p>Choose the correct option for each question:</p> `; mcqs.forEach(mcq => { paperContent += ` <div class="question"> <p class="question-text">${questionNumber++}. ${mcq.question}</p> ${mcq.options.map((opt, idx) => `<p class="option">${String.fromCharCode(65 + idx)}. ${opt}</p>` ).join('')} </div> `; }); // Section B - Fill in the blanks paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">Section B - Fill in the Blanks (1 mark each)</h4> <p>Fill in the blanks with appropriate words:</p> `; fillBlanks.forEach(fb => { paperContent += ` <div class="question"> <p class="question-text">${questionNumber++}. ${fb.question}</p> </div> `; }); // Section C - True/False paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">Section C - True/False Questions (1 mark each)</h4> <p>State whether the following statements are True or False:</p> `; trueFalse.forEach(tf => { paperContent += ` <div class="question"> <p class="question-text">${questionNumber++}. ${tf.question}</p> </div> `; }); // Section D - Very Short Questions paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">Section D - Very Short Answer Questions (2 marks each)</h4> `; veryShort.forEach(q => { paperContent += ` <div class="question"> <p class="question-text">${questionNumber++}. ${q}</p> </div> `; }); // Section E - Short Questions paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">Section E - Short Answer Questions (3 marks each)</h4> `; short.forEach(q => { paperContent += ` <div class="question"> <p class="question-text">${questionNumber++}. ${q}</p> </div> `; }); // Section F - Long Questions paperContent += ` </div> <div class="question-section"> <h4 class="section-heading">Section F - Long Answer Questions (5 marks each)</h4> `; long.forEach(q => { paperContent += ` <div class="question"> <p class="question-text">${questionNumber++}. ${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> `; console.log("Final paper content generated"); generatedPaperContainer.innerHTML = paperContent; console.log("Assignment generated successfully"); } catch (error) { console.error("Error generating assignment:", error); alert("An error occurred while generating the assignment. Please check the console for details."); backToStart(); } } 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 pVIIIels (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++; } // Save PDF pdf.save('Class_8_Math_Assignment.pdf'); console.log("PDF saved successfully"); } catch (error) { console.error('PDF generation error:', error); alert('Error generating PDF. Please check the console for details.'); // Remove temporary div if it exists const tempDiv = document.querySelector('.temp-pdf-container'); if (tempDiv) { document.body.removeChild(tempDiv); } } } </script> </body> </html>