#!/bin/bash

source head.sh

echo '
    <div class="container mt-5">
        <h1 class="mb-4">成绩列表</h1>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>成绩号</th>
                    <th>学生</th>
                    <th>考试</th>
                    <th>科目</th>
                    <th>分数</th>
                </tr>
            </thead>
            <tbody>
'
# 尝试从缓存读取
sql="select jx_score.id, jx_stu.name, jx_test.name, jx_subject.name, jx_score.score  from jx_score  join jx_stu on jx_score.stuId=jx_stu.id  join jx_test on jx_score.testId=jx_test.id  join jx_subject on jx_score.subjectId=jx_subject.id"
source cache.sh

for stu in ${stuList[@]}; do
  # 获取学号、姓名、班级、年龄
  id=$(echo $stu | awk -F "@" '{print $1}')
  name=$(echo $stu | awk -F "@" '{print $2}')
  test=$(echo $stu | awk -F "@" '{print $3}')
  subject=$(echo $stu | awk -F "@" '{print $4}')
  score=$(echo $stu | awk -F "@" '{print $5}')
  echo "
                  <tr>
                      <td>$id</td>
                      <td>$name</td>
                      <td>$test</td>
                      <td>$subject</td>
                      <td>$score</td>
                  </tr>
  "
done
echo '
            </tbody>
        </table>
    </div>
    
    <!-- 引入Bootstrap的JavaScript文件，用于一些表格交互效果 -->
    <script src="/static/js/bootstrap.min.js"></script>
</body>
</html>
'
