mirror of
https://hub.gitmirror.com/https://github.com/ExamAware/ExamCloudSchedule
synced 2025-04-29 07:56:35 +00:00
chore: 添加 .gitignore 和 README 文件
This commit is contained in:
parent
36b35afdfb
commit
17de4302c6
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/configs/*
|
100
README.md
Normal file
100
README.md
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# ExamCloud
|
||||||
|
|
||||||
|
ExamCloud 是一个用于管理和查看考试安排的系统。它包括以下几个主要功能:
|
||||||
|
|
||||||
|
1. **考试看板配置查询**:用户可以通过输入配置 ID 来获取考试安排的详细信息。
|
||||||
|
2. **考试安排显示**:显示考试的详细安排,包括科目、开始时间和结束时间。
|
||||||
|
3. **管理员后台**:管理员可以登录后台管理考试配置文件,包括创建、编辑和删除配置文件。
|
||||||
|
|
||||||
|
## 文件结构
|
||||||
|
|
||||||
|
- `/index.php`:考试看板配置查询页面。
|
||||||
|
- `/ExamCloudSchedule`:考试安排显示页面。
|
||||||
|
- `/admin/login.php`:管理员登录页面。
|
||||||
|
- `/admin/index.php`:管理员后台主页,显示所有配置文件。
|
||||||
|
- `/admin/edit.php`:编辑或创建新的考试配置文件。
|
||||||
|
- `/admin/detete.php`: 删除指定配置文件。
|
||||||
|
- `/includes`: 管理员认证目录。
|
||||||
|
- `/configs`: 安排存放目录。
|
||||||
|
|
||||||
|
## 使用方法
|
||||||
|
|
||||||
|
### 考试看板配置查询
|
||||||
|
|
||||||
|
1. 打开根目录页面。
|
||||||
|
2. 输入配置 ID,例如 `room301`。
|
||||||
|
3. 点击“获取配置”按钮,查看考试安排的详细信息。
|
||||||
|
4. 点击“进入”按钮,跳转到考试安排显示页面。
|
||||||
|
|
||||||
|
### 考试安排显示
|
||||||
|
|
||||||
|
1. 上一部操作后会打开 `ExamCloudSchedule/index.html` 页面。
|
||||||
|
2. 页面会根据 URL 参数 `configId` 显示相应的考试安排。
|
||||||
|
|
||||||
|
### 管理员后台
|
||||||
|
|
||||||
|
1. 打开 `admin` 目录,输入管理员用户名和密码进行登录。
|
||||||
|
2. 登录后,跳转到 `admin/index.php` 页面,显示所有配置文件。
|
||||||
|
3. 点击“新建配置”按钮,跳转到 `admin/edit.php` 页面,创建新的配置文件。
|
||||||
|
4. 在配置文件列表中,可以点击“编辑”按钮编辑配置文件,点击“删除”按钮删除配置文件,点击“预览”按钮查看配置文件的详细信息。
|
||||||
|
|
||||||
|
## 配置文件格式
|
||||||
|
|
||||||
|
配置文件为 JSON 格式,包含以下字段:
|
||||||
|
|
||||||
|
- `examName`:考试名称。
|
||||||
|
- `message`:考试提示语。
|
||||||
|
- `room`:考场号。
|
||||||
|
- `examInfos`:考试科目安排列表,每个科目包含以下字段:
|
||||||
|
- `name`:科目名称。
|
||||||
|
- `start`:开始时间。
|
||||||
|
- `end`:结束时间。
|
||||||
|
|
||||||
|
示例配置文件:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"examName": "期末考试",
|
||||||
|
"message": "请提前10分钟进入考场",
|
||||||
|
"room": "room301",
|
||||||
|
"examInfos": [
|
||||||
|
{
|
||||||
|
"name": "数学",
|
||||||
|
"start": "2023-12-01T09:00:00",
|
||||||
|
"end": "2023-12-01T11:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "英语",
|
||||||
|
"start": "2023-12-01T13:00:00",
|
||||||
|
"end": "2023-12-01T15:00:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 开发环境
|
||||||
|
|
||||||
|
- PHP 7.4+
|
||||||
|
- HTML5
|
||||||
|
- JavaScript
|
||||||
|
- CSS3
|
||||||
|
|
||||||
|
## 安装和运行
|
||||||
|
|
||||||
|
1. 克隆项目到本地:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/yourusername/ExamCloud.git
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 将项目文件放置到 Web 服务器的根目录下。
|
||||||
|
3. 确保 Web 服务器支持 PHP,并启动服务器。
|
||||||
|
4. 访问 `index.php` 页面,开始使用系统。
|
||||||
|
|
||||||
|
## 贡献
|
||||||
|
|
||||||
|
欢迎提交问题和功能请求,您可以通过提交 Pull Request 来贡献代码。
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
本项目采用 MIT 许可证。
|
69
ws_server.php
Normal file
69
ws_server.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
set_time_limit(0);
|
||||||
|
|
||||||
|
require 'path/to/Ratchet/Http/HttpServer.php';
|
||||||
|
require 'path/to/Ratchet/Server/IoServer.php';
|
||||||
|
require 'path/to/Ratchet/WebSocket/WsServer.php';
|
||||||
|
require 'path/to/Ratchet/MessageComponentInterface.php';
|
||||||
|
require 'path/to/Ratchet/ConnectionInterface.php';
|
||||||
|
|
||||||
|
use Ratchet\Http\HttpServer;
|
||||||
|
use Ratchet\Server\IoServer;
|
||||||
|
use Ratchet\WebSocket\WsServer;
|
||||||
|
use Ratchet\MessageComponentInterface;
|
||||||
|
use Ratchet\ConnectionInterface;
|
||||||
|
|
||||||
|
class ConfigChangeNotifier implements MessageComponentInterface {
|
||||||
|
protected $clients;
|
||||||
|
protected $subscriptions;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->clients = new \SplObjectStorage;
|
||||||
|
$this->subscriptions = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onOpen(ConnectionInterface $conn) {
|
||||||
|
$this->clients->attach($conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onMessage(ConnectionInterface $from, $msg) {
|
||||||
|
$data = json_decode($msg, true);
|
||||||
|
if ($data['action'] === 'subscribe') {
|
||||||
|
$configId = $data['configId'];
|
||||||
|
$this->subscriptions[$configId][] = $from;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onClose(ConnectionInterface $conn) {
|
||||||
|
$this->clients->detach($conn);
|
||||||
|
foreach ($this->subscriptions as $configId => $subscribers) {
|
||||||
|
$this->subscriptions[$configId] = array_filter($subscribers, function($subscriber) use ($conn) {
|
||||||
|
return $subscriber !== $conn;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onError(ConnectionInterface $conn, \Exception $e) {
|
||||||
|
$conn->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notifyClients($configId) {
|
||||||
|
if (isset($this->subscriptions[$configId])) {
|
||||||
|
foreach ($this->subscriptions[$configId] as $client) {
|
||||||
|
$client->send(json_encode(['action' => 'reload', 'configId' => $configId]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$server = IoServer::factory(
|
||||||
|
new HttpServer(
|
||||||
|
new WsServer(
|
||||||
|
new ConfigChangeNotifier()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
8080
|
||||||
|
);
|
||||||
|
|
||||||
|
$server->run();
|
||||||
|
?>
|
Loading…
x
Reference in New Issue
Block a user