parent
9a6c7e45ce
commit
3fa158ec45
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
@ -1,59 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>模态框示例</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
|
||||
<style>
|
||||
.modal {
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.modal-content {
|
||||
background-color: #fff;
|
||||
margin: 15% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<button @click="tanchuang">创建房间</button>
|
||||
|
||||
<div class="modal" v-if="isModalVisible">
|
||||
<div class="modal-content">
|
||||
<span @click="closeModal" style="cursor:pointer; float:right;">×</span>
|
||||
<h2>创建房间</h2>
|
||||
<p>这里是房间创建的内容...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
isModalVisible : false
|
||||
},
|
||||
methods: {
|
||||
tanchuang() {
|
||||
this.isModalVisible = true; // 打开模态框
|
||||
},
|
||||
closeModal() {
|
||||
this.isModalVisible = false; // 关闭模态框
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,134 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>课堂点名系统</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
|
||||
<style>
|
||||
.joinbutton {
|
||||
|
||||
border-radius: 15px;
|
||||
|
||||
}
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center; /* 垂直居中 */
|
||||
justify-content: center; /* 水平居中 */
|
||||
height: 90vh; /* 使 body 高度占满视口 */
|
||||
}
|
||||
h1 {
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
input[type="text"],
|
||||
input[type="email"],
|
||||
input[type="password"],
|
||||
input[type="file"] {
|
||||
margin-bottom: 10px;
|
||||
padding: 10px;
|
||||
border: 2px solid #007BFF;
|
||||
border-radius: 20px;
|
||||
width: 250px;
|
||||
top
|
||||
}
|
||||
button {
|
||||
background-color: #020202;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
button:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
#result {
|
||||
margin-top: 100px;
|
||||
padding: 10px;
|
||||
background: white;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
width: 500px;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.modal {
|
||||
position: fixed;
|
||||
z-index: 1; /* 在最上层 */
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色背景 */
|
||||
}
|
||||
.modal-content {
|
||||
background-color: #fff;
|
||||
margin: 15% auto;
|
||||
padding: 40px;
|
||||
border: 1px solid #888;
|
||||
width: 40%; /* 可以根据需要调整宽度 */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<h1>课堂点名系统</h1>
|
||||
<input type="text" placeholder="请输入房间号..." />
|
||||
<div> <button class="joinbutton" @click="tanchuang">加入(创建)房间</button> </div>
|
||||
|
||||
|
||||
|
||||
<!-- 模态框 -->
|
||||
<div class="modal" v-if="isModalVisible">
|
||||
<div class="modal-content">
|
||||
<span @click="closeModal" style="cursor:pointer; float:right;">×</span>
|
||||
<h1>当前房间号没有被创建是否创建房间</h1>
|
||||
<button @click="goToAboutPage">确认创建房间</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 结束模态框 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
isModalVisible:false,
|
||||
isModalVisible2:false
|
||||
},
|
||||
methods: {
|
||||
goToAboutPage() {
|
||||
window.location.href = 'index.html'; // 跳转到 index.html
|
||||
},
|
||||
handleFileUpload(event) {
|
||||
// 这里可以添加处理文件上传的逻辑
|
||||
},
|
||||
tanchuang()
|
||||
{
|
||||
this.isModalVisible = true;
|
||||
|
||||
},
|
||||
uploadFile() {
|
||||
// 调用外部的 uploadFile 函数
|
||||
uploadFile();
|
||||
},
|
||||
closeModal() {
|
||||
this.isModalVisible = false; // 关闭模态框
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,73 +0,0 @@
|
||||
const express = require('express');
|
||||
const multer = require('multer');
|
||||
const XLSX = require('xlsx');
|
||||
const path = require('path');
|
||||
|
||||
const app = express();
|
||||
const upload = multer({ dest: 'uploads/' });
|
||||
|
||||
let students = [];
|
||||
let scores = {};
|
||||
|
||||
// Middleware to serve static files
|
||||
app.use(express.static('public'));
|
||||
|
||||
// Endpoint to upload Excel file
|
||||
app.post('/upload', upload.single('file'), (req, res) => {
|
||||
const workbook = XLSX.readFile(req.file.path);
|
||||
const sheetName = workbook.SheetNames[0];
|
||||
const sheet = workbook.Sheets[sheetName];
|
||||
students = XLSX.utils.sheet_to_json(sheet);
|
||||
|
||||
// Initialize scores
|
||||
students.forEach(student => {
|
||||
scores[student.id] = { name: student.name, points: 0 };
|
||||
});
|
||||
|
||||
res.json(students);
|
||||
});
|
||||
|
||||
// Endpoint to randomly select a student
|
||||
app.get('/random', (req, res) => {
|
||||
if (students.length === 0) return res.status(400).send('No students available.');
|
||||
|
||||
// Calculate weights based on scores
|
||||
const weights = students.map(student => {
|
||||
return Math.max(1, 10 - scores[student.id].points); // Higher score -> lower weight
|
||||
});
|
||||
|
||||
const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
|
||||
const randomNum = Math.random() * totalWeight;
|
||||
let cumulativeWeight = 0;
|
||||
|
||||
for (let i = 0; i < students.length; i++) {
|
||||
cumulativeWeight += weights[i];
|
||||
if (randomNum < cumulativeWeight) {
|
||||
return res.json(students[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Endpoint to update scores
|
||||
app.post('/update-score', (req, res) => {
|
||||
const { id, correctRepeat, correctAnswer } = req.body;
|
||||
|
||||
if (!scores[id]) return res.status(400).send('Invalid student ID.');
|
||||
|
||||
if (correctRepeat) {
|
||||
scores[id].points += 0.5;
|
||||
} else {
|
||||
scores[id].points -= 1;
|
||||
}
|
||||
|
||||
if (correctAnswer) {
|
||||
scores[id].points += 1; // Adjust according to your scoring logic
|
||||
}
|
||||
|
||||
res.json(scores[id]);
|
||||
});
|
||||
|
||||
// Start the server
|
||||
app.listen(3000, () => {
|
||||
console.log('Server is running on http://localhost:3000');
|
||||
});
|
Loading…
Reference in new issue