学生随机点名Html系统源码

提示:本文最后更新于2025-05-09,如有错误或者已经失效,请评论,留言或者告知在线客服。
学生随机点名 Html 系统源码凭借其简单易用的操作、公正无偏的随机点名算法和良好的隐私保护机制,为教师提供了一个理想的课堂点名工具。

班级课堂点名小工具,学生随机点名Html系统源码。学生随机点名 Html 系统源码是一款专为教师设计的课堂点名工具。

它采用纯前端 Html、Css 和 JavaScript 技术构建,无需复杂的服务器支持,只需在浏览器中打开即可使用。通过简单的配置和操作,教师可以轻松实现公正无偏的学生随机点名,有效提升课堂互动和学生参与度。

源码功能

  • 简单易用的界面 :提供直观的用户界面,教师可以快速上手,无需复杂的学习过程。
  • 随机点名算法 :基于随机算法,确保每个学生被点名的机会均等,实现公正无偏的点名。
  • 学生名单管理 :支持手动输入或导入学生名单,方便教师快速配置和管理学生信息。
  • 点名记录保存 :自动保存点名记录,方便教师查看和分析学生参与情况,为教学评估提供依据。
  • 自定义设置 :允许教师根据教学需求自定义点名规则,如点名人数、点名间隔等。

源码特色

  • 无需安装 :作为纯前端应用,无需安装任何软件,只需在浏览器中打开 Html 文件即可使用,方便快捷。
  • 跨平台兼容 :兼容多种操作系统和浏览器,确保在不同设备上都能稳定运行,满足教师在不同场景下的使用需求。
  • 高度可定制 :源码开放,教师可以根据自己的需求进行二次开发和定制,如添加特殊功能、修改界面样式等。
  • 隐私保护 :数据存储在本地浏览器,不涉及网络传输和服务器存储,有效保护学生和教师的隐私。

