From ee4163ae426beecde909025dd1bfd7c92e2910c4 Mon Sep 17 00:00:00 2001 From: Yazdan Haider Date: Sun, 13 Oct 2024 20:48:53 +0530 Subject: [PATCH 1/9] Feature added to progress --- challenge.html | 8 +++++ learn.html | 9 ++++++ script.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ styles.css | 55 +++++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+) diff --git a/challenge.html b/challenge.html index c320280..432f8d0 100644 --- a/challenge.html +++ b/challenge.html @@ -30,6 +30,14 @@

Python Challenges

Welcome to the challenges section! Test your skills with various coding challenges.

+
+

Challenge Progress

+
+
+
+ +
+
+ + +
+

Lesson Progress

+
+
+
+ +
diff --git a/script.js b/script.js index 22d3de7..55153d3 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,66 @@ let editor; let pyodide; +// Add these lines at the beginning of the file +let userProgress = JSON.parse(localStorage.getItem('userProgress')) || { + lessons: {}, + challenges: {} +}; + +function updateProgress(type, item) { + if (type === 'lesson') { + userProgress.lessons[item] = true; + } else if (type === 'challenge') { + userProgress.challenges[item] = true; + } + localStorage.setItem('userProgress', JSON.stringify(userProgress)); + updateProgressBar(); +} + +function updateProgressBar() { + const lessonProgress = document.getElementById('lesson-progress'); + const challengeProgress = document.getElementById('challenge-progress'); + const lessonResetBtn = document.getElementById('lesson-reset-btn'); + const challengeResetBtn = document.getElementById('challenge-reset-btn'); + + if (lessonProgress) { + const completedLessons = Object.values(userProgress.lessons).filter(Boolean).length; + const totalLessons = document.querySelectorAll('.lesson-list li').length; + const lessonPercentage = (completedLessons / totalLessons) * 100; + lessonProgress.style.width = `${lessonPercentage}%`; + lessonProgress.textContent = `${Math.round(lessonPercentage)}%`; + + // Show reset button if there's any progress + if (lessonResetBtn) { + lessonResetBtn.style.display = completedLessons > 0 ? 'inline-block' : 'none'; + } + } + + if (challengeProgress) { + const completedChallenges = Object.values(userProgress.challenges).filter(Boolean).length; + const totalChallenges = document.querySelectorAll('#challenge-list li').length; + const challengePercentage = (completedChallenges / totalChallenges) * 100; + challengeProgress.style.width = `${challengePercentage}%`; + challengeProgress.textContent = `${Math.round(challengePercentage)}%`; + + // Show reset button if there's any progress + if (challengeResetBtn) { + challengeResetBtn.style.display = completedChallenges > 0 ? 'inline-block' : 'none'; + } + } +} + +// Add this function to your script.js file +function resetProgress(type) { + if (type === 'lesson') { + userProgress.lessons = {}; + } else if (type === 'challenge') { + userProgress.challenges = {}; + } + localStorage.setItem('userProgress', JSON.stringify(userProgress)); + updateProgressBar(); +} + async function initPyodide() { try { pyodide = await loadPyodide(); @@ -128,6 +188,7 @@ if "name" in student: major = student.get("major", "No major specified") print("Student's major:", major)`, 1); } + updateProgress('lesson', lesson); } async function runCode() { @@ -236,6 +297,7 @@ document.querySelectorAll('#challenge-list a').forEach(link => { function viewChallenge(challenge) { console.log("View Challenge:", challenge); // Additional logic for viewing the challenge can go here + updateProgress('challenge', challenge); } // Initial theme setting @@ -392,6 +454,7 @@ function viewChallenge(challengeName) { default: description.innerHTML = `

Select a challenge to view its description.

`; } + updateProgress('challenge', challengeName); } // FAQ Accordion @@ -410,4 +473,23 @@ document.addEventListener('DOMContentLoaded', function() { } }); } + updateProgressBar(); }); + +// Add this to your DOMContentLoaded event listener +document.addEventListener('DOMContentLoaded', () => { + // ... existing code ... + + const lessonResetBtn = document.getElementById('lesson-reset-btn'); + const challengeResetBtn = document.getElementById('challenge-reset-btn'); + + if (lessonResetBtn) { + lessonResetBtn.addEventListener('click', () => resetProgress('lesson')); + } + + if (challengeResetBtn) { + challengeResetBtn.addEventListener('click', () => resetProgress('challenge')); + } + + updateProgressBar(); +}); \ No newline at end of file diff --git a/styles.css b/styles.css index 690e450..f376b1d 100644 --- a/styles.css +++ b/styles.css @@ -493,4 +493,59 @@ body.dark-theme .accordion.active { flex: none; width: 100%; } +} + +/* Progress Bar Styles */ +.progress-container { + margin-bottom: 2rem; +} + +.progress-bar { + width: 100%; + background-color: #e0e0e0; + border-radius: 10px; + overflow: hidden; +} + +.progress { + width: 0; + height: 20px; + background-color: #3498db; + text-align: center; + line-height: 20px; + color: white; + transition: width 0.5s ease-in-out; +} + +body.dark-theme .progress-bar { + background-color: #2c3e50; +} + +body.dark-theme .progress { + background-color: #e94560; +} + +/* Add these styles to your styles.css file */ +.reset-btn { + display: none; + margin-top: 10px; + padding: 5px 10px; + background-color: #e74c3c; + color: white; + border: none; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s ease; +} + +.reset-btn:hover { + background-color: #c0392b; +} + +body.dark-theme .reset-btn { + background-color: #e94560; +} + +body.dark-theme .reset-btn:hover { + background-color: #d63649; } \ No newline at end of file From 7240502cd8ed763c8568f3833c0aff665dd8c938 Mon Sep 17 00:00:00 2001 From: mohit-1710 Date: Sun, 13 Oct 2024 21:25:51 +0530 Subject: [PATCH 2/9] added code input and output above boxes --- learn.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/learn.html b/learn.html index b3b2a70..4a19155 100644 --- a/learn.html +++ b/learn.html @@ -50,8 +50,11 @@

Python Lessons

+
+

Code Input :

+

Output :

From 4fa60947d1b0eb1d64ddbdd9acd486b8269767c4 Mon Sep 17 00:00:00 2001 From: Adi-204 Date: Sun, 13 Oct 2024 21:26:11 +0530 Subject: [PATCH 3/9] Fix dark theme bug of About Page --- about.html | 76 ++++++++++-------------------------------------------- styles.css | 35 +++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 62 deletions(-) diff --git a/about.html b/about.html index fb6e260..97d251e 100644 --- a/about.html +++ b/about.html @@ -10,54 +10,6 @@ - -
+
-
-

Our Mission

-

Welcome to Math 4 Python, where we blend the art of Python programming with the science of mathematics. Our mission is to provide a comprehensive learning platform that enhances your coding skills while deepening your understanding of mathematical concepts and problem-solving techniques.

+
+

Our Mission

+

Welcome to Math 4 Python, where we blend the art of Python programming with the science of mathematics. Our mission is to provide a comprehensive learning platform that enhances your coding skills while deepening your understanding of mathematical concepts and problem-solving techniques.

-
-

What We Offer

-

At Math 4 Python, we offer a structured learning path that starts with the basics of Python programming and gradually incorporates complex mathematical problems. Our content includes interactive lessons, practical exercises, and real-world applications to help you master both coding and math.

+
+

What We Offer

+

At Math 4 Python, we offer a structured learning path that starts with the basics of Python programming and gradually incorporates complex mathematical problems. Our content includes interactive lessons, practical exercises, and real-world applications to help you master both coding and math.

-
-

Why Learn With Us?

-

Our unique approach combines theoretical knowledge with hands-on practice. By learning Python through mathematical problems, you gain a dual advantage: proficiency in a powerful programming language and a solid foundation in math. This combination is essential for careers in data science, engineering, finance, and more.

+
+

Why Learn With Us?

+

Our unique approach combines theoretical knowledge with hands-on practice. By learning Python through mathematical problems, you gain a dual advantage: proficiency in a powerful programming language and a solid foundation in math. This combination is essential for careers in data science, engineering, finance, and more.

-
-

Contact Us

-

If you have any questions or would like more information, feel free to reach out to us at https://magicmath.co/.

+
+

Contact Us

+

If you have any questions or would like more information, feel free to reach out to us at https://magicmath.co/.

diff --git a/styles.css b/styles.css index 690e450..e936355 100644 --- a/styles.css +++ b/styles.css @@ -483,6 +483,41 @@ body.dark-theme .accordion.active { background-color: #34495e; } +/* About Page Style */ +.about-container { + width: 80%; + margin: 20px auto; + padding: 20px; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); + border-radius: 8px; +} +.about-h1, .about-h2 { + text-align: center; + color: #2C3E50; +} +.about-p { + line-height: 1.6; + margin-bottom: 20px; + text-align: justify; +} +.about-link { + color: #3498DB; + text-decoration: none; +} +.about-link:hover { + text-decoration: underline; +} +.banner h1 { + margin: 0; + font-size: 2em; +} +.about-section { + margin: 20px 0; +} +body.dark-theme .about-container { + background-color: #0f3460; +} + /* Responsive design for challenge and FAQ pages */ @media (max-width: 768px) { .challenge-container { From 10b0eed68ce71c2893f3a60266db9d1597392f63 Mon Sep 17 00:00:00 2001 From: Adi-204 Date: Sun, 13 Oct 2024 21:56:22 +0530 Subject: [PATCH 4/9] Added Copy and Reset Button features --- learn.html | 5 +++++ script.js | 25 +++++++++++++++++++++++++ styles.css | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/learn.html b/learn.html index b3b2a70..49a03be 100644 --- a/learn.html +++ b/learn.html @@ -51,6 +51,11 @@

Python Lessons

+
+ + + +
diff --git a/script.js b/script.js index 22d3de7..c044ce3 100644 --- a/script.js +++ b/script.js @@ -1,5 +1,6 @@ let editor; let pyodide; +let currentLesson; async function initPyodide() { try { @@ -14,6 +15,7 @@ async function initPyodide() { window.addEventListener('load', initPyodide); function showEditor(lesson) { + currentLesson = lesson; document.getElementById('editor-container').style.display = 'flex'; if (!editor) { editor = ace.edit("editor"); @@ -411,3 +413,26 @@ document.addEventListener('DOMContentLoaded', function() { }); } }); + +// Reset button +document.getElementById('reset-code').addEventListener('click', () => { + if (currentLesson) { + showEditor(currentLesson); + } +}); + +// Copy code button +document.getElementById('copy-code').addEventListener('click', () => { + const code = editor.getValue(); + navigator.clipboard.writeText(code) + .then(() => { + const copyMessage = document.getElementById('copy-message'); + copyMessage.style.display = 'block'; + setTimeout(() => { + copyMessage.style.display = 'none'; + }, 1000); + }) + .catch(err => { + console.error("Failed to copy text: ", err); + }); +}); diff --git a/styles.css b/styles.css index e936355..3c2a23d 100644 --- a/styles.css +++ b/styles.css @@ -518,6 +518,31 @@ body.dark-theme .about-container { background-color: #0f3460; } +#editor-controls { + display: flex; + justify-content: flex-end; + margin-top: 10px; + gap: 8px; +} + +#editor-controls button { + padding: 0.8rem 1.5rem; + color: white; + border: none; + border-radius: 25px; + font-weight: 600; + cursor: pointer; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); + background-color: #2ecc71; +} + +#copy-message { + margin-left: 10px; + font-size: 14px; + font-weight: bold; + color: green; +} + /* Responsive design for challenge and FAQ pages */ @media (max-width: 768px) { .challenge-container { From 8a7ded8fc37873ca85d4af701e5ebbe576891ea7 Mon Sep 17 00:00:00 2001 From: Dishika18 Date: Sun, 13 Oct 2024 21:59:35 +0530 Subject: [PATCH 5/9] UPDATE ABOUT SECTION --- about.css | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ about.html | 94 ++++++++++++++++++++---------------------------------- 2 files changed, 129 insertions(+), 59 deletions(-) create mode 100644 about.css diff --git a/about.css b/about.css new file mode 100644 index 0000000..98b90f3 --- /dev/null +++ b/about.css @@ -0,0 +1,94 @@ +body { + font-family: 'Arial', sans-serif; + margin: 0; + padding: 0; + background-color: #f4f4f4; + color: #333; +} + +.container { + width: 80%; + margin: 20px auto; + padding: 20px; + background: white; + box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); + border-radius: 8px; +} + +h1, +h2 { + text-align: center; + color: #2C3E50; +} + +p { + line-height: 1.6; + margin-bottom: 20px; + text-align: justify; +} + +.banner { + background-color: #7ab7df; + color: white; + padding: 10px 0; + margin-bottom: 20px; + text-align: center; + border-radius: 8px 8px 0 0; +} + +.banner h1 { + margin: 0; + font-size: 2em; +} + +.section { + margin: 20px 0; +} + +/* Style for the cards */ +.cards { + display: flex; + justify-content: space-around; + margin-top: 20px; +} + +.card { + background: #f9f9f9; + border: 1px solid #ddd; + border-radius: 10px; + padding: 20px; + width: 30%; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + text-align: center; + margin: 0 10px; + transition: transform 0.3s ease, box-shadow 0.3s ease; +} + +.card:hover { + transform: translateY(-10px); + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); +} + + +.card h3 { + color: #2C3E50; + margin-bottom: 10px; +} + +.card p { + color: #555; + font-size: 1em; +} + +/* Responsive design for smaller screens */ +@media (max-width: 768px) { + .cards { + flex-direction: column; + align-items: center; + } + + .card { + width: 80%; + margin-bottom: 20px; + } +} \ No newline at end of file diff --git a/about.html b/about.html index fb6e260..f6965f1 100644 --- a/about.html +++ b/about.html @@ -1,5 +1,6 @@ + @@ -7,58 +8,12 @@ About Math 4 Python - - - + + + + + From 560fab63170d5098190aff28602431aea77732af Mon Sep 17 00:00:00 2001 From: shubhambendkhale77 Date: Sun, 13 Oct 2024 22:39:00 +0530 Subject: [PATCH 6/9] add copy and reset button --- learn.html | 11 +++-------- styles.css | 31 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/learn.html b/learn.html index b3b2a70..fd1beb3 100644 --- a/learn.html +++ b/learn.html @@ -26,17 +26,11 @@
- - -
-

Python Lessons

Welcome to the Python lessons! Choose a lesson below to get started.

-
@@ -59,11 +53,12 @@

Python Lessons

+ +
- diff --git a/styles.css b/styles.css index 690e450..b0bce7f 100644 --- a/styles.css +++ b/styles.css @@ -493,4 +493,33 @@ body.dark-theme .accordion.active { flex: none; width: 100%; } -} \ No newline at end of file +} + +/* */ + +#button-container button { + cursor: pointer; + background-color: #007BFF; + color: white; + border: none; + border-radius: 4px; + padding: 10px 20px; + margin: 5px; + font-size: 16px; + transition: background-color 0.3s ease, transform 0.2s ease; +} + +#button-container button:hover { + background-color: #0056b3; + transform: scale(1.05); +} + +#button-container button:active { + background-color: #003f7f; + transform: scale(0.95); +} + +#button-container button:focus { + outline: none; + box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5); +} From 85b856d61f351ade44bdedc5df6768cbd77ef720 Mon Sep 17 00:00:00 2001 From: shubhambendkhale77 Date: Sun, 13 Oct 2024 23:13:24 +0530 Subject: [PATCH 7/9] add Generate Random Question feature button --- learn.html | 8 ++++++++ script.js | 21 +++++++++++++++++++++ styles.css | 27 +++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/learn.html b/learn.html index fd1beb3..7dcef2c 100644 --- a/learn.html +++ b/learn.html @@ -31,6 +31,10 @@

Python Lessons

Welcome to the Python lessons! Choose a lesson below to get started.

+
+ +

+
+
+ + +
diff --git a/script.js b/script.js index 22d3de7..b923a73 100644 --- a/script.js +++ b/script.js @@ -243,6 +243,27 @@ document.addEventListener('DOMContentLoaded', () => { updateThemeIcon(); }); +// genrate random quetions + +const questions = [ + "Write a Python function to find the factorial of a number.", + "Write a Python program to check if a string is a palindrome.", + "Write a Python function to calculate the sum of numbers in a list.", + "Write a Python program to print the Fibonacci sequence.", + "Write a Python function to sort a list of numbers." + // Add more questions as needed +]; + +function generateQuestion() { + const randomIndex = Math.floor(Math.random() * questions.length); + const randomQuestion = questions[randomIndex]; + document.getElementById('random-question').innerText = randomQuestion; +} + +// Call this function on page load if you want to display a question initially +// generateQuestion(); + + // For the challenge page function viewChallenge(challengeName) { diff --git a/styles.css b/styles.css index b0bce7f..2641d46 100644 --- a/styles.css +++ b/styles.css @@ -523,3 +523,30 @@ body.dark-theme .accordion.active { outline: none; box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5); } + +#question-container { + margin-top: 20px; + text-align: center; +} + +#generate-question-button { + cursor: pointer; + background-color: #28a745; + color: white; + border: none; + border-radius: 4px; + padding: 10px 20px; + font-size: 16px; + transition: background-color 0.3s ease, transform 0.2s ease; +} + +#generate-question-button:hover { + background-color: #218838; + transform: scale(1.05); +} + +#random-question { + margin-top: 15px; + font-size: 18px; + font-weight: bold; +} From 40426417612e63e0b04cf5c7d9892db5a6252b55 Mon Sep 17 00:00:00 2001 From: mohit-1710 Date: Sun, 13 Oct 2024 23:23:28 +0530 Subject: [PATCH 8/9] added hamburger menu icon for mobile devices --- about.html | 11 ++++++- challenge.html | 11 ++++++- faq.html | 11 ++++++- hamburger_menu.css | 76 ++++++++++++++++++++++++++++++++++++++++++++++ index.html | 21 ++++++++----- learn.html | 11 ++++++- script.js | 10 ++++++ 7 files changed, 140 insertions(+), 11 deletions(-) create mode 100644 hamburger_menu.css diff --git a/about.html b/about.html index fb6e260..d9d6cdb 100644 --- a/about.html +++ b/about.html @@ -58,10 +58,19 @@ margin: 20px 0; } +