File size: 10,141 Bytes
d49524c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math Solution Classifier</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: rgba(255, 255, 255, 0.95);
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
}
h1 {
text-align: center;
color: #333;
margin-bottom: 30px;
font-size: 2.5em;
background: linear-gradient(135deg, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.form-group {
margin-bottom: 25px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #333;
font-size: 1.1em;
}
textarea {
width: 100%;
min-height: 120px;
padding: 15px;
border: 2px solid #e1e5e9;
border-radius: 12px;
font-size: 16px;
font-family: 'Courier New', monospace;
background: #fafbfc;
transition: all 0.3s ease;
resize: vertical;
}
textarea:focus {
outline: none;
border-color: #667eea;
background: white;
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.classify-btn {
width: 100%;
padding: 18px;
background: linear-gradient(135deg, #667eea, #764ba2);
color: white;
border: none;
border-radius: 12px;
font-size: 18px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
}
.classify-btn:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}
.classify-btn:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
}
.result {
margin-top: 30px;
padding: 25px;
border-radius: 12px;
text-align: center;
font-size: 18px;
font-weight: 600;
opacity: 0;
transform: translateY(20px);
transition: all 0.5s ease;
}
.result.show {
opacity: 1;
transform: translateY(0);
}
.result.correct {
background: linear-gradient(135deg, #4facfe, #00f2fe);
color: white;
border: 3px solid #4facfe;
}
.result.conceptually-flawed {
background: linear-gradient(135deg, #fa709a, #fee140);
color: white;
border: 3px solid #fa709a;
}
.result.computationally-flawed {
background: linear-gradient(135deg, #ff6b6b, #ffa500);
color: white;
border: 3px solid #ff6b6b;
}
.result.error {
background: #f8f9fa;
color: #dc3545;
border: 3px solid #dc3545;
}
.loading {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
margin-right: 10px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.example {
background: #f8f9fa;
border-left: 4px solid #667eea;
padding: 15px;
margin: 20px 0;
border-radius: 0 8px 8px 0;
}
.example h3 {
color: #667eea;
margin-bottom: 10px;
}
.example-text {
font-family: 'Courier New', monospace;
font-size: 14px;
color: #555;
}
</style>
</head>
<body>
<div class="container">
<h1>🧮 Math Solution Classifier</h1>
<div class="example">
<h3>How to use:</h3>
<p>Enter a math question and a solution attempt. The AI will classify the solution as:</p>
<ul style="margin: 10px 0 0 20px;">
<li><strong>Correct:</strong> Solution is mathematically sound</li>
<li><strong>Conceptually Flawed:</strong> Wrong approach or understanding</li>
<li><strong>Computationally Flawed:</strong> Right approach, calculation errors</li>
</ul>
</div>
<form id="classifyForm">
<div class="form-group">
<label for="question">Math Question:</label>
<textarea
id="question"
name="question"
placeholder="e.g., Solve for x: 2x + 5 = 13"
required
></textarea>
</div>
<div class="form-group">
<label for="solution">Proposed Solution:</label>
<textarea
id="solution"
name="solution"
placeholder="e.g., 2x + 5 = 13 2x = 13 - 5 2x = 8 x = 4"
required
></textarea>
</div>
<button type="submit" class="classify-btn" id="submitBtn">
Classify Solution
</button>
</form>
<div id="result" class="result"></div>
</div>
<script>
const form = document.getElementById('classifyForm');
const submitBtn = document.getElementById('submitBtn');
const resultDiv = document.getElementById('result');
// Replace this URL with your actual API endpoint
const API_URL = 'https://your-huggingface-space.hf.space/classify';
form.addEventListener('submit', async (e) => {
e.preventDefault();
const question = document.getElementById('question').value.trim();
const solution = document.getElementById('solution').value.trim();
if (!question || !solution) {
showResult('Please fill in both fields', 'error');
return;
}
// Show loading state
submitBtn.disabled = true;
submitBtn.innerHTML = '<div class="loading"></div>Classifying...';
resultDiv.className = 'result';
resultDiv.textContent = '';
try {
const response = await fetch(API_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
question: question,
solution: solution
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
// Display result
showResult(formatResult(data.classification), data.classification);
} catch (error) {
console.error('Error:', error);
showResult('Error connecting to the classification service. Please try again.', 'error');
} finally {
// Reset button
submitBtn.disabled = false;
submitBtn.innerHTML = 'Classify Solution';
}
});
function formatResult(classification) {
const messages = {
'correct': '✅ Correct Solution!\nThe mathematical approach and calculations are both sound.',
'conceptually-flawed': '🤔 Conceptually Flawed\nThe approach or understanding has fundamental issues.',
'computationally-flawed': '🔢 Computationally Flawed\nThe approach is correct, but there are calculation errors.'
};
return messages[classification] || `Classification: ${classification}`;
}
function showResult(message, type) {
resultDiv.textContent = message;
resultDiv.className = `result ${type} show`;
}
// For demo purposes - remove this when you have a real API
if (API_URL.includes('your-huggingface-space')) {
// Mock API for testing
form.addEventListener('submit', async (e) => {
e.preventDefault();
submitBtn.disabled = true;
submitBtn.innerHTML = '<div class="loading"></div>Classifying...';
// Simulate API delay
await new Promise(resolve => setTimeout(resolve, 2000));
// Mock classification (randomly choose one for demo)
const classifications = ['correct', 'conceptually-flawed', 'computationally-flawed'];
const randomClassification = classifications[Math.floor(Math.random() * classifications.length)];
showResult(formatResult(randomClassification), randomClassification);
submitBtn.disabled = false;
submitBtn.innerHTML = 'Classify Solution';
});
}
</script>
</body>
</html> |