美文网首页
怎么将课程表发布到网上,零成本!

怎么将课程表发布到网上,零成本!

作者: 尘世小书虫 | 来源:发表于2024-01-09 11:59 被阅读0次

背景:

很多小型的的培训学校通常涉及到几位到十几位老师与几十名到上百名学生的课程安排。从成本出发,聘请专业人员去编写由于管理的软件是非常不现实的。可行可靠的做法通常是使用个人电脑office中的excel之类的软件来进行管理。

由于上述这些教育机构的主管没有IT相关背景,同时由于office软件的局限,一些能够增进管理和服务水平的IT方案往往不了解,也无法采用。

设想下面的场景:学校采取小班授课,常常是一对一或者一对N的形式。对于有经验的工作人员,使用excel,只要规模不是超大,完全没有问题。甚至是面对老师学生请假,调课等等情况的加入也能够处理得妥贴。同时,这项工作还要面临很多与学生家长的沟通。尤其是在因为法定假期、因为病事假、因为其它以外情况导致课程时间变更。这个情况下,学校方面会面临大量与家长们沟通。比如在微信群中家长会一个接一个与校方确认更新的课表,每一次询问校方都要专门去查询并回应。这样即影响了工作效率,也耽误了时间。那么有没有办法在不增加校方本身的工作量的基础上,能够随时将最新的课程安排发布到网络上,家长和学生老师如果只需要确认课程安排的话,随时浏览某一个网页就可以。校方和工作人员则可以把更多的精力放到其它事情上面。

解决方案:

很多商业软件都会提供上述功能,但我们在这里寻求的是零成本提供这个解决方案。下面我来使用一个模拟的场景来事例这个解决方案是如何一步一步实现这个功能的。同时在最后会展示工作人员如何通过仅仅一步操作就将信息更新到网络上供随时查阅。

准备

我假设下面是一个学校的课程安排excel表格,里面会看到课程、老师、学生、上课时间、上课地点等信息。

image-20240108165411433.png

数据导出

我们首先将数据从上面的excel表格中导出到本地的json文件。这里我们使用python语言和以下方法:

Python语言我们可以免费下载和安装到本地计算机中。

import pandas as pd

# Load the Excel file into a pandas DataFrame
df = pd.read_excel('./schoolSchedual.xls')

# Remove completely blank rows
df_cleaned = df.dropna(how='all')

# Extract the titles from the first row
titles = df_cleaned.iloc[0].to_dict()

# Use titles as keys and subsequent rows as values
records = []
for index, row in df_cleaned.iterrows():
    if index > 0:  # Skip the first row since it contains titles
        # Create a record dictionary with the correct titles
        record = {title: row[key] for key, title in titles.items()}
        records.append(record)

# Convert the list of record dictionaries to a JSON string
json_data = pd.Series(records).to_json(orient='records', indent=4)

# Output the JSON data to a file
json_output_path = './schedule.json'
with open(json_output_path, 'w') as json_file:
    json_file.write(json_data)

数据过滤

因为学校的内部文件信息中包括学生姓名等信息,我们从保护隐私的角度出发不能将这些信息发布到网络上。数据过滤的作用是将这些信息从导出的json中删除,仅仅保留我们可以公开发布的消息。

因为每一位学生都有自己唯一的学生编号,只有学校和学生及家长知道哪一个学生编号是自己。这样学生家长可以通过显示在网页上的学生编号来核实孩子的课时安排。

import json

# Path to the original JSON file
json_file_path = './schedule.json'

# Load the JSON data from the file
with open(json_file_path, 'r') as file:
    data = json.load(file)

# Remove the first item from the data
data.pop(0)

# Remove the 'Student' key and its value from each remaining item
for item in data:
    if 'Student' in item:
        item.pop('Student')

# Path for the new JSON file
new_json_file_path = './updated_schedule.json'

# Save the updated data to the new JSON file
with open(new_json_file_path, 'w') as file:
    json.dump(data, file, indent=4)

生成网页

我们现在将上面过滤之后的json转化为网页文件:

from jinja2 import Environment, BaseLoader

# Load the JSON data from the generated file
with open('./updated_schedule.json', 'r') as json_file:
    records = json.load(json_file)

# HTML template using Jinja2 syntax
html_template = """
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Schedule</title>
    <style>
......
            {% endfor %}
        </tbody>
    </table>
</body>
</html>
"""

# Initialize Jinja2 environment
env = Environment(loader=BaseLoader())
template = env.from_string(html_template)

# Extract titles for table headers
titles = records[0].keys()

# Render the HTML with the JSON data
html_output = template.render(titles=titles, records=records)

# Define the path for the HTML file
html_file_path = 'schoolSchedual.html'

# Save the rendered HTML to a file
with open(html_file_path, 'w') as file:
    file.write(html_output)

发布网页

在这里我们使用了可以免费申请的GITHub。其中Github Page可以提供简单的静态网页功能,并且完全免费。

#!/bin/bash

 #Set the path to your local GitHub Pages repository
REPO_PATH='/path/to/your/local/repo'

 #Set the path to the HTML file you want to upload
HTML_FILE_PATH='/path/to/your/schoolSchedual.html'

 #Set the commit message
COMMIT_MESSAGE='Update schoolSchedual.html'

 #Change to the repository directory
cd "$REPO_PATH"

 #Copy the HTML file to the repository
cp "$HTML_FILE_PATH" .

 #Add all new and changed files to git
git add .

 #Commit the changes
git commit -m "$COMMIT_MESSAGE"

 #Push the changes to GitHub
git push origin main

查看网页

现在就可以进入浏览器检查一下刚刚发布的更新课表了。以下我使用个人的github网站作为例子:https://toronto-andrew.github.io/AndrewBlogger/others/schoolschedual.html

校方工作人员的“一键操作”

以上是这个解决方案的原理讲解。这里介绍一下学校的工作人员如何“一键发布”课表信息的。由于本人的电脑是linux,见到的界面会有所不同,在windows电脑下的操作将很类似。

andrew@andrew-OptiPlex-Ubuntu:~/PycharmProjects/exportExcel$ publicSchedual2Web.sh schoolSchedual.xls

如果认为上述方案有价值并有兴趣使用的教育机构欢迎与作者联系,本人愿意提供免费技术支持。

相关文章

网友评论

      本文标题:怎么将课程表发布到网上,零成本!

      本文链接:https://www.haomeiwen.com/subject/isunndtx.html