Skip to content

Conversation

@xinshoutw
Copy link
Contributor

This pull request introduces enhanced logic for handling physical education (PE) course probability calculations by incorporating student identity information. It also refactors and improves data structures, fixes a typo, and adds new utility functions for extracting student identity from HTML. The changes allow for more accurate calculation of course selection probabilities, especially for PE courses, by matching enrollment limits based on the student's department and grade.

Enhanced PE Course Probability Calculation:

  • Added a new function get_pe_course_info_with_identity that uses student identity to fetch and calculate PE course probabilities more accurately by matching department-specific enrollment limits. This logic is integrated into the course fetching process when student identity is available. [1] [2]
  • Added fetch_all_courses_with_identity to support course fetching with optional student identity, and updated the main entry point to use this enhanced logic if identity extraction succeeds. [1] [2]

Student Identity Extraction:

  • Introduced the StudentIdentity struct and the extract_student_identity function, which parses HTML content to extract program type, department, and grade information for the current student. [1] [2] [3]

API Response Handling:

  • Added new data structures (CourseDetailResponse, CourseDetail) and the get_course_limit_detail function to fetch and parse department-specific enrollment limit data from the API, supporting the new PE course logic. [1] [2]

Bug Fix:

  • Fixed a typo in the Course struct and related logic, renaming sucess_rate to success_rate throughout the codebase for consistency and correctness. [1] [2] [3]

Code Integration:

  • Updated imports and main logic in src/main.rs to use the new functions and handle fallback when student identity cannot be extracted, ensuring backward compatibility. [1] [2]

@jeffpeng3
Copy link
Member

jeffpeng3 commented Aug 22, 2025

很感謝你的PR
尤其是修正了那個萬年typo的部分XD

由於我是重度vibe coder
所以在看code之前先進行了測試
我按照了我寫的教學去使用
但無法正常提取學生身分
後來發現是我的瀏覽器Vivaldi僅能保存為mhtml
而在保存mhtml時貌似會轉義所有非ascii字元在引擎載入時再重新渲染
關於這個部分你有什麼建議的解決方案嗎

@jeffpeng3
Copy link
Member

稍微翻了一下mhtml內的資料

image image

看來應該不難解決,我再看看有沒有甚麼好方法可以順利的解析它

@xinshoutw
Copy link
Contributor Author

了解,正在著手修改,稍等不久後會推上新的 🐳

@xinshoutw
Copy link
Contributor Author

我這裡測試可以,再麻煩你了 ouob

Copy link
Member

@jeffpeng3 jeffpeng3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起來應該就剩這些改一下就差不多了?

Copy link
Member

@jeffpeng3 jeffpeng3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jeffpeng3 jeffpeng3 merged commit 4fd0136 into NTUST-Tool:rust Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants