Spaces:
Running
Running
undefined - Initial Deployment
Browse files- README.md +7 -5
- index.html +707 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: learning-coding
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,707 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>CodeMaster - Learn Programming Easily</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.language-dropdown:hover .language-menu {
|
| 11 |
+
display: block;
|
| 12 |
+
}
|
| 13 |
+
.lesson-card:hover {
|
| 14 |
+
transform: translateY(-5px);
|
| 15 |
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
|
| 16 |
+
}
|
| 17 |
+
.progress-ring__circle {
|
| 18 |
+
transition: stroke-dashoffset 0.5s;
|
| 19 |
+
transform: rotate(-90deg);
|
| 20 |
+
transform-origin: 50% 50%;
|
| 21 |
+
}
|
| 22 |
+
.quiz-option:hover {
|
| 23 |
+
background-color: #f3f4f6;
|
| 24 |
+
}
|
| 25 |
+
.quiz-option.selected {
|
| 26 |
+
background-color: #3b82f6;
|
| 27 |
+
color: white;
|
| 28 |
+
}
|
| 29 |
+
.quiz-option.correct {
|
| 30 |
+
background-color: #10b981;
|
| 31 |
+
color: white;
|
| 32 |
+
}
|
| 33 |
+
.quiz-option.incorrect {
|
| 34 |
+
background-color: #ef4444;
|
| 35 |
+
color: white;
|
| 36 |
+
}
|
| 37 |
+
</style>
|
| 38 |
+
</head>
|
| 39 |
+
<body class="bg-gray-50 font-sans">
|
| 40 |
+
<!-- Header -->
|
| 41 |
+
<header class="bg-white shadow-sm sticky top-0 z-10">
|
| 42 |
+
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
|
| 43 |
+
<div class="flex items-center space-x-2">
|
| 44 |
+
<i class="fas fa-code text-blue-600 text-2xl"></i>
|
| 45 |
+
<h1 class="text-xl font-bold text-gray-800">CodeMaster</h1>
|
| 46 |
+
</div>
|
| 47 |
+
<div class="flex items-center space-x-4">
|
| 48 |
+
<div class="language-dropdown relative">
|
| 49 |
+
<button id="languageBtn" class="flex items-center space-x-1 px-3 py-2 rounded-md hover:bg-gray-100">
|
| 50 |
+
<i class="fas fa-globe"></i>
|
| 51 |
+
<span>English</span>
|
| 52 |
+
<i class="fas fa-chevron-down text-xs"></i>
|
| 53 |
+
</button>
|
| 54 |
+
<div id="languageMenu" class="language-menu absolute right-0 mt-2 w-40 bg-white rounded-md shadow-lg py-1 z-20 hidden">
|
| 55 |
+
<a href="#" data-lang="en" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">English</a>
|
| 56 |
+
<a href="#" data-lang="ar" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">العربية</a>
|
| 57 |
+
<a href="#" data-lang="es" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Español</a>
|
| 58 |
+
<a href="#" data-lang="fr" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Français</a>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
<button id="themeToggle" class="p-2 rounded-full hover:bg-gray-100">
|
| 62 |
+
<i class="fas fa-moon"></i>
|
| 63 |
+
</button>
|
| 64 |
+
<button id="authBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition">
|
| 65 |
+
Sign In
|
| 66 |
+
</button>
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
| 69 |
+
</header>
|
| 70 |
+
|
| 71 |
+
<!-- Hero Section -->
|
| 72 |
+
<section class="bg-gradient-to-r from-blue-600 to-indigo-700 text-white py-16">
|
| 73 |
+
<div class="container mx-auto px-4 text-center">
|
| 74 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-4">Learn Programming the Easy Way</h1>
|
| 75 |
+
<p class="text-xl mb-8 max-w-2xl mx-auto">Master coding skills with interactive lessons and quizzes. Start your journey today!</p>
|
| 76 |
+
<div class="flex flex-col sm:flex-row justify-center gap-4">
|
| 77 |
+
<button class="bg-white text-blue-600 px-6 py-3 rounded-md font-medium hover:bg-gray-100 transition">Start Learning</button>
|
| 78 |
+
<button class="border-2 border-white text-white px-6 py-3 rounded-md font-medium hover:bg-white hover:text-blue-600 transition">Explore Courses</button>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
</section>
|
| 82 |
+
|
| 83 |
+
<!-- Main Content -->
|
| 84 |
+
<main class="container mx-auto px-4 py-12">
|
| 85 |
+
<div class="flex flex-col lg:flex-row gap-8">
|
| 86 |
+
<!-- Sidebar -->
|
| 87 |
+
<aside class="lg:w-1/4 bg-white rounded-lg shadow-md p-6 h-fit sticky top-24">
|
| 88 |
+
<h2 class="text-xl font-bold mb-4 text-gray-800">Courses</h2>
|
| 89 |
+
<div class="space-y-2">
|
| 90 |
+
<div class="course-category">
|
| 91 |
+
<button class="flex justify-between items-center w-full px-3 py-2 rounded-md hover:bg-gray-100">
|
| 92 |
+
<span class="font-medium">Web Development</span>
|
| 93 |
+
<i class="fas fa-chevron-down text-xs"></i>
|
| 94 |
+
</button>
|
| 95 |
+
<div class="pl-4 mt-1 space-y-1">
|
| 96 |
+
<a href="#" class="block px-3 py-1 text-sm rounded-md hover:bg-gray-100">HTML & CSS</a>
|
| 97 |
+
<a href="#" class="block px-3 py-1 text-sm rounded-md hover:bg-gray-100">JavaScript</a>
|
| 98 |
+
<a href="#" class="block px-3 py-1 text-sm rounded-md hover:bg-gray-100">React</a>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
<div class="course-category">
|
| 102 |
+
<button class="flex justify-between items-center w-full px-3 py-2 rounded-md hover:bg-gray-100">
|
| 103 |
+
<span class="font-medium">Mobile Development</span>
|
| 104 |
+
<i class="fas fa-chevron-down text-xs"></i>
|
| 105 |
+
</button>
|
| 106 |
+
</div>
|
| 107 |
+
<div class="course-category">
|
| 108 |
+
<button class="flex justify-between items-center w-full px-3 py-2 rounded-md hover:bg-gray-100">
|
| 109 |
+
<span class="font-medium">Data Science</span>
|
| 110 |
+
<i class="fas fa-chevron-down text-xs"></i>
|
| 111 |
+
</button>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<div class="mt-8">
|
| 116 |
+
<h3 class="font-bold mb-3 text-gray-800">Your Progress</h3>
|
| 117 |
+
<div class="flex items-center justify-center">
|
| 118 |
+
<div class="relative w-32 h-32">
|
| 119 |
+
<svg class="w-full h-full" viewBox="0 0 100 100">
|
| 120 |
+
<circle class="text-gray-200" stroke-width="8" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" />
|
| 121 |
+
<circle class="text-blue-600 progress-ring__circle" stroke-width="8" stroke-linecap="round" stroke="currentColor" fill="transparent" r="40" cx="50" cy="50" stroke-dasharray="251.2" stroke-dashoffset="125.6" />
|
| 122 |
+
</svg>
|
| 123 |
+
<div class="absolute inset-0 flex items-center justify-center flex-col">
|
| 124 |
+
<span class="text-2xl font-bold">50%</span>
|
| 125 |
+
<span class="text-xs text-gray-500">Completed</span>
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
<div class="mt-4 space-y-2">
|
| 130 |
+
<div class="flex justify-between text-sm">
|
| 131 |
+
<span>Completed Lessons</span>
|
| 132 |
+
<span>12/24</span>
|
| 133 |
+
</div>
|
| 134 |
+
<div class="w-full bg-gray-200 rounded-full h-2">
|
| 135 |
+
<div class="bg-blue-600 h-2 rounded-full" style="width: 50%"></div>
|
| 136 |
+
</div>
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
</aside>
|
| 140 |
+
|
| 141 |
+
<!-- Lessons Content -->
|
| 142 |
+
<div class="lg:w-3/4">
|
| 143 |
+
<!-- Breadcrumbs -->
|
| 144 |
+
<nav class="flex mb-6" aria-label="Breadcrumb">
|
| 145 |
+
<ol class="inline-flex items-center space-x-1 md:space-x-3">
|
| 146 |
+
<li class="inline-flex items-center">
|
| 147 |
+
<a href="#" class="inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600">
|
| 148 |
+
<i class="fas fa-home mr-2"></i>
|
| 149 |
+
Home
|
| 150 |
+
</a>
|
| 151 |
+
</li>
|
| 152 |
+
<li>
|
| 153 |
+
<div class="flex items-center">
|
| 154 |
+
<i class="fas fa-chevron-right text-gray-400 text-xs"></i>
|
| 155 |
+
<a href="#" class="ml-1 text-sm font-medium text-gray-700 hover:text-blue-600 md:ml-2">Web Development</a>
|
| 156 |
+
</div>
|
| 157 |
+
</li>
|
| 158 |
+
<li aria-current="page">
|
| 159 |
+
<div class="flex items-center">
|
| 160 |
+
<i class="fas fa-chevron-right text-gray-400 text-xs"></i>
|
| 161 |
+
<span class="ml-1 text-sm font-medium text-gray-500 md:ml-2">JavaScript Basics</span>
|
| 162 |
+
</div>
|
| 163 |
+
</li>
|
| 164 |
+
</ol>
|
| 165 |
+
</nav>
|
| 166 |
+
|
| 167 |
+
<!-- Current Lesson -->
|
| 168 |
+
<div class="bg-white rounded-lg shadow-md overflow-hidden mb-8">
|
| 169 |
+
<div class="p-6">
|
| 170 |
+
<div class="flex justify-between items-center mb-4">
|
| 171 |
+
<h2 class="text-2xl font-bold text-gray-800">Variables and Data Types</h2>
|
| 172 |
+
<span class="bg-green-100 text-green-800 text-xs font-medium px-2.5 py-0.5 rounded">Beginner</span>
|
| 173 |
+
</div>
|
| 174 |
+
|
| 175 |
+
<div class="prose max-w-none mb-6">
|
| 176 |
+
<p>In JavaScript, variables are containers for storing data values. JavaScript uses the <code>var</code>, <code>let</code>, and <code>const</code> keywords to declare variables.</p>
|
| 177 |
+
|
| 178 |
+
<h3 class="text-xl font-semibold mt-4">Variable Declaration</h3>
|
| 179 |
+
<pre class="bg-gray-100 p-4 rounded-md overflow-x-auto">
|
| 180 |
+
<code>
|
| 181 |
+
// Using var (old way, not recommended)
|
| 182 |
+
var name = "John";
|
| 183 |
+
|
| 184 |
+
// Using let (block-scoped, can be reassigned)
|
| 185 |
+
let age = 25;
|
| 186 |
+
|
| 187 |
+
// Using const (block-scoped, cannot be reassigned)
|
| 188 |
+
const PI = 3.14;
|
| 189 |
+
</code>
|
| 190 |
+
</pre>
|
| 191 |
+
|
| 192 |
+
<h3 class="text-xl font-semibold mt-4">Data Types</h3>
|
| 193 |
+
<p>JavaScript has several data types:</p>
|
| 194 |
+
<ul class="list-disc pl-5">
|
| 195 |
+
<li><strong>String:</strong> Textual data (e.g., "Hello World")</li>
|
| 196 |
+
<li><strong>Number:</strong> Numeric data (e.g., 42, 3.14)</li>
|
| 197 |
+
<li><strong>Boolean:</strong> True or false values</li>
|
| 198 |
+
<li><strong>Object:</strong> Collections of key-value pairs</li>
|
| 199 |
+
<li><strong>Array:</strong> Ordered lists of values</li>
|
| 200 |
+
<li><strong>Null:</strong> Intentional absence of any object value</li>
|
| 201 |
+
<li><strong>Undefined:</strong> Variable that has not been assigned a value</li>
|
| 202 |
+
</ul>
|
| 203 |
+
|
| 204 |
+
<div class="bg-blue-50 border-l-4 border-blue-500 p-4 mt-4">
|
| 205 |
+
<div class="flex">
|
| 206 |
+
<div class="flex-shrink-0">
|
| 207 |
+
<i class="fas fa-lightbulb text-blue-500"></i>
|
| 208 |
+
</div>
|
| 209 |
+
<div class="ml-3">
|
| 210 |
+
<p class="text-sm text-blue-700">
|
| 211 |
+
<strong>Tip:</strong> Always use <code>const</code> by default, and only use <code>let</code> when you know the variable's value will change. Avoid <code>var</code> in modern JavaScript.
|
| 212 |
+
</p>
|
| 213 |
+
</div>
|
| 214 |
+
</div>
|
| 215 |
+
</div>
|
| 216 |
+
</div>
|
| 217 |
+
|
| 218 |
+
<div class="flex justify-between mt-8">
|
| 219 |
+
<button class="flex items-center text-blue-600 hover:text-blue-800">
|
| 220 |
+
<i class="fas fa-arrow-left mr-2"></i>
|
| 221 |
+
Previous Lesson
|
| 222 |
+
</button>
|
| 223 |
+
<button id="startQuizBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition">
|
| 224 |
+
Take Quiz
|
| 225 |
+
<i class="fas fa-arrow-right ml-2"></i>
|
| 226 |
+
</button>
|
| 227 |
+
</div>
|
| 228 |
+
</div>
|
| 229 |
+
</div>
|
| 230 |
+
|
| 231 |
+
<!-- Lesson Navigation -->
|
| 232 |
+
<div class="bg-white rounded-lg shadow-md overflow-hidden mb-8">
|
| 233 |
+
<div class="p-6">
|
| 234 |
+
<h3 class="text-lg font-semibold mb-4">Course Lessons</h3>
|
| 235 |
+
<div class="space-y-3">
|
| 236 |
+
<div class="flex items-center p-3 rounded-md bg-blue-50 border border-blue-200">
|
| 237 |
+
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-blue-600 text-white flex items-center justify-center">
|
| 238 |
+
<span>1</span>
|
| 239 |
+
</div>
|
| 240 |
+
<div class="ml-3 flex-1">
|
| 241 |
+
<h4 class="text-sm font-medium">Introduction to JavaScript</h4>
|
| 242 |
+
<p class="text-xs text-gray-500">Completed</p>
|
| 243 |
+
</div>
|
| 244 |
+
<i class="fas fa-check text-green-500"></i>
|
| 245 |
+
</div>
|
| 246 |
+
|
| 247 |
+
<div class="flex items-center p-3 rounded-md bg-blue-50 border border-blue-200">
|
| 248 |
+
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-blue-600 text-white flex items-center justify-center">
|
| 249 |
+
<span>2</span>
|
| 250 |
+
</div>
|
| 251 |
+
<div class="ml-3 flex-1">
|
| 252 |
+
<h4 class="text-sm font-medium">Variables and Data Types</h4>
|
| 253 |
+
<p class="text-xs text-gray-500">Current Lesson</p>
|
| 254 |
+
</div>
|
| 255 |
+
<i class="fas fa-play text-blue-500"></i>
|
| 256 |
+
</div>
|
| 257 |
+
|
| 258 |
+
<div class="flex items-center p-3 rounded-md hover:bg-gray-50 cursor-pointer">
|
| 259 |
+
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-gray-200 text-gray-600 flex items-center justify-center">
|
| 260 |
+
<span>3</span>
|
| 261 |
+
</div>
|
| 262 |
+
<div class="ml-3 flex-1">
|
| 263 |
+
<h4 class="text-sm font-medium">Operators and Expressions</h4>
|
| 264 |
+
<p class="text-xs text-gray-500">Locked</p>
|
| 265 |
+
</div>
|
| 266 |
+
<i class="fas fa-lock text-gray-400"></i>
|
| 267 |
+
</div>
|
| 268 |
+
|
| 269 |
+
<div class="flex items-center p-3 rounded-md hover:bg-gray-50 cursor-pointer">
|
| 270 |
+
<div class="flex-shrink-0 w-8 h-8 rounded-full bg-gray-200 text-gray-600 flex items-center justify-center">
|
| 271 |
+
<span>4</span>
|
| 272 |
+
</div>
|
| 273 |
+
<div class="ml-3 flex-1">
|
| 274 |
+
<h4 class="text-sm font-medium">Control Flow</h4>
|
| 275 |
+
<p class="text-xs text-gray-500">Locked</p>
|
| 276 |
+
</div>
|
| 277 |
+
<i class="fas fa-lock text-gray-400"></i>
|
| 278 |
+
</div>
|
| 279 |
+
</div>
|
| 280 |
+
</div>
|
| 281 |
+
</div>
|
| 282 |
+
</div>
|
| 283 |
+
</div>
|
| 284 |
+
</main>
|
| 285 |
+
|
| 286 |
+
<!-- Quiz Modal -->
|
| 287 |
+
<div id="quizModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 288 |
+
<div class="bg-white rounded-lg shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto">
|
| 289 |
+
<div class="p-6">
|
| 290 |
+
<div class="flex justify-between items-center mb-6">
|
| 291 |
+
<h3 class="text-xl font-bold">Lesson Quiz</h3>
|
| 292 |
+
<button id="closeQuizModal" class="text-gray-500 hover:text-gray-700">
|
| 293 |
+
<i class="fas fa-times"></i>
|
| 294 |
+
</button>
|
| 295 |
+
</div>
|
| 296 |
+
|
| 297 |
+
<div class="mb-6">
|
| 298 |
+
<div class="flex justify-between text-sm mb-1">
|
| 299 |
+
<span>Progress</span>
|
| 300 |
+
<span><span id="currentQuestion">1</span>/5</span>
|
| 301 |
+
</div>
|
| 302 |
+
<div class="w-full bg-gray-200 rounded-full h-2">
|
| 303 |
+
<div id="quizProgress" class="bg-blue-600 h-2 rounded-full" style="width: 20%"></div>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
|
| 307 |
+
<div id="quizContent">
|
| 308 |
+
<div class="question mb-6">
|
| 309 |
+
<h4 class="text-lg font-semibold mb-4">1. Which keyword is used to declare a variable that cannot be reassigned?</h4>
|
| 310 |
+
<div class="space-y-3">
|
| 311 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 312 |
+
<span>var</span>
|
| 313 |
+
</div>
|
| 314 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 315 |
+
<span>let</span>
|
| 316 |
+
</div>
|
| 317 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true">
|
| 318 |
+
<span>const</span>
|
| 319 |
+
</div>
|
| 320 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 321 |
+
<span>static</span>
|
| 322 |
+
</div>
|
| 323 |
+
</div>
|
| 324 |
+
</div>
|
| 325 |
+
|
| 326 |
+
<div class="question mb-6 hidden">
|
| 327 |
+
<h4 class="text-lg font-semibold mb-4">2. What will be the output of: <code>console.log(typeof 42);</code></h4>
|
| 328 |
+
<div class="space-y-3">
|
| 329 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 330 |
+
<span>"string"</span>
|
| 331 |
+
</div>
|
| 332 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true">
|
| 333 |
+
<span>"number"</span>
|
| 334 |
+
</div>
|
| 335 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 336 |
+
<span>"integer"</span>
|
| 337 |
+
</div>
|
| 338 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 339 |
+
<span>"float"</span>
|
| 340 |
+
</div>
|
| 341 |
+
</div>
|
| 342 |
+
</div>
|
| 343 |
+
|
| 344 |
+
<div class="question mb-6 hidden">
|
| 345 |
+
<h4 class="text-lg font-semibold mb-4">3. Which of the following is NOT a valid JavaScript data type?</h4>
|
| 346 |
+
<div class="space-y-3">
|
| 347 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 348 |
+
<span>Boolean</span>
|
| 349 |
+
</div>
|
| 350 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 351 |
+
<span>Undefined</span>
|
| 352 |
+
</div>
|
| 353 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true">
|
| 354 |
+
<span>Character</span>
|
| 355 |
+
</div>
|
| 356 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 357 |
+
<span>Symbol</span>
|
| 358 |
+
</div>
|
| 359 |
+
</div>
|
| 360 |
+
</div>
|
| 361 |
+
|
| 362 |
+
<div class="question mb-6 hidden">
|
| 363 |
+
<h4 class="text-lg font-semibold mb-4">4. What is the correct way to declare a variable in modern JavaScript?</h4>
|
| 364 |
+
<div class="space-y-3">
|
| 365 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 366 |
+
<span>variable name = "Alice";</span>
|
| 367 |
+
</div>
|
| 368 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true">
|
| 369 |
+
<span>let name = "Alice";</span>
|
| 370 |
+
</div>
|
| 371 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 372 |
+
<span>v name = "Alice";</span>
|
| 373 |
+
</div>
|
| 374 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 375 |
+
<span>string name = "Alice";</span>
|
| 376 |
+
</div>
|
| 377 |
+
</div>
|
| 378 |
+
</div>
|
| 379 |
+
|
| 380 |
+
<div class="question mb-6 hidden">
|
| 381 |
+
<h4 class="text-lg font-semibold mb-4">5. Which of the following is a valid variable name in JavaScript?</h4>
|
| 382 |
+
<div class="space-y-3">
|
| 383 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 384 |
+
<span>2ndPlace</span>
|
| 385 |
+
</div>
|
| 386 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 387 |
+
<span>first-name</span>
|
| 388 |
+
</div>
|
| 389 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="true">
|
| 390 |
+
<span>firstName</span>
|
| 391 |
+
</div>
|
| 392 |
+
<div class="quiz-option p-3 border rounded-md cursor-pointer" data-correct="false">
|
| 393 |
+
<span>let</span>
|
| 394 |
+
</div>
|
| 395 |
+
</div>
|
| 396 |
+
</div>
|
| 397 |
+
</div>
|
| 398 |
+
|
| 399 |
+
<div class="flex justify-between mt-8">
|
| 400 |
+
<button id="prevQuestionBtn" class="text-blue-600 hover:text-blue-800 disabled:opacity-50 disabled:cursor-not-allowed" disabled>
|
| 401 |
+
<i class="fas fa-arrow-left mr-2"></i>
|
| 402 |
+
Previous
|
| 403 |
+
</button>
|
| 404 |
+
<button id="nextQuestionBtn" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition">
|
| 405 |
+
Next Question
|
| 406 |
+
<i class="fas fa-arrow-right ml-2"></i>
|
| 407 |
+
</button>
|
| 408 |
+
</div>
|
| 409 |
+
</div>
|
| 410 |
+
</div>
|
| 411 |
+
</div>
|
| 412 |
+
|
| 413 |
+
<!-- Quiz Results Modal -->
|
| 414 |
+
<div id="resultsModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
|
| 415 |
+
<div class="bg-white rounded-lg shadow-xl w-full max-w-md">
|
| 416 |
+
<div class="p-6 text-center">
|
| 417 |
+
<div class="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-green-100 mb-4">
|
| 418 |
+
<i class="fas fa-trophy text-green-600 text-xl"></i>
|
| 419 |
+
</div>
|
| 420 |
+
<h3 class="text-lg font-medium text-gray-900 mb-2">Quiz Completed!</h3>
|
| 421 |
+
<div class="mt-2">
|
| 422 |
+
<p class="text-sm text-gray-500">You scored <span id="quizScore" class="font-bold">0</span> out of 5</p>
|
| 423 |
+
</div>
|
| 424 |
+
<div class="mt-6">
|
| 425 |
+
<div class="w-full bg-gray-200 rounded-full h-2.5 mb-4">
|
| 426 |
+
<div id="scoreBar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
|
| 427 |
+
</div>
|
| 428 |
+
</div>
|
| 429 |
+
<div class="mt-6 flex justify-center gap-4">
|
| 430 |
+
<button id="retakeQuizBtn" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
|
| 431 |
+
Retake Quiz
|
| 432 |
+
</button>
|
| 433 |
+
<button id="continueLearningBtn" class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">
|
| 434 |
+
Continue Learning
|
| 435 |
+
</button>
|
| 436 |
+
</div>
|
| 437 |
+
</div>
|
| 438 |
+
</div>
|
| 439 |
+
</div>
|
| 440 |
+
|
| 441 |
+
<!-- Footer -->
|
| 442 |
+
<footer class="bg-gray-800 text-white py-12">
|
| 443 |
+
<div class="container mx-auto px-4">
|
| 444 |
+
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
|
| 445 |
+
<div>
|
| 446 |
+
<h3 class="text-lg font-semibold mb-4">CodeMaster</h3>
|
| 447 |
+
<p class="text-gray-400">Learn programming the easy way with interactive lessons and quizzes.</p>
|
| 448 |
+
</div>
|
| 449 |
+
<div>
|
| 450 |
+
<h4 class="text-lg font-semibold mb-4">Courses</h4>
|
| 451 |
+
<ul class="space-y-2">
|
| 452 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Web Development</a></li>
|
| 453 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Mobile Development</a></li>
|
| 454 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Data Science</a></li>
|
| 455 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Algorithms</a></li>
|
| 456 |
+
</ul>
|
| 457 |
+
</div>
|
| 458 |
+
<div>
|
| 459 |
+
<h4 class="text-lg font-semibold mb-4">Resources</h4>
|
| 460 |
+
<ul class="space-y-2">
|
| 461 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Documentation</a></li>
|
| 462 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Blog</a></li>
|
| 463 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Community</a></li>
|
| 464 |
+
<li><a href="#" class="text-gray-400 hover:text-white">Support</a></li>
|
| 465 |
+
</ul>
|
| 466 |
+
</div>
|
| 467 |
+
<div>
|
| 468 |
+
<h4 class="text-lg font-semibold mb-4">Connect</h4>
|
| 469 |
+
<div class="flex space-x-4">
|
| 470 |
+
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-facebook-f"></i></a>
|
| 471 |
+
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-twitter"></i></a>
|
| 472 |
+
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-instagram"></i></a>
|
| 473 |
+
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-linkedin-in"></i></a>
|
| 474 |
+
<a href="#" class="text-gray-400 hover:text-white"><i class="fab fa-github"></i></a>
|
| 475 |
+
</div>
|
| 476 |
+
<div class="mt-4">
|
| 477 |
+
<p class="text-gray-400">Subscribe to our newsletter</p>
|
| 478 |
+
<div class="mt-2 flex">
|
| 479 |
+
<input type="email" placeholder="Your email" class="px-3 py-2 bg-gray-700 text-white rounded-l-md focus:outline-none focus:ring-1 focus:ring-blue-500 w-full">
|
| 480 |
+
<button class="bg-blue-600 text-white px-4 py-2 rounded-r-md hover:bg-blue-700">Subscribe</button>
|
| 481 |
+
</div>
|
| 482 |
+
</div>
|
| 483 |
+
</div>
|
| 484 |
+
</div>
|
| 485 |
+
<div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400 text-sm">
|
| 486 |
+
<p>© 2023 CodeMaster. All rights reserved.</p>
|
| 487 |
+
</div>
|
| 488 |
+
</div>
|
| 489 |
+
</footer>
|
| 490 |
+
|
| 491 |
+
<script>
|
| 492 |
+
// Language switcher
|
| 493 |
+
const languageBtn = document.getElementById('languageBtn');
|
| 494 |
+
const languageMenu = document.getElementById('languageMenu');
|
| 495 |
+
const languageLinks = document.querySelectorAll('#languageMenu a');
|
| 496 |
+
|
| 497 |
+
languageBtn.addEventListener('click', () => {
|
| 498 |
+
languageMenu.classList.toggle('hidden');
|
| 499 |
+
});
|
| 500 |
+
|
| 501 |
+
languageLinks.forEach(link => {
|
| 502 |
+
link.addEventListener('click', (e) => {
|
| 503 |
+
e.preventDefault();
|
| 504 |
+
const lang = link.getAttribute('data-lang');
|
| 505 |
+
languageBtn.querySelector('span').textContent = link.textContent;
|
| 506 |
+
languageMenu.classList.add('hidden');
|
| 507 |
+
|
| 508 |
+
// In a real app, you would change the language here
|
| 509 |
+
console.log(`Language changed to: ${lang}`);
|
| 510 |
+
});
|
| 511 |
+
});
|
| 512 |
+
|
| 513 |
+
// Theme toggle
|
| 514 |
+
const themeToggle = document.getElementById('themeToggle');
|
| 515 |
+
const icon = themeToggle.querySelector('i');
|
| 516 |
+
|
| 517 |
+
themeToggle.addEventListener('click', () => {
|
| 518 |
+
document.documentElement.classList.toggle('dark');
|
| 519 |
+
|
| 520 |
+
if (document.documentElement.classList.contains('dark')) {
|
| 521 |
+
icon.classList.remove('fa-moon');
|
| 522 |
+
icon.classList.add('fa-sun');
|
| 523 |
+
localStorage.setItem('theme', 'dark');
|
| 524 |
+
} else {
|
| 525 |
+
icon.classList.remove('fa-sun');
|
| 526 |
+
icon.classList.add('fa-moon');
|
| 527 |
+
localStorage.setItem('theme', 'light');
|
| 528 |
+
}
|
| 529 |
+
});
|
| 530 |
+
|
| 531 |
+
// Check for saved theme preference
|
| 532 |
+
if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
| 533 |
+
document.documentElement.classList.add('dark');
|
| 534 |
+
icon.classList.remove('fa-moon');
|
| 535 |
+
icon.classList.add('fa-sun');
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
// Quiz functionality
|
| 539 |
+
const quizModal = document.getElementById('quizModal');
|
| 540 |
+
const startQuizBtn = document.getElementById('startQuizBtn');
|
| 541 |
+
const closeQuizModal = document.getElementById('closeQuizModal');
|
| 542 |
+
const nextQuestionBtn = document.getElementById('nextQuestionBtn');
|
| 543 |
+
const prevQuestionBtn = document.getElementById('prevQuestionBtn');
|
| 544 |
+
const currentQuestionDisplay = document.getElementById('currentQuestion');
|
| 545 |
+
const quizProgress = document.getElementById('quizProgress');
|
| 546 |
+
const quizContent = document.getElementById('quizContent');
|
| 547 |
+
const questions = document.querySelectorAll('.question');
|
| 548 |
+
const quizOptions = document.querySelectorAll('.quiz-option');
|
| 549 |
+
const resultsModal = document.getElementById('resultsModal');
|
| 550 |
+
const quizScore = document.getElementById('quizScore');
|
| 551 |
+
const scoreBar = document.getElementById('scoreBar');
|
| 552 |
+
const retakeQuizBtn = document.getElementById('retakeQuizBtn');
|
| 553 |
+
const continueLearningBtn = document.getElementById('continueLearningBtn');
|
| 554 |
+
|
| 555 |
+
let currentQuestion = 0;
|
| 556 |
+
let score = 0;
|
| 557 |
+
let userAnswers = Array(questions.length).fill(null);
|
| 558 |
+
|
| 559 |
+
startQuizBtn.addEventListener('click', () => {
|
| 560 |
+
quizModal.classList.remove('hidden');
|
| 561 |
+
document.body.style.overflow = 'hidden';
|
| 562 |
+
showQuestion(0);
|
| 563 |
+
});
|
| 564 |
+
|
| 565 |
+
closeQuizModal.addEventListener('click', () => {
|
| 566 |
+
quizModal.classList.add('hidden');
|
| 567 |
+
document.body.style.overflow = 'auto';
|
| 568 |
+
});
|
| 569 |
+
|
| 570 |
+
nextQuestionBtn.addEventListener('click', () => {
|
| 571 |
+
if (currentQuestion < questions.length - 1) {
|
| 572 |
+
currentQuestion++;
|
| 573 |
+
showQuestion(currentQuestion);
|
| 574 |
+
} else {
|
| 575 |
+
showResults();
|
| 576 |
+
}
|
| 577 |
+
});
|
| 578 |
+
|
| 579 |
+
prevQuestionBtn.addEventListener('click', () => {
|
| 580 |
+
if (currentQuestion > 0) {
|
| 581 |
+
currentQuestion--;
|
| 582 |
+
showQuestion(currentQuestion);
|
| 583 |
+
}
|
| 584 |
+
});
|
| 585 |
+
|
| 586 |
+
quizOptions.forEach(option => {
|
| 587 |
+
option.addEventListener('click', () => {
|
| 588 |
+
const questionContainer = option.closest('.question');
|
| 589 |
+
const options = questionContainer.querySelectorAll('.quiz-option');
|
| 590 |
+
|
| 591 |
+
// Remove selected class from all options in this question
|
| 592 |
+
options.forEach(opt => {
|
| 593 |
+
opt.classList.remove('selected');
|
| 594 |
+
});
|
| 595 |
+
|
| 596 |
+
// Add selected class to clicked option
|
| 597 |
+
option.classList.add('selected');
|
| 598 |
+
|
| 599 |
+
// Store user answer
|
| 600 |
+
const questionIndex = Array.from(questions).indexOf(questionContainer);
|
| 601 |
+
userAnswers[questionIndex] = option.getAttribute('data-correct') === 'true';
|
| 602 |
+
|
| 603 |
+
// Enable next button
|
| 604 |
+
nextQuestionBtn.disabled = false;
|
| 605 |
+
});
|
| 606 |
+
});
|
| 607 |
+
|
| 608 |
+
retakeQuizBtn.addEventListener('click', () => {
|
| 609 |
+
resultsModal.classList.add('hidden');
|
| 610 |
+
currentQuestion = 0;
|
| 611 |
+
score = 0;
|
| 612 |
+
userAnswers = Array(questions.length).fill(null);
|
| 613 |
+
resetQuiz();
|
| 614 |
+
showQuestion(0);
|
| 615 |
+
quizModal.classList.remove('hidden');
|
| 616 |
+
});
|
| 617 |
+
|
| 618 |
+
continueLearningBtn.addEventListener('click', () => {
|
| 619 |
+
resultsModal.classList.add('hidden');
|
| 620 |
+
quizModal.classList.add('hidden');
|
| 621 |
+
document.body.style.overflow = 'auto';
|
| 622 |
+
});
|
| 623 |
+
|
| 624 |
+
function showQuestion(index) {
|
| 625 |
+
// Hide all questions
|
| 626 |
+
questions.forEach(question => {
|
| 627 |
+
question.classList.add('hidden');
|
| 628 |
+
});
|
| 629 |
+
|
| 630 |
+
// Show current question
|
| 631 |
+
questions[index].classList.remove('hidden');
|
| 632 |
+
|
| 633 |
+
// Update progress display
|
| 634 |
+
currentQuestionDisplay.textContent = index + 1;
|
| 635 |
+
const progressPercent = ((index + 1) / questions.length) * 100;
|
| 636 |
+
quizProgress.style.width = `${progressPercent}%`;
|
| 637 |
+
|
| 638 |
+
// Update button states
|
| 639 |
+
prevQuestionBtn.disabled = index === 0;
|
| 640 |
+
|
| 641 |
+
if (index === questions.length - 1) {
|
| 642 |
+
nextQuestionBtn.innerHTML = 'Finish Quiz <i class="fas fa-check ml-2"></i>';
|
| 643 |
+
} else {
|
| 644 |
+
nextQuestionBtn.innerHTML = 'Next Question <i class="fas fa-arrow-right ml-2"></i>';
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
// Disable next button if no answer selected for current question
|
| 648 |
+
const currentOptions = questions[index].querySelectorAll('.quiz-option');
|
| 649 |
+
const hasSelected = Array.from(currentOptions).some(opt => opt.classList.contains('selected'));
|
| 650 |
+
nextQuestionBtn.disabled = !hasSelected;
|
| 651 |
+
|
| 652 |
+
// Restore user's previous answer if exists
|
| 653 |
+
if (userAnswers[index] !== null) {
|
| 654 |
+
currentOptions.forEach(opt => {
|
| 655 |
+
if (opt.classList.contains('selected')) {
|
| 656 |
+
opt.classList.remove('selected');
|
| 657 |
+
}
|
| 658 |
+
});
|
| 659 |
+
|
| 660 |
+
// In a real app, you would restore the user's actual selected answer
|
| 661 |
+
// This is simplified for the demo
|
| 662 |
+
currentOptions[0].classList.add('selected');
|
| 663 |
+
}
|
| 664 |
+
}
|
| 665 |
+
|
| 666 |
+
function showResults() {
|
| 667 |
+
// Calculate score
|
| 668 |
+
score = userAnswers.filter(answer => answer === true).length;
|
| 669 |
+
|
| 670 |
+
// Update results display
|
| 671 |
+
quizScore.textContent = score;
|
| 672 |
+
const scorePercent = (score / questions.length) * 100;
|
| 673 |
+
scoreBar.style.width = `${scorePercent}%`;
|
| 674 |
+
|
| 675 |
+
// Close quiz modal and show results
|
| 676 |
+
quizModal.classList.add('hidden');
|
| 677 |
+
resultsModal.classList.remove('hidden');
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
function resetQuiz() {
|
| 681 |
+
// Reset all options
|
| 682 |
+
quizOptions.forEach(option => {
|
| 683 |
+
option.classList.remove('selected', 'correct', 'incorrect');
|
| 684 |
+
});
|
| 685 |
+
|
| 686 |
+
// Reset progress
|
| 687 |
+
currentQuestionDisplay.textContent = '1';
|
| 688 |
+
quizProgress.style.width = '20%';
|
| 689 |
+
nextQuestionBtn.innerHTML = 'Next Question <i class="fas fa-arrow-right ml-2"></i>';
|
| 690 |
+
nextQuestionBtn.disabled = true;
|
| 691 |
+
prevQuestionBtn.disabled = true;
|
| 692 |
+
}
|
| 693 |
+
|
| 694 |
+
// Close modals when clicking outside
|
| 695 |
+
window.addEventListener('click', (e) => {
|
| 696 |
+
if (e.target === quizModal) {
|
| 697 |
+
quizModal.classList.add('hidden');
|
| 698 |
+
document.body.style.overflow = 'auto';
|
| 699 |
+
}
|
| 700 |
+
if (e.target === resultsModal) {
|
| 701 |
+
resultsModal.classList.add('hidden');
|
| 702 |
+
document.body.style.overflow = 'auto';
|
| 703 |
+
}
|
| 704 |
+
});
|
| 705 |
+
</script>
|
| 706 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=mohamed7869/learning-coding" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 707 |
+
</html>
|