Access rate limit exceeded. Please log in to continue.
轮胎动平衡检测步骤配对 - 教学版
<!-- 签到遮罩层 -->
<div id="auth-overlay" class="fixed inset-0 bg-slate-900/90 backdrop-blur-md z-[100] flex items-center justify-center p-4">
<div class="bg-white rounded-3xl shadow-2xl p-8 max-w-sm w-full text-center">
<div class="w-20 h-20 bg-blue-100 text-blue-600 rounded-full flex items-center justify-center text-3xl mx-auto mb-6">🔧</div>
<h2 class="text-2xl font-bold mb-2">学生签到</h2>
<p class="text-slate-500 mb-8 text-sm">请输入姓名开始动平衡实训考核</p>
<input type="text" id="student-name-input" placeholder="输入您的姓名"
class="w-full border-2 border-slate-100 rounded-2xl px-5 py-4 mb-6 focus:border-blue-500 focus:ring-4 focus:ring-blue-100 outline-none transition-all text-center text-lg font-medium">
<button onclick="startGame()" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-4 rounded-2xl shadow-lg shadow-blue-200 transition-all active:scale-95 text-lg">
进入挑战
</button>
<p id="env-status" class="mt-6 text-[10px] text-slate-400 uppercase tracking-widest"></p>
</div>
</div>
<div class="max-w-6xl mx-auto py-10 px-6">
<header class="text-center mb-12">
<h1 class="text-4xl font-black text-slate-800 mb-4 tracking-tight">轮胎动平衡检测与校正步骤排列</h1>
<div class="inline-block bg-orange-100 text-orange-700 px-6 py-2 rounded-full font-bold text-sm">
挑战模式:请从选项中挑选出正确步骤并按顺序排列
</div>
<p class="mt-4 text-slate-500 font-medium">当前操作员:<span id="display-name" class="text-blue-600 underline decoration-2 underline-offset-4">未登录</span></p>
</header>
<div class="grid grid-cols-1 lg:grid-cols-12 gap-10">
<div class="lg:col-span-7 space-y-4" id="drop-zones">
<h3 class="text-lg font-bold text-slate-700 mb-4 flex items-center">
<span class="w-8 h-8 bg-blue-600 text-white rounded-lg flex items-center justify-center mr-3 text-sm">GO</span>
标准化操作流程 (8个必选步骤)
</h3>
</div>
<div class="lg:col-span-5">
<div class="bg-white p-6 rounded-3xl shadow-xl shadow-slate-200/50 border border-slate-100 sticky top-10">
<h3 class="text-lg font-bold text-orange-600 mb-4 flex items-center">
<span class="mr-2">📦</span> 备选步骤池 (含干扰项)
</h3>
<div id="options-list" class="space-y-3 p-4 bg-slate-50 rounded-2xl border-2 border-dashed border-slate-200 min-h-[500px]"></div>
</div>
</div>
</div>
<div class="mt-16 flex flex-col items-center gap-6">
<div id="message-box" class="hidden w-full max-w-2xl p-6 rounded-2xl text-center font-bold text-xl shadow-lg transform transition-all"></div>
<div class="flex gap-4">
<button onclick="checkOrder()" class="bg-blue-600 hover:bg-blue-700 text-white px-12 py-5 rounded-2xl font-black shadow-xl transition-all active:scale-95 flex items-center gap-2">提交考核结果</button>
<button onclick="window.confirmReset()" class="bg-white border-2 border-slate-200 text-slate-600 px-8 py-5 rounded-2xl font-bold hover:bg-slate-50 transition-all">重置</button>
</div>
</div>
<div class="mt-24 border-t border-slate-200 pt-10 flex flex-col items-center">
<button onclick="toggleTeacherPortal()" class="text-slate-400 hover:text-blue-500 text-sm font-medium transition-colors flex items-center gap-2">
🔒 教师管理后台 (查看学生正确率)
</button>
<div id="teacher-view" class="hidden w-full mt-10 bg-white rounded-3xl shadow-2xl border border-slate-100 overflow-hidden">
<div class="bg-slate-900 text-white p-6 flex justify-between items-center">
<h3 class="font-bold">实训考核实时监测</h3>
<span id="sync-tag" class="px-3 py-1 bg-slate-700 rounded-full text-[10px] font-bold">LOCAL STORAGE</span>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left">
<thead class="bg-slate-50 text-slate-500 text-xs font-black uppercase tracking-wider">
<tr><th class="p-6">学生姓名</th><th class="p-6">考核正确率</th><th class="p-6">提交时间</th></tr>
</thead>
<tbody id="score-list" class="divide-y divide-slate-100"></tbody>
</table>
</div>
<div class="p-4 bg-slate-50 text-center">
<button onclick="clearLocalData()" class="text-xs text-red-400 hover:text-red-600">清空本地缓存数据</button>
</div>
</div>
</div>
</div>
<div id="modal" class="fixed inset-0 bg-black/60 z-[200] hidden items-center justify-center p-4">
<div class="bg-white rounded-3xl p-8 max-w-sm w-full shadow-2xl text-center">
<p id="modal-text" class="text-slate-800 text-lg font-bold mb-6"></p>
<button onclick="closeModal()" class="w-full bg-slate-900 text-white py-4 rounded-2xl font-bold">确认</button>
</div>
</div>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.6.1/firebase-app.js";
import { getAuth, signInAnonymously, signInWithCustomToken } from "https://www.gstatic.com/firebasejs/11.6.1/firebase-auth.js";
import { getFirestore, collection, addDoc, onSnapshot, serverTimestamp } from "https://www.gstatic.com/firebasejs/11.6.1/firebase-firestore.js";
let db = null;
let auth = null;
let isCloud = false;
let studentName = "";
const appId = typeof __app_id !== 'undefined' ? __app_id : 'tire-balancing-v2';
const correctSteps = [
{ id: 1, text: "清除旧平衡块与轮胎杂物" },
{ id: 2, text: "检查并调整轮胎气压" },
{ id: 3, text: "将轮胎安装至平衡机主轴" },
{ id: 4, text: "输入轮胎尺寸参数 (L/W/D)" },
{ id: 5, text: "启动机器进行旋转测量" },
{ id: 6, text: "寻找内/外侧不平衡位置" },
{ id: 7, text: "在对应位置粘贴或敲入平衡块" },
{ id: 8, text: "再次测量确认数值显示为 0" }
];
const distractors = [
{ id: 101, text: "测量轮胎胎面花纹深度" },
{ id: 102, text: "检查轮毂表面是否有划痕" },
{ id: 103, text: "向轮胎内充入高纯度氮气" }
];
// 初始化环境
const init = async () => {
try {
if (typeof __firebase_config !== 'undefined') {
const config = JSON.parse(__firebase_config);
const app = initializeApp(config);
auth = getAuth(app);
db = getFirestore(app);
if (typeof __initial_auth_token !== 'undefined' && __initial_auth_token) {
await signInWithCustomToken(auth, __initial_auth_token);
} else {
await signInAnonymously(auth);
}
isCloud = true;
document.getElementById('env-status').innerText = "● CLOUD MODE ACTIVE";
document.getElementById('sync-tag').innerText = "LIVE CLOUD SYNC";
document.getElementById('sync-tag').className = "px-3 py-1 bg-green-500 text-white rounded-full text-[10px] font-bold";
} else {
document.getElementById('env-status').innerText = "● LOCAL STORAGE MODE";
}
} catch (e) {
document.getElementById('env-status').innerText = "● LOCAL STORAGE MODE";
}
};
window.startGame = () => {
const input = document.getElementById('student-name-input');
if (!input.value.trim()) { window.alertCustom("请输入姓名"); return; }
studentName = input.value.trim();
document.getElementById('display-name').innerText = studentName;
document.getElementById('auth-overlay').classList.add('hidden');
renderGame();
};
window.checkOrder = async () => {
const zones = document.querySelectorAll('#drop-zones .drop-target');
let correctCount = 0;
let filledCount = 0;
zones.forEach((zone, idx) => {
const child = zone.children[0];
if (child) {
filledCount++;
const isCorrect = parseInt(child.dataset.id) === (idx + 1);
if (isCorrect) correctCount++;
zone.className = `flex-grow drop-target border-2 rounded-2xl p-2 flex items-center ${isCorrect ? 'slot-correct' : 'slot-incorrect'}`;
}
});
if (filledCount < 8) { window.alertCustom("请排满8个步骤"); return; }
const accuracy = Math.round((correctCount / 8) * 100);
const msg = document.getElementById('message-box');
msg.className = `w-full max-w-2xl p-6 rounded-2xl text-center font-bold text-xl shadow-lg block ${accuracy === 100 ? 'bg-green-500 text-white' : 'bg-orange-500 text-white'}`;
msg.innerText = accuracy === 100 ? "🎉 完美!成绩已保存。" : `完成!正确率:${accuracy}%,已记录。`;
msg.classList.remove('hidden');
const scoreData = { name: studentName, accuracy: accuracy, timestamp: Date.now() };
if (isCloud && db) {
await addDoc(collection(db, 'artifacts', appId, 'public', 'data', 'student_scores'), { ...scoreData, timestamp: serverTimestamp() });
} else {
// 保存到本地缓存
let localScores = JSON.parse(localStorage.getItem('tire_scores') || '[]');
localScores.push(scoreData);
localStorage.setItem('tire_scores', JSON.stringify(localScores));
if (!document.getElementById('teacher-view').classList.contains('hidden')) renderTeacherList();
}
};
window.toggleTeacherPortal = () => {
const pw = prompt("请输入管理密码 (123456):");
if (pw === "123456") {
document.getElementById('teacher-view').classList.remove('hidden');
renderTeacherList();
}
};
function renderTeacherList() {
const list = document.getElementById('score-list');
list.innerHTML = '';
if (isCloud && db) {
onSnapshot(collection(db, 'artifacts', appId, 'public', 'data', 'student_scores'), (snap) => {
list.innerHTML = '';
const data = [];
snap.forEach(d => data.push(d.data()));
data.sort((a,b) => (b.timestamp?.seconds || 0) - (a.timestamp?.seconds || 0));
data.forEach(s => addRow(s.name, s.accuracy, s.timestamp?.seconds ? new Date(s.timestamp.seconds*1000).toLocaleString() : '同步中'));
});
} else {
const localData = JSON.parse(localStorage.getItem('tire_scores') || '[]');
localData.sort((a,b) => b.timestamp - a.timestamp);
localData.forEach(s => addRow(s.name, s.accuracy, new Date(s.timestamp).toLocaleString()));
}
}
function addRow(name, acc, time) {
const row = document.createElement('tr');
row.innerHTML = `<td class="p-6 font-bold">${name}</td><td class="p-6 font-black text-blue-600">${acc}%</td><td class="p-6 text-slate-400 text-xs">${time}</td>`;
document.getElementById('score-list').appendChild(row);
}
window.clearLocalData = () => {
if(confirm("确定清空所有本地记录吗?")) {
localStorage.removeItem('tire_scores');
renderTeacherList();
}
};
// 基础功能
function renderGame() {
const zones = document.getElementById('drop-zones');
const options = document.getElementById('options-list');
zones.querySelectorAll('.drop-target').forEach(z => z.remove());
zones.innerHTML = '<h3 class="text-lg font-bold text-slate-700 mb-4 flex items-center"><span class="w-8 h-8 bg-blue-600 text-white rounded-lg flex items-center justify-center mr-3 text-sm">GO</span>标准化操作流程 (8个必选步骤)</h3>';
options.innerHTML = '';
for(let i=1; i<=8; i++) {
const div = document.createElement('div');
div.className = "flex items-center gap-4";
div.innerHTML = `<div class="w-12 h-12 bg-white text-slate-300 rounded-2xl flex items-center justify-center font-black border-2 border-slate-100">${i}</div><div class="flex-grow drop-target slot-empty rounded-2xl p-2 h-[68px] flex items-center border-2" data-index="${i}"></div>`;
zones.appendChild(div);
}
[...correctSteps, ...distractors].sort(()=>Math.random()-0.5).forEach(item => {
const el = document.createElement('div');
el.className = "draggable bg-white border-2 border-slate-100 p-4 rounded-xl shadow-sm text-slate-700 font-bold hover:border-blue-400";
el.draggable = true;
el.innerText = item.text;
el.dataset.id = item.id;
el.ondragstart = () => el.classList.add('dragging');
el.ondragend = () => el.classList.remove('dragging');
options.appendChild(el);
});
document.querySelectorAll('.drop-target, #options-list').forEach(area => {
area.ondragover = (e) => { e.preventDefault(); area.classList.add('bg-blue-50'); };
area.ondragleave = () => area.classList.remove('bg-blue-50');
area.ondrop = (e) => {
e.preventDefault();
area.classList.remove('bg-blue-50');
const drag = document.querySelector('.dragging');
if (area.classList.contains('drop-target') && area.children.length > 0) document.getElementById('options-list').appendChild(area.children[0]);
area.appendChild(drag);
};
});
}
window.confirmReset = () => { if(confirm("确定重置?")) renderGame(); };
window.alertCustom = (t) => { document.getElementById('modal-text').innerText = t; document.getElementById('modal').classList.replace('hidden', 'flex'); };
window.closeModal = () => document.getElementById('modal').classList.replace('flex', 'hidden');
init();
</script>