Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class MessageLookup extends MessageLookupByLibrary {
"accountLock": MessageLookupByLibrary.simpleMessage("Account is locked, please try again in 15 minutes"),
"accountNull": MessageLookupByLibrary.simpleMessage("Please enter your account"),
"accountPasswordError": MessageLookupByLibrary.simpleMessage("Account password incorrect"),
"aduit": MessageLookupByLibrary.simpleMessage("Aduit"),
"aestheticDimension": MessageLookupByLibrary.simpleMessage("Aesthetic dimension"),
"alertError": MessageLookupByLibrary.simpleMessage("An error occurred"),
"androidPrivateBrowseGuideSubTitle":
Expand Down Expand Up @@ -122,6 +123,8 @@ class MessageLookup extends MessageLookupByLibrary {
"getCalendar": MessageLookupByLibrary.simpleMessage("Getting calendar..."),
"getCalendarError": MessageLookupByLibrary.simpleMessage("Getting calendar error"),
"getCourse": MessageLookupByLibrary.simpleMessage("Get schedule..."),
"getCourseClassmateList": MessageLookupByLibrary.simpleMessage("Getting classmate list..."),
"getCourseClassmateListError": MessageLookupByLibrary.simpleMessage("Get classmate list error"),
"getCourseDetail": MessageLookupByLibrary.simpleMessage("Reading course materials..."),
"getCourseDetailError": MessageLookupByLibrary.simpleMessage("Course data reading error"),
"getCourseError": MessageLookupByLibrary.simpleMessage("Getting schedule error"),
Expand Down Expand Up @@ -181,6 +184,8 @@ class MessageLookup extends MessageLookupByLibrary {
"logoutWarning":
MessageLookupByLibrary.simpleMessage("Are you sure you want to log out? \nAll data will be cleared"),
"missingRequiredInformation": MessageLookupByLibrary.simpleMessage("Missing required information"),
"name": MessageLookupByLibrary.simpleMessage("name"),
"nationalTaipeiUniversity": MessageLookupByLibrary.simpleMessage("NTPU"),
"naturalDimension": MessageLookupByLibrary.simpleMessage("Natural dimension"),
"needsVerifyMobileWarning": MessageLookupByLibrary.simpleMessage(
"You may be asked to verify your phone number\nplease check the website entrance for further information."),
Expand Down Expand Up @@ -270,10 +275,12 @@ class MessageLookup extends MessageLookupByLibrary {
"sociologicalDimension": MessageLookupByLibrary.simpleMessage("Sociological Dimension"),
"sortBy": MessageLookupByLibrary.simpleMessage("Sort by"),
"startClass": MessageLookupByLibrary.simpleMessage("Start class"),
"studentId": MessageLookupByLibrary.simpleMessage("student id"),
"studentList": MessageLookupByLibrary.simpleMessage("Student list"),
"subscribe": MessageLookupByLibrary.simpleMessage("Subscribe"),
"sure": MessageLookupByLibrary.simpleMessage("Sure"),
"syllabus": MessageLookupByLibrary.simpleMessage("Syllabus"),
"taipeiMedicineUniversity": MessageLookupByLibrary.simpleMessage("TMU"),
"takeCore": MessageLookupByLibrary.simpleMessage("Take core"),
"takeForeignDepartmentCredits": MessageLookupByLibrary.simpleMessage("Foreign Dep Credits"),
"takeForeignDepartmentCreditsLimit": MessageLookupByLibrary.simpleMessage("Credit limit"),
Expand All @@ -285,9 +292,11 @@ class MessageLookup extends MessageLookupByLibrary {
"titleScore": MessageLookupByLibrary.simpleMessage("Score"),
"totalAverage": MessageLookupByLibrary.simpleMessage("Total average"),
"totalPeople": MessageLookupByLibrary.simpleMessage("Total people"),
"unknownDepartment": MessageLookupByLibrary.simpleMessage("Unknown Department"),
"unknownError": MessageLookupByLibrary.simpleMessage("An unknown error occurred"),
"unknownServerError": MessageLookupByLibrary.simpleMessage(
"A problem occurred when communicating with the campus server, most features may be affected\nPlease confirm that the campus system can be used normally and try again, thanks"),
"unknownStudent": MessageLookupByLibrary.simpleMessage("Unknown Student"),
"update": MessageLookupByLibrary.simpleMessage("Update"),
"useOldPassword": MessageLookupByLibrary.simpleMessage("Use old password"),
"versionInfo": MessageLookupByLibrary.simpleMessage("Version info"),
Expand Down
9 changes: 9 additions & 0 deletions lib/generated/intl/messages_zh_TW.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class MessageLookup extends MessageLookupByLibrary {
"accountLock": MessageLookupByLibrary.simpleMessage("帳號已被鎖住,請15分鐘後再試"),
"accountNull": MessageLookupByLibrary.simpleMessage("請輸入帳號"),
"accountPasswordError": MessageLookupByLibrary.simpleMessage("帳號密碼錯誤"),
"aduit": MessageLookupByLibrary.simpleMessage("隨班附讀"),
"aestheticDimension": MessageLookupByLibrary.simpleMessage("美學向度"),
"alertError": MessageLookupByLibrary.simpleMessage("發生錯誤"),
"androidPrivateBrowseGuideSubTitle": MessageLookupByLibrary.simpleMessage("開啟隱私瀏覽,安全更有保障"),
Expand Down Expand Up @@ -120,6 +121,8 @@ class MessageLookup extends MessageLookupByLibrary {
"getCalendar": MessageLookupByLibrary.simpleMessage("取得行事曆中..."),
"getCalendarError": MessageLookupByLibrary.simpleMessage("取得行事曆錯誤"),
"getCourse": MessageLookupByLibrary.simpleMessage("取得課表..."),
"getCourseClassmateList": MessageLookupByLibrary.simpleMessage("獲取學生名單中..."),
"getCourseClassmateListError": MessageLookupByLibrary.simpleMessage("獲取學生名單錯誤"),
"getCourseDetail": MessageLookupByLibrary.simpleMessage("課程資料讀取中..."),
"getCourseDetailError": MessageLookupByLibrary.simpleMessage("課程資料讀取錯誤"),
"getCourseError": MessageLookupByLibrary.simpleMessage("取得課表錯誤"),
Expand Down Expand Up @@ -175,6 +178,8 @@ class MessageLookup extends MessageLookupByLibrary {
"logout": MessageLookupByLibrary.simpleMessage("登出"),
"logoutWarning": MessageLookupByLibrary.simpleMessage("確定要登出嗎? \n將會清除所有資料"),
"missingRequiredInformation": MessageLookupByLibrary.simpleMessage("缺少必要資訊"),
"name": MessageLookupByLibrary.simpleMessage("姓名"),
"nationalTaipeiUniversity": MessageLookupByLibrary.simpleMessage("國立臺北大學"),
"naturalDimension": MessageLookupByLibrary.simpleMessage("自然向度"),
"needsVerifyMobileWarning": MessageLookupByLibrary.simpleMessage("您可能被要求進行手機號碼驗證\n請至網頁版入口網站進行查看"),
"networkError": MessageLookupByLibrary.simpleMessage("網路發生錯誤"),
Expand Down Expand Up @@ -255,10 +260,12 @@ class MessageLookup extends MessageLookupByLibrary {
"sociologicalDimension": MessageLookupByLibrary.simpleMessage("社哲向度"),
"sortBy": MessageLookupByLibrary.simpleMessage("排序"),
"startClass": MessageLookupByLibrary.simpleMessage("開課班級"),
"studentId": MessageLookupByLibrary.simpleMessage("學號"),
"studentList": MessageLookupByLibrary.simpleMessage("學生清單"),
"subscribe": MessageLookupByLibrary.simpleMessage("訂閱"),
"sure": MessageLookupByLibrary.simpleMessage("確定"),
"syllabus": MessageLookupByLibrary.simpleMessage("教學大綱"),
"taipeiMedicineUniversity": MessageLookupByLibrary.simpleMessage("臺北醫學大學"),
"takeCore": MessageLookupByLibrary.simpleMessage("實得核心"),
"takeForeignDepartmentCredits": MessageLookupByLibrary.simpleMessage("外系學分"),
"takeForeignDepartmentCreditsLimit": MessageLookupByLibrary.simpleMessage("學分上限"),
Expand All @@ -270,8 +277,10 @@ class MessageLookup extends MessageLookupByLibrary {
"titleScore": MessageLookupByLibrary.simpleMessage("成績"),
"totalAverage": MessageLookupByLibrary.simpleMessage("總平均"),
"totalPeople": MessageLookupByLibrary.simpleMessage("總人數"),
"unknownDepartment": MessageLookupByLibrary.simpleMessage("未知系所"),
"unknownError": MessageLookupByLibrary.simpleMessage("發生未知錯誤"),
"unknownServerError": MessageLookupByLibrary.simpleMessage("與校園系統溝通時發生問題,大部分功能可能將受影響\n請確認校園系統能正常使用後再試一次,謝謝"),
"unknownStudent": MessageLookupByLibrary.simpleMessage("未知學生"),
"update": MessageLookupByLibrary.simpleMessage("更新"),
"useOldPassword": MessageLookupByLibrary.simpleMessage("延長原始密碼時間"),
"versionInfo": MessageLookupByLibrary.simpleMessage("版本資訊"),
Expand Down
90 changes: 90 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,14 @@
"androidPrivateBrowseGuideTitle": "About Incognito Browse",
"androidPrivateBrowseGuideSubTitle": "Open Incognito browsing to enhanced security",
"kClass": "class",
"kDepartment": "department"
"kDepartment": "department",
"unknownDepartment": "Unknown Department",
"unknownStudent": "Unknown Student",
"name": "name",
"studentId": "student id",
"getCourseClassmateList": "Getting classmate list...",
"getCourseClassmateListError": "Get classmate list error",
"nationalTaipeiUniversity": "NTPU",
"taipeiMedicineUniversity": "TMU",
"aduit": "Aduit"
}
11 changes: 10 additions & 1 deletion lib/l10n/intl_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,14 @@
"androidPrivateBrowseGuideTitle": "關於隱私瀏覽",
"androidPrivateBrowseGuideSubTitle": "開啟隱私瀏覽,安全更有保障",
"kClass": "班級",
"kDepartment": "系所"
"kDepartment": "系所",
"unknownDepartment": "未知系所",
"unknownStudent": "未知學生",
"name": "姓名",
"studentId": "學號",
"getCourseClassmateList": "獲取學生名單中...",
"getCourseClassmateListError": "獲取學生名單錯誤",
"nationalTaipeiUniversity": "國立臺北大學",
"taipeiMedicineUniversity": "臺北醫學大學",
"aduit": "隨班附讀"
}
73 changes: 73 additions & 0 deletions lib/src/connector/course_connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CourseConnector {
static const String _postTeacherCourseCNUrl = "${_courseCNHost}Teach.jsp";
static const String _postCourseENUrl = "${_courseENHost}Select.jsp";
static const String _creditUrl = "${_courseCNHost}Cprog.jsp";
static const String _getCourseDepartmentUrl = "${_courseCNHost}Subj.jsp";

static Future<CourseConnectorStatus> login() async {
String result;
Expand Down Expand Up @@ -64,6 +65,78 @@ class CourseConnector {
}
}

// It should use code with key (59 -> CSIE, 32 -> Electric), and department name with value.
static Future<Map<String, String>> getDepartmentMap(String year, String semester) async {
try {
ConnectorParameter parameter = ConnectorParameter(_getCourseDepartmentUrl);
parameter.data = {"format": "-2", "year": year, "sem": semester};
String result = await Connector.getDataByGet(parameter);

Document tagNode = parse(result);
List<Element> departmentNodes = tagNode.getElementsByTagName("a");

Map<String, String> departmentMap = {};
for (Element element in departmentNodes) {
final href = element.attributes["href"];
if (href.isEmpty) {
continue;
}
String codeParameter = href.split("&").firstWhere((parameter) => parameter.contains("code"), orElse: () => "");
if (codeParameter == "") {
continue;
}
String code = codeParameter.split("=")[1];
String departmentName = element.text;
departmentMap.putIfAbsent(code, () => departmentName);
}

return departmentMap;
} catch (e, stack) {
Log.eWithStack(e, stack);
return null;
}
}

static Future<Map<String, String>> getTwoYearUndergraduateDepartmentMap(String year) async {
try {
ConnectorParameter parameter = ConnectorParameter(_creditUrl);
parameter.data = {"format": "-3", "year": year, "matric": "6"};
String result = await Connector.getDataByGet(parameter);

Document tagNode = parse(result);
List<Element> departmentNodes = tagNode.getElementsByTagName("a");

Map<String, String> departmentMap = {};
for (Element element in departmentNodes) {
final href = element.attributes["href"];
if (href.isEmpty) {
continue;
}
String divisionParameter =
href.split("&").firstWhere((parameter) => parameter.contains("division"), orElse: () => "");
if (divisionParameter == "") {
continue;
}
final String code = divisionParameter.split("=")[1];
final RegExp regExp = RegExp(".+【(.+)】");
final RegExpMatch matches = regExp.firstMatch(element.text);
if (matches == null || matches.groupCount == 0) {
continue;
}
final departmentName = matches.group(1);
if (departmentName.isEmpty) {
continue;
}
departmentMap.putIfAbsent(code, () => departmentName);
}

return departmentMap;
} catch (e, stack) {
Log.eWithStack(e, stack);
return null;
}
}

static Future<String> getCourseENName(String url) async {
try {
ConnectorParameter parameter;
Expand Down
49 changes: 49 additions & 0 deletions lib/src/connector/ischool_plus_connector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'package:flutter_app/src/util/html_utils.dart';
import 'package:html/dom.dart' as html;
import 'package:html/parser.dart' as html;

import '../model/course/course_student.dart';
import 'core/connector_parameter.dart';
import 'ntut_connector.dart';

Expand All @@ -32,6 +33,7 @@ class ISchoolPlusConnector {
//static final String _postLoginISchoolUrl = _iSchoolPlusUrl + "login.php";
//static final String _iSchoolPlusIndexUrl = _iSchoolPlusUrl + "mooc/index.php";
static const String _getCourseName = "${_iSchoolPlusUrl}learn/mooc_sysbar.php";
static const _getCourseStudentList = "${_iSchoolPlusUrl}learn/learn_ranking.php";
static const _ssoLoginUrl = "${NTUTConnector.host}ssoIndex.do";

/// The Authorization Step of ISchool (2023-10-21)
Expand Down Expand Up @@ -112,6 +114,53 @@ class ISchoolPlusConnector {
}
}

static Future<ReturnWithStatus<List<CourseStudent>>> getCourseStudent(String courseId) async {
try {
if (!await _selectCourse(courseId)) {
final returnResult = ReturnWithStatus();
returnResult.status = IPlusReturnStatus.noPermission;
return returnResult;
}

ConnectorParameter parameter = ConnectorParameter(_getCourseStudentList);
String result = await Connector.getDataByGet(parameter);

html.Document tagNode = html.parse(result);
html.Element table = tagNode.querySelectorAll('table')[1];
List<html.Element> nodes = table.querySelectorAll('tr');

List<CourseStudent> courseStudents = <CourseStudent>[];
for (int i = 0; i < nodes.length; i++) {
html.Element node = nodes[i].querySelectorAll('td')[1];

String information = node.querySelector('div').innerHtml;
int splitIndex = information.indexOf(' ');

String studentId = information.substring(0, splitIndex);
String studentName = information.substring(splitIndex + 2, information.length - 1);

// 過濾掉校務人士,如有多身分考慮枚舉或過濾 Email
if (studentId == 'istudyoaa') {
continue;
}

CourseStudent courseStudent = CourseStudent(department: "", id: studentId, name: studentName);
courseStudents.add(courseStudent);
}
courseStudents.sort((a, b) => a.id.compareTo(b.id));

final returnResult = ReturnWithStatus<List<CourseStudent>>();
returnResult.status = IPlusReturnStatus.success;
returnResult.result = courseStudents;
return returnResult;
} catch (e, stack) {
Log.eWithStack(e, stack);
final returnResult = ReturnWithStatus();
returnResult.status = IPlusReturnStatus.fail;
return returnResult;
}
}

static Future<ReturnWithStatus<List<CourseFileJson>>> getCourseFile(String courseId) async {
ConnectorParameter parameter;
String result;
Expand Down
Loading