|
<!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'); |
|
|
|
|
|
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; |
|
} |
|
|
|
|
|
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(); |
|
|
|
|
|
showResult(formatResult(data.classification), data.classification); |
|
|
|
} catch (error) { |
|
console.error('Error:', error); |
|
showResult('Error connecting to the classification service. Please try again.', 'error'); |
|
} finally { |
|
|
|
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`; |
|
} |
|
|
|
|
|
if (API_URL.includes('your-huggingface-space')) { |
|
|
|
form.addEventListener('submit', async (e) => { |
|
e.preventDefault(); |
|
|
|
submitBtn.disabled = true; |
|
submitBtn.innerHTML = '<div class="loading"></div>Classifying...'; |
|
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 2000)); |
|
|
|
|
|
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> |