diff --git a/README.md b/README.md
index bf8666e..02d54a6 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,8 @@ print_r($score);
- [教学地点列表](docs/api.md#教学地点列表)
- [教室状态查询及详情所需参数](docs/api.md#教室状态查询及详情所需参数)
- [获取教室借用详情信息](docs/api.md#获取教室借用详情信息)
+- [教师授课列表获取](docs/api.md#教师授课列表获取)
+- [教师查询学生花名册](docs/api.md#教师查询学生花名册)
## 适用学校系统
diff --git a/docs/api.md b/docs/api.md
index 0ad9353..b819d42 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -27,6 +27,8 @@
- [教学地点列表](#教学地点列表)
- [教室状态查询及详情所需参数](#教室状态查询及详情所需参数)
- [获取教室借用详情信息](#获取教室借用详情信息)
+- [教师授课列表获取](#教师授课列表获取)
+- [教师查询学生花名册](#教师查询学生花名册)
---
@@ -7908,4 +7910,102 @@ echo json_encode($list);
]
```
-
\ No newline at end of file
+
+
+---
+
+### 教师授课列表获取
+
+> 仅教师账号可使用此方法,获取授课列表
+
+方法:`teacherCourseList()`
+
+调用示例:
+
+```php
+use Airmole\TjustbEdusys\Edusys;
+
+$usercode = '1234'; // 教师账号
+$password = '*********'; // 系统密码
+$edusys = new Edusys();
+$edusys->autoLogin($usercode, $password);
+$list = $edusys->teacherCourseList();
+echo json_encode($list);
+```
+
+
+ 返回参数示例
+
+```json
+[
+ {
+ "title": "XXXX(H01312344)[10102]",
+ "className": "XX2202班",
+ "queryCode": "2023XXXXXXXXXX0"
+ },
+ {
+ "title": "XXXX(H01312344)[10304]",
+ "className": "XX2202班",
+ "queryCode": "2023XXXXXXXXXX0"
+ }
+]
+```
+
+
+
+---
+
+### 教师查询学生花名册
+
+> 仅教师账号可用,传入教师授课列表接口返回的queryCode,获取课堂学生花名册
+
+方法:`classroomList()`
+
+所需参数:
+
+| para | type | nullable | default | tips |
+| ---- | ------ |:--------:| --------- | ------------------------------------- |
+| code | string | ❌ | null | 传入教师授课列表接口返回的queryCode |
+
+调用示例:
+
+```php
+use Airmole\TjustbEdusys\Edusys;
+
+$usercode = '1234'; // 系统账号
+$password = '*********'; // 系统密码
+$edusys = new Edusys();
+$edusys->autoLogin($usercode, $password);
+$list = $edusys->teacherQueryStudentList('2023XXXXXXXXXX0');
+echo json_encode($list);
+```
+
+
+ 返回参数示例
+
+```json
+[
+ {
+ "no": "1",
+ "major": "XXXXX系",
+ "profession": "视觉传达设计",
+ "grade": "2023",
+ "className": "视传230X",
+ "usercode": "23621XXXX",
+ "name": "陈**",
+ "gender": "男"
+ },
+ {
+ "no": "2",
+ "major": "XXXXX系",
+ "profession": "视觉传达设计",
+ "grade": "2023",
+ "className": "视传230X",
+ "usercode": "23621XXXX",
+ "name": "陈**",
+ "gender": "女"
+ }
+]
+```
+
+
diff --git a/src/Edusys.php b/src/Edusys.php
index 897b23e..9ec840a 100644
--- a/src/Edusys.php
+++ b/src/Edusys.php
@@ -590,4 +590,28 @@ public function classroomDetail(
);
}
+ /**
+ * 教师查询授课列表
+ * @throws Exception
+ */
+ public function teacherCourseList(): array
+ {
+ if (empty($this->usercode) || empty($this->cookie)) throw new Exception('账号未登录');
+ $teacher = new Teacher($this->usercode, $this->cookie);
+ return $teacher->courseList();
+ }
+
+ /**
+ * 教师查询学生花名册
+ * @param string $queryCode 查询码
+ * @return array
+ * @throws Exception
+ */
+ public function teacherQueryStudentList(string $queryCode): array
+ {
+ if (empty($this->usercode) || empty($this->cookie)) throw new Exception('账号未登录');
+ $teacher = new Teacher($this->usercode, $this->cookie);
+ return $teacher->queryStudentList($queryCode);
+ }
+
}
\ No newline at end of file
diff --git a/src/Teacher.php b/src/Teacher.php
index 1c14c51..606a19d 100644
--- a/src/Teacher.php
+++ b/src/Teacher.php
@@ -19,7 +19,7 @@ public function __construct(string $usercode = '', string $cookie = '')
$this->cookie = $cookie;
$this->usercode = $usercode;
if (empty($this->cookie)) throw new Exception('cookie不得为空');
- if (empty($this->usercode)) throw new Exception('学号参数不得为空');
+ if (empty($this->usercode)) throw new Exception('账号参数不得为空');
}
/**
@@ -45,7 +45,7 @@ public function courseList(): array
*/
public function formatCourseList(string $html): array
{
- preg_match_all('/list-group-item.*?<\/span>/s', $html, $courseListHtmls);
+ preg_match_all('/list-group-item.*? /s', $html, $courseListHtmls);
$courseListHtmls = $courseListHtmls ? $courseListHtmls[0] : [];
$courses = [];
@@ -79,6 +79,7 @@ public function queryStudentList(string $queryCode): array
if (empty($queryCode)) throw new Exception('查询码不得为空');
$referer = $this->edusysUrl . '/jsxsd/framework/jsMain.jsp';
$url = "/jsxsd/framework/jsMain_hmc.jsp?jx0404id={$queryCode}";
+
$html = $this->httpGet($url, $this->cookie, $referer);
$validHtml = $this->checkCookieByHtml($html['data']);
if ($validHtml !== true) throw new Exception($validHtml['data']);
@@ -93,7 +94,7 @@ public function queryStudentList(string $queryCode): array
*/
public function formatStudentList(string $html): array
{
- preg_match_all('/
(.*?)<\/tr>/',$html,$rows);
+ preg_match_all('/
(.*?)<\/tr>/s',$html,$rows);
$rows = $rows ? $rows[0] : [];
$studentList = [];
@@ -101,14 +102,14 @@ public function formatStudentList(string $html): array
if ($index == 0) continue;
$tempArray = explode("",$row);
$studentList[] = [
- 'no' => $tempArray[0],
- 'major' => $tempArray[1],
- 'profession' => $tempArray[2],
- 'grade' => $tempArray[3],
- 'className' => $tempArray[4],
- 'usercode' => $tempArray[5],
- 'name' => $tempArray[6],
- 'gender' => $tempArray[7],
+ 'no' => $this->stripHtmlTagAndBlankspace($tempArray[0]),
+ 'major' => $this->stripHtmlTagAndBlankspace($tempArray[1]),
+ 'profession' => $this->stripHtmlTagAndBlankspace($tempArray[2]),
+ 'grade' => $this->stripHtmlTagAndBlankspace($tempArray[3]),
+ 'className' => $this->stripHtmlTagAndBlankspace($tempArray[4]),
+ 'usercode' => $this->stripHtmlTagAndBlankspace($tempArray[5]),
+ 'name' => $this->stripHtmlTagAndBlankspace($tempArray[6]),
+ 'gender' => $this->stripHtmlTagAndBlankspace($tempArray[7]),
];
}