代码

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生随机点名系统-渡漳网</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .upload-section {
            margin-bottom: 20px;
            padding: 15px;
            background-color: #f0f8ff;
            border-radius: 5px;
        }
        .result-section {
            margin-top: 20px;
            padding: 15px;
            background-color: #fffaf0;
            border-radius: 5px;
            min-height: 100px;
        }
        .student-list {
            margin-top: 15px;
            max-height: 200px;
            overflow-y: auto;
            border: 1px solid #ddd;
            padding: 10px;
            border-radius: 5px;
        }
        button {
            background-color: #4CAF50;
            color: white;
            border: none;
            padding: 10px 15px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin: 4px 2px;
            cursor: pointer;
            border-radius: 4px;
        }
        button:hover {
            background-color: #45a049;
        }
        .selected {
            background-color: #ffeb3b;
            padding: 5px;
            margin: 2px;
            border-radius: 3px;
            display: inline-block;
        }
        .controls {
            margin: 15px 0;
        }
        .file-info {
            margin-top: 10px;
            font-size: 0.9em;
            color: #666;
        }
        /* 闪动效果样式 */
        .flashing-name {
            font-size: 24px;
            font-weight: bold;
            text-align: center;
            padding: 20px;
            background-color: #ff9800;
            color: white;
            border-radius: 8px;
            margin: 15px 0;
            min-height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s;
            flex-wrap: wrap;
        }
        .flashing-fast {
            animation: flash 0.1s infinite;
        }
        @keyframes flash {
            0% { background-color: #ff9800; }
            50% { background-color: #ff5722; }
            100% { background-color: #ff9800; }
        }
        .final-selection {
            background-color: #4CAF50;
            animation: none;
        }
        .selected-name {
            margin: 5px;
            padding: 8px 15px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 20px;
            display: inline-block;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>学生随机点名系统</h1>
        
        <div class="upload-section">
            <h2>上传学生名单</h2>
            <input type="file" id="fileInput" accept=".txt,.csv,.xlsx,.xls">
            <div class="file-info" id="fileInfo">支持格式: TXT, CSV, XLSX (Excel)</div>
            <p>或手动输入学生名单(每行一个名字):</p>
            <textarea id="manualInput" rows="5" style="width: 100%;"></textarea>
            <button onclick="loadStudents()">加载名单</button>
            
            <div class="student-list" id="studentList">
                <p>当前没有加载学生名单</p>
            </div>
            
            <!-- 闪动显示名字的区域 -->
            <div class="flashing-name" id="flashingName"><a href="http://%78%71%69%61%2e%6e%65%74">准备开始...</a></div>
        </div>
        
        <div class="controls">
            <h2>随机点名</h2>
            <button onclick="startFlashing()">开始闪动</button>
            <button onclick="stopFlashingAndSelect(1)">停止并选择1人</button>
            <button onclick="stopFlashingAndSelect(2)">停止并选择2人</button>
            <button onclick="stopFlashingAndSelect(3)">停止并选择3人</button>
            <input type="number" id="customNumber" min="1" value="1" style="width: 50px;">
            <button onclick="stopFlashingAndSelectCustom()">自定义数量</button>
        </div>
        
        <div class="result-section">
            <h2>点名结果</h2>
            <div id="result"></div>
        </div>
    </div>

    <script>
        let students = [];
        let isFlashing = false;
        let flashInterval;
        let flashSpeed = 100; // 闪动速度(毫秒)
        let lastDisplayedNames = []; // 记录最后显示的名字
        
        function loadStudents() {
            const fileInput = document.getElementById('fileInput');
            const manualInput = document.getElementById('manualInput').value;
            
            if (fileInput.files.length > 0) {
                const file = fileInput.files[0];
                const reader = new FileReader();
                
                reader.onload = function(e) {
                    const data = new Uint8Array(e.target.result);
                    try {
                        // 使用SheetJS库解析Excel文件
                        const workbook = XLSX.read(data, {type: 'array'});
                        
                        // 获取第一个工作表
                        const firstSheetName = workbook.SheetNames[0];
                        const worksheet = workbook.Sheets[firstSheetName];
                        
                        // 将工作表转换为JSON
                        const jsonData = XLSX.utils.sheet_to_json(worksheet, {header: 1});
                        
                        // 提取第一列数据作为学生名单
                        students = [];
                        jsonData.forEach(row => {
                            if (row[0] && typeof row[0] === 'string' && row[0].trim() !== '') {
                                students.push(row[0].trim());
                            }
                        });
                        
                        updateStudentList();
                    } catch (error) {
                        // 如果不是Excel文件,尝试作为文本文件处理
                        const content = new TextDecoder().decode(data);
                        students = content.split(/\r?\n/).filter(name => name.trim() !== '');
                        updateStudentList();
                    }
                };
                
                reader.readAsArrayBuffer(file);
            } else if (manualInput.trim() !== '') {
                students = manualInput.split(/\r?\n/).filter(name => name.trim() !== '');
                updateStudentList();
            } else {
                alert('请上传文件或手动输入学生名单');
            }
        }
        
        function updateStudentList() {
            const studentListElement = document.getElementById('studentList');
            
            if (students.length === 0) {
                studentListElement.innerHTML = '<p>当前没有加载学生名单</p>';
                return;
            }
            
            let html = `<p>已加载 ${students.length} 名学生:</p><ul>`;
            students.forEach(student => {
                html += `<li>${student}</li>`;
            });
            html += '</ul>';
            
            studentListElement.innerHTML = html;
        }
        
        function randomSelect(count) {
            if (students.length === 0) {
                alert('请先加载学生名单');
                return [];
            }
            
            if (count > students.length) {
                alert(`名单中只有 ${students.length} 名学生,无法抽取 ${count} 名`);
                return [];
            }
            
            // 复制数组以避免修改原数组
            const shuffled = [...students].sort(() => 0.5 - Math.random());
            return shuffled.slice(0, count);
        }
        
        // 闪动效果控制函数
        function startFlashing() {
            if (students.length === 0) {
                alert('请先加载学生名单');
                return;
            }
            
            if (isFlashing) return;
            
            isFlashing = true;
            lastDisplayedNames = []; // 清空上次记录
            const flashingElement = document.getElementById('flashingName');
            flashingElement.classList.add('flashing-fast');
            flashingElement.classList.remove('final-selection');
            flashingElement.style.backgroundColor = '#ff9800';
            flashingElement.innerHTML = "<span>随机选择中...</span>";
            
            // 快速切换显示的名字
            flashInterval = setInterval(() => {
                const randomIndex = Math.floor(Math.random() * students.length);
                const currentName = students[randomIndex];
                flashingElement.innerHTML = `<span>${currentName}</span>`;
                
                // 记录最后显示的名字(用于单人选择时保持一致)
                lastDisplayedNames = [currentName];
                
                // 随机改变背景颜色增加视觉效果
                const colors = ['#ff9800', '#ff5722', '#e91e63', '#9c27b0', '#673ab7'];
                const randomColor = colors[Math.floor(Math.random() * colors.length)];
                flashingElement.style.backgroundColor = randomColor;
            }, flashSpeed);
        }
        
        function stopFlashingAndSelect(count) {
            if (!isFlashing) {
                // 如果没有在闪动,直接随机选择
                const selected = randomSelect(count);
                updateFlashingDisplay(selected);
                displayResult(selected);
                return;
            }
            
            isFlashing = false;
            clearInterval(flashInterval);
            
            const flashingElement = document.getElementById('flashingName');
            flashingElement.classList.remove('flashing-fast');
            flashingElement.classList.add('final-selection');
            flashingElement.style.backgroundColor = '#4CAF50';
            
            // 根据数量选择名字
            let selectedNames = [];
            if (count === 1) {
                // 单人选择时使用最后显示的名字
                selectedNames = lastDisplayedNames.length > 0 ? lastDisplayedNames : randomSelect(1);
            } else {
                // 多人选择时进行随机选择
                selectedNames = randomSelect(count);
            }
            
            // 更新闪动区域显示
            updateFlashingDisplay(selectedNames);
            
            // 显示在结果区域
            displayResult(selectedNames);
        }
        
        function stopFlashingAndSelectCustom() {
            const count = parseInt(document.getElementById('customNumber').value);
            if (isNaN(count) || count < 1) {
                alert('请输入有效的数字');
                return;
            }
            stopFlashingAndSelect(count);
        }
        
        function updateFlashingDisplay(selectedNames) {
            const flashingElement = document.getElementById('flashingName');
            
            if (selectedNames.length === 0) {
                flashingElement.innerHTML = "<span>未选择任何学生</span>";
                return;
            }
            
            // 清空并显示所有被选中的名字
            flashingElement.innerHTML = '';
            selectedNames.forEach(name => {
                const nameElement = document.createElement('span');
                nameElement.className = 'selected-name';
                nameElement.textContent = name;
                flashingElement.appendChild(nameElement);
            });
            
            // 添加标题前缀
            const prefix = document.createElement('span');
            prefix.textContent = '已选择: ';
            prefix.style.marginRight = '10px';
            flashingElement.insertBefore(prefix, flashingElement.firstChild);
        }
        
        function displayResult(selectedStudents) {
            const resultElement = document.getElementById('result');
            
            if (selectedStudents.length === 0) {
                resultElement.innerHTML = '<p>没有选择任何学生</p>';
                return;
            }
            
            let html = '<div>';
            selectedStudents.forEach(student => {
                html += `<span class="selected">${student}</span> `;
            });
            html += '</div>';
            
            resultElement.innerHTML = html;
        }
    </script>
</body>
</html>

学生随机点名 Html 系统源码凭借其简单易用的操作、公正无偏的随机点名算法和良好的隐私保护机制,为教师提供了一个理想的课堂点名工具。

它不仅能够提高课堂互动和学生参与度,还能帮助教师更好地管理和分析学生参与情况,提升教学质量。无论是小学、中学还是高等教育阶段,该源码都能满足教师的日常点名需求,是教学管理的得力助手。

学生随机点名Html系统源码插图
班级课堂点名小工具,学生随机点名Html系统源码。

本站声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
名称:渡漳网
网址:https://www.dzcrv.com
邮件:[email protected]
本站资源大多存储在云盘,如有链接失效,请留言反馈站长更新!
本站各种资源及源码软件大部分为网络搜集而来,如有侵犯版权的,请邮件与我们联系,本站将予以改正。
由于网络资源有极快的复制性,付费资源一经购买 ,不以任何形式退款,购买过程中如有付费资源失效,请及时联系站长。

给TA赞赏
共{{data.count}}人
人已赞赏
系统源码

全新二级域名分发系统网站源码终极最强版

2025-5-7 10:00:00

系统源码

最新各类别在线工具箱系统源码带后台附教程

2025-5-9 9:00:00

渡漳网推荐腾讯云服务器
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索